| 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_layer_tiling.h" | 5 #include "cc/resources/picture_layer_tiling.h" |
| 6 | 6 |
| 7 #include <algorithm> |
| 7 #include <cmath> | 8 #include <cmath> |
| 8 | 9 |
| 9 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| 10 #include "cc/base/math_util.h" | 11 #include "cc/base/math_util.h" |
| 11 #include "ui/gfx/point_conversions.h" | 12 #include "ui/gfx/point_conversions.h" |
| 12 #include "ui/gfx/rect_conversions.h" | 13 #include "ui/gfx/rect_conversions.h" |
| 13 #include "ui/gfx/safe_integer_conversions.h" | 14 #include "ui/gfx/safe_integer_conversions.h" |
| 14 #include "ui/gfx/size_conversions.h" | 15 #include "ui/gfx/size_conversions.h" |
| 15 | 16 |
| 16 namespace cc { | 17 namespace cc { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 CreateTilesFromLayerRect(iter.rect()); | 125 CreateTilesFromLayerRect(iter.rect()); |
| 125 } | 126 } |
| 126 } | 127 } |
| 127 | 128 |
| 128 void PictureLayerTiling::Invalidate(const Region& layer_invalidation) { | 129 void PictureLayerTiling::Invalidate(const Region& layer_invalidation) { |
| 129 std::vector<TileMapKey> new_tiles; | 130 std::vector<TileMapKey> new_tiles; |
| 130 | 131 |
| 131 for (Region::Iterator region_iter(layer_invalidation); | 132 for (Region::Iterator region_iter(layer_invalidation); |
| 132 region_iter.has_rect(); | 133 region_iter.has_rect(); |
| 133 region_iter.next()) { | 134 region_iter.next()) { |
| 134 | |
| 135 gfx::Rect layer_invalidation = region_iter.rect(); | 135 gfx::Rect layer_invalidation = region_iter.rect(); |
| 136 layer_invalidation.Intersect(gfx::Rect(layer_bounds_)); | 136 layer_invalidation.Intersect(gfx::Rect(layer_bounds_)); |
| 137 gfx::Rect rect = | 137 gfx::Rect rect = |
| 138 gfx::ToEnclosingRect(ScaleRect(layer_invalidation, contents_scale_)); | 138 gfx::ToEnclosingRect(ScaleRect(layer_invalidation, contents_scale_)); |
| 139 | 139 |
| 140 for (PictureLayerTiling::Iterator tile_iter(this, contents_scale_, rect); | 140 for (PictureLayerTiling::Iterator tile_iter(this, contents_scale_, rect); |
| 141 tile_iter; | 141 tile_iter; |
| 142 ++tile_iter) { | 142 ++tile_iter) { |
| 143 TileMapKey key(tile_iter.tile_i_, tile_iter.tile_j_); | 143 TileMapKey key(tile_iter.tile_i_, tile_iter.tile_j_); |
| 144 TileMap::iterator found = tiles_.find(key); | 144 TileMap::iterator found = tiles_.find(key); |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 tile->SetPriority(tree, priority); | 388 tile->SetPriority(tree, priority); |
| 389 } | 389 } |
| 390 last_prioritized_rect_ = prioritized_rect; | 390 last_prioritized_rect_ = prioritized_rect; |
| 391 | 391 |
| 392 gfx::Rect view_rect(device_viewport); | 392 gfx::Rect view_rect(device_viewport); |
| 393 float current_scale = current_layer_contents_scale / contents_scale_; | 393 float current_scale = current_layer_contents_scale / contents_scale_; |
| 394 float last_scale = last_layer_contents_scale / contents_scale_; | 394 float last_scale = last_layer_contents_scale / contents_scale_; |
| 395 | 395 |
| 396 // Fast path tile priority calculation when both transforms are translations. | 396 // Fast path tile priority calculation when both transforms are translations. |
| 397 if (last_screen_transform.IsIdentityOrTranslation() && | 397 if (last_screen_transform.IsIdentityOrTranslation() && |
| 398 current_screen_transform.IsIdentityOrTranslation()) | 398 current_screen_transform.IsIdentityOrTranslation()) { |
| 399 { | |
| 400 gfx::Vector2dF current_offset( | 399 gfx::Vector2dF current_offset( |
| 401 current_screen_transform.matrix().get(0, 3), | 400 current_screen_transform.matrix().get(0, 3), |
| 402 current_screen_transform.matrix().get(1, 3)); | 401 current_screen_transform.matrix().get(1, 3)); |
| 403 gfx::Vector2dF last_offset( | 402 gfx::Vector2dF last_offset( |
| 404 last_screen_transform.matrix().get(0, 3), | 403 last_screen_transform.matrix().get(0, 3), |
| 405 last_screen_transform.matrix().get(1, 3)); | 404 last_screen_transform.matrix().get(1, 3)); |
| 406 | 405 |
| 407 for (TilingData::Iterator iter(&tiling_data_, prioritized_rect); | 406 for (TilingData::Iterator iter(&tiling_data_, prioritized_rect); |
| 408 iter; ++iter) { | 407 iter; ++iter) { |
| 409 TileMap::iterator find = tiles_.find(iter.index()); | 408 TileMap::iterator find = tiles_.find(iter.index()); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 int* num_edges; | 515 int* num_edges; |
| 517 int distance; | 516 int distance; |
| 518 }; | 517 }; |
| 519 | 518 |
| 520 gfx::Rect PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( | 519 gfx::Rect PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( |
| 521 gfx::Rect starting_rect, | 520 gfx::Rect starting_rect, |
| 522 int64 target_area, | 521 int64 target_area, |
| 523 gfx::Rect bounding_rect) { | 522 gfx::Rect bounding_rect) { |
| 524 DCHECK(!starting_rect.IsEmpty()); | 523 DCHECK(!starting_rect.IsEmpty()); |
| 525 DCHECK(!bounding_rect.IsEmpty()); | 524 DCHECK(!bounding_rect.IsEmpty()); |
| 526 DCHECK(target_area > 0); | 525 DCHECK_GT(target_area, 0); |
| 527 | 526 |
| 528 gfx::Rect rect = IntersectRects(starting_rect, bounding_rect); | 527 gfx::Rect rect = IntersectRects(starting_rect, bounding_rect); |
| 529 if (rect.IsEmpty()) | 528 if (rect.IsEmpty()) |
| 530 return rect; | 529 return rect; |
| 531 | 530 |
| 532 // These values will be updated by the loop and uses as the output. | 531 // These values will be updated by the loop and uses as the output. |
| 533 int origin_x = rect.x(); | 532 int origin_x = rect.x(); |
| 534 int origin_y = rect.y(); | 533 int origin_y = rect.y(); |
| 535 int width = rect.width(); | 534 int width = rect.width(); |
| 536 int height = rect.height(); | 535 int height = rect.height(); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 | 602 |
| 604 // If our delta is less then our event distance, we're done. | 603 // If our delta is less then our event distance, we're done. |
| 605 if (delta < event.distance) | 604 if (delta < event.distance) |
| 606 break; | 605 break; |
| 607 } | 606 } |
| 608 | 607 |
| 609 return gfx::Rect(origin_x, origin_y, width, height); | 608 return gfx::Rect(origin_x, origin_y, width, height); |
| 610 } | 609 } |
| 611 | 610 |
| 612 } // namespace cc | 611 } // namespace cc |
| OLD | NEW |