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 "base/numerics/safe_math.h" | 9 #include "base/numerics/safe_math.h" |
10 #include "cc/base/histograms.h" | 10 #include "cc/base/histograms.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 | 103 |
104 return false; | 104 return false; |
105 } | 105 } |
106 | 106 |
107 bool DisplayListRecordingSource::UpdateAndExpandInvalidation( | 107 bool DisplayListRecordingSource::UpdateAndExpandInvalidation( |
108 ContentLayerClient* painter, | 108 ContentLayerClient* painter, |
109 Region* invalidation, | 109 Region* invalidation, |
110 const gfx::Size& layer_size, | 110 const gfx::Size& layer_size, |
111 const gfx::Rect& visible_layer_rect, | 111 const gfx::Rect& visible_layer_rect, |
112 int frame_number, | 112 int frame_number, |
113 RecordingMode recording_mode) { | 113 RecordingMode recording_mode, |
114 bool blink_synchronous_painting_enabled) { | |
114 ScopedDisplayListRecordingSourceUpdateTimer timer; | 115 ScopedDisplayListRecordingSourceUpdateTimer timer; |
115 bool updated = false; | |
116 | 116 |
117 if (size_ != layer_size) { | 117 if (blink_synchronous_painting_enabled) { |
118 size_ = layer_size; | 118 recorded_viewport_ = gfx::Rect(layer_size); |
119 updated = true; | 119 } else { |
120 bool updated = false; | |
121 | |
122 if (size_ != layer_size) { | |
123 size_ = layer_size; | |
124 updated = true; | |
125 } | |
126 | |
127 // The recorded viewport is the visible layer rect, expanded | |
128 // by the pixel record distance, up to a maximum of the total | |
129 // layer size. | |
130 gfx::Rect potential_new_recorded_viewport = visible_layer_rect; | |
131 potential_new_recorded_viewport.Inset(-pixel_record_distance_, | |
132 -pixel_record_distance_); | |
133 potential_new_recorded_viewport.Intersect(gfx::Rect(GetSize())); | |
enne (OOO)
2015/11/17 23:44:49
Because you still need to add invalidations for ne
chrishtr
2015/11/18 21:09:40
Done.
| |
134 | |
135 if (updated || | |
136 ExposesEnoughNewArea(recorded_viewport_, | |
137 potential_new_recorded_viewport, GetSize())) { | |
138 gfx::Rect old_recorded_viewport = recorded_viewport_; | |
139 recorded_viewport_ = potential_new_recorded_viewport; | |
140 | |
141 // Invalidate newly-exposed and no-longer-exposed areas. | |
enne (OOO)
2015/11/17 23:44:49
This is still needed even for synchronous painting
chrishtr
2015/11/18 21:09:40
Done.
| |
142 Region newly_exposed_region(recorded_viewport_); | |
143 newly_exposed_region.Subtract(old_recorded_viewport); | |
144 invalidation->Union(newly_exposed_region); | |
145 | |
146 Region no_longer_exposed_region(old_recorded_viewport); | |
147 no_longer_exposed_region.Subtract(recorded_viewport_); | |
148 invalidation->Union(no_longer_exposed_region); | |
149 | |
150 updated = true; | |
151 } | |
152 | |
153 // Count the area that is being invalidated. | |
154 Region recorded_invalidation(*invalidation); | |
155 recorded_invalidation.Intersect(recorded_viewport_); | |
156 for (Region::Iterator it(recorded_invalidation); it.has_rect(); it.next()) | |
157 timer.AddArea(it.rect().size().GetCheckedArea()); | |
158 | |
159 if (!updated && !invalidation->Intersects(recorded_viewport_)) | |
160 return false; | |
120 } | 161 } |
121 | 162 |
122 // The recorded viewport is the visible layer rect, expanded | |
123 // by the pixel record distance, up to a maximum of the total | |
124 // layer size. | |
125 gfx::Rect potential_new_recorded_viewport = visible_layer_rect; | |
126 potential_new_recorded_viewport.Inset(-pixel_record_distance_, | |
127 -pixel_record_distance_); | |
128 potential_new_recorded_viewport.Intersect(gfx::Rect(GetSize())); | |
129 | |
130 if (updated || | |
131 ExposesEnoughNewArea(recorded_viewport_, potential_new_recorded_viewport, | |
132 GetSize())) { | |
133 gfx::Rect old_recorded_viewport = recorded_viewport_; | |
134 recorded_viewport_ = potential_new_recorded_viewport; | |
135 | |
136 // Invalidate newly-exposed and no-longer-exposed areas. | |
137 Region newly_exposed_region(recorded_viewport_); | |
138 newly_exposed_region.Subtract(old_recorded_viewport); | |
139 invalidation->Union(newly_exposed_region); | |
140 | |
141 Region no_longer_exposed_region(old_recorded_viewport); | |
142 no_longer_exposed_region.Subtract(recorded_viewport_); | |
143 invalidation->Union(no_longer_exposed_region); | |
144 | |
145 updated = true; | |
146 } | |
147 | |
148 // Count the area that is being invalidated. | |
149 Region recorded_invalidation(*invalidation); | |
150 recorded_invalidation.Intersect(recorded_viewport_); | |
151 for (Region::Iterator it(recorded_invalidation); it.has_rect(); it.next()) | |
152 timer.AddArea(it.rect().size().GetCheckedArea()); | |
153 | |
154 if (!updated && !invalidation->Intersects(recorded_viewport_)) | |
155 return false; | |
156 | |
157 ContentLayerClient::PaintingControlSetting painting_control = | 163 ContentLayerClient::PaintingControlSetting painting_control = |
158 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL; | 164 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL; |
159 | 165 |
160 switch (recording_mode) { | 166 switch (recording_mode) { |
161 case RECORD_NORMALLY: | 167 case RECORD_NORMALLY: |
162 // Already setup for normal recording. | 168 // Already setup for normal recording. |
163 break; | 169 break; |
164 case RECORD_WITH_PAINTING_DISABLED: | 170 case RECORD_WITH_PAINTING_DISABLED: |
165 painting_control = ContentLayerClient::DISPLAY_LIST_PAINTING_DISABLED; | 171 painting_control = ContentLayerClient::DISPLAY_LIST_PAINTING_DISABLED; |
166 break; | 172 break; |
167 case RECORD_WITH_CACHING_DISABLED: | 173 case RECORD_WITH_CACHING_DISABLED: |
168 painting_control = ContentLayerClient::DISPLAY_LIST_CACHING_DISABLED; | 174 painting_control = ContentLayerClient::DISPLAY_LIST_CACHING_DISABLED; |
169 break; | 175 break; |
170 case RECORD_WITH_CONSTRUCTION_DISABLED: | 176 case RECORD_WITH_CONSTRUCTION_DISABLED: |
171 painting_control = ContentLayerClient::DISPLAY_LIST_CONSTRUCTION_DISABLED; | 177 painting_control = ContentLayerClient::DISPLAY_LIST_CONSTRUCTION_DISABLED; |
172 break; | 178 break; |
173 case RECORD_WITH_SK_NULL_CANVAS: | 179 case RECORD_WITH_SK_NULL_CANVAS: |
174 case RECORDING_MODE_COUNT: | 180 case RECORDING_MODE_COUNT: |
175 NOTREACHED(); | 181 NOTREACHED(); |
176 } | 182 } |
177 | 183 |
178 // TODO(vmpstr): Add a slow_down_recording_scale_factor_for_debug_ to be able | 184 // TODO(vmpstr): Add a slow_down_recording_scale_factor_for_debug_ to be able |
179 // to slow down recording. | 185 // to slow down recording. |
180 display_list_ = | 186 display_list_ = painter->PaintContentsToDisplayList(painting_control, |
181 painter->PaintContentsToDisplayList(recorded_viewport_, painting_control); | 187 &recorded_viewport_); |
182 painter_reported_memory_usage_ = painter->GetApproximateUnsharedMemoryUsage(); | 188 painter_reported_memory_usage_ = painter->GetApproximateUnsharedMemoryUsage(); |
183 | 189 |
184 DetermineIfSolidColor(); | 190 DetermineIfSolidColor(); |
185 display_list_->EmitTraceSnapshot(); | 191 display_list_->EmitTraceSnapshot(); |
186 if (generate_discardable_images_metadata_) | 192 if (generate_discardable_images_metadata_) |
187 display_list_->GenerateDiscardableImagesMetadata(); | 193 display_list_->GenerateDiscardableImagesMetadata(); |
188 | 194 |
189 return true; | 195 return true; |
190 } | 196 } |
191 | 197 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
245 } | 251 } |
246 | 252 |
247 void DisplayListRecordingSource::Clear() { | 253 void DisplayListRecordingSource::Clear() { |
248 recorded_viewport_ = gfx::Rect(); | 254 recorded_viewport_ = gfx::Rect(); |
249 display_list_ = nullptr; | 255 display_list_ = nullptr; |
250 painter_reported_memory_usage_ = 0; | 256 painter_reported_memory_usage_ = 0; |
251 is_solid_color_ = false; | 257 is_solid_color_ = false; |
252 } | 258 } |
253 | 259 |
254 } // namespace cc | 260 } // namespace cc |
OLD | NEW |