| 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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 exposed_right - exposed_left, | 371 exposed_right - exposed_left, |
| 372 exposed_top_until - exposed_top); | 372 exposed_top_until - exposed_top); |
| 373 resize_invalidation.Union(left_rect); | 373 resize_invalidation.Union(left_rect); |
| 374 resize_invalidation.Union(right_rect); | 374 resize_invalidation.Union(right_rect); |
| 375 resize_invalidation.Union(top_rect); | 375 resize_invalidation.Union(top_rect); |
| 376 resize_invalidation.Union(bottom_rect); | 376 resize_invalidation.Union(bottom_rect); |
| 377 resize_invalidation.Union(exposed_rect); | 377 resize_invalidation.Union(exposed_rect); |
| 378 } | 378 } |
| 379 } | 379 } |
| 380 | 380 |
| 381 Region invalidation_expanded_to_full_tiles; | 381 // Detect cases where the full pile is invalidated, in this situation we |
| 382 for (Region::Iterator i(*invalidation); i.has_rect(); i.next()) { | 382 // can just drop/invalidate everything. |
| 383 gfx::Rect invalid_rect = i.rect(); | 383 if (invalidation->Contains(gfx::Rect(old_tiling_size)) || |
| 384 | 384 invalidation->Contains(gfx::Rect(tiling_size()))) { |
| 385 for (auto& it : picture_map_) |
| 386 updated = it.second.Invalidate(frame_number) || updated; |
| 387 } else { |
| 385 // Expand invalidation that is outside tiles that intersect the interest | 388 // Expand invalidation that is outside tiles that intersect the interest |
| 386 // rect. These tiles are no longer valid and should be considerered fully | 389 // rect. These tiles are no longer valid and should be considerered fully |
| 387 // invalid, so we can know to not keep around raster tiles that intersect | 390 // invalid, so we can know to not keep around raster tiles that intersect |
| 388 // with these recording tiles. | 391 // with these recording tiles. |
| 389 gfx::Rect invalid_rect_outside_interest_rect_tiles = invalid_rect; | 392 Region invalidation_expanded_to_full_tiles; |
| 390 // TODO(danakj): We should have a Rect-subtract-Rect-to-2-rects operator | |
| 391 // instead of using Rect::Subtract which gives you the bounding box of the | |
| 392 // subtraction. | |
| 393 invalid_rect_outside_interest_rect_tiles.Subtract(interest_rect_over_tiles); | |
| 394 invalidation_expanded_to_full_tiles.Union(tiling_.ExpandRectToTileBounds( | |
| 395 invalid_rect_outside_interest_rect_tiles)); | |
| 396 | 393 |
| 397 // Split this inflated invalidation across tile boundaries and apply it | 394 for (Region::Iterator i(*invalidation); i.has_rect(); i.next()) { |
| 398 // to all tiles that it touches. | 395 gfx::Rect invalid_rect = i.rect(); |
| 399 bool include_borders = true; | |
| 400 for (TilingData::Iterator iter(&tiling_, invalid_rect, include_borders); | |
| 401 iter; | |
| 402 ++iter) { | |
| 403 const PictureMapKey& key = iter.index(); | |
| 404 | 396 |
| 405 PictureMap::iterator picture_it = picture_map_.find(key); | 397 gfx::Rect invalid_rect_outside_interest_rect_tiles = invalid_rect; |
| 406 if (picture_it == picture_map_.end()) | 398 // TODO(danakj): We should have a Rect-subtract-Rect-to-2-rects operator |
| 407 continue; | 399 // instead of using Rect::Subtract which gives you the bounding box of the |
| 400 // subtraction. |
| 401 invalid_rect_outside_interest_rect_tiles.Subtract( |
| 402 interest_rect_over_tiles); |
| 403 invalidation_expanded_to_full_tiles.Union(tiling_.ExpandRectToTileBounds( |
| 404 invalid_rect_outside_interest_rect_tiles)); |
| 408 | 405 |
| 409 // Inform the grid cell that it has been invalidated in this frame. | 406 // Split this inflated invalidation across tile boundaries and apply it |
| 410 updated = picture_it->second.Invalidate(frame_number) || updated; | 407 // to all tiles that it touches. |
| 411 // Invalidate drops the picture so the whole tile better be invalidated if | 408 bool include_borders = true; |
| 412 // it won't be re-recorded below. | 409 for (TilingData::Iterator iter(&tiling_, invalid_rect, include_borders); |
| 413 DCHECK_IMPLIES(!tiling_.TileBounds(key.first, key.second) | 410 iter; |
| 414 .Intersects(interest_rect_over_tiles), | 411 ++iter) { |
| 415 invalidation_expanded_to_full_tiles.Contains( | 412 const PictureMapKey& key = iter.index(); |
| 416 tiling_.TileBounds(key.first, key.second))); | 413 |
| 414 PictureMap::iterator picture_it = picture_map_.find(key); |
| 415 if (picture_it == picture_map_.end()) |
| 416 continue; |
| 417 |
| 418 // Inform the grid cell that it has been invalidated in this frame. |
| 419 updated = picture_it->second.Invalidate(frame_number) || updated; |
| 420 // Invalidate drops the picture so the whole tile better be invalidated |
| 421 // if it won't be re-recorded below. |
| 422 DCHECK_IMPLIES(!tiling_.TileBounds(key.first, key.second) |
| 423 .Intersects(interest_rect_over_tiles), |
| 424 invalidation_expanded_to_full_tiles.Contains( |
| 425 tiling_.TileBounds(key.first, key.second))); |
| 426 } |
| 417 } | 427 } |
| 428 invalidation->Union(invalidation_expanded_to_full_tiles); |
| 418 } | 429 } |
| 419 | 430 |
| 420 invalidation->Union(invalidation_expanded_to_full_tiles); | |
| 421 invalidation->Union(resize_invalidation); | 431 invalidation->Union(resize_invalidation); |
| 422 | 432 |
| 423 // Make a list of all invalid tiles; we will attempt to | 433 // Make a list of all invalid tiles; we will attempt to |
| 424 // cluster these into multiple invalidation regions. | 434 // cluster these into multiple invalidation regions. |
| 425 std::vector<gfx::Rect> invalid_tiles; | 435 std::vector<gfx::Rect> invalid_tiles; |
| 426 bool include_borders = true; | 436 bool include_borders = true; |
| 427 for (TilingData::Iterator it(&tiling_, interest_rect, include_borders); it; | 437 for (TilingData::Iterator it(&tiling_, interest_rect, include_borders); it; |
| 428 ++it) { | 438 ++it) { |
| 429 const PictureMapKey& key = it.index(); | 439 const PictureMapKey& key = it.index(); |
| 430 PictureInfo& info = picture_map_[key]; | 440 PictureInfo& info = picture_map_[key]; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 if (it->second.GetPicture() != picture) | 564 if (it->second.GetPicture() != picture) |
| 555 return; | 565 return; |
| 556 } | 566 } |
| 557 skia::AnalysisCanvas canvas(recorded_viewport_.width(), | 567 skia::AnalysisCanvas canvas(recorded_viewport_.width(), |
| 558 recorded_viewport_.height()); | 568 recorded_viewport_.height()); |
| 559 picture->Raster(&canvas, NULL, Region(), 1.0f); | 569 picture->Raster(&canvas, NULL, Region(), 1.0f); |
| 560 is_solid_color_ = canvas.GetColorIfSolid(&solid_color_); | 570 is_solid_color_ = canvas.GetColorIfSolid(&solid_color_); |
| 561 } | 571 } |
| 562 | 572 |
| 563 } // namespace cc | 573 } // namespace cc |
| OLD | NEW |