From 0154bfa2bd8c5cd8a906deb1e6415f7c7fc417a0 Mon Sep 17 00:00:00 2001 From: schenney Date: Thu, 5 Feb 2015 11:46:49 -0800 Subject: [PATCH] Modify rasterize_and_record for DisplayItemList recording. There is a lot of change here for relatively little effect. That effect is important, however, for moving forward. This depends on https://codereview.chromium.org/880653004/. 1) Move Picture::RecordingMode to RecordingSource, because Display List recording does not use Picture. 2) Add a new recording mode for disabled caches, which has meaning in Display List recording. Picture recording falls back to normal recording, while Display List recording uses painting disabled mode when null canvas is specified, because null canvas has no meaning for Display Lists. 3) Rename the enum in ContentLayerClient to reflect the new painting control modes and the changes in WebContentLayerClient. 4) Adjust all the code that uses these settings. 5) Adjust the benchmark code to make use of the new modes. R=ajuma,vmpstr BUG=451448 Review URL: https://codereview.chromium.org/900043002 Cr-Commit-Position: refs/heads/master@{#314857} --- cc/blink/web_content_layer_impl.cc | 31 +++--- cc/blink/web_content_layer_impl.h | 5 +- cc/debug/picture_record_benchmark.cc | 5 +- cc/debug/rasterize_and_record_benchmark.cc | 113 +++++++++++---------- cc/debug/rasterize_and_record_benchmark.h | 2 +- cc/layers/content_layer.cc | 10 +- cc/layers/content_layer_client.h | 11 +- cc/layers/picture_image_layer.cc | 6 +- cc/layers/picture_image_layer.h | 4 +- cc/layers/picture_image_layer_unittest.cc | 2 +- cc/layers/picture_layer.cc | 7 +- cc/layers/picture_layer_impl_unittest.cc | 6 +- cc/layers/picture_layer_unittest.cc | 9 +- cc/resources/display_list_recording_source.cc | 37 +++++-- cc/resources/display_list_recording_source.h | 15 ++- cc/resources/picture.cc | 31 +++--- cc/resources/picture.h | 21 ++-- cc/resources/picture_pile.cc | 4 +- cc/resources/picture_pile.h | 19 ++-- cc/resources/picture_pile_unittest.cc | 2 +- cc/resources/picture_unittest.cc | 43 ++++---- cc/resources/recording_source.h | 25 +++-- cc/test/fake_content_layer_client.cc | 6 +- cc/test/fake_content_layer_client.h | 15 ++- cc/test/fake_picture_pile_impl.cc | 5 +- cc/test/solid_color_content_layer_client.cc | 4 +- cc/test/solid_color_content_layer_client.h | 9 +- cc/trees/layer_tree_host_common_unittest.cc | 9 +- cc/trees/layer_tree_host_pixeltest_masks.cc | 14 ++- .../layer_tree_host_pixeltest_on_demand_raster.cc | 9 +- cc/trees/layer_tree_host_unittest.cc | 29 +++--- .../measurements/rasterize_and_record_micro.py | 10 ++ ui/compositor/layer.cc | 9 +- ui/compositor/layer.h | 4 +- 34 files changed, 294 insertions(+), 237 deletions(-) diff --git a/cc/blink/web_content_layer_impl.cc b/cc/blink/web_content_layer_impl.cc index abe3eb30d209..922422308d80 100644 --- a/cc/blink/web_content_layer_impl.cc +++ b/cc/blink/web_content_layer_impl.cc @@ -19,6 +19,21 @@ using cc::PictureLayer; namespace cc_blink { +static blink::WebContentLayerClient::PaintingControlSetting +PaintingControlToWeb( + cc::ContentLayerClient::PaintingControlSetting painting_control) { + switch (painting_control) { + case cc::ContentLayerClient::PAINTING_BEHAVIOR_NORMAL: + return blink::WebContentLayerClient::PaintDefaultBehavior; + case cc::ContentLayerClient::DISPLAY_LIST_CONSTRUCTION_DISABLED: + return blink::WebContentLayerClient::DisplayListConstructionDisabled; + case cc::ContentLayerClient::DISPLAY_LIST_CACHING_DISABLED: + return blink::WebContentLayerClient::DisplayListCachingDisabled; + } + NOTREACHED(); + return blink::WebContentLayerClient::PaintDefaultBehavior; +} + WebContentLayerImpl::WebContentLayerImpl(blink::WebContentLayerClient* client) : client_(client) { if (WebLayerImpl::UsingPictureLayer()) @@ -50,30 +65,22 @@ void WebContentLayerImpl::setDrawCheckerboardForMissingTiles(bool enable) { void WebContentLayerImpl::PaintContents( SkCanvas* canvas, const gfx::Rect& clip, - ContentLayerClient::GraphicsContextStatus graphics_context_status) { + cc::ContentLayerClient::PaintingControlSetting painting_control) { if (!client_) return; - client_->paintContents( - canvas, clip, - graphics_context_status == ContentLayerClient::GRAPHICS_CONTEXT_ENABLED - ? blink::WebContentLayerClient::GraphicsContextEnabled - : blink::WebContentLayerClient::GraphicsContextDisabled); + client_->paintContents(canvas, clip, PaintingControlToWeb(painting_control)); } scoped_refptr WebContentLayerImpl::PaintContentsToDisplayList( const gfx::Rect& clip, - ContentLayerClient::GraphicsContextStatus graphics_context_status) { + cc::ContentLayerClient::PaintingControlSetting painting_control) { if (!client_) return cc::DisplayItemList::Create(); WebDisplayItemListImpl list; - client_->paintContents( - &list, clip, - graphics_context_status == ContentLayerClient::GRAPHICS_CONTEXT_ENABLED - ? blink::WebContentLayerClient::GraphicsContextEnabled - : blink::WebContentLayerClient::GraphicsContextDisabled); + client_->paintContents(&list, clip, PaintingControlToWeb(painting_control)); return list.ToDisplayItemList(); } diff --git a/cc/blink/web_content_layer_impl.h b/cc/blink/web_content_layer_impl.h index 148f4fc73609..3e7b55c59a4f 100644 --- a/cc/blink/web_content_layer_impl.h +++ b/cc/blink/web_content_layer_impl.h @@ -38,11 +38,10 @@ class WebContentLayerImpl : public blink::WebContentLayer, // ContentLayerClient implementation. void PaintContents(SkCanvas* canvas, const gfx::Rect& clip, - ContentLayerClient::GraphicsContextStatus - graphics_context_status) override; + PaintingControlSetting painting_control) override; scoped_refptr PaintContentsToDisplayList( const gfx::Rect& clip, - GraphicsContextStatus graphics_context_status) override; + PaintingControlSetting painting_control) override; bool FillsBoundsCompletely() const override; scoped_ptr layer_; diff --git a/cc/debug/picture_record_benchmark.cc b/cc/debug/picture_record_benchmark.cc index d0d031d2c13b..b1b8188d92f1 100644 --- a/cc/debug/picture_record_benchmark.cc +++ b/cc/debug/picture_record_benchmark.cc @@ -106,8 +106,9 @@ void PictureRecordBenchmark::RunOnLayer(PictureLayer* layer) { base::TimeTicks start = base::TimeTicks::Now(); - scoped_refptr picture = Picture::Create( - rect, painter, tile_grid_size, false, Picture::RECORD_NORMALLY); + scoped_refptr picture = + Picture::Create(rect, painter, tile_grid_size, false, + RecordingSource::RECORD_NORMALLY); base::TimeTicks end = base::TimeTicks::Now(); base::TimeDelta duration = end - start; diff --git a/cc/debug/rasterize_and_record_benchmark.cc b/cc/debug/rasterize_and_record_benchmark.cc index 3a0c98b0fb32..e56a1e136d1c 100644 --- a/cc/debug/rasterize_and_record_benchmark.cc +++ b/cc/debug/rasterize_and_record_benchmark.cc @@ -34,10 +34,8 @@ const int kTimeLimitMillis = 1; const int kWarmupRuns = 0; const int kTimeCheckInterval = 1; -const char* kModeSuffixes[Picture::RECORDING_MODE_COUNT] = { - "", - "_sk_null_canvas", - "_painting_disabled"}; +const char* kModeSuffixes[RecordingSource::RECORDING_MODE_COUNT] = + {"", "_sk_null_canvas", "_painting_disabled", "_caching_disabled"}; } // namespace @@ -74,7 +72,7 @@ void RasterizeAndRecordBenchmark::DidUpdateLayers(LayerTreeHost* host) { results_->SetInteger("pixels_recorded", record_results_.pixels_recorded); results_->SetInteger("picture_memory_usage", record_results_.bytes_used); - for (int i = 0; i < Picture::RECORDING_MODE_COUNT; i++) { + for (int i = 0; i < RecordingSource::RECORDING_MODE_COUNT; i++) { std::string name = base::StringPrintf("record_time%s_ms", kModeSuffixes[i]); results_->SetDouble(name, record_results_.total_best_time[i].InMillisecondsF()); @@ -132,10 +130,10 @@ void RasterizeAndRecordBenchmark::RunOnPictureLayer( gfx::Size tile_grid_size = host_->settings().default_tile_size; - for (int mode_index = 0; mode_index < Picture::RECORDING_MODE_COUNT; + for (int mode_index = 0; mode_index < RecordingSource::RECORDING_MODE_COUNT; mode_index++) { - Picture::RecordingMode mode = - static_cast(mode_index); + RecordingSource::RecordingMode mode = + static_cast(mode_index); base::TimeDelta min_time = base::TimeDelta::Max(); size_t memory_used = 0; @@ -164,7 +162,7 @@ void RasterizeAndRecordBenchmark::RunOnPictureLayer( min_time = duration; } - if (mode == Picture::RECORD_NORMALLY) { + if (mode == RecordingSource::RECORD_NORMALLY) { record_results_.bytes_used += memory_used; record_results_.pixels_recorded += visible_content_rect.width() * visible_content_rect.height(); @@ -180,49 +178,62 @@ void RasterizeAndRecordBenchmark::RunOnDisplayListLayer( DCHECK(host_ && host_->settings().use_display_lists); - base::TimeDelta min_time = base::TimeDelta::Max(); - size_t memory_used = 0; - - // TODO(schenney): What are the corresponding Picture::RecordingMode modes - // for Slimming Paint. We could disable SkPicture creation in - // DrawingDisplayItems, or we could only generate the display list and not - // do any work on it in the compositor, or something else, or all of the - // above. - scoped_refptr display_list; - 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); - - do { - // TODO(schenney): Cached content will not be regenerated, which skews - // the results significantly in favor of Slimming Paint (or should). - // Add a flag or API call to disable caching, and maybe run the test - // twice, without and with caching. - display_list = painter->PaintContentsToDisplayList( - visible_content_rect, ContentLayerClient::GRAPHICS_CONTEXT_ENABLED); - - if (memory_used) { - // Verify we are recording the same thing each time. - DCHECK(memory_used == display_list->PictureMemoryUsage()); - } else { - memory_used = display_list->PictureMemoryUsage(); - } - - timer.NextLap(); - } while (!timer.HasTimeLimitExpired()); - base::TimeDelta duration = - base::TimeDelta::FromMillisecondsD(timer.MsPerLap()); - if (duration < min_time) - min_time = duration; - } + for (int mode_index = 0; mode_index < RecordingSource::RECORDING_MODE_COUNT; + mode_index++) { + ContentLayerClient::PaintingControlSetting painting_control = + ContentLayerClient::PAINTING_BEHAVIOR_NORMAL; + switch (static_cast(mode_index)) { + case RecordingSource::RECORD_NORMALLY: + // Already setup for normal recording. + break; + case RecordingSource::RECORD_WITH_SK_NULL_CANVAS: + // TODO(schenney): Remove this when DisplayList recording is the only + // option. For now, fall through and disable construction. + case RecordingSource::RECORD_WITH_PAINTING_DISABLED: + painting_control = + ContentLayerClient::DISPLAY_LIST_CONSTRUCTION_DISABLED; + break; + case RecordingSource::RECORD_WITH_CACHING_DISABLED: + painting_control = ContentLayerClient::DISPLAY_LIST_CACHING_DISABLED; + break; + default: + NOTREACHED(); + } + base::TimeDelta min_time = base::TimeDelta::Max(); + size_t memory_used = 0; - record_results_.bytes_used += memory_used; - record_results_.pixels_recorded += - visible_content_rect.width() * visible_content_rect.height(); - record_results_.total_best_time[Picture::RECORD_NORMALLY] += min_time; + scoped_refptr display_list; + 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); + + do { + display_list = painter->PaintContentsToDisplayList(visible_content_rect, + painting_control); + + if (memory_used) { + // Verify we are recording the same thing each time. + DCHECK(memory_used == display_list->PictureMemoryUsage()); + } else { + memory_used = display_list->PictureMemoryUsage(); + } + + timer.NextLap(); + } while (!timer.HasTimeLimitExpired()); + base::TimeDelta duration = + base::TimeDelta::FromMillisecondsD(timer.MsPerLap()); + if (duration < min_time) + min_time = duration; + } + + record_results_.bytes_used += memory_used; + record_results_.pixels_recorded += + visible_content_rect.width() * visible_content_rect.height(); + record_results_.total_best_time[mode_index] += min_time; + } } RasterizeAndRecordBenchmark::RecordResults::RecordResults() diff --git a/cc/debug/rasterize_and_record_benchmark.h b/cc/debug/rasterize_and_record_benchmark.h index 5ae45faa3cdc..30dcde0bafa5 100644 --- a/cc/debug/rasterize_and_record_benchmark.h +++ b/cc/debug/rasterize_and_record_benchmark.h @@ -51,7 +51,7 @@ class RasterizeAndRecordBenchmark : public MicroBenchmark { int pixels_recorded; size_t bytes_used; - base::TimeDelta total_best_time[Picture::RECORDING_MODE_COUNT]; + base::TimeDelta total_best_time[RecordingSource::RECORDING_MODE_COUNT]; }; RecordResults record_results_; diff --git a/cc/layers/content_layer.cc b/cc/layers/content_layer.cc index 53c7120c09b1..6af92ec45d47 100644 --- a/cc/layers/content_layer.cc +++ b/cc/layers/content_layer.cc @@ -26,9 +26,8 @@ scoped_ptr ContentLayerPainter::Create( void ContentLayerPainter::Paint(SkCanvas* canvas, const gfx::Rect& content_rect) { - client_->PaintContents(canvas, - content_rect, - ContentLayerClient::GRAPHICS_CONTEXT_ENABLED); + client_->PaintContents(canvas, content_rect, + ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); } scoped_refptr ContentLayer::Create(ContentLayerClient* client) { @@ -128,9 +127,8 @@ skia::RefPtr ContentLayer::GetPicture() const { SkPictureRecorder recorder; SkCanvas* canvas = recorder.beginRecording(width, height, nullptr, 0); - client_->PaintContents(canvas, - gfx::Rect(width, height), - ContentLayerClient::GRAPHICS_CONTEXT_ENABLED); + client_->PaintContents(canvas, gfx::Rect(width, height), + ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); skia::RefPtr picture = skia::AdoptRef(recorder.endRecording()); return picture; } diff --git a/cc/layers/content_layer_client.h b/cc/layers/content_layer_client.h index c8d3a7e9873a..4f9c754ec909 100644 --- a/cc/layers/content_layer_client.h +++ b/cc/layers/content_layer_client.h @@ -19,18 +19,19 @@ namespace cc { class CC_EXPORT ContentLayerClient { public: - enum GraphicsContextStatus { - GRAPHICS_CONTEXT_DISABLED, - GRAPHICS_CONTEXT_ENABLED + enum PaintingControlSetting { + PAINTING_BEHAVIOR_NORMAL, + DISPLAY_LIST_CONSTRUCTION_DISABLED, + DISPLAY_LIST_CACHING_DISABLED }; virtual void PaintContents(SkCanvas* canvas, const gfx::Rect& clip, - GraphicsContextStatus gc_status) = 0; + PaintingControlSetting painting_status) = 0; virtual scoped_refptr PaintContentsToDisplayList( const gfx::Rect& clip, - GraphicsContextStatus gc_status) = 0; + PaintingControlSetting painting_status) = 0; // If true the layer may skip clearing the background before rasterizing, // because it will cover any uncleared data with content. diff --git a/cc/layers/picture_image_layer.cc b/cc/layers/picture_image_layer.cc index 85bc582bd681..9f35d6e013f9 100644 --- a/cc/layers/picture_image_layer.cc +++ b/cc/layers/picture_image_layer.cc @@ -47,7 +47,7 @@ void PictureImageLayer::SetBitmap(const SkBitmap& bitmap) { void PictureImageLayer::PaintContents( SkCanvas* canvas, const gfx::Rect& clip, - ContentLayerClient::GraphicsContextStatus gc_status) { + ContentLayerClient::PaintingControlSetting painting_control) { if (!bitmap_.width() || !bitmap_.height()) return; @@ -65,12 +65,12 @@ void PictureImageLayer::PaintContents( scoped_refptr PictureImageLayer::PaintContentsToDisplayList( const gfx::Rect& clip, - GraphicsContextStatus gc_status) { + ContentLayerClient::PaintingControlSetting painting_control) { scoped_refptr display_item_list = DisplayItemList::Create(); SkPictureRecorder recorder; SkCanvas* canvas = recorder.beginRecording(gfx::RectToSkRect(clip)); - PaintContents(canvas, clip, gc_status); + PaintContents(canvas, clip, painting_control); skia::RefPtr picture = skia::AdoptRef(recorder.endRecording()); display_item_list->AppendItem( diff --git a/cc/layers/picture_image_layer.h b/cc/layers/picture_image_layer.h index 57c7de258f30..8d40550bd19d 100644 --- a/cc/layers/picture_image_layer.h +++ b/cc/layers/picture_image_layer.h @@ -26,10 +26,10 @@ class CC_EXPORT PictureImageLayer : public PictureLayer, ContentLayerClient { void PaintContents( SkCanvas* canvas, const gfx::Rect& clip, - ContentLayerClient::GraphicsContextStatus gc_status) override; + ContentLayerClient::PaintingControlSetting painting_control) override; scoped_refptr PaintContentsToDisplayList( const gfx::Rect& clip, - GraphicsContextStatus gc_status) override; + ContentLayerClient::PaintingControlSetting painting_control) override; bool FillsBoundsCompletely() const override; protected: diff --git a/cc/layers/picture_image_layer_unittest.cc b/cc/layers/picture_image_layer_unittest.cc index acf691dece51..5b9375d26472 100644 --- a/cc/layers/picture_image_layer_unittest.cc +++ b/cc/layers/picture_image_layer_unittest.cc @@ -35,7 +35,7 @@ TEST(PictureImageLayerTest, PaintContentsToDisplayList) { scoped_refptr display_list = layer->PaintContentsToDisplayList( - layer_rect, ContentLayerClient::GRAPHICS_CONTEXT_ENABLED); + 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 0b7d699d533a..52288e90c8e1 100644 --- a/cc/layers/picture_layer.cc +++ b/cc/layers/picture_layer.cc @@ -148,7 +148,7 @@ bool PictureLayer::Update(ResourceUpdateQueue* queue, updated |= recording_source_->UpdateAndExpandInvalidation( client_, &recording_invalidation_, can_use_lcd_text_for_update_, layer_size, visible_layer_rect, update_source_frame_number_, - Picture::RECORD_NORMALLY); + RecordingSource::RECORD_NORMALLY); last_updated_visible_content_rect_ = visible_content_rect(); if (updated) { @@ -192,9 +192,8 @@ skia::RefPtr PictureLayer::GetPicture() const { SkPictureRecorder recorder; SkCanvas* canvas = recorder.beginRecording(width, height, nullptr, 0); - client_->PaintContents(canvas, - gfx::Rect(width, height), - ContentLayerClient::GRAPHICS_CONTEXT_ENABLED); + client_->PaintContents(canvas, gfx::Rect(width, height), + ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); skia::RefPtr picture = skia::AdoptRef(recorder.endRecording()); return picture; } diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc index 0a95f317d720..e39b7ceaff34 100644 --- a/cc/layers/picture_layer_impl_unittest.cc +++ b/cc/layers/picture_layer_impl_unittest.cc @@ -4644,7 +4644,7 @@ void PictureLayerImplTest::TestQuadsForSolidColor(bool test_for_solid) { Region invalidation(layer_rect); recording_source->UpdateAndExpandInvalidation( &client, &invalidation, false, layer_bounds, layer_rect, frame_number++, - Picture::RECORD_NORMALLY); + RecordingSource::RECORD_NORMALLY); scoped_refptr pending_raster_source = recording_source->CreateRasterSource(); @@ -4707,7 +4707,7 @@ TEST_F(PictureLayerImplTest, NonSolidToSolidNoTilings) { Region invalidation1(layer_rect); recording_source->UpdateAndExpandInvalidation( &client, &invalidation1, false, layer_bounds, layer_rect, frame_number++, - Picture::RECORD_NORMALLY); + RecordingSource::RECORD_NORMALLY); scoped_refptr raster_source1 = recording_source->CreateRasterSource(); @@ -4725,7 +4725,7 @@ TEST_F(PictureLayerImplTest, NonSolidToSolidNoTilings) { Region invalidation2(layer_rect); recording_source->UpdateAndExpandInvalidation( &client, &invalidation2, false, layer_bounds, layer_rect, frame_number++, - Picture::RECORD_NORMALLY); + RecordingSource::RECORD_NORMALLY); scoped_refptr raster_source2 = recording_source->CreateRasterSource(); diff --git a/cc/layers/picture_layer_unittest.cc b/cc/layers/picture_layer_unittest.cc index 9327e1300a9a..afb60969e713 100644 --- a/cc/layers/picture_layer_unittest.cc +++ b/cc/layers/picture_layer_unittest.cc @@ -20,13 +20,12 @@ namespace { class MockContentLayerClient : public ContentLayerClient { public: - void PaintContents( - SkCanvas* canvas, - const gfx::Rect& clip, - ContentLayerClient::GraphicsContextStatus gc_status) override {} + void PaintContents(SkCanvas* canvas, + const gfx::Rect& clip, + PaintingControlSetting picture_control) override {} scoped_refptr PaintContentsToDisplayList( const gfx::Rect& clip, - GraphicsContextStatus gc_status) override { + PaintingControlSetting picture_control) override { NOTIMPLEMENTED(); return DisplayItemList::Create(); } diff --git a/cc/resources/display_list_recording_source.cc b/cc/resources/display_list_recording_source.cc index 7b98e50ddf0a..e60e4c16d294 100644 --- a/cc/resources/display_list_recording_source.cc +++ b/cc/resources/display_list_recording_source.cc @@ -45,7 +45,7 @@ bool DisplayListRecordingSource::UpdateAndExpandInvalidation( const gfx::Size& layer_size, const gfx::Rect& visible_layer_rect, int frame_number, - Picture::RecordingMode recording_mode) { + RecordingMode recording_mode) { bool updated = false; if (size_ != layer_size) { @@ -81,12 +81,37 @@ bool DisplayListRecordingSource::UpdateAndExpandInvalidation( if (!updated && !invalidation->Intersects(recorded_viewport_)) return false; - // TODO(ajuma): Does repeating this way really makes sense with display lists? - // With Blink caching recordings, repeated calls will not cause re-recording. - int repeat_count = std::max(1, slow_down_raster_scale_factor_for_debug_); + ContentLayerClient::PaintingControlSetting painting_control = + ContentLayerClient::PAINTING_BEHAVIOR_NORMAL; + + switch (recording_mode) { + case RECORD_NORMALLY: + // Already setup for normal recording. + break; + case RECORD_WITH_SK_NULL_CANVAS: + // TODO(schenney): Remove this when DisplayList recording is the only + // option. For now, fall through and disable construction. + case RECORD_WITH_PAINTING_DISABLED: + painting_control = ContentLayerClient::DISPLAY_LIST_CONSTRUCTION_DISABLED; + break; + case RECORD_WITH_CACHING_DISABLED: + painting_control = ContentLayerClient::DISPLAY_LIST_CACHING_DISABLED; + break; + default: + NOTREACHED(); + } + + int repeat_count = 1; + if (slow_down_raster_scale_factor_for_debug_ > 1) { + repeat_count = slow_down_raster_scale_factor_for_debug_; + if (painting_control != + ContentLayerClient::DISPLAY_LIST_CONSTRUCTION_DISABLED) { + painting_control = ContentLayerClient::DISPLAY_LIST_CACHING_DISABLED; + } + } for (int i = 0; i < repeat_count; ++i) { - display_list_ = painter->PaintContentsToDisplayList( - recorded_viewport_, ContentLayerClient::GRAPHICS_CONTEXT_ENABLED); + display_list_ = painter->PaintContentsToDisplayList(recorded_viewport_, + painting_control); } display_list_->set_layer_rect(recorded_viewport_); is_suitable_for_gpu_rasterization_ = diff --git a/cc/resources/display_list_recording_source.h b/cc/resources/display_list_recording_source.h index a2c8ea6a5b18..05e2ed7ee99f 100644 --- a/cc/resources/display_list_recording_source.h +++ b/cc/resources/display_list_recording_source.h @@ -18,14 +18,13 @@ class CC_EXPORT DisplayListRecordingSource : public RecordingSource { ~DisplayListRecordingSource() override; // RecordingSource overrides. - bool UpdateAndExpandInvalidation( - ContentLayerClient* painter, - Region* invalidation, - bool can_use_lcd_text, - const gfx::Size& layer_size, - const gfx::Rect& visible_layer_rect, - int frame_number, - Picture::RecordingMode recording_mode) override; + bool UpdateAndExpandInvalidation(ContentLayerClient* painter, + Region* invalidation, + bool can_use_lcd_text, + const gfx::Size& layer_size, + const gfx::Rect& visible_layer_rect, + int frame_number, + RecordingMode recording_mode) override; scoped_refptr CreateRasterSource() const override; gfx::Size GetSize() const final; void SetEmptyBounds() override; diff --git a/cc/resources/picture.cc b/cc/resources/picture.cc index 003a8f17503b..6bbeeaaefb08 100644 --- a/cc/resources/picture.cc +++ b/cc/resources/picture.cc @@ -53,11 +53,12 @@ bool DecodeBitmap(const void* buffer, size_t size, SkBitmap* bm) { } // namespace -scoped_refptr Picture::Create(const gfx::Rect& layer_rect, - ContentLayerClient* client, - const gfx::Size& tile_grid_size, - bool gather_pixel_refs, - RecordingMode recording_mode) { +scoped_refptr Picture::Create( + const gfx::Rect& layer_rect, + ContentLayerClient* client, + const gfx::Size& tile_grid_size, + bool gather_pixel_refs, + RecordingSource::RecordingMode recording_mode) { scoped_refptr picture = make_scoped_refptr(new Picture(layer_rect)); picture->Record(client, tile_grid_size, recording_mode); @@ -169,7 +170,7 @@ bool Picture::HasText() const { void Picture::Record(ContentLayerClient* painter, const gfx::Size& tile_grid_size, - RecordingMode recording_mode) { + RecordingSource::RecordingMode recording_mode) { TRACE_EVENT2("cc", "Picture::Record", "data", @@ -189,23 +190,27 @@ void Picture::Record(ContentLayerClient* painter, layer_rect_.width(), layer_rect_.height(), &factory, SkPictureRecorder::kComputeSaveLayerInfo_RecordFlag)); - ContentLayerClient::GraphicsContextStatus graphics_context_status = - ContentLayerClient::GRAPHICS_CONTEXT_ENABLED; + ContentLayerClient::PaintingControlSetting painting_control = + ContentLayerClient::PAINTING_BEHAVIOR_NORMAL; switch (recording_mode) { - case RECORD_NORMALLY: + case RecordingSource::RECORD_NORMALLY: // Already setup for normal recording. break; - case RECORD_WITH_SK_NULL_CANVAS: + case RecordingSource::RECORD_WITH_SK_NULL_CANVAS: canvas = skia::AdoptRef(SkCreateNullCanvas()); break; - case RECORD_WITH_PAINTING_DISABLED: + case RecordingSource::RECORD_WITH_PAINTING_DISABLED: // We pass a disable flag through the paint calls when perfromance // testing (the only time this case should ever arise) when we want to // prevent the Blink GraphicsContext object from consuming any compute // time. canvas = skia::AdoptRef(SkCreateNullCanvas()); - graphics_context_status = ContentLayerClient::GRAPHICS_CONTEXT_DISABLED; + painting_control = ContentLayerClient::DISPLAY_LIST_CONSTRUCTION_DISABLED; + break; + case RecordingSource::RECORD_WITH_CACHING_DISABLED: + // This mode should give the same results as RECORD_NORMALLY. + painting_control = ContentLayerClient::DISPLAY_LIST_CACHING_DISABLED; break; default: NOTREACHED(); @@ -221,7 +226,7 @@ void Picture::Record(ContentLayerClient* painter, layer_rect_.height()); canvas->clipRect(layer_skrect); - painter->PaintContents(canvas.get(), layer_rect_, graphics_context_status); + painter->PaintContents(canvas.get(), layer_rect_, painting_control); canvas->restore(); picture_ = skia::AdoptRef(recorder.endRecording()); diff --git a/cc/resources/picture.h b/cc/resources/picture.h index ec76f455555d..a2a4ec2b6548 100644 --- a/cc/resources/picture.h +++ b/cc/resources/picture.h @@ -18,6 +18,7 @@ #include "base/trace_event/trace_event.h" #include "cc/base/cc_export.h" #include "cc/base/region.h" +#include "cc/resources/recording_source.h" #include "skia/ext/refptr.h" #include "third_party/skia/include/core/SkPicture.h" #include "ui/gfx/geometry/rect.h" @@ -44,18 +45,12 @@ class CC_EXPORT Picture typedef std::vector PixelRefs; typedef base::hash_map PixelRefMap; - enum RecordingMode { - RECORD_NORMALLY, - RECORD_WITH_SK_NULL_CANVAS, - RECORD_WITH_PAINTING_DISABLED, - RECORDING_MODE_COUNT, // Must be the last entry. - }; - - static scoped_refptr Create(const gfx::Rect& layer_rect, - ContentLayerClient* client, - const gfx::Size& tile_grid_size, - bool gather_pixels_refs, - RecordingMode recording_mode); + static scoped_refptr Create( + const gfx::Rect& layer_rect, + ContentLayerClient* client, + const gfx::Size& tile_grid_size, + bool gather_pixels_refs, + RecordingSource::RecordingMode recording_mode); static scoped_refptr CreateFromValue(const base::Value* value); static scoped_refptr CreateFromSkpValue(const base::Value* value); @@ -141,7 +136,7 @@ class CC_EXPORT Picture // playback on a different thread this can only be called once. void Record(ContentLayerClient* client, const gfx::Size& tile_grid_size, - RecordingMode recording_mode); + RecordingSource::RecordingMode recording_mode); // Gather pixel refs from recording. void GatherPixelRefs(const gfx::Size& tile_grid_info); diff --git a/cc/resources/picture_pile.cc b/cc/resources/picture_pile.cc index f42244cf2f13..dcfe49ea7a04 100644 --- a/cc/resources/picture_pile.cc +++ b/cc/resources/picture_pile.cc @@ -181,7 +181,7 @@ bool PicturePile::UpdateAndExpandInvalidation( const gfx::Size& layer_size, const gfx::Rect& visible_layer_rect, int frame_number, - Picture::RecordingMode recording_mode) { + RecordingSource::RecordingMode recording_mode) { bool can_use_lcd_text_changed = can_use_lcd_text_ != can_use_lcd_text; can_use_lcd_text_ = can_use_lcd_text; @@ -532,7 +532,7 @@ void PicturePile::GetInvalidTileRects(const gfx::Rect& interest_rect, } void PicturePile::CreatePictures(ContentLayerClient* painter, - Picture::RecordingMode recording_mode, + RecordingSource::RecordingMode recording_mode, const std::vector& record_rects) { for (const auto& record_rect : record_rects) { gfx::Rect padded_record_rect = PadRect(record_rect); diff --git a/cc/resources/picture_pile.h b/cc/resources/picture_pile.h index 1e3368c0a72f..8000c422d2d7 100644 --- a/cc/resources/picture_pile.h +++ b/cc/resources/picture_pile.h @@ -12,7 +12,7 @@ #include "base/containers/hash_tables.h" #include "base/memory/ref_counted.h" #include "cc/base/tiling_data.h" -#include "cc/resources/recording_source.h" +#include "cc/resources/picture.h" namespace cc { class PicturePileImpl; @@ -23,14 +23,13 @@ class CC_EXPORT PicturePile : public RecordingSource { ~PicturePile() override; // RecordingSource overrides. - bool UpdateAndExpandInvalidation( - ContentLayerClient* painter, - Region* invalidation, - bool can_use_lcd_text, - const gfx::Size& layer_size, - const gfx::Rect& visible_layer_rect, - int frame_number, - Picture::RecordingMode recording_mode) override; + bool UpdateAndExpandInvalidation(ContentLayerClient* painter, + Region* invalidation, + bool can_use_lcd_text, + const gfx::Size& layer_size, + const gfx::Rect& visible_layer_rect, + int frame_number, + RecordingMode recording_mode) override; scoped_refptr CreateRasterSource() const override; gfx::Size GetSize() const final; void SetEmptyBounds() override; @@ -106,7 +105,7 @@ class CC_EXPORT PicturePile : public RecordingSource { friend class PicturePileImpl; void CreatePictures(ContentLayerClient* painter, - Picture::RecordingMode recording_mode, + RecordingMode recording_mode, const std::vector& record_rects); void GetInvalidTileRects(const gfx::Rect& interest_rect, Region* invalidation, diff --git a/cc/resources/picture_pile_unittest.cc b/cc/resources/picture_pile_unittest.cc index 4e3fe157f40e..b834979f6b5b 100644 --- a/cc/resources/picture_pile_unittest.cc +++ b/cc/resources/picture_pile_unittest.cc @@ -44,7 +44,7 @@ class PicturePileTestBase { frame_number_++; return pile_.UpdateAndExpandInvalidation( &client_, invalidation, false, layer_size, visible_layer_rect, - frame_number_, Picture::RECORD_NORMALLY); + frame_number_, RecordingSource::RECORD_NORMALLY); } bool UpdateWholePile() { diff --git a/cc/resources/picture_unittest.cc b/cc/resources/picture_unittest.cc index 0c41215549e4..1e2ba44fe3bc 100644 --- a/cc/resources/picture_unittest.cc +++ b/cc/resources/picture_unittest.cc @@ -44,7 +44,7 @@ TEST(PictureTest, AsBase64String) { scoped_refptr one_rect_picture = Picture::Create(layer_rect, &content_layer_client, tile_grid_size, false, - Picture::RECORD_NORMALLY); + RecordingSource::RECORD_NORMALLY); scoped_ptr serialized_one_rect(one_rect_picture->AsValue()); // Reconstruct the picture. @@ -66,7 +66,7 @@ TEST(PictureTest, AsBase64String) { scoped_refptr two_rect_picture = Picture::Create(layer_rect, &content_layer_client, tile_grid_size, false, - Picture::RECORD_NORMALLY); + RecordingSource::RECORD_NORMALLY); scoped_ptr serialized_two_rect(two_rect_picture->AsValue()); @@ -118,7 +118,7 @@ TEST(PictureTest, PixelRefIterator) { scoped_refptr picture = Picture::Create(layer_rect, &content_layer_client, tile_grid_size, true, - Picture::RECORD_NORMALLY); + RecordingSource::RECORD_NORMALLY); // Default iterator does not have any pixel refs { @@ -213,7 +213,7 @@ TEST(PictureTest, PixelRefIteratorNonZeroLayer) { scoped_refptr picture = Picture::Create(layer_rect, &content_layer_client, tile_grid_size, true, - Picture::RECORD_NORMALLY); + RecordingSource::RECORD_NORMALLY); // Default iterator does not have any pixel refs { @@ -331,7 +331,7 @@ TEST(PictureTest, PixelRefIteratorOnePixelQuery) { scoped_refptr picture = Picture::Create(layer_rect, &content_layer_client, tile_grid_size, true, - Picture::RECORD_NORMALLY); + RecordingSource::RECORD_NORMALLY); for (int y = 0; y < 4; ++y) { for (int x = 0; x < 4; ++x) { @@ -374,7 +374,7 @@ TEST(PictureTest, CreateFromSkpValue) { content_layer_client.add_draw_rect(layer_rect, red_paint); scoped_refptr one_rect_picture = Picture::Create(layer_rect, &content_layer_client, tile_grid_size, false, - Picture::RECORD_NORMALLY); + RecordingSource::RECORD_NORMALLY); scoped_ptr serialized_one_rect( one_rect_picture->AsValue()); @@ -406,27 +406,36 @@ TEST(PictureTest, RecordingModes) { scoped_refptr picture = Picture::Create(layer_rect, &content_layer_client, tile_grid_size, false, - Picture::RECORD_NORMALLY); + RecordingSource::RECORD_NORMALLY); EXPECT_TRUE(content_layer_client.last_canvas() != NULL); - EXPECT_EQ(ContentLayerClient::GRAPHICS_CONTEXT_ENABLED, - content_layer_client.last_context_status()); + EXPECT_EQ(ContentLayerClient::PAINTING_BEHAVIOR_NORMAL, + content_layer_client.last_painting_control()); EXPECT_TRUE(picture.get()); picture = Picture::Create(layer_rect, &content_layer_client, tile_grid_size, - false, Picture::RECORD_WITH_SK_NULL_CANVAS); + false, RecordingSource::RECORD_WITH_SK_NULL_CANVAS); EXPECT_TRUE(content_layer_client.last_canvas() != NULL); - EXPECT_EQ(ContentLayerClient::GRAPHICS_CONTEXT_ENABLED, - content_layer_client.last_context_status()); + EXPECT_EQ(ContentLayerClient::PAINTING_BEHAVIOR_NORMAL, + content_layer_client.last_painting_control()); EXPECT_TRUE(picture.get()); - picture = Picture::Create(layer_rect, &content_layer_client, tile_grid_size, - false, Picture::RECORD_WITH_PAINTING_DISABLED); + picture = + Picture::Create(layer_rect, &content_layer_client, tile_grid_size, false, + RecordingSource::RECORD_WITH_PAINTING_DISABLED); + EXPECT_TRUE(content_layer_client.last_canvas() != NULL); + EXPECT_EQ(ContentLayerClient::DISPLAY_LIST_CONSTRUCTION_DISABLED, + content_layer_client.last_painting_control()); + EXPECT_TRUE(picture.get()); + + picture = + Picture::Create(layer_rect, &content_layer_client, tile_grid_size, false, + RecordingSource::RECORD_WITH_CACHING_DISABLED); EXPECT_TRUE(content_layer_client.last_canvas() != NULL); - EXPECT_EQ(ContentLayerClient::GRAPHICS_CONTEXT_DISABLED, - content_layer_client.last_context_status()); + EXPECT_EQ(ContentLayerClient::DISPLAY_LIST_CACHING_DISABLED, + content_layer_client.last_painting_control()); EXPECT_TRUE(picture.get()); - EXPECT_EQ(3, Picture::RECORDING_MODE_COUNT); + EXPECT_EQ(4, RecordingSource::RECORDING_MODE_COUNT); } } // namespace diff --git a/cc/resources/recording_source.h b/cc/resources/recording_source.h index 1e450471974e..d96c0fa37689 100644 --- a/cc/resources/recording_source.h +++ b/cc/resources/recording_source.h @@ -5,8 +5,8 @@ #ifndef CC_RESOURCES_RECORDING_SOURCE_H_ #define CC_RESOURCES_RECORDING_SOURCE_H_ +#include "base/memory/ref_counted.h" #include "cc/base/cc_export.h" -#include "cc/resources/picture.h" #include "third_party/skia/include/core/SkColor.h" #include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/size.h" @@ -18,20 +18,27 @@ class RasterSource; class CC_EXPORT RecordingSource { public: + enum RecordingMode { + RECORD_NORMALLY, + RECORD_WITH_SK_NULL_CANVAS, + RECORD_WITH_PAINTING_DISABLED, + RECORD_WITH_CACHING_DISABLED, + RECORDING_MODE_COUNT, // Must be the last entry. + }; + virtual ~RecordingSource() {} // Re-record parts of the picture that are invalid. // Invalidations are in layer space, and will be expanded to cover everything // that was either recorded/changed or that has no recording, leaving out only // pieces that we had a recording for and it was not changed. // Return true iff the pile was modified. - virtual bool UpdateAndExpandInvalidation( - ContentLayerClient* painter, - Region* invalidation, - bool can_use_lcd_text, - const gfx::Size& layer_size, - const gfx::Rect& visible_layer_rect, - int frame_number, - Picture::RecordingMode recording_mode) = 0; + virtual bool UpdateAndExpandInvalidation(ContentLayerClient* painter, + Region* invalidation, + bool can_use_lcd_text, + const gfx::Size& layer_size, + const gfx::Rect& visible_layer_rect, + int frame_number, + RecordingMode recording_mode) = 0; virtual scoped_refptr CreateRasterSource() const = 0; diff --git a/cc/test/fake_content_layer_client.cc b/cc/test/fake_content_layer_client.cc index 46d1baa83647..23b73f5f18a7 100644 --- a/cc/test/fake_content_layer_client.cc +++ b/cc/test/fake_content_layer_client.cc @@ -22,9 +22,9 @@ FakeContentLayerClient::~FakeContentLayerClient() { void FakeContentLayerClient::PaintContents( SkCanvas* canvas, const gfx::Rect& paint_rect, - ContentLayerClient::GraphicsContextStatus gc_status) { + PaintingControlSetting painting_control) { last_canvas_ = canvas; - last_context_status_ = gc_status; + last_painting_control_ = painting_control; canvas->clipRect(gfx::RectToSkRect(paint_rect)); for (RectPaintVector::const_iterator it = draw_rects_.begin(); @@ -58,7 +58,7 @@ void FakeContentLayerClient::PaintContents( scoped_refptr FakeContentLayerClient::PaintContentsToDisplayList( const gfx::Rect& clip, - GraphicsContextStatus gc_status) { + PaintingControlSetting painting_control) { SkPictureRecorder recorder; skia::RefPtr canvas; skia::RefPtr picture; diff --git a/cc/test/fake_content_layer_client.h b/cc/test/fake_content_layer_client.h index 1060d0845889..d53d34e2ea3d 100644 --- a/cc/test/fake_content_layer_client.h +++ b/cc/test/fake_content_layer_client.h @@ -27,13 +27,12 @@ class FakeContentLayerClient : public ContentLayerClient { FakeContentLayerClient(); ~FakeContentLayerClient() override; - void PaintContents( - SkCanvas* canvas, - const gfx::Rect& rect, - ContentLayerClient::GraphicsContextStatus gc_status) override; + void PaintContents(SkCanvas* canvas, + const gfx::Rect& rect, + PaintingControlSetting painting_control) override; scoped_refptr PaintContentsToDisplayList( const gfx::Rect& clip, - GraphicsContextStatus gc_status) override; + PaintingControlSetting painting_control) override; bool FillsBoundsCompletely() const override; void set_fill_with_nonsolid_color(bool nonsolid) { @@ -56,8 +55,8 @@ class FakeContentLayerClient : public ContentLayerClient { SkCanvas* last_canvas() const { return last_canvas_; } - ContentLayerClient::GraphicsContextStatus last_context_status() const { - return last_context_status_; + PaintingControlSetting last_painting_control() const { + return last_painting_control_; } private: @@ -68,7 +67,7 @@ class FakeContentLayerClient : public ContentLayerClient { RectPaintVector draw_rects_; BitmapVector draw_bitmaps_; SkCanvas* last_canvas_; - ContentLayerClient::GraphicsContextStatus last_context_status_; + PaintingControlSetting last_painting_control_; }; } // namespace cc diff --git a/cc/test/fake_picture_pile_impl.cc b/cc/test/fake_picture_pile_impl.cc index 420b5d6ccab0..bdba09255fe4 100644 --- a/cc/test/fake_picture_pile_impl.cc +++ b/cc/test/fake_picture_pile_impl.cc @@ -120,8 +120,9 @@ void FakePicturePileImpl::AddRecordingAt(int x, int y) { gfx::Rect bounds(tiling().TileBounds(x, y)); bounds.Inset(-buffer_pixels(), -buffer_pixels()); - scoped_refptr picture(Picture::Create( - bounds, &client_, tile_grid_size_, true, Picture::RECORD_NORMALLY)); + scoped_refptr picture( + Picture::Create(bounds, &client_, tile_grid_size_, true, + RecordingSource::RECORD_NORMALLY)); picture_map_[std::pair(x, y)].SetPicture(picture); EXPECT_TRUE(HasRecordingAt(x, y)); diff --git a/cc/test/solid_color_content_layer_client.cc b/cc/test/solid_color_content_layer_client.cc index 701f004ffd3f..7e97bb8ae92d 100644 --- a/cc/test/solid_color_content_layer_client.cc +++ b/cc/test/solid_color_content_layer_client.cc @@ -14,7 +14,7 @@ namespace cc { void SolidColorContentLayerClient::PaintContents( SkCanvas* canvas, const gfx::Rect& rect, - ContentLayerClient::GraphicsContextStatus gc_status) { + PaintingControlSetting painting_control) { SkPaint paint; paint.setStyle(SkPaint::kFill_Style); paint.setColor(color_); @@ -28,7 +28,7 @@ void SolidColorContentLayerClient::PaintContents( scoped_refptr SolidColorContentLayerClient::PaintContentsToDisplayList( const gfx::Rect& clip, - GraphicsContextStatus gc_status) { + PaintingControlSetting painting_control) { NOTIMPLEMENTED(); return DisplayItemList::Create(); } diff --git a/cc/test/solid_color_content_layer_client.h b/cc/test/solid_color_content_layer_client.h index 93fca844555e..1ab4c4d712f0 100644 --- a/cc/test/solid_color_content_layer_client.h +++ b/cc/test/solid_color_content_layer_client.h @@ -16,13 +16,12 @@ class SolidColorContentLayerClient : public ContentLayerClient { explicit SolidColorContentLayerClient(SkColor color) : color_(color) {} // ContentLayerClient implementation. - void PaintContents( - SkCanvas* canvas, - const gfx::Rect& rect, - ContentLayerClient::GraphicsContextStatus gc_status) override; + void PaintContents(SkCanvas* canvas, + const gfx::Rect& rect, + PaintingControlSetting painting_control) override; scoped_refptr PaintContentsToDisplayList( const gfx::Rect& clip, - GraphicsContextStatus gc_status) override; + PaintingControlSetting painting_control) override; bool FillsBoundsCompletely() const override; private: diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc index df2b30e1f22e..de5f44a4eed9 100644 --- a/cc/trees/layer_tree_host_common_unittest.cc +++ b/cc/trees/layer_tree_host_common_unittest.cc @@ -56,13 +56,12 @@ class MockContentLayerClient : public ContentLayerClient { public: MockContentLayerClient() {} ~MockContentLayerClient() override {} - void PaintContents( - SkCanvas* canvas, - const gfx::Rect& clip, - ContentLayerClient::GraphicsContextStatus gc_status) override {} + void PaintContents(SkCanvas* canvas, + const gfx::Rect& clip, + PaintingControlSetting picture_control) override {} scoped_refptr PaintContentsToDisplayList( const gfx::Rect& clip, - GraphicsContextStatus gc_status) override { + PaintingControlSetting picture_control) override { NOTIMPLEMENTED(); return DisplayItemList::Create(); } diff --git a/cc/trees/layer_tree_host_pixeltest_masks.cc b/cc/trees/layer_tree_host_pixeltest_masks.cc index 1235e15fdfa5..eecc5a0e3edd 100644 --- a/cc/trees/layer_tree_host_pixeltest_masks.cc +++ b/cc/trees/layer_tree_host_pixeltest_masks.cc @@ -26,10 +26,9 @@ class MaskContentLayerClient : public ContentLayerClient { bool FillsBoundsCompletely() const override { return false; } - void PaintContents( - SkCanvas* canvas, - const gfx::Rect& rect, - ContentLayerClient::GraphicsContextStatus gc_status) override { + void PaintContents(SkCanvas* canvas, + const gfx::Rect& rect, + PaintingControlSetting picture_control) override { SkPaint paint; paint.setStyle(SkPaint::kStroke_Style); paint.setStrokeWidth(SkIntToScalar(2)); @@ -49,7 +48,7 @@ class MaskContentLayerClient : public ContentLayerClient { scoped_refptr PaintContentsToDisplayList( const gfx::Rect& clip, - GraphicsContextStatus gc_status) override { + PaintingControlSetting picture_control) override { NOTIMPLEMENTED(); return DisplayItemList::Create(); } @@ -97,9 +96,8 @@ TEST_P(LayerTreeHostMasksPixelTest, ImageMaskOfLayer) { SkCanvas canvas(bitmap); canvas.scale(SkIntToScalar(4), SkIntToScalar(4)); MaskContentLayerClient client(mask_bounds); - client.PaintContents(&canvas, - gfx::Rect(mask_bounds), - ContentLayerClient::GRAPHICS_CONTEXT_ENABLED); + client.PaintContents(&canvas, gfx::Rect(mask_bounds), + ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); mask->SetBitmap(bitmap); scoped_refptr green = CreateSolidColorLayerWithBorder( diff --git a/cc/trees/layer_tree_host_pixeltest_on_demand_raster.cc b/cc/trees/layer_tree_host_pixeltest_on_demand_raster.cc index 4d60baf355e8..5d828c58b9aa 100644 --- a/cc/trees/layer_tree_host_pixeltest_on_demand_raster.cc +++ b/cc/trees/layer_tree_host_pixeltest_on_demand_raster.cc @@ -61,10 +61,9 @@ class BlueYellowLayerClient : public ContentLayerClient { bool FillsBoundsCompletely() const override { return false; } - void PaintContents( - SkCanvas* canvas, - const gfx::Rect& clip, - ContentLayerClient::GraphicsContextStatus gc_status) override { + void PaintContents(SkCanvas* canvas, + const gfx::Rect& clip, + PaintingControlSetting picture_control) override { SkPaint paint; paint.setColor(SK_ColorBLUE); canvas->drawRect(SkRect::MakeWH(layer_rect_.width(), @@ -82,7 +81,7 @@ class BlueYellowLayerClient : public ContentLayerClient { scoped_refptr PaintContentsToDisplayList( const gfx::Rect& clip, - GraphicsContextStatus gc_status) override { + PaintingControlSetting picture_control) override { NOTIMPLEMENTED(); return DisplayItemList::Create(); } diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc index 06867158f917..8dab1af16ef4 100644 --- a/cc/trees/layer_tree_host_unittest.cc +++ b/cc/trees/layer_tree_host_unittest.cc @@ -1106,17 +1106,16 @@ class TestOpacityChangeLayerDelegate : public ContentLayerClient { void SetTestLayer(Layer* test_layer) { test_layer_ = test_layer; } - void PaintContents( - SkCanvas* canvas, - const gfx::Rect& clip, - ContentLayerClient::GraphicsContextStatus gc_status) override { + 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); } scoped_refptr PaintContentsToDisplayList( const gfx::Rect& clip, - GraphicsContextStatus gc_status) override { + PaintingControlSetting picture_control) override { NOTIMPLEMENTED(); return DisplayItemList::Create(); } @@ -2329,17 +2328,16 @@ class LayerTreeHostTestLCDChange : public LayerTreeHostTest { int paint_count() const { return paint_count_; } - void PaintContents( - SkCanvas* canvas, - const gfx::Rect& clip, - ContentLayerClient::GraphicsContextStatus gc_status) override { - FakeContentLayerClient::PaintContents(canvas, clip, gc_status); + void PaintContents(SkCanvas* canvas, + const gfx::Rect& clip, + PaintingControlSetting picture_control) override { + FakeContentLayerClient::PaintContents(canvas, clip, picture_control); ++paint_count_; } scoped_refptr PaintContentsToDisplayList( const gfx::Rect& clip, - GraphicsContextStatus gc_status) override { + PaintingControlSetting picture_control) override { NOTIMPLEMENTED(); return DisplayItemList::Create(); } @@ -2607,16 +2605,15 @@ class LayerTreeHostTestChangeLayerPropertiesInPaintContents void set_layer(Layer* layer) { layer_ = layer; } - void PaintContents( - SkCanvas* canvas, - const gfx::Rect& clip, - ContentLayerClient::GraphicsContextStatus gc_status) override { + void PaintContents(SkCanvas* canvas, + const gfx::Rect& clip, + PaintingControlSetting picture_control) override { layer_->SetBounds(gfx::Size(2, 2)); } scoped_refptr PaintContentsToDisplayList( const gfx::Rect& clip, - GraphicsContextStatus gc_status) override { + PaintingControlSetting picture_control) override { NOTIMPLEMENTED(); return DisplayItemList::Create(); } diff --git a/tools/perf/measurements/rasterize_and_record_micro.py b/tools/perf/measurements/rasterize_and_record_micro.py index 3523a7bb362b..f278ff66b55c 100644 --- a/tools/perf/measurements/rasterize_and_record_micro.py +++ b/tools/perf/measurements/rasterize_and_record_micro.py @@ -83,14 +83,24 @@ class RasterizeAndRecordMicro(page_test.PageTest): picture_memory_usage)) results.AddValue(scalar.ScalarValue( results.current_page, 'record_time', 'ms', record_time)) + record_time_sk_null_canvas = data['record_time_sk_null_canvas_ms'] record_time_painting_disabled = data['record_time_painting_disabled_ms'] + # TODO(schenney): Remove this workaround when reference builds get past + # the change that adds this comment. + if ('record_time_caching_disabled_ms' in data): + record_time_caching_disabled = data['record_time_caching_disabled_ms'] + else: + record_time_caching_disabled = 0 results.AddValue(scalar.ScalarValue( results.current_page, 'record_time_sk_null_canvas', 'ms', record_time_sk_null_canvas)) results.AddValue(scalar.ScalarValue( results.current_page, 'record_time_painting_disabled', 'ms', record_time_painting_disabled)) + results.AddValue(scalar.ScalarValue( + results.current_page, 'record_time_caching_disabled', 'ms', + record_time_caching_disabled)) if self._report_detailed_results: pixels_rasterized_with_non_solid_color = \ diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc index c5de63247901..4625e0d24c6e 100644 --- a/ui/compositor/layer.cc +++ b/ui/compositor/layer.cc @@ -726,9 +726,10 @@ void Layer::RequestCopyOfOutput(scoped_ptr request) { cc_layer_->RequestCopyOfOutput(request.Pass()); } -void Layer::PaintContents(SkCanvas* sk_canvas, - const gfx::Rect& clip, - ContentLayerClient::GraphicsContextStatus gc_status) { +void Layer::PaintContents( + SkCanvas* sk_canvas, + const gfx::Rect& clip, + ContentLayerClient::PaintingControlSetting painting_control) { TRACE_EVENT1("ui", "Layer::PaintContents", "name", name_); scoped_ptr canvas(gfx::Canvas::CreateCanvasWithoutScaling( sk_canvas, device_scale_factor_)); @@ -738,7 +739,7 @@ void Layer::PaintContents(SkCanvas* sk_canvas, scoped_refptr Layer::PaintContentsToDisplayList( const gfx::Rect& clip, - ContentLayerClient::GraphicsContextStatus gc_status) { + ContentLayerClient::PaintingControlSetting painting_control) { NOTIMPLEMENTED(); return cc::DisplayItemList::Create(); } diff --git a/ui/compositor/layer.h b/ui/compositor/layer.h index d49101b451be..598739e6254b 100644 --- a/ui/compositor/layer.h +++ b/ui/compositor/layer.h @@ -340,10 +340,10 @@ class COMPOSITOR_EXPORT Layer void PaintContents( SkCanvas* canvas, const gfx::Rect& clip, - ContentLayerClient::GraphicsContextStatus gc_status) override; + ContentLayerClient::PaintingControlSetting painting_control) override; scoped_refptr PaintContentsToDisplayList( const gfx::Rect& clip, - GraphicsContextStatus gc_status) override; + ContentLayerClient::PaintingControlSetting painting_control) override; bool FillsBoundsCompletely() const override; cc::Layer* cc_layer() { return cc_layer_; } -- 2.11.4.GIT