diff options
27 files changed, 109 insertions, 156 deletions
diff --git a/cc/blink/web_content_layer_impl.cc b/cc/blink/web_content_layer_impl.cc index 9e31bb6..932179f 100644 --- a/cc/blink/web_content_layer_impl.cc +++ b/cc/blink/web_content_layer_impl.cc @@ -76,15 +76,19 @@ void WebContentLayerImpl::PaintContents( client_->paintContents(canvas, clip, PaintingControlToWeb(painting_control)); } -void WebContentLayerImpl::PaintContentsToDisplayList( - cc::DisplayItemList* display_list, +scoped_refptr<cc::DisplayItemList> +WebContentLayerImpl::PaintContentsToDisplayList( const gfx::Rect& clip, cc::ContentLayerClient::PaintingControlSetting painting_control) { - if (!client_) - return; - - WebDisplayItemListImpl list(display_list); - client_->paintContents(&list, clip, PaintingControlToWeb(painting_control)); + const bool use_cached_picture = true; + scoped_refptr<cc::DisplayItemList> display_list = + cc::DisplayItemList::Create(clip, use_cached_picture); + if (client_) { + WebDisplayItemListImpl list(display_list.get()); + client_->paintContents(&list, clip, PaintingControlToWeb(painting_control)); + } + display_list->Finalize(); + return display_list; } bool WebContentLayerImpl::FillsBoundsCompletely() const { diff --git a/cc/blink/web_content_layer_impl.h b/cc/blink/web_content_layer_impl.h index e7b04b0..3e7b55c 100644 --- a/cc/blink/web_content_layer_impl.h +++ b/cc/blink/web_content_layer_impl.h @@ -39,8 +39,7 @@ class WebContentLayerImpl : public blink::WebContentLayer, void PaintContents(SkCanvas* canvas, const gfx::Rect& clip, PaintingControlSetting painting_control) override; - void PaintContentsToDisplayList( - cc::DisplayItemList* display_list, + scoped_refptr<cc::DisplayItemList> PaintContentsToDisplayList( const gfx::Rect& clip, PaintingControlSetting painting_control) override; bool FillsBoundsCompletely() const override; diff --git a/cc/debug/rasterize_and_record_benchmark.cc b/cc/debug/rasterize_and_record_benchmark.cc index c843985..ff8aa6b 100644 --- a/cc/debug/rasterize_and_record_benchmark.cc +++ b/cc/debug/rasterize_and_record_benchmark.cc @@ -218,12 +218,8 @@ void RasterizeAndRecordBenchmark::RunOnDisplayListLayer( kTimeCheckInterval); do { - const bool use_cached_picture = true; - display_list = - DisplayItemList::Create(visible_layer_rect, use_cached_picture); - painter->PaintContentsToDisplayList( - display_list.get(), visible_layer_rect, painting_control); - display_list->CreateAndCacheSkPicture(); + display_list = painter->PaintContentsToDisplayList(visible_layer_rect, + painting_control); if (memory_used) { // Verify we are recording the same thing each time. diff --git a/cc/layers/content_layer_client.h b/cc/layers/content_layer_client.h index 9125b97..3a56263 100644 --- a/cc/layers/content_layer_client.h +++ b/cc/layers/content_layer_client.h @@ -12,7 +12,6 @@ class SkCanvas; namespace gfx { class Rect; -class RectF; } namespace cc { @@ -30,8 +29,7 @@ class CC_EXPORT ContentLayerClient { const gfx::Rect& clip, PaintingControlSetting painting_status) = 0; - virtual void PaintContentsToDisplayList( - DisplayItemList* display_list, + virtual scoped_refptr<DisplayItemList> PaintContentsToDisplayList( const gfx::Rect& clip, PaintingControlSetting painting_status) = 0; diff --git a/cc/layers/picture_image_layer.cc b/cc/layers/picture_image_layer.cc index f9d13d72..6d903bd 100644 --- a/cc/layers/picture_image_layer.cc +++ b/cc/layers/picture_image_layer.cc @@ -66,10 +66,15 @@ void PictureImageLayer::PaintContents( canvas->drawBitmap(bitmap_, 0, 0); } -void PictureImageLayer::PaintContentsToDisplayList( - DisplayItemList* display_list, +scoped_refptr<DisplayItemList> PictureImageLayer::PaintContentsToDisplayList( const gfx::Rect& clip, ContentLayerClient::PaintingControlSetting painting_control) { + // Picture image layers can be used with GatherPixelRefs, so cached SkPictures + // are currently required. + const bool use_cached_picture = true; + scoped_refptr<DisplayItemList> display_list = + DisplayItemList::Create(clip, use_cached_picture); + SkPictureRecorder recorder; SkCanvas* canvas = recorder.beginRecording(gfx::RectToSkRect(clip)); PaintContents(canvas, clip, painting_control); @@ -78,6 +83,9 @@ void PictureImageLayer::PaintContentsToDisplayList( skia::AdoptRef(recorder.endRecordingAsPicture()); auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>(); item->SetNew(picture.Pass()); + + display_list->Finalize(); + return display_list; } bool PictureImageLayer::FillsBoundsCompletely() const { diff --git a/cc/layers/picture_image_layer.h b/cc/layers/picture_image_layer.h index 0c1adb5..df597f3 100644 --- a/cc/layers/picture_image_layer.h +++ b/cc/layers/picture_image_layer.h @@ -27,8 +27,7 @@ class CC_EXPORT PictureImageLayer : public PictureLayer, ContentLayerClient { SkCanvas* canvas, const gfx::Rect& clip, ContentLayerClient::PaintingControlSetting painting_control) override; - void PaintContentsToDisplayList( - DisplayItemList* display_list, + scoped_refptr<DisplayItemList> PaintContentsToDisplayList( const gfx::Rect& clip, ContentLayerClient::PaintingControlSetting painting_control) override; bool FillsBoundsCompletely() const override; diff --git a/cc/layers/picture_image_layer_unittest.cc b/cc/layers/picture_image_layer_unittest.cc index 76f9cf5..fafdbf1 100644 --- a/cc/layers/picture_image_layer_unittest.cc +++ b/cc/layers/picture_image_layer_unittest.cc @@ -35,47 +35,9 @@ TEST(PictureImageLayerTest, PaintContentsToDisplayList) { layer->SetBitmap(image_bitmap); layer->SetBounds(gfx::Size(layer_rect.width(), layer_rect.height())); - bool use_cached_picture = false; scoped_refptr<DisplayItemList> display_list = - DisplayItemList::Create(layer_rect, use_cached_picture); - layer->PaintContentsToDisplayList( - display_list.get(), layer_rect, - ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); - display_list->ProcessAppendedItems(); - unsigned char actual_pixels[4 * 200 * 200] = {0}; - DrawDisplayList(actual_pixels, layer_rect, display_list); - - EXPECT_EQ(0, memcmp(actual_pixels, image_pixels, 4 * 200 * 200)); -} - -TEST(PictureImageLayerTest, PaintContentsToCachedDisplayList) { - scoped_refptr<PictureImageLayer> layer = - PictureImageLayer::Create(LayerSettings()); - gfx::Rect layer_rect(200, 200); - - SkBitmap image_bitmap; - unsigned char image_pixels[4 * 200 * 200] = {0}; - SkImageInfo info = - SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); - image_bitmap.installPixels(info, image_pixels, info.minRowBytes()); - SkCanvas image_canvas(image_bitmap); - image_canvas.clear(SK_ColorRED); - SkPaint blue_paint; - blue_paint.setColor(SK_ColorBLUE); - image_canvas.drawRectCoords(0.f, 0.f, 100.f, 100.f, blue_paint); - image_canvas.drawRectCoords(100.f, 100.f, 200.f, 200.f, blue_paint); - - layer->SetBitmap(image_bitmap); - layer->SetBounds(gfx::Size(layer_rect.width(), layer_rect.height())); - - bool use_cached_picture = true; - scoped_refptr<DisplayItemList> display_list = - DisplayItemList::Create(layer_rect, use_cached_picture); - layer->PaintContentsToDisplayList( - display_list.get(), layer_rect, - ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); - display_list->ProcessAppendedItems(); - display_list->CreateAndCacheSkPicture(); + layer->PaintContentsToDisplayList( + layer_rect, ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); unsigned char actual_pixels[4 * 200 * 200] = {0}; DrawDisplayList(actual_pixels, layer_rect, display_list); diff --git a/cc/layers/picture_layer.cc b/cc/layers/picture_layer.cc index eb037ad..f55f4c4 100644 --- a/cc/layers/picture_layer.cc +++ b/cc/layers/picture_layer.cc @@ -92,9 +92,8 @@ void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) { const LayerTreeSettings& settings = layer_tree_host()->settings(); if (!recording_source_) { if (settings.use_display_lists) { - recording_source_.reset(new DisplayListRecordingSource( - settings.default_tile_grid_size, - settings.use_cached_picture_in_display_list)); + recording_source_.reset( + new DisplayListRecordingSource(settings.default_tile_grid_size)); } else { recording_source_.reset(new PicturePile(settings.minimum_contents_scale, settings.default_tile_grid_size)); @@ -190,9 +189,8 @@ skia::RefPtr<SkPicture> PictureLayer::GetPicture() const { if (settings.use_display_lists) { scoped_ptr<RecordingSource> recording_source; - recording_source.reset(new DisplayListRecordingSource( - settings.default_tile_grid_size, - settings.use_cached_picture_in_display_list)); + recording_source.reset( + new DisplayListRecordingSource(settings.default_tile_grid_size)); Region recording_invalidation; recording_source->UpdateAndExpandInvalidation( client_, &recording_invalidation, layer_size, gfx::Rect(layer_size), diff --git a/cc/layers/picture_layer_unittest.cc b/cc/layers/picture_layer_unittest.cc index edbc621..87c4bd7 100644 --- a/cc/layers/picture_layer_unittest.cc +++ b/cc/layers/picture_layer_unittest.cc @@ -25,11 +25,11 @@ class MockContentLayerClient : public ContentLayerClient { void PaintContents(SkCanvas* canvas, const gfx::Rect& clip, PaintingControlSetting picture_control) override {} - void PaintContentsToDisplayList( - DisplayItemList* display_list, + scoped_refptr<DisplayItemList> PaintContentsToDisplayList( const gfx::Rect& clip, PaintingControlSetting picture_control) override { NOTIMPLEMENTED(); + return nullptr; } bool FillsBoundsCompletely() const override { return false; }; }; diff --git a/cc/playback/display_item_list.cc b/cc/playback/display_item_list.cc index e530e19..a0b3e71 100644 --- a/cc/playback/display_item_list.cc +++ b/cc/playback/display_item_list.cc @@ -146,16 +146,20 @@ void DisplayItemList::ProcessAppendedItems() { items_.clear(); } -void DisplayItemList::CreateAndCacheSkPicture() { - DCHECK(ProcessAppendedItemsCalled()); - // Convert to an SkPicture for faster rasterization. - DCHECK(use_cached_picture_); - DCHECK(!picture_); - picture_ = skia::AdoptRef(recorder_->endRecordingAsPicture()); - DCHECK(picture_); - picture_memory_usage_ += SkPictureUtils::ApproximateBytesUsed(picture_.get()); - recorder_.reset(); - canvas_.clear(); +void DisplayItemList::Finalize() { + ProcessAppendedItems(); + + if (use_cached_picture_) { + // Convert to an SkPicture for faster rasterization. + DCHECK(use_cached_picture_); + DCHECK(!picture_); + picture_ = skia::AdoptRef(recorder_->endRecordingAsPicture()); + DCHECK(picture_); + picture_memory_usage_ += + SkPictureUtils::ApproximateBytesUsed(picture_.get()); + recorder_.reset(); + canvas_.clear(); + } } bool DisplayItemList::IsSuitableForGpuRasterization() const { diff --git a/cc/playback/display_item_list.h b/cc/playback/display_item_list.h index 1c8d088..dfc697f 100644 --- a/cc/playback/display_item_list.h +++ b/cc/playback/display_item_list.h @@ -44,8 +44,9 @@ class CC_EXPORT DisplayItemList return items_.AllocateAndConstruct<DisplayItemType>(); } - void ProcessAppendedItems(); - void CreateAndCacheSkPicture(); + // Called after all items are appended, to process the items and, if + // applicable, create an internally cached SkPicture. + void Finalize(); bool IsSuitableForGpuRasterization() const; int ApproximateOpCount() const; @@ -67,6 +68,7 @@ class CC_EXPORT DisplayItemList // While appending new items, if they are not being retained, this can process // periodically to avoid retaining all the items and processing at the end. void ProcessAppendedItemsOnTheFly(); + void ProcessAppendedItems(); #if DCHECK_IS_ON() bool ProcessAppendedItemsCalled() const { return !needs_process_; } bool needs_process_; diff --git a/cc/playback/display_item_list_unittest.cc b/cc/playback/display_item_list_unittest.cc index 6a5bbf6..81fbae4 100644 --- a/cc/playback/display_item_list_unittest.cc +++ b/cc/playback/display_item_list_unittest.cc @@ -50,8 +50,7 @@ TEST(DisplayItemListTest, SingleDrawingItem) { picture = skia::AdoptRef(recorder.endRecordingAsPicture()); auto* item = list->CreateAndAppendItem<DrawingDisplayItem>(); item->SetNew(picture); - list->ProcessAppendedItems(); - list->CreateAndCacheSkPicture(); + list->Finalize(); DrawDisplayList(pixels, layer_rect, list); SkBitmap expected_bitmap; @@ -110,8 +109,7 @@ TEST(DisplayItemListTest, ClipItem) { item3->SetNew(picture.Pass()); list->CreateAndAppendItem<EndClipDisplayItem>(); - list->ProcessAppendedItems(); - list->CreateAndCacheSkPicture(); + list->Finalize(); DrawDisplayList(pixels, layer_rect, list); @@ -173,8 +171,7 @@ TEST(DisplayItemListTest, TransformItem) { item3->SetNew(picture); list->CreateAndAppendItem<EndTransformDisplayItem>(); - list->ProcessAppendedItems(); - list->CreateAndCacheSkPicture(); + list->Finalize(); DrawDisplayList(pixels, layer_rect, list); @@ -228,8 +225,7 @@ TEST(DisplayItemListTest, FilterItem) { auto* item = list->CreateAndAppendItem<FilterDisplayItem>(); item->SetNew(filters, filter_bounds); list->CreateAndAppendItem<EndFilterDisplayItem>(); - list->ProcessAppendedItems(); - list->CreateAndCacheSkPicture(); + list->Finalize(); DrawDisplayList(pixels, layer_rect, list); @@ -272,7 +268,7 @@ TEST(DisplayItemListTest, CompactingItems) { picture = skia::AdoptRef(recorder.endRecordingAsPicture()); auto* item1 = list_without_caching->CreateAndAppendItem<DrawingDisplayItem>(); item1->SetNew(picture); - list_without_caching->ProcessAppendedItems(); + list_without_caching->Finalize(); DrawDisplayList(pixels, layer_rect, list_without_caching); unsigned char expected_pixels[4 * 100 * 100] = {0}; @@ -281,8 +277,7 @@ TEST(DisplayItemListTest, CompactingItems) { DisplayItemList::Create(layer_rect, use_cached_picture); auto* item2 = list_with_caching->CreateAndAppendItem<DrawingDisplayItem>(); item2->SetNew(picture); - list_with_caching->ProcessAppendedItems(); - list_with_caching->CreateAndCacheSkPicture(); + list_with_caching->Finalize(); DrawDisplayList(expected_pixels, layer_rect, list_with_caching); EXPECT_EQ(0, memcmp(pixels, expected_pixels, 4 * 100 * 100)); @@ -310,8 +305,7 @@ TEST(DisplayItemListTest, PictureMemoryUsage) { list = DisplayItemList::Create(layer_rect, true); auto* item = list->CreateAndAppendItem<DrawingDisplayItem>(); item->SetNew(picture); - list->ProcessAppendedItems(); - list->CreateAndCacheSkPicture(); + list->Finalize(); memory_usage = list->PictureMemoryUsage(); EXPECT_GE(memory_usage, picture_size); EXPECT_LE(memory_usage, 2 * picture_size); @@ -320,7 +314,7 @@ TEST(DisplayItemListTest, PictureMemoryUsage) { list = DisplayItemList::Create(layer_rect, false); item = list->CreateAndAppendItem<DrawingDisplayItem>(); item->SetNew(picture); - list->ProcessAppendedItems(); + list->Finalize(); memory_usage = list->PictureMemoryUsage(); EXPECT_GE(memory_usage, picture_size); EXPECT_LE(memory_usage, 2 * picture_size); @@ -331,8 +325,7 @@ TEST(DisplayItemListTest, PictureMemoryUsage) { list = new DisplayItemList(layer_rect, true, true); item = list->CreateAndAppendItem<DrawingDisplayItem>(); item->SetNew(picture); - list->ProcessAppendedItems(); - list->CreateAndCacheSkPicture(); + list->Finalize(); memory_usage = list->PictureMemoryUsage(); EXPECT_EQ(static_cast<size_t>(0), memory_usage); } diff --git a/cc/playback/display_list_recording_source.cc b/cc/playback/display_list_recording_source.cc index 9caed71..cb044d3 100644 --- a/cc/playback/display_list_recording_source.cc +++ b/cc/playback/display_list_recording_source.cc @@ -33,10 +33,8 @@ DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER( namespace cc { DisplayListRecordingSource::DisplayListRecordingSource( - const gfx::Size& grid_cell_size, - bool use_cached_picture) - : use_cached_picture_(use_cached_picture), - slow_down_raster_scale_factor_for_debug_(0), + const gfx::Size& grid_cell_size) + : slow_down_raster_scale_factor_for_debug_(0), gather_pixel_refs_(false), requires_clear_(false), is_solid_color_(false), @@ -119,14 +117,9 @@ bool DisplayListRecordingSource::UpdateAndExpandInvalidation( painting_control = ContentLayerClient::DISPLAY_LIST_CACHING_DISABLED; } for (int i = 0; i < repeat_count; ++i) { - display_list_ = - DisplayItemList::Create(recorded_viewport_, use_cached_picture_); - painter->PaintContentsToDisplayList(display_list_.get(), recorded_viewport_, - painting_control); + display_list_ = painter->PaintContentsToDisplayList(recorded_viewport_, + painting_control); } - display_list_->ProcessAppendedItems(); - if (use_cached_picture_) - display_list_->CreateAndCacheSkPicture(); is_suitable_for_gpu_rasterization_ = display_list_->IsSuitableForGpuRasterization(); diff --git a/cc/playback/display_list_recording_source.h b/cc/playback/display_list_recording_source.h index 8d652fa..d95362b 100644 --- a/cc/playback/display_list_recording_source.h +++ b/cc/playback/display_list_recording_source.h @@ -14,8 +14,7 @@ class DisplayListRasterSource; class CC_EXPORT DisplayListRecordingSource : public RecordingSource { public: - DisplayListRecordingSource(const gfx::Size& grid_cell_size, - bool use_cached_picture); + explicit DisplayListRecordingSource(const gfx::Size& grid_cell_size); ~DisplayListRecordingSource() override; // RecordingSource overrides. @@ -40,8 +39,6 @@ class CC_EXPORT DisplayListRecordingSource : public RecordingSource { protected: void Clear(); - const bool use_cached_picture_; - gfx::Rect recorded_viewport_; gfx::Size size_; int slow_down_raster_scale_factor_for_debug_; diff --git a/cc/test/fake_content_layer_client.cc b/cc/test/fake_content_layer_client.cc index 5d949bf..b0dacb3 100644 --- a/cc/test/fake_content_layer_client.cc +++ b/cc/test/fake_content_layer_client.cc @@ -71,10 +71,15 @@ void FakeContentLayerClient::PaintContents( } } -void FakeContentLayerClient::PaintContentsToDisplayList( - DisplayItemList* display_list, +scoped_refptr<DisplayItemList> +FakeContentLayerClient::PaintContentsToDisplayList( const gfx::Rect& clip, PaintingControlSetting painting_control) { + // Cached picture is used because unit tests expect to be able to + // use GatherPixelRefs. + const bool use_cached_picture = true; + scoped_refptr<DisplayItemList> display_list = + DisplayItemList::Create(clip, use_cached_picture); SkPictureRecorder recorder; skia::RefPtr<SkCanvas> canvas; skia::RefPtr<SkPicture> picture; @@ -128,6 +133,9 @@ void FakeContentLayerClient::PaintContentsToDisplayList( } display_list->CreateAndAppendItem<EndClipDisplayItem>(); + + display_list->Finalize(); + return display_list; } bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } diff --git a/cc/test/fake_content_layer_client.h b/cc/test/fake_content_layer_client.h index d01bbd1..a4ecc59 100644 --- a/cc/test/fake_content_layer_client.h +++ b/cc/test/fake_content_layer_client.h @@ -40,8 +40,7 @@ class FakeContentLayerClient : public ContentLayerClient { void PaintContents(SkCanvas* canvas, const gfx::Rect& rect, PaintingControlSetting painting_control) override; - void PaintContentsToDisplayList( - DisplayItemList* display_list, + scoped_refptr<DisplayItemList> PaintContentsToDisplayList( const gfx::Rect& clip, PaintingControlSetting painting_control) override; bool FillsBoundsCompletely() const override; diff --git a/cc/test/fake_display_list_recording_source.h b/cc/test/fake_display_list_recording_source.h index d4506ad..bb55a66 100644 --- a/cc/test/fake_display_list_recording_source.h +++ b/cc/test/fake_display_list_recording_source.h @@ -16,17 +16,15 @@ namespace cc { // display list. class FakeDisplayListRecordingSource : public DisplayListRecordingSource { public: - FakeDisplayListRecordingSource(const gfx::Size& grid_cell_size, - bool use_cached_picture) - : DisplayListRecordingSource(grid_cell_size, use_cached_picture) {} + explicit FakeDisplayListRecordingSource(const gfx::Size& grid_cell_size) + : DisplayListRecordingSource(grid_cell_size) {} ~FakeDisplayListRecordingSource() override {} static scoped_ptr<FakeDisplayListRecordingSource> CreateRecordingSource( const gfx::Rect& recorded_viewport) { scoped_ptr<FakeDisplayListRecordingSource> recording_source( new FakeDisplayListRecordingSource( - ImplSidePaintingSettings().default_tile_grid_size, - ImplSidePaintingSettings().use_cached_picture_in_display_list)); + ImplSidePaintingSettings().default_tile_grid_size)); recording_source->SetRecordedViewport(recorded_viewport); return recording_source; } @@ -42,13 +40,8 @@ class FakeDisplayListRecordingSource : public DisplayListRecordingSource { void Rerecord() { ContentLayerClient::PaintingControlSetting painting_control = ContentLayerClient::PAINTING_BEHAVIOR_NORMAL; - bool use_cached_picture = true; - display_list_ = - DisplayItemList::Create(recorded_viewport_, use_cached_picture); - client_.PaintContentsToDisplayList(display_list_.get(), recorded_viewport_, - painting_control); - display_list_->ProcessAppendedItems(); - display_list_->CreateAndCacheSkPicture(); + display_list_ = client_.PaintContentsToDisplayList(recorded_viewport_, + painting_control); if (gather_pixel_refs_) display_list_->GatherPixelRefs(grid_cell_size_); } diff --git a/cc/test/solid_color_content_layer_client.cc b/cc/test/solid_color_content_layer_client.cc index fe13526..a80f4a8 100644 --- a/cc/test/solid_color_content_layer_client.cc +++ b/cc/test/solid_color_content_layer_client.cc @@ -25,11 +25,12 @@ void SolidColorContentLayerClient::PaintContents( paint); } -void SolidColorContentLayerClient::PaintContentsToDisplayList( - DisplayItemList* display_list, +scoped_refptr<DisplayItemList> +SolidColorContentLayerClient::PaintContentsToDisplayList( const gfx::Rect& clip, PaintingControlSetting painting_control) { NOTIMPLEMENTED(); + return nullptr; } bool SolidColorContentLayerClient::FillsBoundsCompletely() const { diff --git a/cc/test/solid_color_content_layer_client.h b/cc/test/solid_color_content_layer_client.h index 3068f9ae..1ab4c4d 100644 --- a/cc/test/solid_color_content_layer_client.h +++ b/cc/test/solid_color_content_layer_client.h @@ -19,8 +19,7 @@ class SolidColorContentLayerClient : public ContentLayerClient { void PaintContents(SkCanvas* canvas, const gfx::Rect& rect, PaintingControlSetting painting_control) override; - void PaintContentsToDisplayList( - DisplayItemList* display_list, + scoped_refptr<DisplayItemList> PaintContentsToDisplayList( const gfx::Rect& clip, PaintingControlSetting painting_control) override; bool FillsBoundsCompletely() const override; diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc index 7e3778f..17800fe 100644 --- a/cc/trees/layer_tree_host_common_unittest.cc +++ b/cc/trees/layer_tree_host_common_unittest.cc @@ -64,11 +64,11 @@ class MockContentLayerClient : public ContentLayerClient { void PaintContents(SkCanvas* canvas, const gfx::Rect& clip, PaintingControlSetting picture_control) override {} - void PaintContentsToDisplayList( - DisplayItemList* display_list, + scoped_refptr<DisplayItemList> PaintContentsToDisplayList( const gfx::Rect& clip, PaintingControlSetting picture_control) override { NOTIMPLEMENTED(); + return nullptr; } bool FillsBoundsCompletely() const override { return false; } }; diff --git a/cc/trees/layer_tree_host_pixeltest_masks.cc b/cc/trees/layer_tree_host_pixeltest_masks.cc index 086f3ea..6a4bebd 100644 --- a/cc/trees/layer_tree_host_pixeltest_masks.cc +++ b/cc/trees/layer_tree_host_pixeltest_masks.cc @@ -46,11 +46,11 @@ class MaskContentLayerClient : public ContentLayerClient { } } - void PaintContentsToDisplayList( - DisplayItemList* display_list, + scoped_refptr<DisplayItemList> PaintContentsToDisplayList( const gfx::Rect& clip, PaintingControlSetting picture_control) override { NOTIMPLEMENTED(); + return nullptr; } private: @@ -310,11 +310,11 @@ class CheckerContentLayerClient : public ContentLayerClient { } } } - void PaintContentsToDisplayList( - DisplayItemList* display_list, + scoped_refptr<DisplayItemList> PaintContentsToDisplayList( const gfx::Rect& clip, PaintingControlSetting picture_control) override { NOTIMPLEMENTED(); + return nullptr; } private: @@ -341,11 +341,11 @@ class CircleContentLayerClient : public ContentLayerClient { bounds_.width() / 4, paint); } - void PaintContentsToDisplayList( - DisplayItemList* display_list, + scoped_refptr<DisplayItemList> PaintContentsToDisplayList( const gfx::Rect& clip, PaintingControlSetting picture_control) override { NOTIMPLEMENTED(); + return nullptr; } private: diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc index 53de149..808fb93 100644 --- a/cc/trees/layer_tree_host_unittest.cc +++ b/cc/trees/layer_tree_host_unittest.cc @@ -1379,11 +1379,11 @@ class TestOpacityChangeLayerDelegate : public ContentLayerClient { if (test_layer_) test_layer_->SetOpacity(0.f); } - void PaintContentsToDisplayList( - DisplayItemList* display_list, + scoped_refptr<DisplayItemList> PaintContentsToDisplayList( const gfx::Rect& clip, PaintingControlSetting picture_control) override { NOTIMPLEMENTED(); + return nullptr; } bool FillsBoundsCompletely() const override { return false; } @@ -2946,11 +2946,11 @@ class LayerTreeHostTestChangeLayerPropertiesInPaintContents layer_->SetBounds(gfx::Size(2, 2)); } - void PaintContentsToDisplayList( - DisplayItemList* display_list, + scoped_refptr<DisplayItemList> PaintContentsToDisplayList( const gfx::Rect& clip, PaintingControlSetting picture_control) override { NOTIMPLEMENTED(); + return nullptr; } bool FillsBoundsCompletely() const override { return false; } diff --git a/cc/trees/layer_tree_settings.cc b/cc/trees/layer_tree_settings.cc index 35da140..fa312f1 100644 --- a/cc/trees/layer_tree_settings.cc +++ b/cc/trees/layer_tree_settings.cc @@ -71,7 +71,6 @@ LayerTreeSettings::LayerTreeSettings() use_occlusion_for_tile_prioritization(false), record_full_layer(false), use_display_lists(false), - use_cached_picture_in_display_list(true), verify_property_trees(false), gather_pixel_refs(false), max_bytes_per_copy_operation(std::numeric_limits<size_t>::max()) { diff --git a/cc/trees/layer_tree_settings.h b/cc/trees/layer_tree_settings.h index d62657a..a73b134 100644 --- a/cc/trees/layer_tree_settings.h +++ b/cc/trees/layer_tree_settings.h @@ -86,7 +86,6 @@ class CC_EXPORT LayerTreeSettings { bool use_occlusion_for_tile_prioritization; bool record_full_layer; bool use_display_lists; - bool use_cached_picture_in_display_list; bool verify_property_trees; bool gather_pixel_refs; LayerSettings hud_layer_settings; diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc index 14db614..b17e504 100644 --- a/ui/compositor/compositor.cc +++ b/ui/compositor/compositor.cc @@ -129,7 +129,6 @@ Compositor::Compositor(gfx::AcceleratedWidget widget, settings.impl_side_painting = IsUIImplSidePaintingEnabled(); settings.use_display_lists = IsUISlimmingPaintEnabled(); - settings.use_cached_picture_in_display_list = false; settings.use_zero_copy = IsUIZeroCopyEnabled(); settings.use_one_copy = IsUIOneCopyEnabled(); diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc index fc18bca..895b39c 100644 --- a/ui/compositor/layer.cc +++ b/ui/compositor/layer.cc @@ -779,8 +779,7 @@ void Layer::PaintContents( } } -void Layer::PaintContentsToDisplayList( - cc::DisplayItemList* display_list, +scoped_refptr<cc::DisplayItemList> Layer::PaintContentsToDisplayList( const gfx::Rect& clip, ContentLayerClient::PaintingControlSetting painting_control) { TRACE_EVENT1("ui", "Layer::PaintContentsToDisplayList", "name", name_); @@ -789,10 +788,15 @@ void Layer::PaintContentsToDisplayList( gfx::IntersectRects(damaged_region_.bounds(), local_bounds)); DCHECK(clip.Contains(invalidation)); ClearDamagedRects(); - if (!delegate_) - return; - delegate_->OnPaintLayer( - PaintContext(display_list, device_scale_factor_, clip, invalidation)); + const bool use_cached_picture = false; + scoped_refptr<cc::DisplayItemList> display_list = + cc::DisplayItemList::Create(clip, use_cached_picture); + if (delegate_) { + delegate_->OnPaintLayer(PaintContext( + display_list.get(), device_scale_factor_, clip, invalidation)); + } + display_list->Finalize(); + return display_list; } bool Layer::FillsBoundsCompletely() const { return fills_bounds_completely_; } diff --git a/ui/compositor/layer.h b/ui/compositor/layer.h index 8120197..623e56c 100644 --- a/ui/compositor/layer.h +++ b/ui/compositor/layer.h @@ -353,8 +353,7 @@ class COMPOSITOR_EXPORT Layer SkCanvas* canvas, const gfx::Rect& clip, ContentLayerClient::PaintingControlSetting painting_control) override; - void PaintContentsToDisplayList( - cc::DisplayItemList* display_list, + scoped_refptr<cc::DisplayItemList> PaintContentsToDisplayList( const gfx::Rect& clip, ContentLayerClient::PaintingControlSetting painting_control) override; bool FillsBoundsCompletely() const override; |