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 <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 "Tiling created with scale too small as contents become empty." << | 43 "Tiling created with scale too small as contents become empty." << |
44 " Layer bounds: " << layer_bounds.ToString() << | 44 " Layer bounds: " << layer_bounds.ToString() << |
45 " Contents scale: " << contents_scale; | 45 " Contents scale: " << contents_scale; |
46 | 46 |
47 tiling_data_.SetTotalSize(content_bounds); | 47 tiling_data_.SetTotalSize(content_bounds); |
48 tiling_data_.SetMaxTextureSize(tile_size); | 48 tiling_data_.SetMaxTextureSize(tile_size); |
49 } | 49 } |
50 | 50 |
51 PictureLayerTiling::~PictureLayerTiling() { | 51 PictureLayerTiling::~PictureLayerTiling() { |
52 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) | 52 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) |
53 client_->DestroyTile(it->second); | 53 client_->DestroyTile(it->second.get()); |
54 } | 54 } |
55 | 55 |
56 void PictureLayerTiling::SetClient(PictureLayerTilingClient* client) { | 56 void PictureLayerTiling::SetClient(PictureLayerTilingClient* client) { |
57 client_ = client; | 57 client_ = client; |
58 } | 58 } |
59 | 59 |
60 gfx::Rect PictureLayerTiling::ContentRect() const { | 60 gfx::Rect PictureLayerTiling::ContentRect() const { |
61 return gfx::Rect(tiling_data_.total_size()); | 61 return gfx::Rect(tiling_data_.total_size()); |
62 } | 62 } |
63 | 63 |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 return texture_rect; | 331 return texture_rect; |
332 } | 332 } |
333 | 333 |
334 gfx::Size PictureLayerTiling::CoverageIterator::texture_size() const { | 334 gfx::Size PictureLayerTiling::CoverageIterator::texture_size() const { |
335 return tiling_->tiling_data_.max_texture_size(); | 335 return tiling_->tiling_data_.max_texture_size(); |
336 } | 336 } |
337 | 337 |
338 void PictureLayerTiling::Reset() { | 338 void PictureLayerTiling::Reset() { |
339 live_tiles_rect_ = gfx::Rect(); | 339 live_tiles_rect_ = gfx::Rect(); |
340 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) | 340 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) |
341 client_->DestroyTile(it->second); | 341 client_->DestroyTile(it->second.get()); |
342 tiles_.clear(); | 342 tiles_.clear(); |
343 } | 343 } |
344 | 344 |
345 void PictureLayerTiling::UpdateTilePriorities( | 345 void PictureLayerTiling::UpdateTilePriorities( |
346 WhichTree tree, | 346 WhichTree tree, |
347 gfx::Size device_viewport, | 347 gfx::Size device_viewport, |
348 gfx::Rect viewport_in_layer_space, | 348 gfx::Rect viewport_in_layer_space, |
349 gfx::Rect visible_layer_rect, | 349 gfx::Rect visible_layer_rect, |
350 gfx::Size last_layer_bounds, | 350 gfx::Size last_layer_bounds, |
351 gfx::Size current_layer_bounds, | 351 gfx::Size current_layer_bounds, |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 live_tiles_rect_, | 503 live_tiles_rect_, |
504 new_live_tiles_rect); | 504 new_live_tiles_rect); |
505 iter; | 505 iter; |
506 ++iter) { | 506 ++iter) { |
507 TileMapKey key(iter.index()); | 507 TileMapKey key(iter.index()); |
508 TileMap::iterator found = tiles_.find(key); | 508 TileMap::iterator found = tiles_.find(key); |
509 // If the tile was outside of the recorded region, it won't exist even | 509 // If the tile was outside of the recorded region, it won't exist even |
510 // though it was in the live rect. | 510 // though it was in the live rect. |
511 if (found == tiles_.end()) | 511 if (found == tiles_.end()) |
512 continue; | 512 continue; |
513 client_->DestroyTile(found->second); | 513 client_->DestroyTile(found->second.get()); |
514 tiles_.erase(found); | 514 tiles_.erase(found); |
515 } | 515 } |
516 | 516 |
517 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); | 517 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); |
518 | 518 |
519 // Iterate to allocate new tiles for all regions with newly exposed area. | 519 // Iterate to allocate new tiles for all regions with newly exposed area. |
520 for (TilingData::DifferenceIterator iter(&tiling_data_, | 520 for (TilingData::DifferenceIterator iter(&tiling_data_, |
521 new_live_tiles_rect, | 521 new_live_tiles_rect, |
522 live_tiles_rect_); | 522 live_tiles_rect_); |
523 iter; | 523 iter; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 | 690 |
691 // If our delta is less then our event distance, we're done. | 691 // If our delta is less then our event distance, we're done. |
692 if (delta < event.distance) | 692 if (delta < event.distance) |
693 break; | 693 break; |
694 } | 694 } |
695 | 695 |
696 return gfx::Rect(origin_x, origin_y, width, height); | 696 return gfx::Rect(origin_x, origin_y, width, height); |
697 } | 697 } |
698 | 698 |
699 } // namespace cc | 699 } // namespace cc |
OLD | NEW |