Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/resources/display_list_recording_source.h" | 5 #include "cc/resources/display_list_recording_source.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "cc/base/histogram_macros.h" | |
| 9 #include "cc/base/region.h" | 10 #include "cc/base/region.h" |
| 10 #include "cc/layers/content_layer_client.h" | 11 #include "cc/layers/content_layer_client.h" |
| 11 #include "cc/resources/display_item_list.h" | 12 #include "cc/resources/display_item_list.h" |
| 12 #include "cc/resources/display_list_raster_source.h" | 13 #include "cc/resources/display_list_raster_source.h" |
| 13 #include "skia/ext/analysis_canvas.h" | 14 #include "skia/ext/analysis_canvas.h" |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 // Layout pixel buffer around the visible layer rect to record. Any base | 18 // Layout pixel buffer around the visible layer rect to record. Any base |
| 18 // picture that intersects the visible layer rect expanded by this distance | 19 // picture that intersects the visible layer rect expanded by this distance |
| 19 // will be recorded. | 20 // will be recorded. |
| 20 const int kPixelDistanceToRecord = 8000; | 21 const int kPixelDistanceToRecord = 8000; |
| 21 // We don't perform solid color analysis on images that have more than 10 skia | 22 // We don't perform solid color analysis on images that have more than 10 skia |
| 22 // operations. | 23 // operations. |
| 23 const int kOpCountThatIsOkToAnalyze = 10; | 24 const int kOpCountThatIsOkToAnalyze = 10; |
| 24 | 25 |
| 26 DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER( | |
| 27 ScopedDisplayListRecordingSourceUpdateTimer, | |
| 28 "Renderer4.DisplayListRecordingSourceUpdateUs", | |
| 29 "Renderer4.DisplayListRecordingSourceUpdatePixelsPerMs"); | |
| 30 | |
| 25 } // namespace | 31 } // namespace |
| 26 | 32 |
| 27 namespace cc { | 33 namespace cc { |
| 28 | 34 |
| 29 DisplayListRecordingSource::DisplayListRecordingSource( | 35 DisplayListRecordingSource::DisplayListRecordingSource( |
| 30 const gfx::Size& grid_cell_size) | 36 const gfx::Size& grid_cell_size) |
| 31 : slow_down_raster_scale_factor_for_debug_(0), | 37 : slow_down_raster_scale_factor_for_debug_(0), |
| 32 gather_pixel_refs_(false), | 38 gather_pixel_refs_(false), |
| 33 requires_clear_(false), | 39 requires_clear_(false), |
| 34 is_solid_color_(false), | 40 is_solid_color_(false), |
| 35 solid_color_(SK_ColorTRANSPARENT), | 41 solid_color_(SK_ColorTRANSPARENT), |
| 36 background_color_(SK_ColorTRANSPARENT), | 42 background_color_(SK_ColorTRANSPARENT), |
| 37 pixel_record_distance_(kPixelDistanceToRecord), | 43 pixel_record_distance_(kPixelDistanceToRecord), |
| 38 grid_cell_size_(grid_cell_size), | 44 grid_cell_size_(grid_cell_size), |
| 39 is_suitable_for_gpu_rasterization_(true) { | 45 is_suitable_for_gpu_rasterization_(true) { |
| 40 } | 46 } |
| 41 | 47 |
| 42 DisplayListRecordingSource::~DisplayListRecordingSource() { | 48 DisplayListRecordingSource::~DisplayListRecordingSource() { |
| 43 } | 49 } |
| 44 | 50 |
| 45 bool DisplayListRecordingSource::UpdateAndExpandInvalidation( | 51 bool DisplayListRecordingSource::UpdateAndExpandInvalidation( |
| 46 ContentLayerClient* painter, | 52 ContentLayerClient* painter, |
| 47 Region* invalidation, | 53 Region* invalidation, |
| 48 const gfx::Size& layer_size, | 54 const gfx::Size& layer_size, |
| 49 const gfx::Rect& visible_layer_rect, | 55 const gfx::Rect& visible_layer_rect, |
| 50 int frame_number, | 56 int frame_number, |
| 51 RecordingMode recording_mode) { | 57 RecordingMode recording_mode) { |
| 58 ScopedDisplayListRecordingSourceUpdateTimer timer; | |
| 52 bool updated = false; | 59 bool updated = false; |
| 53 | 60 |
| 54 if (size_ != layer_size) { | 61 if (size_ != layer_size) { |
| 55 size_ = layer_size; | 62 size_ = layer_size; |
| 56 updated = true; | 63 updated = true; |
| 57 } | 64 } |
| 58 | 65 |
| 59 gfx::Rect old_recorded_viewport = recorded_viewport_; | 66 gfx::Rect old_recorded_viewport = recorded_viewport_; |
| 60 recorded_viewport_ = visible_layer_rect; | 67 recorded_viewport_ = visible_layer_rect; |
| 61 recorded_viewport_.Inset(-pixel_record_distance_, -pixel_record_distance_); | 68 recorded_viewport_.Inset(-pixel_record_distance_, -pixel_record_distance_); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 is_suitable_for_gpu_rasterization_ = | 120 is_suitable_for_gpu_rasterization_ = |
| 114 display_list_->IsSuitableForGpuRasterization(); | 121 display_list_->IsSuitableForGpuRasterization(); |
| 115 | 122 |
| 116 DetermineIfSolidColor(); | 123 DetermineIfSolidColor(); |
| 117 display_list_->EmitTraceSnapshot(); | 124 display_list_->EmitTraceSnapshot(); |
| 118 | 125 |
| 119 display_list_->CreateAndCacheSkPicture(); | 126 display_list_->CreateAndCacheSkPicture(); |
| 120 if (gather_pixel_refs_) | 127 if (gather_pixel_refs_) |
| 121 display_list_->GatherPixelRefs(grid_cell_size_); | 128 display_list_->GatherPixelRefs(grid_cell_size_); |
| 122 | 129 |
| 130 timer.SetArea(recorded_viewport_.size().GetArea()); | |
|
chrishtr
2015/04/10 17:41:39
What if you just set the area to the invalidation
jbroman
2015/04/13 19:34:00
Changed as discussed in meeting on Friday.
| |
| 131 | |
| 123 return true; | 132 return true; |
| 124 } | 133 } |
| 125 | 134 |
| 126 gfx::Size DisplayListRecordingSource::GetSize() const { | 135 gfx::Size DisplayListRecordingSource::GetSize() const { |
| 127 return size_; | 136 return size_; |
| 128 } | 137 } |
| 129 | 138 |
| 130 void DisplayListRecordingSource::SetEmptyBounds() { | 139 void DisplayListRecordingSource::SetEmptyBounds() { |
| 131 size_ = gfx::Size(); | 140 size_ = gfx::Size(); |
| 132 Clear(); | 141 Clear(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 is_solid_color_ = canvas.GetColorIfSolid(&solid_color_); | 190 is_solid_color_ = canvas.GetColorIfSolid(&solid_color_); |
| 182 } | 191 } |
| 183 | 192 |
| 184 void DisplayListRecordingSource::Clear() { | 193 void DisplayListRecordingSource::Clear() { |
| 185 recorded_viewport_ = gfx::Rect(); | 194 recorded_viewport_ = gfx::Rect(); |
| 186 display_list_ = NULL; | 195 display_list_ = NULL; |
| 187 is_solid_color_ = false; | 196 is_solid_color_ = false; |
| 188 } | 197 } |
| 189 | 198 |
| 190 } // namespace cc | 199 } // namespace cc |
| OLD | NEW |