Make runtime/... and shell/common/... compatible with .clang-tidy. (flutter/engine#48158)

This commit is contained in:
Matan Lurey
2023-11-20 14:31:49 -08:00
committed by GitHub
parent 13f3bd212b
commit f9adfbc62c
13 changed files with 31 additions and 17 deletions

View File

@@ -91,6 +91,7 @@ class DartIsolate : public UIDartState {
/// isolate and start over.
///
enum class Phase {
// NOLINTBEGIN(readability-identifier-naming)
//--------------------------------------------------------------------------
/// The initial phase of all Dart isolates. This is an internal phase and
/// callers can never get a reference to a Dart isolate in this phase.
@@ -132,6 +133,7 @@ class DartIsolate : public UIDartState {
/// reference to a Dart isolate in this phase.
///
Shutdown,
// NOLINTEND(readability-identifier-naming)
};
//----------------------------------------------------------------------------

View File

@@ -71,6 +71,7 @@ class DartVMRef {
return vm_.get();
}
// NOLINTNEXTLINE(google-runtime-operator)
DartVM* operator&() {
FML_DCHECK(vm_);
return vm_.get();

View File

@@ -104,7 +104,7 @@ TEST_F(ShellTest, VSyncTargetTime) {
platform_task.wait();
on_target_time_latch.Wait();
const auto vsync_waiter_target_time =
ConstantFiringVsyncWaiter::frame_target_time;
ConstantFiringVsyncWaiter::kFrameTargetTime;
ASSERT_EQ(vsync_waiter_target_time.ToEpochDelta().ToMicroseconds(),
target_time);

View File

@@ -76,6 +76,7 @@ class Engine final : public RuntimeDelegate, PointerDataDispatcher::Delegate {
/// @brief Indicates the result of the call to `Engine::Run`.
///
enum class RunStatus {
// NOLINTBEGIN(readability-identifier-naming)
//--------------------------------------------------------------------------
/// The call to |Engine::Run| was successful and the root isolate is in the
/// `DartIsolate::Phase::Running` phase with its entry-point invocation
@@ -125,6 +126,7 @@ class Engine final : public RuntimeDelegate, PointerDataDispatcher::Delegate {
/// AOT mode operation of the Dart VM.
///
Failure,
// NOLINTEND(readability-identifier-naming)
};
//----------------------------------------------------------------------------

View File

@@ -27,9 +27,11 @@ struct PipelineProduceResult {
};
enum class PipelineConsumeResult {
// NOLINTBEGIN(readability-identifier-naming)
NoneAvailable,
Done,
MoreAvailable,
// NOLINTEND(readability-identifier-naming)
};
size_t GetNextPipelineTraceID();

View File

@@ -42,11 +42,9 @@ static constexpr std::chrono::milliseconds kSkiaCleanupExpiration(15000);
Rasterizer::Rasterizer(Delegate& delegate,
MakeGpuImageBehavior gpu_image_behavior)
: is_torn_down_(false),
delegate_(delegate),
: delegate_(delegate),
gpu_image_behavior_(gpu_image_behavior),
compositor_context_(std::make_unique<flutter::CompositorContext>(*this)),
user_override_resource_cache_bytes_(false),
snapshot_controller_(
SnapshotController::Make(*this, delegate.GetSettings())),
weak_factory_(this) {

View File

@@ -344,6 +344,7 @@ class Rasterizer final : public SnapshotDelegate,
/// rendered layer tree.
///
enum class ScreenshotType {
// NOLINTBEGIN(readability-identifier-naming)
//--------------------------------------------------------------------------
/// A format used to denote a Skia picture. A Skia picture is a serialized
/// representation of an `SkPicture` that can be used to introspect the
@@ -373,6 +374,7 @@ class Rasterizer final : public SnapshotDelegate,
/// is determined from the surface. This is the only way to read wide gamut
/// color data, but isn't supported everywhere.
SurfaceData,
// NOLINTEND(readability-identifier-naming)
};
//----------------------------------------------------------------------------
@@ -711,7 +713,7 @@ class Rasterizer final : public SnapshotDelegate,
static bool ShouldResubmitFrame(const DoDrawResult& result);
static DrawStatus ToDrawStatus(DoDrawStatus status);
bool is_torn_down_;
bool is_torn_down_ = false;
Delegate& delegate_;
MakeGpuImageBehavior gpu_image_behavior_;
std::weak_ptr<impeller::Context> impeller_context_;
@@ -720,7 +722,7 @@ class Rasterizer final : public SnapshotDelegate,
std::unique_ptr<flutter::CompositorContext> compositor_context_;
std::unordered_map<int64_t, ViewRecord> view_records_;
fml::closure next_frame_callback_;
bool user_override_resource_cache_bytes_;
bool user_override_resource_cache_bytes_ = false;
std::optional<size_t> max_cache_bytes_;
fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger_;
std::shared_ptr<ExternalViewEmbedder> external_view_embedder_;

View File

@@ -24,13 +24,14 @@ class ResourceCacheLimitItem {
class ResourceCacheLimitCalculator {
public:
ResourceCacheLimitCalculator(size_t max_bytes_threshold)
explicit ResourceCacheLimitCalculator(size_t max_bytes_threshold)
: max_bytes_threshold_(max_bytes_threshold) {}
~ResourceCacheLimitCalculator() = default;
// This will be called on the platform thread.
void AddResourceCacheLimitItem(fml::WeakPtr<ResourceCacheLimitItem> item) {
void AddResourceCacheLimitItem(
const fml::WeakPtr<ResourceCacheLimitItem>& item) {
items_.push_back(item);
}

View File

@@ -45,6 +45,7 @@ namespace flutter {
/// Error exit codes for the Dart isolate.
enum class DartErrorCode {
// NOLINTBEGIN(readability-identifier-naming)
/// No error has occurred.
NoError = 0,
/// The Dart error code for an API error.
@@ -53,6 +54,7 @@ enum class DartErrorCode {
CompilationError = 254,
/// The Dart error code for an unknown error.
UnknownError = 255
// NOLINTEND(readability-identifier-naming)
};
/// Values for |Shell::SetGpuAvailability|.

View File

@@ -36,7 +36,7 @@ class ShellTestPlatformView : public PlatformView {
protected:
ShellTestPlatformView(PlatformView::Delegate& delegate,
TaskRunners task_runners)
const TaskRunners& task_runners)
: PlatformView(delegate, task_runners) {}
FML_DISALLOW_COPY_AND_ASSIGN(ShellTestPlatformView);
@@ -53,7 +53,7 @@ class ShellTestPlatformViewBuilder {
ShellTestPlatformView::BackendType::kDefaultBackend;
};
ShellTestPlatformViewBuilder(Config config);
explicit ShellTestPlatformViewBuilder(Config config);
~ShellTestPlatformViewBuilder() = default;
// Override operator () to make this class assignable to std::function.

View File

@@ -20,11 +20,13 @@ using ThreadConfigSetter = fml::Thread::ThreadConfigSetter;
/// The collection of all the threads used by the engine.
struct ThreadHost {
enum Type {
// NOLINTBEGIN(readability-identifier-naming)
Platform = 1 << 0,
UI = 1 << 1,
RASTER = 1 << 2,
IO = 1 << 3,
Profiler = 1 << 4,
// NOLINTEND(readability-identifier-naming)
};
/// The collection of all the thread configures, and we create custom thread

View File

@@ -60,7 +60,7 @@ void ConstantFiringVsyncWaiter::AwaitVSync() {
FML_DCHECK(task_runners_.GetUITaskRunner()->RunsTasksOnCurrentThread());
auto async_wait = std::async([this]() {
task_runners_.GetPlatformTaskRunner()->PostTask(
[this]() { FireCallback(frame_begin_time, frame_target_time); });
[this]() { FireCallback(kFrameBeginTime, kFrameTargetTime); });
});
}

View File

@@ -7,6 +7,8 @@
#ifndef FLUTTER_SHELL_COMMON_VSYNC_WAITERS_TEST_H_
#define FLUTTER_SHELL_COMMON_VSYNC_WAITERS_TEST_H_
#include <utility>
#include "flutter/shell/common/shell.h"
namespace flutter {
@@ -30,9 +32,9 @@ class ShellTestVsyncClock {
class ShellTestVsyncWaiter : public VsyncWaiter {
public:
ShellTestVsyncWaiter(TaskRunners task_runners,
ShellTestVsyncWaiter(const TaskRunners& task_runners,
std::shared_ptr<ShellTestVsyncClock> clock)
: VsyncWaiter(std::move(task_runners)), clock_(clock) {}
: VsyncWaiter(task_runners), clock_(std::move(clock)) {}
protected:
void AwaitVSync() override;
@@ -44,13 +46,13 @@ class ShellTestVsyncWaiter : public VsyncWaiter {
class ConstantFiringVsyncWaiter : public VsyncWaiter {
public:
// both of these are set in the past so as to fire immediately.
static constexpr fml::TimePoint frame_begin_time =
static constexpr fml::TimePoint kFrameBeginTime =
fml::TimePoint::FromEpochDelta(fml::TimeDelta::FromSeconds(0));
static constexpr fml::TimePoint frame_target_time =
static constexpr fml::TimePoint kFrameTargetTime =
fml::TimePoint::FromEpochDelta(fml::TimeDelta::FromSeconds(100));
explicit ConstantFiringVsyncWaiter(TaskRunners task_runners)
: VsyncWaiter(std::move(task_runners)) {}
explicit ConstantFiringVsyncWaiter(const TaskRunners& task_runners)
: VsyncWaiter(task_runners) {}
protected:
void AwaitVSync() override;