Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions lib/ui/painting/color_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions lib/ui/painting/engine_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/painting/image_encoding_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 0 additions & 2 deletions lib/ui/painting/image_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 5 additions & 6 deletions lib/ui/painting/multi_frame_codec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand All @@ -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(),
Expand Down
6 changes: 2 additions & 4 deletions lib/ui/painting/multi_frame_codec.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

#include <utility>

using tonic::DartPersistentValue;

namespace flutter {

class MultiFrameCodec : public Codec {
Expand Down Expand Up @@ -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.
Expand All @@ -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,
Expand Down
13 changes: 7 additions & 6 deletions lib/ui/painting/single_frame_codec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}

Expand Down Expand Up @@ -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)});
Expand Down
8 changes: 3 additions & 5 deletions lib/ui/painting/single_frame_codec.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
Expand Down