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

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

Issue 504513002: cc: Fix CanRaster dcheck failures ONCE AND FOR ALL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: canraster: evenbetter Created 6 years, 4 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
« no previous file with comments | « no previous file | cc/resources/picture_pile_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 219
220 // If a recording is dropped and not re-recorded below, invalidate that 220 // If a recording is dropped and not re-recorded below, invalidate that
221 // full recording to cause any raster tiles that would use it to be 221 // full recording to cause any raster tiles that would use it to be
222 // dropped. 222 // dropped.
223 // If the recording will be replaced below, just invalidate newly exposed 223 // If the recording will be replaced below, just invalidate newly exposed
224 // areas to force raster tiles that include the old recording to know 224 // areas to force raster tiles that include the old recording to know
225 // there is new recording to display. 225 // there is new recording to display.
226 gfx::Rect old_tiling_rect_over_tiles = 226 gfx::Rect old_tiling_rect_over_tiles =
227 tiling_.ExpandRectToTileBounds(gfx::Rect(old_tiling_size)); 227 tiling_.ExpandRectToTileBounds(gfx::Rect(old_tiling_size));
228 if (min_toss_x < tiling_.num_tiles_x()) { 228 if (min_toss_x < tiling_.num_tiles_x()) {
229 int unrecorded_left = std::max(tiling_.TilePositionX(min_toss_x), 229 // The bounds which we want to invalidate are the tiles along the old
230 interest_rect_over_tiles.right()); 230 // edge of the pile. We'll call this bounding box the OLD EDGE RECT.
231 //
232 // In the picture below, the old edge rect would be the bounding box
233 // of tiles {h,i,j}. |min_toss_x| would be equal to the horizontal index
234 // of the same tiles.
235 //
236 // old pile edge-v new pile edge-v
237 // ---------------+ - - - - - - - -+
238 // mmppssvvyybbeeh|h .
239 // mmppssvvyybbeeh|h .
240 // nnqqttwwzzccffi|i .
241 // nnqqttwwzzccffi|i .
242 // oorruuxxaaddggj|j .
243 // oorruuxxaaddggj|j .
244 // ---------------+ - - - - - - - -+ <- old pile edge
245 // .
246 // - - - - - - - - - - - - - - - -+ <- new pile edge
247 //
248 // If you were to slide a vertical beam from the left edge of the
249 // old edge rect toward the right, it would either hit the right edge
250 // of the old edge rect, or the interest rect (expanded to the bounds
251 // of the tiles it touches). The same is true for a beam parallel to
252 // any of the four edges, sliding accross the old edge rect. We use
253 // the union of these four rectangles generated by these beams to
254 // determine which part of the old edge rect is outside of the expanded
255 // interest rect.
256 //
257 // Case 1: Intersect rect is outside the old edge rect. It can be
258 // either on the left or the right. The |left_rect| and |right_rect|,
259 // cover this case, one will be empty and one will cover the full
260 // old edge rect. In the picture below, |left_rect| would cover the
261 // old edge rect, and |right_rect| would be empty.
262 // +----------------------+ |^^^^^^^^^^^^^^^|
263 // |===> OLD EDGE RECT | | |
264 // |===> | | INTEREST RECT |
265 // |===> | | |
266 // |===> | | |
267 // +----------------------+ |vvvvvvvvvvvvvvv|
268 //
269 // Case 2: Interest rect is inside the old edge rect. It will always
270 // fill the entire old edge rect horizontally since the old edge rect
271 // is a single tile wide, and the interst rect has been expanded to the
enne (OOO) 2014/08/25 20:06:16 typo
272 // bounds of the tiles it touches. In this case the |left_rect| and
273 // |right_rect| will be empty, but the case is handled by the |top_rect|
274 // and |bottom_rect|. In the picture below, neither the |top_rect| nor
275 // |bottom_rect| would empty, they would each cover the area of the old
276 // edge rect outside the expanded interest rect.
277 // +-----------------+
278 // |:::::::::::::::::|
279 // |:::::::::::::::::|
280 // |vvvvvvvvvvvvvvvvv|
281 // | |
282 // +-----------------+
283 // | INTEREST RECT |
284 // | |
285 // +-----------------+
286 // | |
287 // | OLD EDGE RECT |
288 // +-----------------+
289 //
290 // Lastly, we need to consider tiles inside the expanded interest rect.
291 // For those tiles, we want to invalidate exactly the newly exposed
292 // pixels. In the picture below the tiles in the old edge rect have been
293 // resized and the area covered by periods must be invalidated. The
294 // |exposed_rect| will cover exactly that area.
295 // v-old pile edge
296 // +---------+-------+
297 // | ........|
298 // | ........|
299 // | OLD EDGE.RECT..|
300 // | ........|
301 // | ........|
302 // | ........|
303 // | ........|
304 // | ........|
305 // | ........|
306 // +---------+-------+
307
308 int left = tiling_.TilePositionX(min_toss_x);
309 int right = left + tiling_.TileSizeX(min_toss_x);
310 int top = old_tiling_rect_over_tiles.y();
311 int bottom = old_tiling_rect_over_tiles.bottom();
312
313 int left_until = std::min(interest_rect_over_tiles.x(), right);
314 int right_until = std::max(interest_rect_over_tiles.right(), left);
315 int top_until = std::min(interest_rect_over_tiles.y(), bottom);
316 int bottom_until = std::max(interest_rect_over_tiles.bottom(), top);
317
231 int exposed_left = old_tiling_size.width(); 318 int exposed_left = old_tiling_size.width();
232 int left = std::min(unrecorded_left, exposed_left); 319 int exposed_left_until = right;
233 int tile_right = 320 DCHECK_GE(exposed_left, left);
234 tiling_.TilePositionX(min_toss_x) + tiling_.TileSizeX(min_toss_x); 321
235 int exposed_right = tiling_size().width(); 322 gfx::Rect left_rect(left, top, left_until - left, bottom - top);
236 int right = std::min(tile_right, exposed_right); 323 gfx::Rect right_rect(right_until, top, right - right_until, bottom - top);
237 gfx::Rect right_side(left, 324 gfx::Rect top_rect(left, top, right - left, top_until - top);
238 old_tiling_rect_over_tiles.y(), 325 gfx::Rect bottom_rect(
239 right - left, 326 left, bottom_until, right - left, bottom - bottom_until);
240 old_tiling_rect_over_tiles.height()); 327 gfx::Rect exposed_rect(
241 resize_invalidation.Union(right_side); 328 exposed_left, top, exposed_left_until - exposed_left, bottom - top);
329 resize_invalidation.Union(left_rect);
330 resize_invalidation.Union(right_rect);
331 resize_invalidation.Union(top_rect);
332 resize_invalidation.Union(bottom_rect);
333 resize_invalidation.Union(exposed_rect);
242 } 334 }
243 if (min_toss_y < tiling_.num_tiles_y()) { 335 if (min_toss_y < tiling_.num_tiles_y()) {
244 int unrecorded_top = std::max(tiling_.TilePositionY(min_toss_y), 336 // The same thing occurs here as in the case above, but the invalidation
245 interest_rect_over_tiles.bottom()); 337 // rect is the bounding box around the bottom row of tiles in the old
338 // pile. This would be tiles {o,r,u,x,a,d,g,j} in the above picture.
339
340 int top = tiling_.TilePositionY(min_toss_y);
341 int bottom = top + tiling_.TileSizeY(min_toss_y);
342 int left = old_tiling_rect_over_tiles.x();
343 int right = old_tiling_rect_over_tiles.right();
344
345 int top_until = std::min(interest_rect_over_tiles.y(), bottom);
346 int bottom_until = std::max(interest_rect_over_tiles.bottom(), top);
347 int left_until = std::min(interest_rect_over_tiles.x(), right);
348 int right_until = std::max(interest_rect_over_tiles.right(), left);
349
246 int exposed_top = old_tiling_size.height(); 350 int exposed_top = old_tiling_size.height();
247 int top = std::min(unrecorded_top, exposed_top); 351 int exposed_top_until = bottom;
248 int tile_bottom = 352 DCHECK_GE(exposed_top, top);
249 tiling_.TilePositionY(min_toss_y) + tiling_.TileSizeY(min_toss_y); 353
250 int exposed_bottom = tiling_size().height(); 354 gfx::Rect left_rect(left, top, left_until - left, bottom - top);
251 int bottom = std::min(tile_bottom, exposed_bottom); 355 gfx::Rect right_rect(right_until, top, right - right_until, bottom - top);
252 gfx::Rect bottom_side(old_tiling_rect_over_tiles.x(), 356 gfx::Rect top_rect(left, top, right - left, top_until - top);
253 top, 357 gfx::Rect bottom_rect(
254 old_tiling_rect_over_tiles.width(), 358 left, bottom_until, right - left, bottom - bottom_until);
255 bottom - top); 359 gfx::Rect exposed_rect(
256 resize_invalidation.Union(bottom_side); 360 left, exposed_top, right - left, exposed_top_until - exposed_top);
361 resize_invalidation.Union(left_rect);
362 resize_invalidation.Union(right_rect);
363 resize_invalidation.Union(top_rect);
364 resize_invalidation.Union(bottom_rect);
365 resize_invalidation.Union(exposed_rect);
257 } 366 }
258 } 367 }
259 368
260 Region invalidation_expanded_to_full_tiles; 369 Region invalidation_expanded_to_full_tiles;
261 for (Region::Iterator i(*invalidation); i.has_rect(); i.next()) { 370 for (Region::Iterator i(*invalidation); i.has_rect(); i.next()) {
262 gfx::Rect invalid_rect = i.rect(); 371 gfx::Rect invalid_rect = i.rect();
263 372
264 // Expand invalidation that is outside tiles that intersect the interest 373 // Expand invalidation that is outside tiles that intersect the interest
265 // rect. These tiles are no longer valid and should be considerered fully 374 // rect. These tiles are no longer valid and should be considerered fully
266 // invalid, so we can know to not keep around raster tiles that intersect 375 // invalid, so we can know to not keep around raster tiles that intersect
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 } 510 }
402 511
403 void PicturePile::SetEmptyBounds() { 512 void PicturePile::SetEmptyBounds() {
404 tiling_.SetTilingSize(gfx::Size()); 513 tiling_.SetTilingSize(gfx::Size());
405 picture_map_.clear(); 514 picture_map_.clear();
406 has_any_recordings_ = false; 515 has_any_recordings_ = false;
407 recorded_viewport_ = gfx::Rect(); 516 recorded_viewport_ = gfx::Rect();
408 } 517 }
409 518
410 } // namespace cc 519 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/resources/picture_pile_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698