| 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/histograms.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 "Compositing.DisplayListRecordingSource.UpdateUs", |
| 29 "Compositing.DisplayListRecordingSource.UpdateInvalidatedAreaPerMs"); |
| 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_); |
| 62 recorded_viewport_.Intersect(gfx::Rect(GetSize())); | 69 recorded_viewport_.Intersect(gfx::Rect(GetSize())); |
| 63 | 70 |
| 64 if (recorded_viewport_ != old_recorded_viewport) { | 71 if (recorded_viewport_ != old_recorded_viewport) { |
| 65 // Invalidate newly-exposed and no-longer-exposed areas. | 72 // Invalidate newly-exposed and no-longer-exposed areas. |
| 66 Region newly_exposed_region(recorded_viewport_); | 73 Region newly_exposed_region(recorded_viewport_); |
| 67 newly_exposed_region.Subtract(old_recorded_viewport); | 74 newly_exposed_region.Subtract(old_recorded_viewport); |
| 68 invalidation->Union(newly_exposed_region); | 75 invalidation->Union(newly_exposed_region); |
| 69 | 76 |
| 70 Region no_longer_exposed_region(old_recorded_viewport); | 77 Region no_longer_exposed_region(old_recorded_viewport); |
| 71 no_longer_exposed_region.Subtract(recorded_viewport_); | 78 no_longer_exposed_region.Subtract(recorded_viewport_); |
| 72 invalidation->Union(no_longer_exposed_region); | 79 invalidation->Union(no_longer_exposed_region); |
| 73 | 80 |
| 74 updated = true; | 81 updated = true; |
| 75 } | 82 } |
| 76 | 83 |
| 84 // Count the area that is being invalidated. |
| 85 Region recorded_invalidation(*invalidation); |
| 86 recorded_invalidation.Intersect(recorded_viewport_); |
| 87 for (Region::Iterator it(recorded_invalidation); it.has_rect(); it.next()) |
| 88 timer.AddArea(it.rect().size().GetArea()); |
| 89 |
| 77 if (!updated && !invalidation->Intersects(recorded_viewport_)) | 90 if (!updated && !invalidation->Intersects(recorded_viewport_)) |
| 78 return false; | 91 return false; |
| 79 | 92 |
| 80 ContentLayerClient::PaintingControlSetting painting_control = | 93 ContentLayerClient::PaintingControlSetting painting_control = |
| 81 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL; | 94 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL; |
| 82 | 95 |
| 83 switch (recording_mode) { | 96 switch (recording_mode) { |
| 84 case RECORD_NORMALLY: | 97 case RECORD_NORMALLY: |
| 85 // Already setup for normal recording. | 98 // Already setup for normal recording. |
| 86 break; | 99 break; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 is_solid_color_ = canvas.GetColorIfSolid(&solid_color_); | 194 is_solid_color_ = canvas.GetColorIfSolid(&solid_color_); |
| 182 } | 195 } |
| 183 | 196 |
| 184 void DisplayListRecordingSource::Clear() { | 197 void DisplayListRecordingSource::Clear() { |
| 185 recorded_viewport_ = gfx::Rect(); | 198 recorded_viewport_ = gfx::Rect(); |
| 186 display_list_ = NULL; | 199 display_list_ = NULL; |
| 187 is_solid_color_ = false; | 200 is_solid_color_ = false; |
| 188 } | 201 } |
| 189 | 202 |
| 190 } // namespace cc | 203 } // namespace cc |
| OLD | NEW |