diff options
-rw-r--r-- | cc/debug/rasterize_and_record_benchmark.cc | 11 | ||||
-rw-r--r-- | cc/playback/display_item_list.cc | 8 | ||||
-rw-r--r-- | cc/playback/display_item_list.h | 1 | ||||
-rw-r--r-- | cc/playback/display_list_recording_source.cc | 5 | ||||
-rw-r--r-- | cc/playback/picture.cc | 8 | ||||
-rw-r--r-- | cc/playback/picture.h | 1 | ||||
-rw-r--r-- | cc/playback/picture_pile.cc | 5 |
7 files changed, 31 insertions, 8 deletions
diff --git a/cc/debug/rasterize_and_record_benchmark.cc b/cc/debug/rasterize_and_record_benchmark.cc index a7ee99d..b253436 100644 --- a/cc/debug/rasterize_and_record_benchmark.cc +++ b/cc/debug/rasterize_and_record_benchmark.cc @@ -20,6 +20,7 @@ #include "cc/playback/picture_pile.h" #include "cc/trees/layer_tree_host.h" #include "cc/trees/layer_tree_host_common.h" +#include "skia/ext/analysis_canvas.h" #include "third_party/skia/include/utils/SkPictureUtils.h" #include "ui/gfx/geometry/rect.h" @@ -151,6 +152,11 @@ void RasterizeAndRecordBenchmark::RunOnPictureLayer( 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()); @@ -220,6 +226,11 @@ void RasterizeAndRecordBenchmark::RunOnDisplayListLayer( do { display_list = painter->PaintContentsToDisplayList(visible_layer_rect, painting_control); + if (display_list->ShouldBeAnalyzedForSolidColor()) { + gfx::Size layer_size = layer->paint_properties().bounds; + skia::AnalysisCanvas canvas(layer_size.width(), layer_size.height()); + display_list->Raster(&canvas, nullptr, gfx::Rect(), 1.f); + } if (memory_used) { // Verify we are recording the same thing each time. diff --git a/cc/playback/display_item_list.cc b/cc/playback/display_item_list.cc index 08fe71d..b044e98 100644 --- a/cc/playback/display_item_list.cc +++ b/cc/playback/display_item_list.cc @@ -25,6 +25,10 @@ namespace cc { namespace { +// We don't perform per-layer solid color analysis when there are too many skia +// operations. +const int kOpCountThatIsOkToAnalyze = 10; + bool DisplayItemsTracingEnabled() { bool tracing_enabled; TRACE_EVENT_CATEGORY_GROUP_ENABLED( @@ -240,6 +244,10 @@ size_t DisplayItemList::ApproximateMemoryUsage() const { return memory_usage; } +bool DisplayItemList::ShouldBeAnalyzedForSolidColor() const { + return ApproximateOpCount() <= kOpCountThatIsOkToAnalyze; +} + scoped_refptr<base::trace_event::ConvertableToTraceFormat> DisplayItemList::AsValue(bool include_items) const { DCHECK(ProcessAppendedItemsCalled()); diff --git a/cc/playback/display_item_list.h b/cc/playback/display_item_list.h index 35bcb8c..3778b00 100644 --- a/cc/playback/display_item_list.h +++ b/cc/playback/display_item_list.h @@ -71,6 +71,7 @@ class CC_EXPORT DisplayItemList bool IsSuitableForGpuRasterization() const; int ApproximateOpCount() const; size_t ApproximateMemoryUsage() const; + bool ShouldBeAnalyzedForSolidColor() const; bool RetainsIndividualDisplayItems() const; diff --git a/cc/playback/display_list_recording_source.cc b/cc/playback/display_list_recording_source.cc index e93c0dc..5f877a0 100644 --- a/cc/playback/display_list_recording_source.cc +++ b/cc/playback/display_list_recording_source.cc @@ -19,9 +19,6 @@ namespace { // picture that intersects the visible layer rect expanded by this distance // will be recorded. const int kPixelDistanceToRecord = 8000; -// We don't perform solid color analysis on images that have more than 10 skia -// operations. -const int kOpCountThatIsOkToAnalyze = 10; // This is the distance, in layer space, by which the recorded viewport has to // change before causing a paint of the new content. For example, it means @@ -245,7 +242,7 @@ void DisplayListRecordingSource::DetermineIfSolidColor() { is_solid_color_ = false; solid_color_ = SK_ColorTRANSPARENT; - if (display_list_->ApproximateOpCount() > kOpCountThatIsOkToAnalyze) + if (!display_list_->ShouldBeAnalyzedForSolidColor()) return; gfx::Size layer_size = GetSize(); diff --git a/cc/playback/picture.cc b/cc/playback/picture.cc index 8ce9c66..431022c 100644 --- a/cc/playback/picture.cc +++ b/cc/playback/picture.cc @@ -32,6 +32,10 @@ namespace cc { namespace { +// We don't perform per-layer solid color analysis when there are too many skia +// operations. +const int kOpCountThatIsOkToAnalyze = 10; + bool DecodeBitmap(const void* buffer, size_t size, SkBitmap* bm) { const unsigned char* data = static_cast<const unsigned char *>(buffer); @@ -157,6 +161,10 @@ size_t Picture::ApproximateMemoryUsage() const { return SkPictureUtils::ApproximateBytesUsed(picture_.get()); } +bool Picture::ShouldBeAnalyzedForSolidColor() const { + return ApproximateOpCount() <= kOpCountThatIsOkToAnalyze; +} + bool Picture::HasText() const { DCHECK(picture_); return picture_->hasText(); diff --git a/cc/playback/picture.h b/cc/playback/picture.h index b19504b..f8f6118 100644 --- a/cc/playback/picture.h +++ b/cc/playback/picture.h @@ -54,6 +54,7 @@ class CC_EXPORT Picture bool IsSuitableForGpuRasterization(const char** reason) const; int ApproximateOpCount() const; size_t ApproximateMemoryUsage() const; + bool ShouldBeAnalyzedForSolidColor() const; bool HasText() const; diff --git a/cc/playback/picture_pile.cc b/cc/playback/picture_pile.cc index 28828ff..bafa0ed 100644 --- a/cc/playback/picture_pile.cc +++ b/cc/playback/picture_pile.cc @@ -18,9 +18,6 @@ namespace { // picture that intersects the visible layer rect expanded by this distance // will be recorded. const int kPixelDistanceToRecord = 8000; -// We don't perform solid color analysis on images that have more than 10 skia -// operations. -const int kOpCountThatIsOkToAnalyze = 10; // Dimensions of the tiles in this picture pile as well as the dimensions of // the base picture in each tile. @@ -651,7 +648,7 @@ void PicturePile::DetermineIfSolidColor() { return; // Don't bother doing more work if the first image is too complicated. - if (picture->ApproximateOpCount() > kOpCountThatIsOkToAnalyze) + if (!picture->ShouldBeAnalyzedForSolidColor()) return; // Make sure all of the mapped images point to the same picture. |