diff options
author | pdr <pdr@chromium.org> | 2015-09-16 11:34:19 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-09-16 18:35:58 +0000 |
commit | b42dfda3dd350ddac88a682cc094d816ab054090 (patch) | |
tree | 8f8e49fdbcb36415495c9cd2f2b46ba8beafadfd /cc | |
parent | c9d5f8671ddfbc4d8a6c2988e4818517c19f7de2 (diff) | |
download | chromium_src-b42dfda3dd350ddac88a682cc094d816ab054090.zip chromium_src-b42dfda3dd350ddac88a682cc094d816ab054090.tar.gz chromium_src-b42dfda3dd350ddac88a682cc094d816ab054090.tar.bz2 |
Remove non-slimming-paint codepaths in chrome
Slimming paint has shipped so the non-sp codepaths are rapidly rotting.
This patch removes the slimming paint codepaths in chrome while leaving
the removal of PicturePile and ContentLayerClient::PaintContents to a
followup.
BUG=524314
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
Review URL: https://codereview.chromium.org/1343493003
Cr-Commit-Position: refs/heads/master@{#349168}
Diffstat (limited to 'cc')
-rw-r--r-- | cc/BUILD.gn | 1 | ||||
-rw-r--r-- | cc/cc_tests.gyp | 1 | ||||
-rw-r--r-- | cc/debug/rasterize_and_record_benchmark.cc | 68 | ||||
-rw-r--r-- | cc/debug/rasterize_and_record_benchmark.h | 2 | ||||
-rw-r--r-- | cc/layers/picture_layer.cc | 41 | ||||
-rw-r--r-- | cc/layers/picture_layer_unittest.cc | 23 | ||||
-rw-r--r-- | cc/playback/display_list_recording_source.cc | 4 | ||||
-rw-r--r-- | cc/playback/display_list_recording_source.h | 1 | ||||
-rw-r--r-- | cc/playback/picture_pile.cc | 4 | ||||
-rw-r--r-- | cc/playback/picture_pile.h | 1 | ||||
-rw-r--r-- | cc/playback/recording_source.h | 1 | ||||
-rw-r--r-- | cc/test/fake_display_list_recording_source.cc | 20 | ||||
-rw-r--r-- | cc/test/fake_display_list_recording_source.h | 7 | ||||
-rw-r--r-- | cc/test/fake_picture_pile_impl.cc | 4 | ||||
-rw-r--r-- | cc/test/fake_picture_pile_impl.h | 1 | ||||
-rw-r--r-- | cc/test/solid_color_content_layer_client.cc | 38 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_pixeltest_masks.cc | 91 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_pixeltest_tiles.cc | 1 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_unittest.cc | 39 | ||||
-rw-r--r-- | cc/trees/layer_tree_settings.cc | 1 | ||||
-rw-r--r-- | cc/trees/layer_tree_settings.h | 1 |
21 files changed, 171 insertions, 179 deletions
diff --git a/cc/BUILD.gn b/cc/BUILD.gn index 8513213..095c6de 100644 --- a/cc/BUILD.gn +++ b/cc/BUILD.gn @@ -552,6 +552,7 @@ source_set("test_support") { "test/fake_delegated_renderer_layer.h", "test/fake_delegated_renderer_layer_impl.cc", "test/fake_delegated_renderer_layer_impl.h", + "test/fake_display_list_recording_source.cc", "test/fake_display_list_recording_source.h", "test/fake_external_begin_frame_source.cc", "test/fake_external_begin_frame_source.h", diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp index deb7d32..0ce77be 100644 --- a/cc/cc_tests.gyp +++ b/cc/cc_tests.gyp @@ -166,6 +166,7 @@ 'test/fake_delegated_renderer_layer.h', 'test/fake_delegated_renderer_layer_impl.cc', 'test/fake_delegated_renderer_layer_impl.h', + 'test/fake_display_list_recording_source.cc', 'test/fake_display_list_recording_source.h', 'test/fake_external_begin_frame_source.cc', 'test/fake_external_begin_frame_source.h', diff --git a/cc/debug/rasterize_and_record_benchmark.cc b/cc/debug/rasterize_and_record_benchmark.cc index b253436..0f47cd8 100644 --- a/cc/debug/rasterize_and_record_benchmark.cc +++ b/cc/debug/rasterize_and_record_benchmark.cc @@ -114,71 +114,7 @@ void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) { if (visible_layer_rect.IsEmpty()) return; - if (host_->settings().use_display_lists) { - RunOnDisplayListLayer(layer, visible_layer_rect); - } else { - RunOnPictureLayer(layer, visible_layer_rect); - } -} - -void RasterizeAndRecordBenchmark::RunOnPictureLayer( - PictureLayer* layer, - const gfx::Rect& visible_layer_rect) { - ContentLayerClient* painter = layer->client(); - - DCHECK(host_ && !host_->settings().use_display_lists); - - gfx::Size tile_grid_size = host_->settings().default_tile_size; - - for (int mode_index = 0; mode_index < RecordingSource::RECORDING_MODE_COUNT; - mode_index++) { - RecordingSource::RecordingMode mode = - static_cast<RecordingSource::RecordingMode>(mode_index); - - // Not supported for SkPicture recording. - if (mode == RecordingSource::RECORD_WITH_CONSTRUCTION_DISABLED) - continue; - - base::TimeDelta min_time = base::TimeDelta::Max(); - size_t memory_used = 0; - - for (int i = 0; i < record_repeat_count_; ++i) { - // Run for a minimum amount of time to avoid problems with timer - // quantization when the layer is very small. - LapTimer timer(kWarmupRuns, - base::TimeDelta::FromMilliseconds(kTimeLimitMillis), - kTimeCheckInterval); - scoped_refptr<Picture> picture; - do { - picture = Picture::Create(visible_layer_rect, painter, tile_grid_size, - false, mode); - if (picture->ShouldBeAnalyzedForSolidColor()) { - gfx::Size layer_size = layer->paint_properties().bounds; - skia::AnalysisCanvas canvas(layer_size.width(), layer_size.height()); - picture->Raster(&canvas, nullptr, gfx::Rect(), 1.f); - } - if (memory_used) { - // Verify we are recording the same thing each time. - DCHECK(memory_used == picture->ApproximateMemoryUsage()); - } else { - memory_used = picture->ApproximateMemoryUsage(); - } - - timer.NextLap(); - } while (!timer.HasTimeLimitExpired()); - base::TimeDelta duration = - base::TimeDelta::FromMillisecondsD(timer.MsPerLap()); - if (duration < min_time) - min_time = duration; - } - - if (mode == RecordingSource::RECORD_NORMALLY) { - record_results_.bytes_used += memory_used; - record_results_.pixels_recorded += - visible_layer_rect.width() * visible_layer_rect.height(); - } - record_results_.total_best_time[mode_index] += min_time; - } + RunOnDisplayListLayer(layer, visible_layer_rect); } void RasterizeAndRecordBenchmark::RunOnDisplayListLayer( @@ -186,8 +122,6 @@ void RasterizeAndRecordBenchmark::RunOnDisplayListLayer( const gfx::Rect& visible_layer_rect) { ContentLayerClient* painter = layer->client(); - DCHECK(host_ && host_->settings().use_display_lists); - for (int mode_index = 0; mode_index < RecordingSource::RECORDING_MODE_COUNT; mode_index++) { ContentLayerClient::PaintingControlSetting painting_control = diff --git a/cc/debug/rasterize_and_record_benchmark.h b/cc/debug/rasterize_and_record_benchmark.h index 207254f..3e873ce 100644 --- a/cc/debug/rasterize_and_record_benchmark.h +++ b/cc/debug/rasterize_and_record_benchmark.h @@ -40,8 +40,6 @@ class RasterizeAndRecordBenchmark : public MicroBenchmark { private: void RunOnDisplayListLayer(PictureLayer* layer, const gfx::Rect& visible_layer_rect); - void RunOnPictureLayer(PictureLayer* layer, - const gfx::Rect& visible_layer_rect); void RecordRasterResults(scoped_ptr<base::Value> results); diff --git a/cc/layers/picture_layer.cc b/cc/layers/picture_layer.cc index 9590f11..c15f7a4 100644 --- a/cc/layers/picture_layer.cc +++ b/cc/layers/picture_layer.cc @@ -91,13 +91,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)); - } else { - recording_source_.reset(new PicturePile(settings.minimum_contents_scale, - settings.default_tile_grid_size)); - } + recording_source_.reset( + new DisplayListRecordingSource(settings.default_tile_grid_size)); } recording_source_->SetSlowdownRasterScaleFactor( host->debug_state().slow_down_raster_scale_factor); @@ -183,31 +178,17 @@ skia::RefPtr<SkPicture> PictureLayer::GetPicture() const { gfx::Size layer_size = bounds(); const LayerTreeSettings& settings = layer_tree_host()->settings(); - if (settings.use_display_lists) { - scoped_ptr<RecordingSource> recording_source; - 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), - update_source_frame_number_, RecordingSource::RECORD_NORMALLY); - - scoped_refptr<RasterSource> raster_source = - recording_source->CreateRasterSource(false); - - return raster_source->GetFlattenedPicture(); - } + scoped_ptr<RecordingSource> recording_source( + new DisplayListRecordingSource(settings.default_tile_grid_size)); + Region recording_invalidation; + recording_source->UpdateAndExpandInvalidation( + client_, &recording_invalidation, layer_size, gfx::Rect(layer_size), + update_source_frame_number_, RecordingSource::RECORD_NORMALLY); - int width = layer_size.width(); - int height = layer_size.height(); + scoped_refptr<RasterSource> raster_source = + recording_source->CreateRasterSource(false); - SkPictureRecorder recorder; - SkCanvas* canvas = recorder.beginRecording(width, height, nullptr, 0); - client_->PaintContents(canvas, gfx::Rect(width, height), - ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); - skia::RefPtr<SkPicture> picture = - skia::AdoptRef(recorder.endRecordingAsPicture()); - return picture; + return raster_source->GetFlattenedPicture(); } bool PictureLayer::IsSuitableForGpuRasterization() const { diff --git a/cc/layers/picture_layer_unittest.cc b/cc/layers/picture_layer_unittest.cc index 8c397b4f..8260999 100644 --- a/cc/layers/picture_layer_unittest.cc +++ b/cc/layers/picture_layer_unittest.cc @@ -27,8 +27,7 @@ class MockContentLayerClient : public ContentLayerClient { scoped_refptr<DisplayItemList> PaintContentsToDisplayList( const gfx::Rect& clip, PaintingControlSetting picture_control) override { - NOTIMPLEMENTED(); - return nullptr; + return DisplayItemList::Create(clip, false); } bool FillsBoundsCompletely() const override { return false; }; size_t GetApproximateUnsharedMemoryUsage() const override { return 0; } @@ -98,26 +97,6 @@ TEST(PictureLayerTest, SuitableForGpuRasterization) { EXPECT_FALSE(layer->IsSuitableForGpuRasterization()); } -TEST(PictureLayerTest, UseTileGridSize) { - LayerTreeSettings settings; - settings.default_tile_grid_size = gfx::Size(123, 123); - - MockContentLayerClient client; - scoped_refptr<PictureLayer> layer = - PictureLayer::Create(LayerSettings(), &client); - FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); - TestTaskGraphRunner task_graph_runner; - scoped_ptr<FakeLayerTreeHost> host = - FakeLayerTreeHost::Create(&host_client, &task_graph_runner, settings); - host->SetRootLayer(layer); - - // Tile-grid is set according to its setting. - gfx::Size size = - layer->GetRecordingSourceForTesting()->GetTileGridSizeForTesting(); - EXPECT_EQ(size.width(), 123); - EXPECT_EQ(size.height(), 123); -} - // PicturePile uses the source frame number as a unit for measuring invalidation // frequency. When a pile moves between compositors, the frame number increases // non-monotonically. This executes that code path under this scenario allowing diff --git a/cc/playback/display_list_recording_source.cc b/cc/playback/display_list_recording_source.cc index 39126ed..1ed5a1f 100644 --- a/cc/playback/display_list_recording_source.cc +++ b/cc/playback/display_list_recording_source.cc @@ -234,10 +234,6 @@ scoped_refptr<RasterSource> DisplayListRecordingSource::CreateRasterSource( this, can_use_lcd_text)); } -gfx::Size DisplayListRecordingSource::GetTileGridSizeForTesting() const { - return gfx::Size(); -} - void DisplayListRecordingSource::DetermineIfSolidColor() { DCHECK(display_list_.get()); is_solid_color_ = false; diff --git a/cc/playback/display_list_recording_source.h b/cc/playback/display_list_recording_source.h index daef594..5824b10 100644 --- a/cc/playback/display_list_recording_source.h +++ b/cc/playback/display_list_recording_source.h @@ -34,7 +34,6 @@ class CC_EXPORT DisplayListRecordingSource : public RecordingSource { void SetRequiresClear(bool requires_clear) override; bool IsSuitableForGpuRasterization() const override; void SetUnsuitableForGpuRasterizationForTesting() override; - gfx::Size GetTileGridSizeForTesting() const override; // Returns true if the new recorded viewport exposes enough new area to be // worth re-recording. static bool ExposesEnoughNewArea( diff --git a/cc/playback/picture_pile.cc b/cc/playback/picture_pile.cc index 37ec30b..1351ac6 100644 --- a/cc/playback/picture_pile.cc +++ b/cc/playback/picture_pile.cc @@ -616,10 +616,6 @@ void PicturePile::SetUnsuitableForGpuRasterizationForTesting() { is_suitable_for_gpu_rasterization_ = false; } -gfx::Size PicturePile::GetTileGridSizeForTesting() const { - return tile_grid_size_; -} - bool PicturePile::CanRasterSlowTileCheck(const gfx::Rect& layer_rect) const { bool include_borders = false; for (TilingData::Iterator tile_iter(&tiling_, layer_rect, include_borders); diff --git a/cc/playback/picture_pile.h b/cc/playback/picture_pile.h index e5c0984..e0500a3 100644 --- a/cc/playback/picture_pile.h +++ b/cc/playback/picture_pile.h @@ -39,7 +39,6 @@ class CC_EXPORT PicturePile : public RecordingSource { void SetRequiresClear(bool requires_clear) override; bool IsSuitableForGpuRasterization() const override; void SetUnsuitableForGpuRasterizationForTesting() override; - gfx::Size GetTileGridSizeForTesting() const override; typedef std::pair<int, int> PictureMapKey; typedef base::hash_map<PictureMapKey, scoped_refptr<const Picture>> diff --git a/cc/playback/recording_source.h b/cc/playback/recording_source.h index 7505e5f..c4584ef 100644 --- a/cc/playback/recording_source.h +++ b/cc/playback/recording_source.h @@ -55,7 +55,6 @@ class CC_EXPORT RecordingSource { // TODO(hendrikw): Figure out how to remove this. virtual void SetUnsuitableForGpuRasterizationForTesting() = 0; - virtual gfx::Size GetTileGridSizeForTesting() const = 0; }; } // namespace cc diff --git a/cc/test/fake_display_list_recording_source.cc b/cc/test/fake_display_list_recording_source.cc new file mode 100644 index 0000000..b85fed1 --- /dev/null +++ b/cc/test/fake_display_list_recording_source.cc @@ -0,0 +1,20 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "cc/test/fake_display_list_recording_source.h" + +namespace cc { + +bool FakeDisplayListRecordingSource::IsSuitableForGpuRasterization() const { + if (force_unsuitable_for_gpu_rasterization_) + return false; + return DisplayListRecordingSource::IsSuitableForGpuRasterization(); +} + +void FakeDisplayListRecordingSource:: + SetUnsuitableForGpuRasterizationForTesting() { + force_unsuitable_for_gpu_rasterization_ = true; +} + +} // namespace cc diff --git a/cc/test/fake_display_list_recording_source.h b/cc/test/fake_display_list_recording_source.h index 0826030..6cb3b19 100644 --- a/cc/test/fake_display_list_recording_source.h +++ b/cc/test/fake_display_list_recording_source.h @@ -18,7 +18,8 @@ namespace cc { class FakeDisplayListRecordingSource : public DisplayListRecordingSource { public: explicit FakeDisplayListRecordingSource(const gfx::Size& grid_cell_size) - : DisplayListRecordingSource(grid_cell_size) {} + : DisplayListRecordingSource(grid_cell_size), + force_unsuitable_for_gpu_rasterization_(false) {} ~FakeDisplayListRecordingSource() override {} static scoped_ptr<FakeDisplayListRecordingSource> CreateRecordingSource( @@ -93,9 +94,13 @@ class FakeDisplayListRecordingSource : public DisplayListRecordingSource { client_.set_reported_memory_usage(reported_memory_usage); } + bool IsSuitableForGpuRasterization() const override; + void SetUnsuitableForGpuRasterizationForTesting() override; + private: FakeContentLayerClient client_; SkPaint default_paint_; + bool force_unsuitable_for_gpu_rasterization_; }; } // namespace cc diff --git a/cc/test/fake_picture_pile_impl.cc b/cc/test/fake_picture_pile_impl.cc index 931a924..eff8821 100644 --- a/cc/test/fake_picture_pile_impl.cc +++ b/cc/test/fake_picture_pile_impl.cc @@ -22,9 +22,7 @@ FakePicturePileImpl::FakePicturePileImpl( const PicturePile* other, base::WaitableEvent* playback_allowed_event) : PicturePileImpl(other, true), - playback_allowed_event_(playback_allowed_event), - tile_grid_size_(other->GetTileGridSizeForTesting()) { -} + playback_allowed_event_(playback_allowed_event) {} FakePicturePileImpl::~FakePicturePileImpl() {} diff --git a/cc/test/fake_picture_pile_impl.h b/cc/test/fake_picture_pile_impl.h index b89c617..b038a92 100644 --- a/cc/test/fake_picture_pile_impl.h +++ b/cc/test/fake_picture_pile_impl.h @@ -65,7 +65,6 @@ class FakePicturePileImpl : public PicturePileImpl { ~FakePicturePileImpl() override; base::WaitableEvent* playback_allowed_event_; - gfx::Size tile_grid_size_; }; } // namespace cc diff --git a/cc/test/solid_color_content_layer_client.cc b/cc/test/solid_color_content_layer_client.cc index f47fbd0..d61e858 100644 --- a/cc/test/solid_color_content_layer_client.cc +++ b/cc/test/solid_color_content_layer_client.cc @@ -4,33 +4,53 @@ #include "cc/test/solid_color_content_layer_client.h" +#include "cc/playback/drawing_display_item.h" #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkPaint.h" +#include "third_party/skia/include/core/SkPictureRecorder.h" #include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect_f.h" +#include "ui/gfx/skia_util.h" namespace cc { +// TODO(pdr): Remove PaintContents as all calls should go through +// PaintContentsToDisplayList. void SolidColorContentLayerClient::PaintContents( SkCanvas* canvas, const gfx::Rect& rect, PaintingControlSetting painting_control) { + scoped_refptr<DisplayItemList> contents = + PaintContentsToDisplayList(rect, painting_control); + contents->Raster(canvas, nullptr, rect, 1.0f); +} + +scoped_refptr<DisplayItemList> +SolidColorContentLayerClient::PaintContentsToDisplayList( + const gfx::Rect& clip, + PaintingControlSetting painting_control) { + SkPictureRecorder recorder; + skia::RefPtr<SkCanvas> canvas = + skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(clip))); + SkPaint paint; paint.setStyle(SkPaint::kFill_Style); paint.setColor(color_); canvas->clear(SK_ColorTRANSPARENT); canvas->drawRect( - SkRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.height()), - paint); -} + SkRect::MakeXYWH(clip.x(), clip.y(), clip.width(), clip.height()), paint); -scoped_refptr<DisplayItemList> -SolidColorContentLayerClient::PaintContentsToDisplayList( - const gfx::Rect& clip, - PaintingControlSetting painting_control) { - NOTIMPLEMENTED(); - return nullptr; + scoped_refptr<DisplayItemList> display_list = + DisplayItemList::Create(clip, false); + auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>(); + + skia::RefPtr<SkPicture> picture = + skia::AdoptRef(recorder.endRecordingAsPicture()); + item->SetNew(picture.Pass()); + + display_list->Finalize(); + return display_list; } bool SolidColorContentLayerClient::FillsBoundsCompletely() const { diff --git a/cc/trees/layer_tree_host_pixeltest_masks.cc b/cc/trees/layer_tree_host_pixeltest_masks.cc index eda8023..491da336 100644 --- a/cc/trees/layer_tree_host_pixeltest_masks.cc +++ b/cc/trees/layer_tree_host_pixeltest_masks.cc @@ -7,9 +7,11 @@ #include "cc/layers/picture_image_layer.h" #include "cc/layers/picture_layer.h" #include "cc/layers/solid_color_layer.h" +#include "cc/playback/drawing_display_item.h" #include "cc/test/layer_tree_pixel_resource_test.h" #include "cc/test/pixel_comparator.h" #include "third_party/skia/include/core/SkImage.h" +#include "third_party/skia/include/core/SkPictureRecorder.h" #include "third_party/skia/include/core/SkSurface.h" #if !defined(OS_ANDROID) @@ -29,9 +31,23 @@ class MaskContentLayerClient : public ContentLayerClient { bool FillsBoundsCompletely() const override { return false; } size_t GetApproximateUnsharedMemoryUsage() const override { return 0; } + // TODO(pdr): Remove PaintContents as all calls should go through + // PaintContentsToDisplayList. void PaintContents(SkCanvas* canvas, const gfx::Rect& rect, PaintingControlSetting picture_control) override { + scoped_refptr<DisplayItemList> contents = + PaintContentsToDisplayList(rect, picture_control); + contents->Raster(canvas, nullptr, rect, 1.0f); + } + + scoped_refptr<DisplayItemList> PaintContentsToDisplayList( + const gfx::Rect& clip, + PaintingControlSetting picture_control) override { + SkPictureRecorder recorder; + skia::RefPtr<SkCanvas> canvas = skia::SharePtr( + recorder.beginRecording(gfx::RectToSkRect(gfx::Rect(bounds_)))); + SkPaint paint; paint.setStyle(SkPaint::kStroke_Style); paint.setStrokeWidth(SkIntToScalar(2)); @@ -47,13 +63,17 @@ class MaskContentLayerClient : public ContentLayerClient { paint); inset_rect.Inset(3, 3, 2, 2); } - } - scoped_refptr<DisplayItemList> PaintContentsToDisplayList( - const gfx::Rect& clip, - PaintingControlSetting picture_control) override { - NOTIMPLEMENTED(); - return nullptr; + scoped_refptr<DisplayItemList> display_list = + DisplayItemList::Create(clip, false); + auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>(); + + skia::RefPtr<SkPicture> picture = + skia::AdoptRef(recorder.endRecordingAsPicture()); + item->SetNew(picture.Pass()); + + display_list->Finalize(); + return display_list; } private: @@ -298,9 +318,22 @@ class CheckerContentLayerClient : public ContentLayerClient { ~CheckerContentLayerClient() override {} bool FillsBoundsCompletely() const override { return false; } size_t GetApproximateUnsharedMemoryUsage() const override { return 0; } + // TODO(pdr): Remove PaintContents as all calls should go through + // PaintContentsToDisplayList. void PaintContents(SkCanvas* canvas, const gfx::Rect& rect, PaintingControlSetting picture_control) override { + scoped_refptr<DisplayItemList> contents = + PaintContentsToDisplayList(rect, picture_control); + contents->Raster(canvas, nullptr, rect, 1.0f); + } + scoped_refptr<DisplayItemList> PaintContentsToDisplayList( + const gfx::Rect& clip, + PaintingControlSetting picture_control) override { + SkPictureRecorder recorder; + skia::RefPtr<SkCanvas> canvas = skia::SharePtr( + recorder.beginRecording(gfx::RectToSkRect(gfx::Rect(bounds_)))); + SkPaint paint; paint.setStyle(SkPaint::kStroke_Style); paint.setStrokeWidth(SkIntToScalar(4)); @@ -315,12 +348,17 @@ class CheckerContentLayerClient : public ContentLayerClient { canvas->drawLine(0, i, bounds_.width(), i, paint); } } - } - scoped_refptr<DisplayItemList> PaintContentsToDisplayList( - const gfx::Rect& clip, - PaintingControlSetting picture_control) override { - NOTIMPLEMENTED(); - return nullptr; + + scoped_refptr<DisplayItemList> display_list = + DisplayItemList::Create(clip, false); + auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>(); + + skia::RefPtr<SkPicture> picture = + skia::AdoptRef(recorder.endRecordingAsPicture()); + item->SetNew(picture.Pass()); + + display_list->Finalize(); + return display_list; } private: @@ -336,9 +374,22 @@ class CircleContentLayerClient : public ContentLayerClient { ~CircleContentLayerClient() override {} bool FillsBoundsCompletely() const override { return false; } size_t GetApproximateUnsharedMemoryUsage() const override { return 0; } + // TODO(pdr): Remove PaintContents as all calls should go through + // PaintContentsToDisplayList. void PaintContents(SkCanvas* canvas, const gfx::Rect& rect, PaintingControlSetting picture_control) override { + scoped_refptr<DisplayItemList> contents = + PaintContentsToDisplayList(rect, picture_control); + contents->Raster(canvas, nullptr, rect, 1.0f); + } + scoped_refptr<DisplayItemList> PaintContentsToDisplayList( + const gfx::Rect& clip, + PaintingControlSetting picture_control) override { + SkPictureRecorder recorder; + skia::RefPtr<SkCanvas> canvas = skia::SharePtr( + recorder.beginRecording(gfx::RectToSkRect(gfx::Rect(bounds_)))); + SkPaint paint; paint.setStyle(SkPaint::kFill_Style); paint.setColor(SK_ColorWHITE); @@ -347,12 +398,16 @@ class CircleContentLayerClient : public ContentLayerClient { bounds_.height() / 2, bounds_.width() / 4, paint); - } - scoped_refptr<DisplayItemList> PaintContentsToDisplayList( - const gfx::Rect& clip, - PaintingControlSetting picture_control) override { - NOTIMPLEMENTED(); - return nullptr; + + scoped_refptr<DisplayItemList> display_list = + DisplayItemList::Create(clip, false); + auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>(); + skia::RefPtr<SkPicture> picture = + skia::AdoptRef(recorder.endRecordingAsPicture()); + item->SetNew(picture.Pass()); + + display_list->Finalize(); + return display_list; } private: diff --git a/cc/trees/layer_tree_host_pixeltest_tiles.cc b/cc/trees/layer_tree_host_pixeltest_tiles.cc index 9259ca3..1147b86 100644 --- a/cc/trees/layer_tree_host_pixeltest_tiles.cc +++ b/cc/trees/layer_tree_host_pixeltest_tiles.cc @@ -28,7 +28,6 @@ class LayerTreeHostTilesPixelTest : public LayerTreePixelTest { protected: void InitializeSettings(LayerTreeSettings* settings) override { LayerTreePixelTest::InitializeSettings(settings); - settings->use_display_lists = true; switch (raster_mode_) { case PARTIAL_ONE_COPY: settings->use_zero_copy = false; diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc index 588f9e4..4e3850f 100644 --- a/cc/trees/layer_tree_host_unittest.cc +++ b/cc/trees/layer_tree_host_unittest.cc @@ -31,6 +31,7 @@ #include "cc/quads/render_pass_draw_quad.h" #include "cc/quads/tile_draw_quad.h" #include "cc/test/fake_content_layer_client.h" +#include "cc/test/fake_display_list_recording_source.h" #include "cc/test/fake_layer_tree_host_client.h" #include "cc/test/fake_output_surface.h" #include "cc/test/fake_painted_scrollbar_layer.h" @@ -1494,15 +1495,19 @@ class TestOpacityChangeLayerDelegate : public ContentLayerClient { void PaintContents(SkCanvas* canvas, const gfx::Rect& clip, PaintingControlSetting picture_control) override { - // Set layer opacity to 0. - if (test_layer_) - test_layer_->SetOpacity(0.f); + NOTIMPLEMENTED(); } scoped_refptr<DisplayItemList> PaintContentsToDisplayList( const gfx::Rect& clip, PaintingControlSetting picture_control) override { - NOTIMPLEMENTED(); - return nullptr; + // Set layer opacity to 0. + if (test_layer_) + test_layer_->SetOpacity(0.f); + + // Return a dummy display list. + scoped_refptr<DisplayItemList> display_list = + DisplayItemList::Create(clip, false); + return display_list; } bool FillsBoundsCompletely() const override { return false; } size_t GetApproximateUnsharedMemoryUsage() const override { return 0; } @@ -2096,14 +2101,18 @@ class LayerTreeHostTestChangeLayerPropertiesInPaintContents void PaintContents(SkCanvas* canvas, const gfx::Rect& clip, PaintingControlSetting picture_control) override { - layer_->SetBounds(gfx::Size(2, 2)); + NOTIMPLEMENTED(); } scoped_refptr<DisplayItemList> PaintContentsToDisplayList( const gfx::Rect& clip, PaintingControlSetting picture_control) override { - NOTIMPLEMENTED(); - return nullptr; + layer_->SetBounds(gfx::Size(2, 2)); + + // Return a dummy display list. + scoped_refptr<DisplayItemList> display_list = + DisplayItemList::Create(clip, false); + return display_list; } bool FillsBoundsCompletely() const override { return false; } @@ -4415,8 +4424,12 @@ class LayerTreeHostTestGpuRasterizationEnabled : public LayerTreeHostTest { void SetupTree() override { LayerTreeHostTest::SetupTree(); - scoped_refptr<PictureLayer> layer = - PictureLayer::Create(layer_settings(), &layer_client_); + scoped_ptr<FakeDisplayListRecordingSource> recording_source( + new FakeDisplayListRecordingSource(gfx::Size(10, 10))); + + scoped_refptr<FakePictureLayer> layer = + FakePictureLayer::CreateWithRecordingSource( + layer_settings(), &layer_client_, recording_source.Pass()); layer->SetBounds(gfx::Size(10, 10)); layer->SetIsDrawable(true); layer_tree_host()->root_layer()->AddChild(layer); @@ -4424,8 +4437,10 @@ class LayerTreeHostTestGpuRasterizationEnabled : public LayerTreeHostTest { void BeginTest() override { Layer* root = layer_tree_host()->root_layer(); - PictureLayer* layer = static_cast<PictureLayer*>(root->child_at(0)); - RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); + FakePictureLayer* layer = static_cast<FakePictureLayer*>(root->child_at(0)); + FakeDisplayListRecordingSource* recording_source = + static_cast<FakeDisplayListRecordingSource*>( + layer->GetRecordingSourceForTesting()); // Verify default values. EXPECT_TRUE(root->IsSuitableForGpuRasterization()); diff --git a/cc/trees/layer_tree_settings.cc b/cc/trees/layer_tree_settings.cc index c77e52e..aa190e2 100644 --- a/cc/trees/layer_tree_settings.cc +++ b/cc/trees/layer_tree_settings.cc @@ -66,7 +66,6 @@ LayerTreeSettings::LayerTreeSettings() scheduled_raster_task_limit(32), use_occlusion_for_tile_prioritization(false), record_full_layer(false), - use_display_lists(false), verify_property_trees(false), gather_images(false), use_compositor_animation_timelines(false), diff --git a/cc/trees/layer_tree_settings.h b/cc/trees/layer_tree_settings.h index 0feaf45..2cc4fbc 100644 --- a/cc/trees/layer_tree_settings.h +++ b/cc/trees/layer_tree_settings.h @@ -80,7 +80,6 @@ class CC_EXPORT LayerTreeSettings { size_t scheduled_raster_task_limit; bool use_occlusion_for_tile_prioritization; bool record_full_layer; - bool use_display_lists; bool verify_property_trees; bool gather_images; bool use_compositor_animation_timelines; |