From 32bbd9d1302fe637f9d605c837604a1af7df9f43 Mon Sep 17 00:00:00 2001 From: Matan Lurey Date: Mon, 13 Nov 2023 15:10:45 -0800 Subject: [PATCH 1/4] Make `lib/ui/painting/...` compatible with `.clang_tidy`. --- lib/ui/painting/color_filter.h | 2 -- lib/ui/painting/engine_layer.h | 5 +++-- lib/ui/painting/image_encoding_impl.h | 4 ++-- lib/ui/painting/image_filter.h | 2 -- lib/ui/painting/multi_frame_codec.h | 6 ++---- lib/ui/painting/single_frame_codec.h | 6 ++---- 6 files changed, 9 insertions(+), 16 deletions(-) diff --git a/lib/ui/painting/color_filter.h b/lib/ui/painting/color_filter.h index 667962955406d..3427d3d71e84f 100644 --- a/lib/ui/painting/color_filter.h +++ b/lib/ui/painting/color_filter.h @@ -9,8 +9,6 @@ #include "flutter/lib/ui/dart_wrapper.h" #include "third_party/tonic/typed_data/typed_list.h" -using tonic::DartPersistentValue; - namespace flutter { // A handle to an SkCodec object. diff --git a/lib/ui/painting/engine_layer.h b/lib/ui/painting/engine_layer.h index e13a7517183d5..163091d7bffd8 100644 --- a/lib/ui/painting/engine_layer.h +++ b/lib/ui/painting/engine_layer.h @@ -18,8 +18,9 @@ class EngineLayer : public RefCountedDartWrappable { public: ~EngineLayer() override; - static void MakeRetained(Dart_Handle dart_handle, - std::shared_ptr layer) { + static void MakeRetained( + Dart_Handle dart_handle, + const std::shared_ptr& layer) { auto engine_layer = fml::MakeRefCounted(layer); engine_layer->AssociateWithDartWrapper(dart_handle); } diff --git a/lib/ui/painting/image_encoding_impl.h b/lib/ui/painting/image_encoding_impl.h index 595f8276e4c96..c8af051dc5a0b 100644 --- a/lib/ui/painting/image_encoding_impl.h +++ b/lib/ui/painting/image_encoding_impl.h @@ -16,8 +16,8 @@ namespace flutter { template sk_sp ConvertToRasterUsingResourceContext( - sk_sp image, - fml::WeakPtr resource_context, + const sk_sp& image, + const fml::WeakPtr& resource_context, const std::shared_ptr& is_gpu_disabled_sync_switch) { sk_sp surface; SkImageInfo surface_info = SkImageInfo::MakeN32Premul(image->dimensions()); diff --git a/lib/ui/painting/image_filter.h b/lib/ui/painting/image_filter.h index 788747385998c..68d70b3f150c5 100644 --- a/lib/ui/painting/image_filter.h +++ b/lib/ui/painting/image_filter.h @@ -11,8 +11,6 @@ #include "flutter/lib/ui/painting/color_filter.h" #include "third_party/tonic/typed_data/typed_list.h" -using tonic::DartPersistentValue; - namespace tonic { class DartLibraryNatives; } // namespace tonic diff --git a/lib/ui/painting/multi_frame_codec.h b/lib/ui/painting/multi_frame_codec.h index ef288f27bf439..b0fd35c15d66a 100644 --- a/lib/ui/painting/multi_frame_codec.h +++ b/lib/ui/painting/multi_frame_codec.h @@ -11,8 +11,6 @@ #include -using tonic::DartPersistentValue; - namespace flutter { class MultiFrameCodec : public Codec { @@ -51,7 +49,7 @@ class MultiFrameCodec : public Codec { // The non-const members and functions below here are only read or written // to on the IO thread. They are not safe to access or write on the UI // thread. - int nextFrameIndex_; + int nextFrameIndex_ = 0; // The last decoded frame that's required to decode any subsequent frames. std::optional lastRequiredFrame_; // The index of the last decoded required frame. @@ -68,7 +66,7 @@ class MultiFrameCodec : public Codec { fml::RefPtr unref_queue); void GetNextFrameAndInvokeCallback( - std::unique_ptr callback, + std::unique_ptr callback, const fml::RefPtr& ui_task_runner, fml::WeakPtr resourceContext, fml::RefPtr unref_queue, diff --git a/lib/ui/painting/single_frame_codec.h b/lib/ui/painting/single_frame_codec.h index ef5fca8e58adb..034172c8f9709 100644 --- a/lib/ui/painting/single_frame_codec.h +++ b/lib/ui/painting/single_frame_codec.h @@ -11,8 +11,6 @@ #include "flutter/lib/ui/painting/image_decoder.h" #include "flutter/lib/ui/painting/image_descriptor.h" -using tonic::DartPersistentValue; - namespace flutter { class SingleFrameCodec : public Codec { @@ -34,12 +32,12 @@ class SingleFrameCodec : public Codec { private: enum class Status { kNew, kInProgress, kComplete }; - Status status_; + Status status_ = Status::kNew; fml::RefPtr descriptor_; uint32_t target_width_; uint32_t target_height_; fml::RefPtr cached_image_; - std::vector pending_callbacks_; + std::vector pending_callbacks_; FML_FRIEND_MAKE_REF_COUNTED(SingleFrameCodec); FML_FRIEND_REF_COUNTED_THREAD_SAFE(SingleFrameCodec); From 3c7aa5e8e2139472f1e49bbb83c8683f3517bb86 Mon Sep 17 00:00:00 2001 From: Matan Lurey Date: Mon, 13 Nov 2023 15:25:07 -0800 Subject: [PATCH 2/4] ++ --- lib/ui/painting/multi_frame_codec.cc | 8 ++++---- lib/ui/painting/single_frame_codec.cc | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/ui/painting/multi_frame_codec.cc b/lib/ui/painting/multi_frame_codec.cc index 815034f8e004a..bef921bebf1d9 100644 --- a/lib/ui/painting/multi_frame_codec.cc +++ b/lib/ui/painting/multi_frame_codec.cc @@ -40,7 +40,7 @@ static void InvokeNextFrameCallback( const fml::RefPtr& image, int duration, const std::string& decode_error, - std::unique_ptr callback, + std::unique_ptr callback, size_t trace_id) { std::shared_ptr dart_state = callback->dart_state().lock(); if (!dart_state) { @@ -183,7 +183,7 @@ MultiFrameCodec::State::GetNextFrameImage( } void MultiFrameCodec::State::GetNextFrameAndInvokeCallback( - std::unique_ptr callback, + std::unique_ptr callback, const fml::RefPtr& ui_task_runner, fml::WeakPtr resourceContext, fml::RefPtr unref_queue, @@ -233,7 +233,7 @@ Dart_Handle MultiFrameCodec::getNextFrame(Dart_Handle callback_handle) { FML_LOG(ERROR) << decode_error; task_runners.GetUITaskRunner()->PostTask(fml::MakeCopyable( [trace_id, decode_error = std::move(decode_error), - callback = std::make_unique( + callback = std::make_unique( tonic::DartState::Current(), callback_handle)]() mutable { InvokeNextFrameCallback(nullptr, 0, decode_error, std::move(callback), trace_id); @@ -242,7 +242,7 @@ Dart_Handle MultiFrameCodec::getNextFrame(Dart_Handle callback_handle) { } task_runners.GetIOTaskRunner()->PostTask(fml::MakeCopyable( - [callback = std::make_unique( + [callback = std::make_unique( tonic::DartState::Current(), callback_handle), weak_state = std::weak_ptr(state_), trace_id, ui_task_runner = task_runners.GetUITaskRunner(), diff --git a/lib/ui/painting/single_frame_codec.cc b/lib/ui/painting/single_frame_codec.cc index 758cc56c055c8..00c2ee74b6f64 100644 --- a/lib/ui/painting/single_frame_codec.cc +++ b/lib/ui/painting/single_frame_codec.cc @@ -97,7 +97,8 @@ Dart_Handle SingleFrameCodec::getNextFrame(Dart_Handle callback_handle) { codec->status_ = Status::kComplete; // Invoke any callbacks that were provided before the frame was decoded. - for (const DartPersistentValue& callback : codec->pending_callbacks_) { + for (const tonic::DartPersistentValue& callback : + codec->pending_callbacks_) { tonic::DartInvoke(callback.value(), {tonic::ToDart(codec->cached_image_), tonic::ToDart(0), tonic::ToDart(decode_error)}); From 1916bdbf46c018c8007bbe7b8d971c2f82cd870f Mon Sep 17 00:00:00 2001 From: Matan Lurey Date: Wed, 15 Nov 2023 12:48:30 -0800 Subject: [PATCH 3/4] ++ --- lib/ui/painting/single_frame_codec.cc | 10 +++++----- lib/ui/painting/single_frame_codec.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/ui/painting/single_frame_codec.cc b/lib/ui/painting/single_frame_codec.cc index 00c2ee74b6f64..47ce1b6f4b66d 100644 --- a/lib/ui/painting/single_frame_codec.cc +++ b/lib/ui/painting/single_frame_codec.cc @@ -9,11 +9,11 @@ namespace flutter { -SingleFrameCodec::SingleFrameCodec(fml::RefPtr descriptor, - uint32_t target_width, - uint32_t target_height) - : status_(Status::kNew), - descriptor_(std::move(descriptor)), +SingleFrameCodec::SingleFrameCodec( + const fml::RefPtr& descriptor, + uint32_t target_width, + uint32_t target_height) + : descriptor_(std::move(descriptor)), target_width_(target_width), target_height_(target_height) {} diff --git a/lib/ui/painting/single_frame_codec.h b/lib/ui/painting/single_frame_codec.h index 034172c8f9709..8a1080b4d55e0 100644 --- a/lib/ui/painting/single_frame_codec.h +++ b/lib/ui/painting/single_frame_codec.h @@ -15,7 +15,7 @@ namespace flutter { class SingleFrameCodec : public Codec { public: - SingleFrameCodec(fml::RefPtr descriptor, + SingleFrameCodec(const fml::RefPtr& descriptor, uint32_t target_width, uint32_t target_height); From 231142417f50f6a7dc6b2dafac3dae3dcf4d21ff Mon Sep 17 00:00:00 2001 From: Matan Lurey Date: Wed, 15 Nov 2023 13:52:11 -0800 Subject: [PATCH 4/4] ++ --- lib/ui/painting/multi_frame_codec.cc | 3 +-- lib/ui/painting/single_frame_codec.cc | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/ui/painting/multi_frame_codec.cc b/lib/ui/painting/multi_frame_codec.cc index bef921bebf1d9..32d1bd0695920 100644 --- a/lib/ui/painting/multi_frame_codec.cc +++ b/lib/ui/painting/multi_frame_codec.cc @@ -33,8 +33,7 @@ MultiFrameCodec::State::State(std::shared_ptr generator) ImageGenerator::kInfinitePlayCount ? -1 : generator_->GetPlayCount() - 1), - is_impeller_enabled_(UIDartState::Current()->IsImpellerEnabled()), - nextFrameIndex_(0) {} + is_impeller_enabled_(UIDartState::Current()->IsImpellerEnabled()) {} static void InvokeNextFrameCallback( const fml::RefPtr& image, diff --git a/lib/ui/painting/single_frame_codec.cc b/lib/ui/painting/single_frame_codec.cc index 47ce1b6f4b66d..7f55ac8c85100 100644 --- a/lib/ui/painting/single_frame_codec.cc +++ b/lib/ui/painting/single_frame_codec.cc @@ -13,7 +13,7 @@ SingleFrameCodec::SingleFrameCodec( const fml::RefPtr& descriptor, uint32_t target_width, uint32_t target_height) - : descriptor_(std::move(descriptor)), + : descriptor_(descriptor), target_width_(target_width), target_height_(target_height) {}