Make lib/ui/painting/... compatible with .clang_tidy. (flutter/engine#47999)

Work towards https://github.com/flutter/flutter/issues/134969.

All changes were made automatically (i.e. with `--fix`).
This commit is contained in:
Matan Lurey
2023-11-16 08:40:42 -08:00
committed by GitHub
parent 4638f4fc85
commit 5bb5a50b0a
8 changed files with 22 additions and 29 deletions

View File

@@ -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.

View File

@@ -18,8 +18,9 @@ class EngineLayer : public RefCountedDartWrappable<EngineLayer> {
public:
~EngineLayer() override;
static void MakeRetained(Dart_Handle dart_handle,
std::shared_ptr<flutter::ContainerLayer> layer) {
static void MakeRetained(
Dart_Handle dart_handle,
const std::shared_ptr<flutter::ContainerLayer>& layer) {
auto engine_layer = fml::MakeRefCounted<EngineLayer>(layer);
engine_layer->AssociateWithDartWrapper(dart_handle);
}

View File

@@ -16,8 +16,8 @@ namespace flutter {
template <typename SyncSwitch>
sk_sp<SkImage> ConvertToRasterUsingResourceContext(
sk_sp<SkImage> image,
fml::WeakPtr<GrDirectContext> resource_context,
const sk_sp<SkImage>& image,
const fml::WeakPtr<GrDirectContext>& resource_context,
const std::shared_ptr<const SyncSwitch>& is_gpu_disabled_sync_switch) {
sk_sp<SkSurface> surface;
SkImageInfo surface_info = SkImageInfo::MakeN32Premul(image->dimensions());

View File

@@ -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

View File

@@ -33,14 +33,13 @@ MultiFrameCodec::State::State(std::shared_ptr<ImageGenerator> 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<CanvasImage>& image,
int duration,
const std::string& decode_error,
std::unique_ptr<DartPersistentValue> callback,
std::unique_ptr<tonic::DartPersistentValue> callback,
size_t trace_id) {
std::shared_ptr<tonic::DartState> dart_state = callback->dart_state().lock();
if (!dart_state) {
@@ -183,7 +182,7 @@ MultiFrameCodec::State::GetNextFrameImage(
}
void MultiFrameCodec::State::GetNextFrameAndInvokeCallback(
std::unique_ptr<DartPersistentValue> callback,
std::unique_ptr<tonic::DartPersistentValue> callback,
const fml::RefPtr<fml::TaskRunner>& ui_task_runner,
fml::WeakPtr<GrDirectContext> resourceContext,
fml::RefPtr<flutter::SkiaUnrefQueue> unref_queue,
@@ -233,7 +232,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<DartPersistentValue>(
callback = std::make_unique<tonic::DartPersistentValue>(
tonic::DartState::Current(), callback_handle)]() mutable {
InvokeNextFrameCallback(nullptr, 0, decode_error, std::move(callback),
trace_id);
@@ -242,7 +241,7 @@ Dart_Handle MultiFrameCodec::getNextFrame(Dart_Handle callback_handle) {
}
task_runners.GetIOTaskRunner()->PostTask(fml::MakeCopyable(
[callback = std::make_unique<DartPersistentValue>(
[callback = std::make_unique<tonic::DartPersistentValue>(
tonic::DartState::Current(), callback_handle),
weak_state = std::weak_ptr<MultiFrameCodec::State>(state_), trace_id,
ui_task_runner = task_runners.GetUITaskRunner(),

View File

@@ -11,8 +11,6 @@
#include <utility>
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<SkBitmap> lastRequiredFrame_;
// The index of the last decoded required frame.
@@ -68,7 +66,7 @@ class MultiFrameCodec : public Codec {
fml::RefPtr<flutter::SkiaUnrefQueue> unref_queue);
void GetNextFrameAndInvokeCallback(
std::unique_ptr<DartPersistentValue> callback,
std::unique_ptr<tonic::DartPersistentValue> callback,
const fml::RefPtr<fml::TaskRunner>& ui_task_runner,
fml::WeakPtr<GrDirectContext> resourceContext,
fml::RefPtr<flutter::SkiaUnrefQueue> unref_queue,

View File

@@ -9,11 +9,11 @@
namespace flutter {
SingleFrameCodec::SingleFrameCodec(fml::RefPtr<ImageDescriptor> descriptor,
uint32_t target_width,
uint32_t target_height)
: status_(Status::kNew),
descriptor_(std::move(descriptor)),
SingleFrameCodec::SingleFrameCodec(
const fml::RefPtr<ImageDescriptor>& descriptor,
uint32_t target_width,
uint32_t target_height)
: descriptor_(descriptor),
target_width_(target_width),
target_height_(target_height) {}
@@ -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)});

View File

@@ -11,13 +11,11 @@
#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 {
public:
SingleFrameCodec(fml::RefPtr<ImageDescriptor> descriptor,
SingleFrameCodec(const fml::RefPtr<ImageDescriptor>& descriptor,
uint32_t target_width,
uint32_t target_height);
@@ -34,12 +32,12 @@ class SingleFrameCodec : public Codec {
private:
enum class Status { kNew, kInProgress, kComplete };
Status status_;
Status status_ = Status::kNew;
fml::RefPtr<ImageDescriptor> descriptor_;
uint32_t target_width_;
uint32_t target_height_;
fml::RefPtr<CanvasImage> cached_image_;
std::vector<DartPersistentValue> pending_callbacks_;
std::vector<tonic::DartPersistentValue> pending_callbacks_;
FML_FRIEND_MAKE_REF_COUNTED(SingleFrameCodec);
FML_FRIEND_REF_COUNTED_THREAD_SAFE(SingleFrameCodec);