0

Use sk_sp-based picture recording APIs

1) use SkPictureRecorder::finishRecordingAsPicture() over
   endRecordingAsPicture()

2) convert to sk_sp<SkPicture> fields/params where feasible

BUG=skia:5077
R=reed@google.com,danakj@chromium.org,enne@chromium.org
TBR=pdr@chromium.org,alekseys@chromium.org
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel

Review URL: https://codereview.chromium.org/1819683002

Cr-Commit-Position: refs/heads/master@{#382563}
This commit is contained in:
fmalita
2016-03-22 06:32:10 -07:00
committed by Commit bot
parent c2db76301d
commit 2d74328888
37 changed files with 89 additions and 115 deletions

@ -50,12 +50,12 @@ WebDisplayItemListImpl::WebDisplayItemListImpl(
void WebDisplayItemListImpl::appendDrawingItem(
const blink::WebRect& visual_rect,
const SkPicture* picture) {
sk_sp<const SkPicture> picture) {
if (display_item_list_->RetainsIndividualDisplayItems()) {
display_item_list_->CreateAndAppendItem<cc::DrawingDisplayItem>(
visual_rect, skia::SharePtr(picture));
visual_rect, std::move(picture));
} else {
cc::DrawingDisplayItem item(skia::SharePtr(picture));
cc::DrawingDisplayItem item(std::move(picture));
display_item_list_->RasterIntoCanvas(item);
}
}

@ -42,7 +42,8 @@ class WebDisplayItemListImpl : public blink::WebDisplayItemList {
~WebDisplayItemListImpl() override;
// blink::WebDisplayItemList implementation.
void appendDrawingItem(const blink::WebRect&, const SkPicture*) override;
void appendDrawingItem(const blink::WebRect&,
sk_sp<const SkPicture>) override;
void appendClipItem(
const blink::WebRect& visual_rect,
const blink::WebRect& clip_rect,

@ -217,8 +217,8 @@ bool Layer::IsPropertyChangeAllowed() const {
return !layer_tree_host_->in_paint_layer_contents();
}
skia::RefPtr<SkPicture> Layer::GetPicture() const {
return skia::RefPtr<SkPicture>();
sk_sp<SkPicture> Layer::GetPicture() const {
return nullptr;
}
void Layer::SetParent(Layer* layer) {

@ -28,7 +28,6 @@
#include "cc/layers/paint_properties.h"
#include "cc/output/filter_operations.h"
#include "cc/trees/property_tree.h"
#include "skia/ext/refptr.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkImageFilter.h"
#include "third_party/skia/include/core/SkPicture.h"
@ -400,7 +399,7 @@ class CC_EXPORT Layer : public base::RefCounted<Layer> {
virtual ScrollbarLayerInterface* ToScrollbarLayer();
virtual skia::RefPtr<SkPicture> GetPicture() const;
virtual sk_sp<SkPicture> GetPicture() const;
// Constructs a LayerImpl of the correct runtime type for this Layer type.
virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl);

@ -464,8 +464,8 @@ bool LayerImpl::user_scrollable(ScrollbarOrientation orientation) const {
: user_scrollable_vertical_;
}
skia::RefPtr<SkPicture> LayerImpl::GetPicture() {
return skia::RefPtr<SkPicture>();
sk_sp<SkPicture> LayerImpl::GetPicture() {
return nullptr;
}
scoped_ptr<LayerImpl> LayerImpl::CreateLayerImpl(LayerTreeImpl* tree_impl) {

@ -32,7 +32,6 @@
#include "cc/quads/shared_quad_state.h"
#include "cc/resources/resource_provider.h"
#include "cc/tiles/tile_priority.h"
#include "skia/ext/refptr.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkImageFilter.h"
#include "third_party/skia/include/core/SkPicture.h"
@ -530,7 +529,7 @@ class CC_EXPORT LayerImpl {
// ReleaseResources call.
virtual void RecreateResources();
virtual skia::RefPtr<SkPicture> GetPicture();
virtual sk_sp<SkPicture> GetPicture();
virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl);
virtual void PushPropertiesTo(LayerImpl* layer);

@ -80,10 +80,8 @@ scoped_refptr<DisplayItemList> PictureImageLayer::PaintContentsToDisplayList(
// transparent images blend correctly.
canvas->drawImage(image_.get(), 0, 0);
skia::RefPtr<SkPicture> picture =
skia::AdoptRef(recorder.endRecordingAsPicture());
display_list->CreateAndAppendItem<DrawingDisplayItem>(PaintableRegion(),
std::move(picture));
display_list->CreateAndAppendItem<DrawingDisplayItem>(
PaintableRegion(), recorder.finishRecordingAsPicture());
display_list->Finalize();
return display_list;

@ -129,12 +129,12 @@ void PictureLayer::SetIsMask(bool is_mask) {
is_mask_ = is_mask;
}
skia::RefPtr<SkPicture> PictureLayer::GetPicture() const {
sk_sp<SkPicture> PictureLayer::GetPicture() const {
// We could either flatten the DisplayListRecordingSource into a single
// SkPicture, or paint a fresh one depending on what we intend to do with the
// picture. For now we just paint a fresh one to get consistent results.
if (!DrawsContent())
return skia::RefPtr<SkPicture>();
return nullptr;
gfx::Size layer_size = bounds();
scoped_ptr<DisplayListRecordingSource> recording_source(

@ -32,7 +32,7 @@ class CC_EXPORT PictureLayer : public Layer {
void SetNeedsDisplayRect(const gfx::Rect& layer_rect) override;
bool Update() override;
void SetIsMask(bool is_mask) override;
skia::RefPtr<SkPicture> GetPicture() const override;
sk_sp<SkPicture> GetPicture() const override;
bool IsSuitableForGpuRasterization() const override;
void RunMicroBenchmark(MicroBenchmark* benchmark) override;

@ -649,7 +649,7 @@ void PictureLayerImpl::RecreateResources() {
layer_tree_impl()->set_needs_update_draw_properties();
}
skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() {
sk_sp<SkPicture> PictureLayerImpl::GetPicture() {
return raster_source_->GetFlattenedPicture();
}

@ -49,7 +49,7 @@ class CC_EXPORT PictureLayerImpl
void DidBeginTracing() override;
void ReleaseResources() override;
void RecreateResources() override;
skia::RefPtr<SkPicture> GetPicture() override;
sk_sp<SkPicture> GetPicture() override;
Region GetInvalidationRegionForDebugging() override;
// PictureLayerTilingClient overrides.

@ -184,7 +184,7 @@ void DisplayItemList::Finalize() {
// Convert to an SkPicture for faster rasterization.
DCHECK(settings_.use_cached_picture);
DCHECK(!picture_);
picture_ = skia::AdoptRef(recorder_->endRecordingAsPicture());
picture_ = recorder_->finishRecordingAsPicture();
DCHECK(picture_);
picture_memory_usage_ =
SkPictureUtils::ApproximateBytesUsed(picture_.get());
@ -265,8 +265,7 @@ DisplayItemList::AsValue(bool include_items) const {
canvas->translate(-layer_rect_.x(), -layer_rect_.y());
canvas->clipRect(gfx::RectToSkRect(layer_rect_));
Raster(canvas, NULL, gfx::Rect(), 1.f);
skia::RefPtr<SkPicture> picture =
skia::AdoptRef(recorder.endRecordingAsPicture());
sk_sp<SkPicture> picture = recorder.finishRecordingAsPicture();
std::string b64_picture;
PictureDebugUtil::SerializeAsBase64(picture.get(), &b64_picture);

@ -126,7 +126,7 @@ class CC_EXPORT DisplayItemList
// |items_| . These rects are intentionally kept separate
// because they are not needed while walking the |items_| for raster.
std::vector<gfx::Rect> visual_rects_;
skia::RefPtr<SkPicture> picture_;
sk_sp<SkPicture> picture_;
scoped_ptr<SkPictureRecorder> recorder_;
skia::RefPtr<SkCanvas> canvas_;

@ -56,7 +56,7 @@ void AppendFirstSerializationTestPicture(scoped_refptr<DisplayItemList> list,
canvas->translate(offset.x(), offset.y());
canvas->drawRectCoords(0.f, 0.f, 4.f, 4.f, red_paint);
list->CreateAndAppendItem<DrawingDisplayItem>(
kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture()));
kVisualRect, recorder.finishRecordingAsPicture());
}
void AppendSecondSerializationTestPicture(scoped_refptr<DisplayItemList> list,
@ -73,7 +73,7 @@ void AppendSecondSerializationTestPicture(scoped_refptr<DisplayItemList> list,
canvas->translate(offset.x(), offset.y());
canvas->drawRectCoords(3.f, 3.f, 7.f, 7.f, blue_paint);
list->CreateAndAppendItem<DrawingDisplayItem>(
kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture()));
kVisualRect, recorder.finishRecordingAsPicture());
}
void ValidateDisplayItemListSerialization(const gfx::Size& layer_size,
@ -256,7 +256,6 @@ TEST(DisplayItemListTest, SingleDrawingItem) {
gfx::Rect layer_rect(100, 100);
SkPictureRecorder recorder;
skia::RefPtr<SkCanvas> canvas;
skia::RefPtr<SkPicture> picture;
SkPaint blue_paint;
blue_paint.setColor(SK_ColorBLUE);
SkPaint red_paint;
@ -273,9 +272,8 @@ TEST(DisplayItemListTest, SingleDrawingItem) {
canvas->translate(offset.x(), offset.y());
canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint);
canvas->drawRectCoords(50.f, 50.f, 75.f, 75.f, blue_paint);
picture = skia::AdoptRef(recorder.endRecordingAsPicture());
list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect,
std::move(picture));
list->CreateAndAppendItem<DrawingDisplayItem>(
kVisualRect, recorder.finishRecordingAsPicture());
list->Finalize();
DrawDisplayList(pixels, layer_rect, list);
@ -317,7 +315,7 @@ TEST(DisplayItemListTest, ClipItem) {
canvas->translate(first_offset.x(), first_offset.y());
canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint);
list->CreateAndAppendItem<DrawingDisplayItem>(
kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture()));
kVisualRect, recorder.finishRecordingAsPicture());
gfx::Rect clip_rect(60, 60, 10, 10);
list->CreateAndAppendItem<ClipDisplayItem>(kVisualRect, clip_rect,
@ -331,7 +329,7 @@ TEST(DisplayItemListTest, ClipItem) {
canvas->translate(second_offset.x(), second_offset.y());
canvas->drawRectCoords(50.f, 50.f, 75.f, 75.f, blue_paint);
list->CreateAndAppendItem<DrawingDisplayItem>(
kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture()));
kVisualRect, recorder.finishRecordingAsPicture());
list->CreateAndAppendItem<EndClipDisplayItem>(kVisualRect);
list->Finalize();
@ -377,7 +375,7 @@ TEST(DisplayItemListTest, TransformItem) {
canvas->translate(first_offset.x(), first_offset.y());
canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint);
list->CreateAndAppendItem<DrawingDisplayItem>(
kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture()));
kVisualRect, recorder.finishRecordingAsPicture());
gfx::Transform transform;
transform.Rotate(45.0);
@ -391,7 +389,7 @@ TEST(DisplayItemListTest, TransformItem) {
canvas->translate(second_offset.x(), second_offset.y());
canvas->drawRectCoords(50.f, 50.f, 75.f, 75.f, blue_paint);
list->CreateAndAppendItem<DrawingDisplayItem>(
kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture()));
kVisualRect, recorder.finishRecordingAsPicture());
list->CreateAndAppendItem<EndTransformDisplayItem>(kVisualRect);
list->Finalize();
@ -472,7 +470,6 @@ TEST(DisplayItemListTest, CompactingItems) {
gfx::Rect layer_rect(100, 100);
SkPictureRecorder recorder;
skia::RefPtr<SkCanvas> canvas;
skia::RefPtr<SkPicture> picture;
SkPaint blue_paint;
blue_paint.setColor(SK_ColorBLUE);
SkPaint red_paint;
@ -492,7 +489,7 @@ TEST(DisplayItemListTest, CompactingItems) {
canvas->translate(offset.x(), offset.y());
canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint);
canvas->drawRectCoords(50.f, 50.f, 75.f, 75.f, blue_paint);
picture = skia::AdoptRef(recorder.endRecordingAsPicture());
sk_sp<SkPicture> picture = recorder.finishRecordingAsPicture();
list_without_caching->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect,
picture);
list_without_caching->Finalize();
@ -535,8 +532,7 @@ TEST(DisplayItemListTest, IsSuitableForGpuRasterizationWithCachedPicture) {
paint.setAntiAlias(true);
canvas->drawPath(path, paint);
skia::RefPtr<SkPicture> suitable_picture =
skia::AdoptRef(recorder.endRecordingAsPicture());
sk_sp<SkPicture> suitable_picture = recorder.finishRecordingAsPicture();
list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect, suitable_picture);
list->Finalize();
@ -556,8 +552,7 @@ TEST(DisplayItemListTest, IsSuitableForGpuRasterizationWithCachedPicture) {
skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(layer_rect)));
for (int i = 0; i < 10; ++i)
canvas->drawPath(path, paint);
skia::RefPtr<SkPicture> unsuitable_picture =
skia::AdoptRef(recorder.endRecordingAsPicture());
sk_sp<SkPicture> unsuitable_picture = recorder.finishRecordingAsPicture();
list->CreateAndAppendItem<DrawingDisplayItem>(kVisualRect,
unsuitable_picture);
list->Finalize();
@ -600,7 +595,7 @@ TEST(DisplayItemListTest, IsSuitableForGpuRasterizationWithoutCachedPicture) {
canvas->drawPath(path, paint);
list->CreateAndAppendItem<DrawingDisplayItem>(
kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture()));
kVisualRect, recorder.finishRecordingAsPicture());
list->Finalize();
// A single DrawingDisplayItem with a large AA concave path shouldn't trigger
@ -613,7 +608,7 @@ TEST(DisplayItemListTest, IsSuitableForGpuRasterizationWithoutCachedPicture) {
for (int i = 0; i < 10; ++i)
canvas->drawPath(path, paint);
list->CreateAndAppendItem<DrawingDisplayItem>(
kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture()));
kVisualRect, recorder.finishRecordingAsPicture());
list->Finalize();
// A single DrawingDisplayItem with several large AA concave paths should
@ -626,7 +621,7 @@ TEST(DisplayItemListTest, IsSuitableForGpuRasterizationWithoutCachedPicture) {
skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(layer_rect)));
canvas->drawPath(path, paint);
list->CreateAndAppendItem<DrawingDisplayItem>(
kVisualRect, skia::AdoptRef(recorder.endRecordingAsPicture()));
kVisualRect, recorder.finishRecordingAsPicture());
}
list->Finalize();
@ -649,8 +644,7 @@ TEST(DisplayItemListTest, ApproximateMemoryUsage) {
SkCanvas* canvas = recorder.beginRecording(gfx::RectToSkRect(layer_rect));
for (int i = 0; i < kNumCommandsInTestSkPicture; i++)
canvas->drawPaint(blue_paint);
skia::RefPtr<SkPicture> picture =
skia::AdoptRef(recorder.endRecordingAsPicture());
sk_sp<SkPicture> picture = recorder.finishRecordingAsPicture();
size_t picture_size = SkPictureUtils::ApproximateBytesUsed(picture.get());
ASSERT_GE(picture_size, kNumCommandsInTestSkPicture * sizeof(blue_paint));

@ -260,7 +260,7 @@ void DisplayListRasterSource::RasterCommon(
}
}
skia::RefPtr<SkPicture> DisplayListRasterSource::GetFlattenedPicture() {
sk_sp<SkPicture> DisplayListRasterSource::GetFlattenedPicture() {
TRACE_EVENT0("cc", "DisplayListRasterSource::GetFlattenedPicture");
gfx::Rect display_list_rect(size_);
@ -272,10 +272,8 @@ skia::RefPtr<SkPicture> DisplayListRasterSource::GetFlattenedPicture() {
1.f);
RasterCommon(canvas, nullptr, display_list_rect, display_list_rect, 1.f);
}
skia::RefPtr<SkPicture> picture =
skia::AdoptRef(recorder.endRecordingAsPicture());
return picture;
return recorder.finishRecordingAsPicture();
}
size_t DisplayListRasterSource::GetPictureMemoryUsage() const {

@ -18,7 +18,6 @@
#include "cc/debug/rendering_stats_instrumentation.h"
#include "cc/playback/display_list_recording_source.h"
#include "skia/ext/analysis_canvas.h"
#include "skia/ext/refptr.h"
#include "third_party/skia/include/core/SkPicture.h"
namespace cc {
@ -103,7 +102,7 @@ class CC_EXPORT DisplayListRasterSource
// Tracing functionality.
virtual void DidBeginTracing();
virtual void AsValueInto(base::trace_event::TracedValue* array) const;
virtual skia::RefPtr<SkPicture> GetFlattenedPicture();
virtual sk_sp<SkPicture> GetFlattenedPicture();
virtual size_t GetPictureMemoryUsage() const;
// Return true if LCD anti-aliasing may be used when rastering text.

@ -26,7 +26,7 @@ namespace cc {
DrawingDisplayItem::DrawingDisplayItem() {}
DrawingDisplayItem::DrawingDisplayItem(skia::RefPtr<const SkPicture> picture) {
DrawingDisplayItem::DrawingDisplayItem(sk_sp<const SkPicture> picture) {
SetNew(std::move(picture));
}
@ -35,13 +35,13 @@ DrawingDisplayItem::DrawingDisplayItem(
ImageSerializationProcessor* image_serialization_processor) {
DCHECK_EQ(proto::DisplayItem::Type_Drawing, proto.type());
skia::RefPtr<SkPicture> picture;
sk_sp<SkPicture> picture;
const proto::DrawingDisplayItem& details = proto.drawing_item();
if (details.has_picture()) {
SkMemoryStream stream(details.picture().data(), details.picture().size());
picture = skia::AdoptRef(SkPicture::CreateFromStream(
&stream, image_serialization_processor->GetPixelDeserializer()));
picture = SkPicture::MakeFromStream(
&stream, image_serialization_processor->GetPixelDeserializer());
}
SetNew(std::move(picture));
@ -54,7 +54,7 @@ DrawingDisplayItem::DrawingDisplayItem(const DrawingDisplayItem& item) {
DrawingDisplayItem::~DrawingDisplayItem() {
}
void DrawingDisplayItem::SetNew(skia::RefPtr<const SkPicture> picture) {
void DrawingDisplayItem::SetNew(sk_sp<const SkPicture> picture) {
picture_ = std::move(picture);
}

@ -10,7 +10,7 @@
#include "base/memory/scoped_ptr.h"
#include "cc/base/cc_export.h"
#include "cc/playback/display_item.h"
#include "skia/ext/refptr.h"
#include "third_party/skia/include/core/SkRefCnt.h"
#include "ui/gfx/geometry/point_f.h"
class SkCanvas;
@ -22,7 +22,7 @@ class ImageSerializationProcessor;
class CC_EXPORT DrawingDisplayItem : public DisplayItem {
public:
DrawingDisplayItem();
explicit DrawingDisplayItem(skia::RefPtr<const SkPicture> picture);
explicit DrawingDisplayItem(sk_sp<const SkPicture> picture);
explicit DrawingDisplayItem(
const proto::DisplayItem& proto,
ImageSerializationProcessor* image_serialization_processor);
@ -45,9 +45,9 @@ class CC_EXPORT DrawingDisplayItem : public DisplayItem {
void CloneTo(DrawingDisplayItem* item) const;
private:
void SetNew(skia::RefPtr<const SkPicture> picture);
void SetNew(sk_sp<const SkPicture> picture);
skia::RefPtr<const SkPicture> picture_;
sk_sp<const SkPicture> picture_;
};
} // namespace cc

@ -55,8 +55,7 @@ void GpuRasterizer::RasterizeSource(
raster_source->PlaybackToCanvas(canvas.get(), raster_full_rect, playback_rect,
scale, include_images);
canvas->restore();
skia::RefPtr<SkPicture> picture =
skia::AdoptRef(recorder.endRecordingAsPicture());
sk_sp<SkPicture> picture = recorder.finishRecordingAsPicture();
// Turn on distance fields for layers that have ever animated.
bool use_distance_field_text =

@ -67,8 +67,7 @@ FakeContentLayerClient::PaintContentsToDisplayList(
skia::SharePtr(recorder.beginRecording(gfx::RectFToSkRect(draw_rect)));
canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint);
display_list->CreateAndAppendItem<DrawingDisplayItem>(
ToEnclosingRect(draw_rect),
skia::AdoptRef(recorder.endRecordingAsPicture()));
ToEnclosingRect(draw_rect), recorder.finishRecordingAsPicture());
}
for (ImageVector::const_iterator it = draw_images_.begin();
@ -82,7 +81,7 @@ FakeContentLayerClient::PaintContentsToDisplayList(
canvas->drawImage(it->image.get(), it->point.x(), it->point.y(),
&it->paint);
display_list->CreateAndAppendItem<DrawingDisplayItem>(
PaintableRegion(), skia::AdoptRef(recorder.endRecordingAsPicture()));
PaintableRegion(), recorder.finishRecordingAsPicture());
if (!it->transform.IsIdentity()) {
display_list->CreateAndAppendItem<EndTransformDisplayItem>(
PaintableRegion());
@ -99,7 +98,7 @@ FakeContentLayerClient::PaintContentsToDisplayList(
skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(draw_rect)));
canvas->drawIRect(gfx::RectToSkIRect(draw_rect), paint);
display_list->CreateAndAppendItem<DrawingDisplayItem>(
draw_rect, skia::AdoptRef(recorder.endRecordingAsPicture()));
draw_rect, recorder.finishRecordingAsPicture());
draw_rect.Inset(1, 1);
}
}

@ -43,7 +43,7 @@ SolidColorContentLayerClient::PaintContentsToDisplayList(
DisplayItemList::Create(clip, settings);
display_list->CreateAndAppendItem<DrawingDisplayItem>(
clip, skia::AdoptRef(recorder.endRecordingAsPicture()));
clip, recorder.finishRecordingAsPicture());
display_list->Finalize();
return display_list;

@ -61,7 +61,7 @@ class MaskContentLayerClient : public ContentLayerClient {
scoped_refptr<DisplayItemList> display_list =
DisplayItemList::Create(PaintableRegion(), DisplayItemListSettings());
display_list->CreateAndAppendItem<DrawingDisplayItem>(
PaintableRegion(), skia::AdoptRef(recorder.endRecordingAsPicture()));
PaintableRegion(), recorder.finishRecordingAsPicture());
display_list->Finalize();
return display_list;
@ -329,7 +329,7 @@ class CheckerContentLayerClient : public ContentLayerClient {
scoped_refptr<DisplayItemList> display_list =
DisplayItemList::Create(PaintableRegion(), DisplayItemListSettings());
display_list->CreateAndAppendItem<DrawingDisplayItem>(
PaintableRegion(), skia::AdoptRef(recorder.endRecordingAsPicture()));
PaintableRegion(), recorder.finishRecordingAsPicture());
display_list->Finalize();
return display_list;
@ -367,7 +367,7 @@ class CircleContentLayerClient : public ContentLayerClient {
scoped_refptr<DisplayItemList> display_list =
DisplayItemList::Create(PaintableRegion(), DisplayItemListSettings());
display_list->CreateAndAppendItem<DrawingDisplayItem>(
PaintableRegion(), skia::AdoptRef(recorder.endRecordingAsPicture()));
PaintableRegion(), recorder.finishRecordingAsPicture());
display_list->Finalize();
return display_list;

@ -133,7 +133,7 @@ class BlueYellowClient : public ContentLayerClient {
canvas->drawRect(gfx::RectToSkRect(yellow_rect), paint);
display_list->CreateAndAppendItem<DrawingDisplayItem>(
PaintableRegion(), skia::AdoptRef(recorder.endRecordingAsPicture()));
PaintableRegion(), recorder.finishRecordingAsPicture());
display_list->Finalize();
return display_list;
}

@ -127,7 +127,7 @@ class SkPictureSerializer {
Serialize(children[i].get());
}
skia::RefPtr<SkPicture> picture = layer->GetPicture();
sk_sp<SkPicture> picture = layer->GetPicture();
if (!picture)
return;

@ -51,7 +51,7 @@ struct Page {
SkSize page_size_;
SkRect content_area_;
float scale_factor_;
skia::RefPtr<SkPicture> content_;
sk_sp<SkPicture> content_;
};
bool WriteAssetToBuffer(const SkStreamAsset* asset,
@ -144,7 +144,7 @@ bool PdfMetafileSkia::FinishPage() {
return false;
DCHECK(!(data_->pages_.back().content_));
data_->pages_.back().content_ =
skia::AdoptRef(data_->recorder_.endRecordingAsPicture());
data_->recorder_.finishRecordingAsPicture();
return true;
}
@ -173,7 +173,7 @@ bool PdfMetafileSkia::FinishDocument() {
page.page_size_.width(), page.page_size_.height(), &page.content_area_);
// No need to save/restore, since this canvas is not reused after endPage()
canvas->scale(page.scale_factor_, page.scale_factor_);
canvas->drawPicture(page.content_.get());
canvas->drawPicture(page.content_);
pdf_doc->endPage();
}
if (!pdf_doc->close())

@ -345,8 +345,7 @@ TEST(AnalysisCanvasTest, EarlyOutNotSolid) {
record_canvas->drawText(
text.c_str(), text.length(), point.fX, point.fY, paint);
skia::RefPtr<SkPicture> picture =
skia::AdoptRef(recorder.endRecordingAsPicture());
sk_sp<SkPicture> picture = recorder.finishRecordingAsPicture();
// Draw the picture into the analysis canvas, using the canvas as a callback
// as well.

@ -58,9 +58,9 @@ SkCanvas* StartRecording(SkPictureRecorder* recorder, gfx::Rect layer_rect) {
return canvas;
}
SkPicture* StopRecording(SkPictureRecorder* recorder, SkCanvas* canvas) {
sk_sp<SkPicture> StopRecording(SkPictureRecorder* recorder, SkCanvas* canvas) {
canvas->restore();
return recorder->endRecordingAsPicture();
return recorder->finishRecordingAsPicture();
}
} // namespace
@ -104,8 +104,7 @@ TEST(PixelRefUtilsTest, DrawPaint) {
canvas->clipRect(SkRect::MakeWH(100, 100));
canvas->drawPaint(third_paint);
skia::RefPtr<SkPicture> picture =
skia::AdoptRef(StopRecording(&recorder, canvas));
sk_sp<SkPicture> picture = StopRecording(&recorder, canvas);
std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
@ -164,8 +163,7 @@ TEST(PixelRefUtilsTest, DrawPoints) {
// (50, 55, 150, 145).
canvas->drawPoints(SkCanvas::kPolygon_PointMode, 3, points, third_paint);
skia::RefPtr<SkPicture> picture =
skia::AdoptRef(StopRecording(&recorder, canvas));
sk_sp<SkPicture> picture = StopRecording(&recorder, canvas);
std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
@ -216,8 +214,7 @@ TEST(PixelRefUtilsTest, DrawRect) {
// (20, 20, 100, 100)
canvas->drawRect(SkRect::MakeXYWH(0, 0, 100, 100), third_paint);
skia::RefPtr<SkPicture> picture =
skia::AdoptRef(StopRecording(&recorder, canvas));
sk_sp<SkPicture> picture = StopRecording(&recorder, canvas);
std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
@ -273,8 +270,7 @@ TEST(PixelRefUtilsTest, DrawRRect) {
// (20, 20, 100, 100)
canvas->drawRRect(rrect, third_paint);
skia::RefPtr<SkPicture> picture =
skia::AdoptRef(StopRecording(&recorder, canvas));
sk_sp<SkPicture> picture = StopRecording(&recorder, canvas);
std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
@ -329,8 +325,7 @@ TEST(PixelRefUtilsTest, DrawOval) {
// (20, 20, 100, 100).
canvas->drawRect(SkRect::MakeXYWH(0, 0, 100, 100), third_paint);
skia::RefPtr<SkPicture> picture =
skia::AdoptRef(StopRecording(&recorder, canvas));
sk_sp<SkPicture> picture = StopRecording(&recorder, canvas);
std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
@ -379,8 +374,7 @@ TEST(PixelRefUtilsTest, DrawPath) {
canvas->restore();
skia::RefPtr<SkPicture> picture =
skia::AdoptRef(StopRecording(&recorder, canvas));
sk_sp<SkPicture> picture = StopRecording(&recorder, canvas);
std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
@ -422,8 +416,7 @@ TEST(PixelRefUtilsTest, DrawText) {
canvas->drawPosText("text", 4, points, first_paint);
canvas->drawTextOnPath("text", 4, path, NULL, first_paint);
skia::RefPtr<SkPicture> picture =
skia::AdoptRef(StopRecording(&recorder, canvas));
sk_sp<SkPicture> picture = StopRecording(&recorder, canvas);
std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
@ -494,8 +487,7 @@ TEST(PixelRefUtilsTest, DrawVertices) {
3,
third_paint);
skia::RefPtr<SkPicture> picture =
skia::AdoptRef(StopRecording(&recorder, canvas));
sk_sp<SkPicture> picture = StopRecording(&recorder, canvas);
std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
@ -563,8 +555,7 @@ TEST(PixelRefUtilsTest, DrawImage) {
canvas->restore();
skia::RefPtr<SkPicture> picture =
skia::AdoptRef(StopRecording(&recorder, canvas));
sk_sp<SkPicture> picture = StopRecording(&recorder, canvas);
std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);
@ -627,8 +618,7 @@ TEST(PixelRefUtilsTest, DrawImageRect) {
canvas->restore();
skia::RefPtr<SkPicture> picture =
skia::AdoptRef(StopRecording(&recorder, canvas));
sk_sp<SkPicture> picture = StopRecording(&recorder, canvas);
std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs;
skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs);

@ -57,8 +57,8 @@ static void paintArtifactToWebDisplayItemList(WebDisplayItemList* list, const Pa
// separate layers and send those to the compositor, instead of sending
// one big flat SkPicture.
SkRect skBounds = SkRect::MakeXYWH(bounds.x(), bounds.y(), bounds.width(), bounds.height());
RefPtr<SkPicture> picture = paintArtifactToSkPicture(artifact, skBounds);
list->appendDrawingItem(WebRect(bounds.x(), bounds.y(), bounds.width(), bounds.height()), picture.get());
list->appendDrawingItem(WebRect(bounds.x(), bounds.y(), bounds.width(), bounds.height()),
paintArtifactToSkPicture(artifact, skBounds));
return;
}
artifact.appendToWebDisplayItemList(list);

@ -84,7 +84,7 @@ static void appendDisplayItemToCcDisplayItemList(const DisplayItem& displayItem,
if (!picture)
return;
gfx::Rect bounds = gfx::SkIRectToRect(picture->cullRect().roundOut());
list->CreateAndAppendItem<cc::DrawingDisplayItem>(bounds, skia::SharePtr(picture));
list->CreateAndAppendItem<cc::DrawingDisplayItem>(bounds, sk_ref_sp(picture));
}
}

@ -25,7 +25,7 @@ void DrawingDisplayItem::replay(GraphicsContext& context) const
void DrawingDisplayItem::appendToWebDisplayItemList(const IntRect& visualRect, WebDisplayItemList* list) const
{
if (m_picture)
list->appendDrawingItem(visualRect, m_picture.get());
list->appendDrawingItem(visualRect, toSkSp(m_picture));
}
bool DrawingDisplayItem::drawsContent() const

@ -136,12 +136,12 @@ void paintArtifactToSkCanvas(const PaintArtifact& artifact, SkCanvas* canvas)
}
}
PassRefPtr<SkPicture> paintArtifactToSkPicture(const PaintArtifact& artifact, const SkRect& bounds)
sk_sp<const SkPicture> paintArtifactToSkPicture(const PaintArtifact& artifact, const SkRect& bounds)
{
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(bounds);
paintArtifactToSkCanvas(artifact, canvas);
return adoptRef(recorder.endRecordingAsPicture());
return recorder.finishRecordingAsPicture();
}
} // namespace blink

@ -6,7 +6,7 @@
#define PaintArtifactToSkCanvas_h
#include "platform/PlatformExport.h"
#include "wtf/PassRefPtr.h"
#include "third_party/skia/include/core/SkRefCnt.h"
class SkCanvas;
class SkPicture;
@ -26,7 +26,7 @@ class PaintArtifact;
PLATFORM_EXPORT void paintArtifactToSkCanvas(const PaintArtifact&, SkCanvas*);
// Using the previous, converts the paint artifact to an SkPicture.
PLATFORM_EXPORT PassRefPtr<SkPicture> paintArtifactToSkPicture(
PLATFORM_EXPORT sk_sp<const SkPicture> paintArtifactToSkPicture(
const PaintArtifact&, const SkRect& bounds);
} // namespace blink

@ -273,8 +273,8 @@ void LinkHighlightImpl::paintContents(WebDisplayItemList* webDisplayItemList, We
paint.setColor(m_node->layoutObject()->style()->tapHighlightColor().rgb());
canvas->drawPath(m_path.getSkPath(), paint);
RefPtr<const SkPicture> picture = adoptRef(recorder.endRecording());
webDisplayItemList->appendDrawingItem(WebRect(visualRect.x(), visualRect.y(), visualRect.width(), visualRect.height()), picture.get());
webDisplayItemList->appendDrawingItem(WebRect(visualRect.x(), visualRect.y(),
visualRect.width(), visualRect.height()), recorder.finishRecordingAsPicture());
}
void LinkHighlightImpl::startHighlightAnimationIfNeeded()

@ -16,7 +16,7 @@ SimDisplayItemList::SimDisplayItemList()
{
}
void SimDisplayItemList::appendDrawingItem(const WebRect&, const SkPicture* picture)
void SimDisplayItemList::appendDrawingItem(const WebRect&, sk_sp<const SkPicture> picture)
{
m_containsText |= picture->hasText();

@ -15,7 +15,7 @@ class SimDisplayItemList final : public WebDisplayItemList {
public:
SimDisplayItemList();
void appendDrawingItem(const WebRect&, const SkPicture*) override;
void appendDrawingItem(const WebRect&, sk_sp<const SkPicture>) override;
int drawCount() const { return m_commands.size(); }

@ -14,6 +14,7 @@
#include "third_party/skia/include/core/SkColorFilter.h"
#include "third_party/skia/include/core/SkRRect.h"
#include "third_party/skia/include/core/SkRefCnt.h"
#include "third_party/skia/include/core/SkRegion.h"
#include "third_party/skia/include/core/SkXfermode.h"
#include "third_party/skia/include/utils/SkMatrix44.h"
@ -36,8 +37,7 @@ class WebDisplayItemList {
public:
virtual ~WebDisplayItemList() { }
// This grabs a ref on the passed-in SkPicture.
virtual void appendDrawingItem(const WebRect& visualRect, const SkPicture*) { }
virtual void appendDrawingItem(const WebRect& visualRect, sk_sp<const SkPicture>) { }
virtual void appendClipItem(const WebRect& visualRect, const WebRect& clipRect, const WebVector<SkRRect>& roundedClipRects) { }
virtual void appendEndClipItem(const WebRect& visualRect) { }

@ -43,7 +43,7 @@ PaintRecorder::~PaintRecorder() {
const auto& item =
context_.list_->CreateAndAppendItem<cc::DrawingDisplayItem>(
bounds_in_layer_,
skia::AdoptRef(context_.recorder_->endRecordingAsPicture()));
context_.recorder_->finishRecordingAsPicture());
if (cache_)
cache_->SetCache(item);
}