Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: cc/resources/picture_pile.cc

Issue 196343005: cc: Replace recorded region with direct map lookup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 for (TilingData::Iterator iter(&tiling_, invalidation);
174 iter; ++iter) { 176 iter; ++iter) {
175 const PictureMapKey& key = iter.index(); 177 const PictureMapKey& key = iter.index();
176 178
(...skipping 22 matching lines...) Expand all
199 if (info.NeedsRecording(frame_number, distance_to_visible)) { 201 if (info.NeedsRecording(frame_number, distance_to_visible)) {
200 gfx::Rect tile = tiling_.TileBounds(key.first, key.second); 202 gfx::Rect tile = tiling_.TileBounds(key.first, key.second);
201 invalid_tiles.push_back(tile); 203 invalid_tiles.push_back(tile);
202 } 204 }
203 } 205 }
204 206
205 std::vector<gfx::Rect> record_rects; 207 std::vector<gfx::Rect> record_rects;
206 ClusterTiles(invalid_tiles, &record_rects); 208 ClusterTiles(invalid_tiles, &record_rects);
207 209
208 if (record_rects.empty()) { 210 if (record_rects.empty()) {
209 if (invalidated)
210 UpdateRecordedRegion();
211 return invalidated; 211 return invalidated;
212 } 212 }
vmpstr 2014/03/12 23:57:35 nit: remove the braces as well, please
enne (OOO) 2014/03/13 01:35:43 Done, but make sure you imagine me grumbling as I
213 213
214 for (std::vector<gfx::Rect>::iterator it = record_rects.begin(); 214 for (std::vector<gfx::Rect>::iterator it = record_rects.begin();
215 it != record_rects.end(); 215 it != record_rects.end();
216 it++) { 216 it++) {
217 gfx::Rect record_rect = *it; 217 gfx::Rect record_rect = *it;
218 record_rect = PadRect(record_rect); 218 record_rect = PadRect(record_rect);
219 219
220 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_);
221 scoped_refptr<Picture> picture; 221 scoped_refptr<Picture> picture;
222 int num_raster_threads = RasterWorkerPool::GetNumRasterThreads(); 222 int num_raster_threads = RasterWorkerPool::GetNumRasterThreads();
(...skipping 15 matching lines...) Expand all
238 num_raster_threads); 238 num_raster_threads);
239 base::TimeDelta duration = 239 base::TimeDelta duration =
240 stats_instrumentation->EndRecording(start_time); 240 stats_instrumentation->EndRecording(start_time);
241 best_duration = std::min(duration, best_duration); 241 best_duration = std::min(duration, best_duration);
242 } 242 }
243 int recorded_pixel_count = 243 int recorded_pixel_count =
244 picture->LayerRect().width() * picture->LayerRect().height(); 244 picture->LayerRect().width() * picture->LayerRect().height();
245 stats_instrumentation->AddRecord(best_duration, recorded_pixel_count); 245 stats_instrumentation->AddRecord(best_duration, recorded_pixel_count);
246 } 246 }
247 247
248 bool found_tile_for_recorded_picture = false;
248 for (TilingData::Iterator it(&tiling_, record_rect); 249 for (TilingData::Iterator it(&tiling_, record_rect);
249 it; ++it) { 250 it; ++it) {
250 const PictureMapKey& key = it.index(); 251 const PictureMapKey& key = it.index();
251 gfx::Rect tile = PaddedRect(key); 252 gfx::Rect tile = PaddedRect(key);
252 if (record_rect.Contains(tile)) { 253 if (record_rect.Contains(tile)) {
253 PictureInfo& info = picture_map_[key]; 254 PictureInfo& info = picture_map_[key];
254 info.SetPicture(picture); 255 info.SetPicture(picture);
256 found_tile_for_recorded_picture = true;
255 } 257 }
256 } 258 }
259 DCHECK(found_tile_for_recorded_picture);
257 } 260 }
258 261
259 UpdateRecordedRegion(); 262 has_any_recordings_ = true;
260 return true; 263 return true;
261 } 264 }
262 265
263 } // namespace cc 266 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698