diff --git a/common/graphics/texture.cc b/common/graphics/texture.cc index 07025ff085779..74d76c909f823 100644 --- a/common/graphics/texture.cc +++ b/common/graphics/texture.cc @@ -14,7 +14,7 @@ Texture::Texture(int64_t id) : id_(id) {} Texture::~Texture() = default; -TextureRegistry::TextureRegistry() : image_counter_(0) {} +TextureRegistry::TextureRegistry() = default; void TextureRegistry::RegisterTexture(const std::shared_ptr& texture) { if (!texture) { diff --git a/common/graphics/texture.h b/common/graphics/texture.h index 9b582a84da286..3f4ea4fcecfde 100644 --- a/common/graphics/texture.h +++ b/common/graphics/texture.h @@ -95,7 +95,7 @@ class TextureRegistry { private: std::map> mapping_; - size_t image_counter_; + size_t image_counter_ = 0; // This map keeps track of registered context listeners by their own // externally provided id. It indexes into ordered_images_. std::map image_indices_; diff --git a/display_list/display_list.h b/display_list/display_list.h index 668a247d5596f..f7c7aa09a9651 100644 --- a/display_list/display_list.h +++ b/display_list/display_list.h @@ -159,7 +159,8 @@ class SaveLayerOptions { SaveLayerOptions() : flags_(0) {} SaveLayerOptions(const SaveLayerOptions& options) : flags_(options.flags_) {} - SaveLayerOptions(const SaveLayerOptions* options) : flags_(options->flags_) {} + explicit SaveLayerOptions(const SaveLayerOptions* options) + : flags_(options->flags_) {} SaveLayerOptions without_optimizations() const { SaveLayerOptions options; diff --git a/display_list/dl_canvas.h b/display_list/dl_canvas.h index f04645c157788..96f4a3f91a345 100644 --- a/display_list/dl_canvas.h +++ b/display_list/dl_canvas.h @@ -152,7 +152,7 @@ class DlCanvas { virtual void DrawVertices(const DlVertices* vertices, DlBlendMode mode, const DlPaint& paint) = 0; - void DrawVertices(const std::shared_ptr vertices, + void DrawVertices(const std::shared_ptr& vertices, DlBlendMode mode, const DlPaint& paint) { DrawVertices(vertices.get(), mode, paint); diff --git a/display_list/geometry/dl_rtree.cc b/display_list/geometry/dl_rtree.cc index a4a805957bcc3..1598f505e88e1 100644 --- a/display_list/geometry/dl_rtree.cc +++ b/display_list/geometry/dl_rtree.cc @@ -217,7 +217,7 @@ const SkRect& DlRTree::bounds() const { if (!nodes_.empty()) { return nodes_.back().bounds; } else { - return empty_; + return kEmpty; } } diff --git a/display_list/geometry/dl_rtree.h b/display_list/geometry/dl_rtree.h index f12486edcce76..efda1613e38b1 100644 --- a/display_list/geometry/dl_rtree.h +++ b/display_list/geometry/dl_rtree.h @@ -96,7 +96,7 @@ class DlRTree : public SkRefCnt { const SkRect& bounds(int result_index) const { return (result_index >= 0 && result_index < leaf_count_) ? nodes_[result_index].bounds - : empty_; + : kEmpty; } /// Returns the bytes used by the object and all of its node data. @@ -136,7 +136,7 @@ class DlRTree : public SkRefCnt { } private: - static constexpr SkRect empty_ = SkRect::MakeEmpty(); + static constexpr SkRect kEmpty = SkRect::MakeEmpty(); void search(const Node& parent, const SkRect& query, diff --git a/display_list/image/dl_image.h b/display_list/image/dl_image.h index bc4a8602545ad..137fe03ac7acb 100644 --- a/display_list/image/dl_image.h +++ b/display_list/image/dl_image.h @@ -131,7 +131,9 @@ class DlImage : public SkRefCnt { bool Equals(const DlImage& other) const { return Equals(&other); } - bool Equals(sk_sp other) const { return Equals(other.get()); } + bool Equals(const sk_sp& other) const { + return Equals(other.get()); + } protected: DlImage(); diff --git a/display_list/image/dl_image_skia.h b/display_list/image/dl_image_skia.h index a29985d095929..03bcfa144a83a 100644 --- a/display_list/image/dl_image_skia.h +++ b/display_list/image/dl_image_skia.h @@ -12,7 +12,7 @@ namespace flutter { class DlImageSkia final : public DlImage { public: - DlImageSkia(sk_sp image); + explicit DlImageSkia(sk_sp image); // |DlImage| ~DlImageSkia() override; diff --git a/fml/base32.h b/fml/base32.h index aacbdc696e3ad..7892aaddb3484 100644 --- a/fml/base32.h +++ b/fml/base32.h @@ -25,7 +25,7 @@ class BitConverter { int Extract() { FML_DCHECK(CanExtract()); int result = Peek(); - buffer_ = (buffer_ << to_length) & mask_; + buffer_ = (buffer_ << to_length) & kMask; lower_free_bits_ += to_length; return result; } @@ -40,7 +40,7 @@ class BitConverter { static_assert(buffer_length >= 2 * to_length); static_assert(buffer_length < sizeof(int) * 8); - static constexpr int mask_ = (1 << buffer_length) - 1; + static constexpr int kMask = (1 << buffer_length) - 1; int buffer_ = 0; int lower_free_bits_ = buffer_length; diff --git a/fml/endianness.h b/fml/endianness.h index eff90f9cafb3c..18758b7b69492 100644 --- a/fml/endianness.h +++ b/fml/endianness.h @@ -32,11 +32,11 @@ struct IsByteSwappable integral_constant || std::is_enum_v> { }; template -constexpr bool IsByteSwappableV = IsByteSwappable::value; +constexpr bool kIsByteSwappableV = IsByteSwappable::value; /// @brief Flips the endianness of the given value. /// The given value must be an integral type of size 1, 2, 4, or 8. -template >> +template >> constexpr T ByteSwap(T n) { if constexpr (sizeof(T) == 1) { return n; @@ -55,7 +55,7 @@ constexpr T ByteSwap(T n) { /// current architecture. This is effectively a cross platform /// ntohl/ntohs (as network byte order is always Big Endian). /// The given value must be an integral type of size 1, 2, 4, or 8. -template >> +template >> constexpr T BigEndianToArch(T n) { #if FML_ARCH_CPU_LITTLE_ENDIAN return ByteSwap(n); @@ -67,7 +67,7 @@ constexpr T BigEndianToArch(T n) { /// @brief Convert a known little endian value to match the endianness of the /// current architecture. /// The given value must be an integral type of size 1, 2, 4, or 8. -template >> +template >> constexpr T LittleEndianToArch(T n) { #if !FML_ARCH_CPU_LITTLE_ENDIAN return ByteSwap(n); diff --git a/fml/math.h b/fml/math.h index 6182ada09d60c..57dced6630b3b 100644 --- a/fml/math.h +++ b/fml/math.h @@ -12,16 +12,16 @@ namespace math { constexpr float kE = 2.7182818284590452354; // log_2 e -constexpr float kLog2_E = 1.4426950408889634074; +constexpr float kLog2E = 1.4426950408889634074; // log_10 e -constexpr float kLog10_E = 0.43429448190325182765; +constexpr float kLog10E = 0.43429448190325182765; // log_e 2 -constexpr float klogE_2 = 0.69314718055994530942; +constexpr float kLogE2 = 0.69314718055994530942; // log_e 10 -constexpr float klogE_10 = 2.30258509299404568402; +constexpr float kLogE10 = 2.30258509299404568402; // pi constexpr float kPi = 3.14159265358979323846; diff --git a/fml/math_unittests.cc b/fml/math_unittests.cc index 0e627e28bb615..020d886037bbd 100644 --- a/fml/math_unittests.cc +++ b/fml/math_unittests.cc @@ -12,9 +12,9 @@ namespace testing { TEST(MathTest, Constants) { // Don't use the constants in cmath as those aren't portable. - EXPECT_FLOAT_EQ(std::log2(math::kE), math::kLog2_E); - EXPECT_FLOAT_EQ(std::log10(math::kE), math::kLog10_E); - EXPECT_FLOAT_EQ(std::log(2.0f), math::klogE_2); + EXPECT_FLOAT_EQ(std::log2(math::kE), math::kLog2E); + EXPECT_FLOAT_EQ(std::log10(math::kE), math::kLog10E); + EXPECT_FLOAT_EQ(std::log(2.0f), math::kLogE2); EXPECT_FLOAT_EQ(math::kPi / 2.0f, math::kPiOver2); EXPECT_FLOAT_EQ(math::kPi / 4.0f, math::kPiOver4); EXPECT_FLOAT_EQ(1.0f / math::kPi, math::k1OverPi); diff --git a/fml/memory/ref_ptr.h b/fml/memory/ref_ptr.h index c426a4901d7a2..149c058987a8e 100644 --- a/fml/memory/ref_ptr.h +++ b/fml/memory/ref_ptr.h @@ -205,7 +205,7 @@ class RefPtr final { friend RefPtr AdoptRef(T*); - enum AdoptTag { ADOPT }; + enum AdoptTag { kAdopt }; RefPtr(T* ptr, AdoptTag) : ptr_(ptr) { FML_DCHECK(ptr_); } T* ptr_; @@ -222,7 +222,7 @@ inline RefPtr AdoptRef(T* ptr) { #ifndef NDEBUG ptr->Adopt(); #endif - return RefPtr(ptr, RefPtr::ADOPT); + return RefPtr(ptr, RefPtr::kAdopt); } // Constructs a |RefPtr| from a plain pointer (to an object that must diff --git a/fml/message_loop_task_queues.cc b/fml/message_loop_task_queues.cc index 30c1e37880421..f92dd86bfbf20 100644 --- a/fml/message_loop_task_queues.cc +++ b/fml/message_loop_task_queues.cc @@ -36,7 +36,7 @@ FML_THREAD_LOCAL ThreadLocalUniquePtr tls_task_source_grade; TaskQueueEntry::TaskQueueEntry(TaskQueueId created_for_arg) - : subsumed_by(_kUnmerged), created_for(created_for_arg) { + : subsumed_by(kUnmerged), created_for(created_for_arg) { wakeable = NULL; task_observers = TaskObservers(); task_source = std::make_unique(created_for); @@ -66,7 +66,7 @@ MessageLoopTaskQueues::~MessageLoopTaskQueues() = default; void MessageLoopTaskQueues::Dispose(TaskQueueId queue_id) { std::lock_guard guard(queue_mutex_); const auto& queue_entry = queue_entries_.at(queue_id); - FML_DCHECK(queue_entry->subsumed_by == _kUnmerged); + FML_DCHECK(queue_entry->subsumed_by == kUnmerged); auto& subsumed_set = queue_entry->owner_of; for (auto& subsumed : subsumed_set) { queue_entries_.erase(subsumed); @@ -78,7 +78,7 @@ void MessageLoopTaskQueues::Dispose(TaskQueueId queue_id) { void MessageLoopTaskQueues::DisposeTasks(TaskQueueId queue_id) { std::lock_guard guard(queue_mutex_); const auto& queue_entry = queue_entries_.at(queue_id); - FML_DCHECK(queue_entry->subsumed_by == _kUnmerged); + FML_DCHECK(queue_entry->subsumed_by == kUnmerged); auto& subsumed_set = queue_entry->owner_of; queue_entry->task_source->ShutDown(); for (auto& subsumed : subsumed_set) { @@ -101,7 +101,7 @@ void MessageLoopTaskQueues::RegisterTask( queue_entry->task_source->RegisterTask( {order, task, target_time, task_source_grade}); TaskQueueId loop_to_wake = queue_id; - if (queue_entry->subsumed_by != _kUnmerged) { + if (queue_entry->subsumed_by != kUnmerged) { loop_to_wake = queue_entry->subsumed_by; } @@ -151,7 +151,7 @@ void MessageLoopTaskQueues::WakeUpUnlocked(TaskQueueId queue_id, size_t MessageLoopTaskQueues::GetNumPendingTasks(TaskQueueId queue_id) const { std::lock_guard guard(queue_mutex_); const auto& queue_entry = queue_entries_.at(queue_id); - if (queue_entry->subsumed_by != _kUnmerged) { + if (queue_entry->subsumed_by != kUnmerged) { return 0; } @@ -185,7 +185,7 @@ std::vector MessageLoopTaskQueues::GetObserversToNotify( std::lock_guard guard(queue_mutex_); std::vector observers; - if (queue_entries_.at(queue_id)->subsumed_by != _kUnmerged) { + if (queue_entries_.at(queue_id)->subsumed_by != kUnmerged) { return observers; } @@ -226,8 +226,8 @@ bool MessageLoopTaskQueues::Merge(TaskQueueId owner, TaskQueueId subsumed) { // Won't check owner_entry->owner_of, because it may contains items when // merged with other different queues. - // Ensure owner_entry->subsumed_by being _kUnmerged - if (owner_entry->subsumed_by != _kUnmerged) { + // Ensure owner_entry->subsumed_by being kUnmerged + if (owner_entry->subsumed_by != kUnmerged) { FML_LOG(WARNING) << "Thread merging failed: owner_entry was already " "subsumed by others, owner=" << owner << ", subsumed=" << subsumed @@ -242,8 +242,8 @@ bool MessageLoopTaskQueues::Merge(TaskQueueId owner, TaskQueueId subsumed) { << ", subsumed->owner_of.size()=" << subsumed_entry->owner_of.size(); return false; } - // Ensure subsumed_entry->subsumed_by being _kUnmerged - if (subsumed_entry->subsumed_by != _kUnmerged) { + // Ensure subsumed_entry->subsumed_by being kUnmerged + if (subsumed_entry->subsumed_by != kUnmerged) { FML_LOG(WARNING) << "Thread merging failed: subsumed_entry was already " "subsumed by others, owner=" << owner << ", subsumed=" << subsumed @@ -271,14 +271,14 @@ bool MessageLoopTaskQueues::Unmerge(TaskQueueId owner, TaskQueueId subsumed) { << owner << ", subsumed=" << subsumed; return false; } - if (owner_entry->subsumed_by != _kUnmerged) { + if (owner_entry->subsumed_by != kUnmerged) { FML_LOG(WARNING) << "Thread unmerging failed: owner_entry was subsumed by others, owner=" << owner << ", subsumed=" << subsumed << ", owner_entry->subsumed_by=" << owner_entry->subsumed_by; return false; } - if (queue_entries_.at(subsumed)->subsumed_by == _kUnmerged) { + if (queue_entries_.at(subsumed)->subsumed_by == kUnmerged) { FML_LOG(WARNING) << "Thread unmerging failed: subsumed_entry wasn't " "subsumed by others, owner=" << owner << ", subsumed=" << subsumed; @@ -291,7 +291,7 @@ bool MessageLoopTaskQueues::Unmerge(TaskQueueId owner, TaskQueueId subsumed) { return false; } - queue_entries_.at(subsumed)->subsumed_by = _kUnmerged; + queue_entries_.at(subsumed)->subsumed_by = kUnmerged; owner_entry->owner_of.erase(subsumed); if (HasPendingTasksUnlocked(owner)) { @@ -308,7 +308,7 @@ bool MessageLoopTaskQueues::Unmerge(TaskQueueId owner, TaskQueueId subsumed) { bool MessageLoopTaskQueues::Owns(TaskQueueId owner, TaskQueueId subsumed) const { std::lock_guard guard(queue_mutex_); - if (owner == _kUnmerged || subsumed == _kUnmerged) { + if (owner == kUnmerged || subsumed == kUnmerged) { return false; } auto& subsumed_set = queue_entries_.at(owner)->owner_of; @@ -340,7 +340,7 @@ void MessageLoopTaskQueues::ResumeSecondarySource(TaskQueueId queue_id) { bool MessageLoopTaskQueues::HasPendingTasksUnlocked( TaskQueueId queue_id) const { const auto& entry = queue_entries_.at(queue_id); - bool is_subsumed = entry->subsumed_by != _kUnmerged; + bool is_subsumed = entry->subsumed_by != kUnmerged; if (is_subsumed) { return false; } diff --git a/fml/message_loop_task_queues.h b/fml/message_loop_task_queues.h index 2d89caac305ab..ba464493952c0 100644 --- a/fml/message_loop_task_queues.h +++ b/fml/message_loop_task_queues.h @@ -22,7 +22,7 @@ namespace fml { -static const TaskQueueId _kUnmerged = TaskQueueId(TaskQueueId::kUnmerged); +static const TaskQueueId kUnmerged = TaskQueueId(TaskQueueId::kUnmerged); /// A collection of tasks and observers associated with one TaskQueue. /// @@ -40,7 +40,7 @@ class TaskQueueEntry { /// empty, this TaskQueue does not own any other TaskQueues. std::set owner_of; - /// Identifies the TaskQueue that subsumes this TaskQueue. If it is _kUnmerged + /// Identifies the TaskQueue that subsumes this TaskQueue. If it is kUnmerged /// it indicates that this TaskQueue is not owned by any other TaskQueue. TaskQueueId subsumed_by; diff --git a/fml/message_loop_task_queues_unittests.cc b/fml/message_loop_task_queues_unittests.cc index f9753ea8ad34c..7681d99379b74 100644 --- a/fml/message_loop_task_queues_unittests.cc +++ b/fml/message_loop_task_queues_unittests.cc @@ -338,9 +338,9 @@ TEST(MessageLoopTaskQueue, QueueDoNotOwnItself) { TEST(MessageLoopTaskQueue, QueueDoNotOwnUnmergedTaskQueueId) { auto task_queue = fml::MessageLoopTaskQueues::GetInstance(); - ASSERT_FALSE(task_queue->Owns(task_queue->CreateTaskQueue(), _kUnmerged)); - ASSERT_FALSE(task_queue->Owns(_kUnmerged, task_queue->CreateTaskQueue())); - ASSERT_FALSE(task_queue->Owns(_kUnmerged, _kUnmerged)); + ASSERT_FALSE(task_queue->Owns(task_queue->CreateTaskQueue(), kUnmerged)); + ASSERT_FALSE(task_queue->Owns(kUnmerged, task_queue->CreateTaskQueue())); + ASSERT_FALSE(task_queue->Owns(kUnmerged, kUnmerged)); } TEST(MessageLoopTaskQueue, QueueOwnsMergedTaskQueueId) { diff --git a/fml/platform/darwin/scoped_block.h b/fml/platform/darwin/scoped_block.h index 2608d1ef3149e..319cb25d0d0ee 100644 --- a/fml/platform/darwin/scoped_block.h +++ b/fml/platform/darwin/scoped_block.h @@ -17,20 +17,20 @@ namespace fml { enum class OwnershipPolicy { // The scoped object takes ownership of an object by taking over an existing // ownership claim. - Assume, + kAssume, // The scoped object will retain the object and any initial ownership is // not changed. - Retain, + kRetain, }; template class ScopedBlock { public: explicit ScopedBlock(B block = nullptr, - OwnershipPolicy policy = OwnershipPolicy::Assume) + OwnershipPolicy policy = OwnershipPolicy::kAssume) : block_(block) { - if (block_ && policy == OwnershipPolicy::Retain) { + if (block_ && policy == OwnershipPolicy::kRetain) { block_ = Block_copy(block); } } @@ -48,13 +48,13 @@ class ScopedBlock { } ScopedBlock& operator=(const ScopedBlock& that) { - reset(that.get(), OwnershipPolicy::Retain); + reset(that.get(), OwnershipPolicy::kRetain); return *this; } void reset(B block = nullptr, - OwnershipPolicy policy = OwnershipPolicy::Assume) { - if (block && policy == OwnershipPolicy::Retain) { + OwnershipPolicy policy = OwnershipPolicy::kAssume) { + if (block && policy == OwnershipPolicy::kRetain) { block = Block_copy(block); } if (block_) { diff --git a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm index f78ca85f79ee4..c3223766d4c01 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm @@ -717,7 +717,7 @@ - (void)setSplashScreenView:(UIView*)view { } - (void)setFlutterViewDidRenderCallback:(void (^)(void))callback { - _flutterViewRenderedCallback.reset(callback, fml::OwnershipPolicy::Retain); + _flutterViewRenderedCallback.reset(callback, fml::OwnershipPolicy::kRetain); } #pragma mark - Surface creation and teardown updates diff --git a/shell/platform/darwin/ios/framework/Source/platform_message_response_darwin.mm b/shell/platform/darwin/ios/framework/Source/platform_message_response_darwin.mm index 53b04e484d6fb..ffe0f60802608 100644 --- a/shell/platform/darwin/ios/framework/Source/platform_message_response_darwin.mm +++ b/shell/platform/darwin/ios/framework/Source/platform_message_response_darwin.mm @@ -9,7 +9,7 @@ PlatformMessageResponseDarwin::PlatformMessageResponseDarwin( PlatformMessageResponseCallback callback, fml::RefPtr platform_task_runner) - : callback_(callback, fml::OwnershipPolicy::Retain), + : callback_(callback, fml::OwnershipPolicy::kRetain), platform_task_runner_(std::move(platform_task_runner)) {} PlatformMessageResponseDarwin::~PlatformMessageResponseDarwin() = default; diff --git a/shell/platform/darwin/ios/platform_message_handler_ios.mm b/shell/platform/darwin/ios/platform_message_handler_ios.mm index 8a1b2ebe0d66b..b9011009798c8 100644 --- a/shell/platform/darwin/ios/platform_message_handler_ios.mm +++ b/shell/platform/darwin/ios/platform_message_handler_ios.mm @@ -125,7 +125,7 @@ - (void)dispatch:(dispatch_block_t)block { message_handlers_[channel] = { .task_queue = fml::scoped_nsprotocol([task_queue retain]), .handler = - fml::ScopedBlock{handler, fml::OwnershipPolicy::Retain}, + fml::ScopedBlock{handler, fml::OwnershipPolicy::kRetain}, }; } }