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())); | |
167 | 169 |
168 bool invalidated = false; | 170 bool invalidated = false; |
169 for (Region::Iterator i(invalidation); i.has_rect(); i.next()) { | 171 for (Region::Iterator i(invalidation); i.has_rect(); i.next()) { |
170 gfx::Rect invalidation = i.rect(); | 172 gfx::Rect invalidation = i.rect(); |
171 // Split this inflated invalidation across tile boundaries and apply it | 173 // Split this inflated invalidation across tile boundaries and apply it |
172 // to all tiles that it touches. | 174 // to all tiles that it touches. |
173 for (TilingData::Iterator iter(&tiling_, invalidation); | 175 bool include_borders = true; |
174 iter; ++iter) { | 176 for (TilingData::Iterator iter(&tiling_, invalidation, include_borders); |
177 iter; | |
178 ++iter) { | |
175 const PictureMapKey& key = iter.index(); | 179 const PictureMapKey& key = iter.index(); |
176 | 180 |
177 PictureMap::iterator picture_it = picture_map_.find(key); | 181 PictureMap::iterator picture_it = picture_map_.find(key); |
178 if (picture_it == picture_map_.end()) | 182 if (picture_it == picture_map_.end()) |
179 continue; | 183 continue; |
180 | 184 |
181 // Inform the grid cell that it has been invalidated in this frame. | 185 // Inform the grid cell that it has been invalidated in this frame. |
182 invalidated = picture_it->second.Invalidate(frame_number) || invalidated; | 186 invalidated = picture_it->second.Invalidate(frame_number) || invalidated; |
183 } | 187 } |
184 } | 188 } |
185 | 189 |
186 // Make a list of all invalid tiles; we will attempt to | 190 // Make a list of all invalid tiles; we will attempt to |
187 // cluster these into multiple invalidation regions. | 191 // cluster these into multiple invalidation regions. |
188 std::vector<gfx::Rect> invalid_tiles; | 192 std::vector<gfx::Rect> invalid_tiles; |
189 | 193 bool include_borders = true; |
190 for (TilingData::Iterator it(&tiling_, interest_rect); | 194 for (TilingData::Iterator it(&tiling_, interest_rect, include_borders); it; |
191 it; ++it) { | 195 ++it) { |
192 const PictureMapKey& key = it.index(); | 196 const PictureMapKey& key = it.index(); |
193 PictureInfo& info = picture_map_[key]; | 197 PictureInfo& info = picture_map_[key]; |
194 | 198 |
195 gfx::Rect rect = PaddedRect(key); | 199 gfx::Rect rect = PaddedRect(key); |
196 int distance_to_visible = | 200 int distance_to_visible = |
197 rect.ManhattanInternalDistance(visible_layer_rect); | 201 rect.ManhattanInternalDistance(visible_layer_rect); |
198 | 202 |
199 if (info.NeedsRecording(frame_number, distance_to_visible)) { | 203 if (info.NeedsRecording(frame_number, distance_to_visible)) { |
200 gfx::Rect tile = tiling_.TileBounds(key.first, key.second); | 204 gfx::Rect tile = tiling_.TileBounds(key.first, key.second); |
201 invalid_tiles.push_back(tile); | 205 invalid_tiles.push_back(tile); |
206 } else if (recorded_viewport_.Intersects(rect)) { | |
vmpstr
2014/03/18 17:24:54
Should this have a "&& !info.picture"? If it doesn
enne (OOO)
2014/03/18 17:52:16
Oh! Yes!
| |
207 // Recorded viewport is just an optimization for a fully recorded | |
208 // interest rect. In this case, a tile in that rect has declined | |
209 // to be recorded (probably due to frequent invalidations). | |
210 // TODO(enne): Shrink the recorded_viewport_ rather than clearing. | |
211 recorded_viewport_ = gfx::Rect(); | |
enne (OOO)
2014/03/18 00:55:20
The core issue is that if something gets invalidat
| |
202 } | 212 } |
203 } | 213 } |
204 | 214 |
205 std::vector<gfx::Rect> record_rects; | 215 std::vector<gfx::Rect> record_rects; |
206 ClusterTiles(invalid_tiles, &record_rects); | 216 ClusterTiles(invalid_tiles, &record_rects); |
207 | 217 |
208 if (record_rects.empty()) { | 218 if (record_rects.empty()) |
209 if (invalidated) | |
210 UpdateRecordedRegion(); | |
211 return invalidated; | 219 return invalidated; |
212 } | |
213 | 220 |
214 for (std::vector<gfx::Rect>::iterator it = record_rects.begin(); | 221 for (std::vector<gfx::Rect>::iterator it = record_rects.begin(); |
215 it != record_rects.end(); | 222 it != record_rects.end(); |
216 it++) { | 223 it++) { |
217 gfx::Rect record_rect = *it; | 224 gfx::Rect record_rect = *it; |
218 record_rect = PadRect(record_rect); | 225 record_rect = PadRect(record_rect); |
219 | 226 |
220 int repeat_count = std::max(1, slow_down_raster_scale_factor_for_debug_); | 227 int repeat_count = std::max(1, slow_down_raster_scale_factor_for_debug_); |
221 scoped_refptr<Picture> picture; | 228 scoped_refptr<Picture> picture; |
222 int num_raster_threads = RasterWorkerPool::GetNumRasterThreads(); | 229 int num_raster_threads = RasterWorkerPool::GetNumRasterThreads(); |
(...skipping 15 matching lines...) Expand all Loading... | |
238 num_raster_threads); | 245 num_raster_threads); |
239 base::TimeDelta duration = | 246 base::TimeDelta duration = |
240 stats_instrumentation->EndRecording(start_time); | 247 stats_instrumentation->EndRecording(start_time); |
241 best_duration = std::min(duration, best_duration); | 248 best_duration = std::min(duration, best_duration); |
242 } | 249 } |
243 int recorded_pixel_count = | 250 int recorded_pixel_count = |
244 picture->LayerRect().width() * picture->LayerRect().height(); | 251 picture->LayerRect().width() * picture->LayerRect().height(); |
245 stats_instrumentation->AddRecord(best_duration, recorded_pixel_count); | 252 stats_instrumentation->AddRecord(best_duration, recorded_pixel_count); |
246 } | 253 } |
247 | 254 |
248 for (TilingData::Iterator it(&tiling_, record_rect); | 255 bool found_tile_for_recorded_picture = false; |
249 it; ++it) { | 256 |
257 bool include_borders = true; | |
258 for (TilingData::Iterator it(&tiling_, record_rect, include_borders); it; | |
259 ++it) { | |
250 const PictureMapKey& key = it.index(); | 260 const PictureMapKey& key = it.index(); |
251 gfx::Rect tile = PaddedRect(key); | 261 gfx::Rect tile = PaddedRect(key); |
252 if (record_rect.Contains(tile)) { | 262 if (record_rect.Contains(tile)) { |
253 PictureInfo& info = picture_map_[key]; | 263 PictureInfo& info = picture_map_[key]; |
254 info.SetPicture(picture); | 264 info.SetPicture(picture); |
265 found_tile_for_recorded_picture = true; | |
255 } | 266 } |
256 } | 267 } |
268 DCHECK(found_tile_for_recorded_picture); | |
257 } | 269 } |
258 | 270 |
259 UpdateRecordedRegion(); | 271 has_any_recordings_ = true; |
272 DCHECK(CanRasterSlowTileCheck(recorded_viewport_)); | |
enne (OOO)
2014/03/18 00:55:20
Just an additional sanity check.
| |
260 return true; | 273 return true; |
261 } | 274 } |
262 | 275 |
263 } // namespace cc | 276 } // namespace cc |
OLD | NEW |