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/playback/display_list_recording_source.h" | 5 #include "cc/playback/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/playback/display_item_list.h" | 12 #include "cc/playback/display_item_list.h" |
12 #include "cc/playback/display_list_raster_source.h" | 13 #include "cc/playback/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 bool use_cached_picture) | 37 bool use_cached_picture) |
32 : use_cached_picture_(use_cached_picture), | 38 : use_cached_picture_(use_cached_picture), |
33 slow_down_raster_scale_factor_for_debug_(0), | 39 slow_down_raster_scale_factor_for_debug_(0), |
34 gather_pixel_refs_(false), | 40 gather_pixel_refs_(false), |
35 requires_clear_(false), | 41 requires_clear_(false), |
36 is_solid_color_(false), | 42 is_solid_color_(false), |
37 solid_color_(SK_ColorTRANSPARENT), | 43 solid_color_(SK_ColorTRANSPARENT), |
38 background_color_(SK_ColorTRANSPARENT), | 44 background_color_(SK_ColorTRANSPARENT), |
39 pixel_record_distance_(kPixelDistanceToRecord), | 45 pixel_record_distance_(kPixelDistanceToRecord), |
40 grid_cell_size_(grid_cell_size), | 46 grid_cell_size_(grid_cell_size), |
41 is_suitable_for_gpu_rasterization_(true) { | 47 is_suitable_for_gpu_rasterization_(true) { |
42 } | 48 } |
43 | 49 |
44 DisplayListRecordingSource::~DisplayListRecordingSource() { | 50 DisplayListRecordingSource::~DisplayListRecordingSource() { |
45 } | 51 } |
46 | 52 |
47 bool DisplayListRecordingSource::UpdateAndExpandInvalidation( | 53 bool DisplayListRecordingSource::UpdateAndExpandInvalidation( |
48 ContentLayerClient* painter, | 54 ContentLayerClient* painter, |
49 Region* invalidation, | 55 Region* invalidation, |
50 const gfx::Size& layer_size, | 56 const gfx::Size& layer_size, |
51 const gfx::Rect& visible_layer_rect, | 57 const gfx::Rect& visible_layer_rect, |
52 int frame_number, | 58 int frame_number, |
53 RecordingMode recording_mode) { | 59 RecordingMode recording_mode) { |
| 60 ScopedDisplayListRecordingSourceUpdateTimer timer; |
54 bool updated = false; | 61 bool updated = false; |
55 | 62 |
56 if (size_ != layer_size) { | 63 if (size_ != layer_size) { |
57 size_ = layer_size; | 64 size_ = layer_size; |
58 updated = true; | 65 updated = true; |
59 } | 66 } |
60 | 67 |
61 gfx::Rect old_recorded_viewport = recorded_viewport_; | 68 gfx::Rect old_recorded_viewport = recorded_viewport_; |
62 recorded_viewport_ = visible_layer_rect; | 69 recorded_viewport_ = visible_layer_rect; |
63 recorded_viewport_.Inset(-pixel_record_distance_, -pixel_record_distance_); | 70 recorded_viewport_.Inset(-pixel_record_distance_, -pixel_record_distance_); |
64 recorded_viewport_.Intersect(gfx::Rect(GetSize())); | 71 recorded_viewport_.Intersect(gfx::Rect(GetSize())); |
65 | 72 |
66 if (recorded_viewport_ != old_recorded_viewport) { | 73 if (recorded_viewport_ != old_recorded_viewport) { |
67 // Invalidate newly-exposed and no-longer-exposed areas. | 74 // Invalidate newly-exposed and no-longer-exposed areas. |
68 Region newly_exposed_region(recorded_viewport_); | 75 Region newly_exposed_region(recorded_viewport_); |
69 newly_exposed_region.Subtract(old_recorded_viewport); | 76 newly_exposed_region.Subtract(old_recorded_viewport); |
70 invalidation->Union(newly_exposed_region); | 77 invalidation->Union(newly_exposed_region); |
71 | 78 |
72 Region no_longer_exposed_region(old_recorded_viewport); | 79 Region no_longer_exposed_region(old_recorded_viewport); |
73 no_longer_exposed_region.Subtract(recorded_viewport_); | 80 no_longer_exposed_region.Subtract(recorded_viewport_); |
74 invalidation->Union(no_longer_exposed_region); | 81 invalidation->Union(no_longer_exposed_region); |
75 | 82 |
76 updated = true; | 83 updated = true; |
77 } | 84 } |
78 | 85 |
| 86 // Count the area that is being invalidated. |
| 87 Region recorded_invalidation(*invalidation); |
| 88 recorded_invalidation.Intersect(recorded_viewport_); |
| 89 for (Region::Iterator it(recorded_invalidation); it.has_rect(); it.next()) |
| 90 timer.AddArea(it.rect().size().GetArea()); |
| 91 |
79 if (!updated && !invalidation->Intersects(recorded_viewport_)) | 92 if (!updated && !invalidation->Intersects(recorded_viewport_)) |
80 return false; | 93 return false; |
81 | 94 |
82 ContentLayerClient::PaintingControlSetting painting_control = | 95 ContentLayerClient::PaintingControlSetting painting_control = |
83 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL; | 96 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL; |
84 | 97 |
85 switch (recording_mode) { | 98 switch (recording_mode) { |
86 case RECORD_NORMALLY: | 99 case RECORD_NORMALLY: |
87 // Already setup for normal recording. | 100 // Already setup for normal recording. |
88 break; | 101 break; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 is_solid_color_ = canvas.GetColorIfSolid(&solid_color_); | 196 is_solid_color_ = canvas.GetColorIfSolid(&solid_color_); |
184 } | 197 } |
185 | 198 |
186 void DisplayListRecordingSource::Clear() { | 199 void DisplayListRecordingSource::Clear() { |
187 recorded_viewport_ = gfx::Rect(); | 200 recorded_viewport_ = gfx::Rect(); |
188 display_list_ = NULL; | 201 display_list_ = NULL; |
189 is_solid_color_ = false; | 202 is_solid_color_ = false; |
190 } | 203 } |
191 | 204 |
192 } // namespace cc | 205 } // namespace cc |
OLD | NEW |