Skip to content

Commit

Permalink
Rename SkiaGPUObject::get() to skia_object() (flutter#27126)
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-simmons authored Jul 16, 2021
1 parent 1ce3c32 commit 63c78a8
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 33 deletions.
8 changes: 4 additions & 4 deletions flow/layers/picture_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ void PictureLayer::Diff(DiffContext* context, const Layer* old_layer) {
bool PictureLayer::Compare(DiffContext::Statistics& statistics,
const PictureLayer* l1,
const PictureLayer* l2) {
const auto& pic1 = l1->picture_.get();
const auto& pic2 = l2->picture_.get();
const auto& pic1 = l1->picture_.skia_object();
const auto& pic2 = l2->picture_.skia_object();
if (pic1.get() == pic2.get()) {
statistics.AddSameInstancePicture();
return true;
Expand Down Expand Up @@ -99,7 +99,7 @@ sk_sp<SkData> PictureLayer::SerializedPicture() const {
},
nullptr,
};
cached_serialized_picture_ = picture_.get()->serialize(&procs);
cached_serialized_picture_ = picture_.skia_object()->serialize(&procs);
}
return cached_serialized_picture_;
}
Expand Down Expand Up @@ -129,7 +129,7 @@ void PictureLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {

void PictureLayer::Paint(PaintContext& context) const {
TRACE_EVENT0("flutter", "PictureLayer::Paint");
FML_DCHECK(picture_.get());
FML_DCHECK(picture_.skia_object());
FML_DCHECK(needs_painting(context));

SkAutoCanvasRestore save(context.leaf_nodes_canvas, true);
Expand Down
2 changes: 1 addition & 1 deletion flow/layers/picture_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class PictureLayer : public Layer {
bool is_complex,
bool will_change);

SkPicture* picture() const { return picture_.get().get(); }
SkPicture* picture() const { return picture_.skia_object().get(); }

#ifdef FLUTTER_ENABLE_DIFF_CONTEXT

Expand Down
2 changes: 1 addition & 1 deletion flow/layers/picture_layer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ TEST_F(PictureLayerTest, PaintBeforePrerollInvalidPictureDies) {
layer_offset, SkiaGPUObject<SkPicture>(), false, false);

EXPECT_DEATH_IF_SUPPORTED(layer->Paint(paint_context()),
"picture_\\.get\\(\\)");
"picture_\\.skia_object\\(\\)");
}

TEST_F(PictureLayerTest, PaintBeforePrerollDies) {
Expand Down
2 changes: 1 addition & 1 deletion flow/skia_gpu_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class SkiaGPUObject {

SkiaGPUObject& operator=(SkiaGPUObject&&) = default;

sk_sp<SkiaObjectType> get() const { return object_; }
sk_sp<SkiaObjectType> skia_object() const { return object_; }

void reset() {
if (object_ && queue_) {
Expand Down
6 changes: 3 additions & 3 deletions flow/skia_gpu_object_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ TEST_F(SkiaGpuObjectTest, ObjectReset) {
sk_make_sp<TestSkObject>(latch, &dtor_task_queue_id), unref_queue());
// Verify that explicitly resetting the GPU object queues and unref.
sk_object.reset();
ASSERT_EQ(sk_object.get(), nullptr);
ASSERT_EQ(sk_object.skia_object(), nullptr);
latch->Wait();
ASSERT_EQ(dtor_task_queue_id, unref_task_runner()->GetTaskQueueId());
}
Expand All @@ -119,9 +119,9 @@ TEST_F(SkiaGpuObjectTest, ObjectResetTwice) {
sk_make_sp<TestSkObject>(latch, &dtor_task_queue_id), unref_queue());

sk_object.reset();
ASSERT_EQ(sk_object.get(), nullptr);
ASSERT_EQ(sk_object.skia_object(), nullptr);
sk_object.reset();
ASSERT_EQ(sk_object.get(), nullptr);
ASSERT_EQ(sk_object.skia_object(), nullptr);

latch->Wait();
ASSERT_EQ(dtor_task_queue_id, unref_task_runner()->GetTaskQueueId());
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/painting/gradient.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class CanvasGradient : public Shader {
const tonic::Float64List& matrix4);

sk_sp<SkShader> shader(SkSamplingOptions) override {
return sk_shader_.get();
return sk_shader_.skia_object();
}

static void RegisterNatives(tonic::DartLibraryNatives* natives);
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/painting/image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void CanvasImage::dispose() {
}

size_t CanvasImage::GetAllocationSize() const {
if (auto image = image_.get()) {
if (auto image = image_.skia_object()) {
const auto& info = image->imageInfo();
const auto kMipmapOverhead = 4.0 / 3.0;
const size_t image_byte_size = info.computeMinByteSize() * kMipmapOverhead;
Expand Down
6 changes: 3 additions & 3 deletions lib/ui/painting/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ class CanvasImage final : public RefCountedDartWrappable<CanvasImage> {
return fml::MakeRefCounted<CanvasImage>();
}

int width() { return image_.get()->width(); }
int width() { return image_.skia_object()->width(); }

int height() { return image_.get()->height(); }
int height() { return image_.skia_object()->height(); }

Dart_Handle toByteData(int format, Dart_Handle callback);

void dispose();

sk_sp<SkImage> image() const { return image_.get(); }
sk_sp<SkImage> image() const { return image_.skia_object(); }
void set_image(flutter::SkiaGPUObject<SkImage> image) {
image_ = std::move(image);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/painting/image_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ void ImageDecoder::Decode(fml::RefPtr<ImageDescriptor> descriptor_ref_ptr,
auto uploaded =
UploadRasterImage(std::move(decompressed), io_manager, flow);

if (!uploaded.get()) {
if (!uploaded.skia_object()) {
FML_DLOG(ERROR) << "Could not upload image to the GPU.";
result({}, std::move(flow));
return;
Expand Down
18 changes: 9 additions & 9 deletions lib/ui/painting/image_decoder_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ TEST_F(ImageDecoderFixtureTest, InvalidImageResultsError) {

ImageDecoder::ImageResult callback = [&](SkiaGPUObject<SkImage> image) {
ASSERT_TRUE(runners.GetUITaskRunner()->RunsTasksOnCurrentThread());
ASSERT_FALSE(image.get());
ASSERT_FALSE(image.skia_object());
latch.Signal();
};
decoder.Decode(image_descriptor, 0, 0, callback);
Expand Down Expand Up @@ -245,7 +245,7 @@ TEST_F(ImageDecoderFixtureTest, ValidImageResultsInSuccess) {

ImageDecoder::ImageResult callback = [&](SkiaGPUObject<SkImage> image) {
ASSERT_TRUE(runners.GetUITaskRunner()->RunsTasksOnCurrentThread());
ASSERT_TRUE(image.get());
ASSERT_TRUE(image.skia_object());
EXPECT_TRUE(io_manager->did_access_is_gpu_disabled_sync_switch_);
runners.GetIOTaskRunner()->PostTask(release_io_manager);
};
Expand Down Expand Up @@ -302,8 +302,8 @@ TEST_F(ImageDecoderFixtureTest, ExifDataIsRespectedOnDecode) {

ImageDecoder::ImageResult callback = [&](SkiaGPUObject<SkImage> image) {
ASSERT_TRUE(runners.GetUITaskRunner()->RunsTasksOnCurrentThread());
ASSERT_TRUE(image.get());
decoded_size = image.get()->dimensions();
ASSERT_TRUE(image.skia_object());
decoded_size = image.skia_object()->dimensions();
runners.GetIOTaskRunner()->PostTask(release_io_manager);
};
image_decoder->Decode(descriptor, descriptor->width(), descriptor->height(),
Expand Down Expand Up @@ -361,7 +361,7 @@ TEST_F(ImageDecoderFixtureTest, CanDecodeWithoutAGPUContext) {

ImageDecoder::ImageResult callback = [&](SkiaGPUObject<SkImage> image) {
ASSERT_TRUE(runners.GetUITaskRunner()->RunsTasksOnCurrentThread());
ASSERT_TRUE(image.get());
ASSERT_TRUE(image.skia_object());
runners.GetIOTaskRunner()->PostTask(release_io_manager);
};
image_decoder->Decode(descriptor, descriptor->width(), descriptor->height(),
Expand Down Expand Up @@ -436,8 +436,8 @@ TEST_F(ImageDecoderFixtureTest, CanDecodeWithResizes) {

ImageDecoder::ImageResult callback = [&](SkiaGPUObject<SkImage> image) {
ASSERT_TRUE(runners.GetUITaskRunner()->RunsTasksOnCurrentThread());
ASSERT_TRUE(image.get());
final_size = image.get()->dimensions();
ASSERT_TRUE(image.skia_object());
final_size = image.skia_object()->dimensions();
latch.Signal();
};
image_decoder->Decode(descriptor, target_width, target_height, callback);
Expand Down Expand Up @@ -534,8 +534,8 @@ TEST_F(ImageDecoderFixtureTest, DISABLED_CanResizeWithoutDecode) {

ImageDecoder::ImageResult callback = [&](SkiaGPUObject<SkImage> image) {
ASSERT_TRUE(runners.GetUITaskRunner()->RunsTasksOnCurrentThread());
ASSERT_TRUE(image.get());
final_size = image.get()->dimensions();
ASSERT_TRUE(image.skia_object());
final_size = image.skia_object()->dimensions();
latch.Signal();
};
image_decoder->Decode(descriptor, target_width, target_height, callback);
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/painting/image_shader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ sk_sp<SkShader> ImageShader::shader(SkSamplingOptions sampling) {
if (sampling_is_locked_) {
sampling = cached_sampling_;
}
if (!cached_shader_.get() || cached_sampling_ != sampling) {
if (!cached_shader_.skia_object() || cached_sampling_ != sampling) {
cached_sampling_ = sampling;
cached_shader_ = UIDartState::CreateGPUObject(
sk_image_->makeShader(tmx_, tmy_, sampling, &local_matrix_));
}
return cached_shader_.get();
return cached_shader_.skia_object();
}

ImageShader::ImageShader() = default;
Expand Down
9 changes: 5 additions & 4 deletions lib/ui/painting/picture.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ Dart_Handle Picture::toImage(uint32_t width,
},
width, height, raw_image_callback);
} else {
if (!picture_.get()) {
if (!picture_.skia_object()) {
return tonic::ToDart("Picture is null");
}
return RasterizeToImage(picture_.get(), width, height, raw_image_callback);
return RasterizeToImage(picture_.skia_object(), width, height,
raw_image_callback);
}
}

Expand All @@ -77,9 +78,9 @@ void Picture::dispose() {
}

size_t Picture::GetAllocationSize() const {
if (auto picture = picture_.get()) {
if (auto picture = picture_.skia_object()) {
return picture->approximateBytesUsed() + sizeof(Picture);
} else if (auto display_list = display_list_.get()) {
} else if (display_list_) {
return display_list_->bytes() + sizeof(Picture);
} else {
return sizeof(Picture);
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/painting/picture.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Picture : public RefCountedDartWrappable<Picture> {
static fml::RefPtr<Picture> Create(Dart_Handle dart_handle,
sk_sp<DisplayList> display_list);

sk_sp<SkPicture> picture() const { return picture_.get(); }
sk_sp<SkPicture> picture() const { return picture_.skia_object(); }
sk_sp<DisplayList> display_list() const { return display_list_; }

Dart_Handle toImage(uint32_t width,
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/painting/single_frame_codec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Dart_Handle SingleFrameCodec::getNextFrame(Dart_Handle callback_handle) {

tonic::DartState::Scope scope(state.get());

if (image.get()) {
if (image.skia_object()) {
auto canvas_image = fml::MakeRefCounted<CanvasImage>();
canvas_image->set_image(std::move(image));

Expand Down

0 comments on commit 63c78a8

Please sign in to comment.