OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/picture_pile.h" | 5 #include "cc/resources/picture_pile.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 RenderingStatsInstrumentation* stats_instrumentation) { | 157 RenderingStatsInstrumentation* stats_instrumentation) { |
158 background_color_ = background_color; | 158 background_color_ = background_color; |
159 contents_opaque_ = contents_opaque; | 159 contents_opaque_ = contents_opaque; |
160 | 160 |
161 gfx::Rect interest_rect = visible_layer_rect; | 161 gfx::Rect interest_rect = visible_layer_rect; |
162 interest_rect.Inset( | 162 interest_rect.Inset( |
163 -kPixelDistanceToRecord, | 163 -kPixelDistanceToRecord, |
164 -kPixelDistanceToRecord, | 164 -kPixelDistanceToRecord, |
165 -kPixelDistanceToRecord, | 165 -kPixelDistanceToRecord, |
166 -kPixelDistanceToRecord); | 166 -kPixelDistanceToRecord); |
167 recorded_viewport_ = interest_rect; | |
168 recorded_viewport_.Intersect(gfx::Rect(size())); | |
169 | 167 |
170 bool invalidated = false; | 168 bool invalidated = false; |
171 for (Region::Iterator i(invalidation); i.has_rect(); i.next()) { | 169 for (Region::Iterator i(invalidation); i.has_rect(); i.next()) { |
172 gfx::Rect invalidation = i.rect(); | 170 gfx::Rect invalidation = i.rect(); |
173 // Split this inflated invalidation across tile boundaries and apply it | 171 // Split this inflated invalidation across tile boundaries and apply it |
174 // to all tiles that it touches. | 172 // to all tiles that it touches. |
175 for (TilingData::Iterator iter(&tiling_, invalidation); | 173 for (TilingData::Iterator iter(&tiling_, invalidation); |
176 iter; ++iter) { | 174 iter; ++iter) { |
177 const PictureMapKey& key = iter.index(); | 175 const PictureMapKey& key = iter.index(); |
178 | 176 |
(...skipping 21 matching lines...) Expand all Loading... |
200 | 198 |
201 if (info.NeedsRecording(frame_number, distance_to_visible)) { | 199 if (info.NeedsRecording(frame_number, distance_to_visible)) { |
202 gfx::Rect tile = tiling_.TileBounds(key.first, key.second); | 200 gfx::Rect tile = tiling_.TileBounds(key.first, key.second); |
203 invalid_tiles.push_back(tile); | 201 invalid_tiles.push_back(tile); |
204 } | 202 } |
205 } | 203 } |
206 | 204 |
207 std::vector<gfx::Rect> record_rects; | 205 std::vector<gfx::Rect> record_rects; |
208 ClusterTiles(invalid_tiles, &record_rects); | 206 ClusterTiles(invalid_tiles, &record_rects); |
209 | 207 |
210 if (record_rects.empty()) | 208 if (record_rects.empty()) { |
| 209 if (invalidated) |
| 210 UpdateRecordedRegion(); |
211 return invalidated; | 211 return invalidated; |
| 212 } |
212 | 213 |
213 for (std::vector<gfx::Rect>::iterator it = record_rects.begin(); | 214 for (std::vector<gfx::Rect>::iterator it = record_rects.begin(); |
214 it != record_rects.end(); | 215 it != record_rects.end(); |
215 it++) { | 216 it++) { |
216 gfx::Rect record_rect = *it; | 217 gfx::Rect record_rect = *it; |
217 record_rect = PadRect(record_rect); | 218 record_rect = PadRect(record_rect); |
218 | 219 |
219 int repeat_count = std::max(1, slow_down_raster_scale_factor_for_debug_); | 220 int repeat_count = std::max(1, slow_down_raster_scale_factor_for_debug_); |
220 scoped_refptr<Picture> picture; | 221 scoped_refptr<Picture> picture; |
221 int num_raster_threads = RasterWorkerPool::GetNumRasterThreads(); | 222 int num_raster_threads = RasterWorkerPool::GetNumRasterThreads(); |
(...skipping 15 matching lines...) Expand all Loading... |
237 num_raster_threads); | 238 num_raster_threads); |
238 base::TimeDelta duration = | 239 base::TimeDelta duration = |
239 stats_instrumentation->EndRecording(start_time); | 240 stats_instrumentation->EndRecording(start_time); |
240 best_duration = std::min(duration, best_duration); | 241 best_duration = std::min(duration, best_duration); |
241 } | 242 } |
242 int recorded_pixel_count = | 243 int recorded_pixel_count = |
243 picture->LayerRect().width() * picture->LayerRect().height(); | 244 picture->LayerRect().width() * picture->LayerRect().height(); |
244 stats_instrumentation->AddRecord(best_duration, recorded_pixel_count); | 245 stats_instrumentation->AddRecord(best_duration, recorded_pixel_count); |
245 } | 246 } |
246 | 247 |
247 bool found_tile_for_recorded_picture = false; | |
248 for (TilingData::Iterator it(&tiling_, record_rect); | 248 for (TilingData::Iterator it(&tiling_, record_rect); |
249 it; ++it) { | 249 it; ++it) { |
250 const PictureMapKey& key = it.index(); | 250 const PictureMapKey& key = it.index(); |
251 gfx::Rect tile = PaddedRect(key); | 251 gfx::Rect tile = PaddedRect(key); |
252 if (record_rect.Contains(tile)) { | 252 if (record_rect.Contains(tile)) { |
253 PictureInfo& info = picture_map_[key]; | 253 PictureInfo& info = picture_map_[key]; |
254 info.SetPicture(picture); | 254 info.SetPicture(picture); |
255 found_tile_for_recorded_picture = true; | |
256 } | 255 } |
257 } | 256 } |
258 DCHECK(found_tile_for_recorded_picture); | |
259 } | 257 } |
260 | 258 |
261 has_any_recordings_ = true; | 259 UpdateRecordedRegion(); |
262 return true; | 260 return true; |
263 } | 261 } |
264 | 262 |
265 } // namespace cc | 263 } // namespace cc |
OLD | NEW |