| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/layer_tiling_data.h" | 5 #include "cc/resources/layer_tiling_data.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 | 10 |
| 11 namespace cc { | 11 namespace cc { |
| 12 | 12 |
| 13 scoped_ptr<LayerTilingData> LayerTilingData::Create(const gfx::Size& tile_size, | 13 scoped_ptr<LayerTilingData> LayerTilingData::Create(gfx::Size tile_size, |
| 14 BorderTexelOption border) { | 14 BorderTexelOption border) { |
| 15 return make_scoped_ptr(new LayerTilingData(tile_size, border)); | 15 return make_scoped_ptr(new LayerTilingData(tile_size, border)); |
| 16 } | 16 } |
| 17 | 17 |
| 18 LayerTilingData::LayerTilingData(const gfx::Size& tile_size, | 18 LayerTilingData::LayerTilingData(gfx::Size tile_size, BorderTexelOption border) |
| 19 BorderTexelOption border) | |
| 20 : tiling_data_(tile_size, gfx::Size(), border == HAS_BORDER_TEXELS) { | 19 : tiling_data_(tile_size, gfx::Size(), border == HAS_BORDER_TEXELS) { |
| 21 SetTileSize(tile_size); | 20 SetTileSize(tile_size); |
| 22 } | 21 } |
| 23 | 22 |
| 24 LayerTilingData::~LayerTilingData() {} | 23 LayerTilingData::~LayerTilingData() {} |
| 25 | 24 |
| 26 void LayerTilingData::SetTileSize(const gfx::Size& size) { | 25 void LayerTilingData::SetTileSize(gfx::Size size) { |
| 27 if (tile_size() == size) | 26 if (tile_size() == size) |
| 28 return; | 27 return; |
| 29 | 28 |
| 30 reset(); | 29 reset(); |
| 31 | 30 |
| 32 tiling_data_.SetMaxTextureSize(size); | 31 tiling_data_.SetMaxTextureSize(size); |
| 33 } | 32 } |
| 34 | 33 |
| 35 gfx::Size LayerTilingData::tile_size() const { | 34 gfx::Size LayerTilingData::tile_size() const { |
| 36 return tiling_data_.max_texture_size(); | 35 return tiling_data_.max_texture_size(); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 continue; | 104 continue; |
| 106 | 105 |
| 107 gfx::Rect tile_opaque_rect = | 106 gfx::Rect tile_opaque_rect = |
| 108 gfx::IntersectRects(content_rect, tile->opaque_rect()); | 107 gfx::IntersectRects(content_rect, tile->opaque_rect()); |
| 109 opaque_region.Union(tile_opaque_rect); | 108 opaque_region.Union(tile_opaque_rect); |
| 110 } | 109 } |
| 111 } | 110 } |
| 112 return opaque_region; | 111 return opaque_region; |
| 113 } | 112 } |
| 114 | 113 |
| 115 void LayerTilingData::SetBounds(const gfx::Size& size) { | 114 void LayerTilingData::SetBounds(gfx::Size size) { |
| 116 tiling_data_.SetTotalSize(size); | 115 tiling_data_.SetTotalSize(size); |
| 117 if (size.IsEmpty()) { | 116 if (size.IsEmpty()) { |
| 118 tiles_.clear(); | 117 tiles_.clear(); |
| 119 return; | 118 return; |
| 120 } | 119 } |
| 121 | 120 |
| 122 // Any tiles completely outside our new bounds are invalid and should be | 121 // Any tiles completely outside our new bounds are invalid and should be |
| 123 // dropped. | 122 // dropped. |
| 124 int left, top, right, bottom; | 123 int left, top, right, bottom; |
| 125 ContentRectToTileIndices( | 124 ContentRectToTileIndices( |
| 126 gfx::Rect(size), &left, &top, &right, &bottom); | 125 gfx::Rect(size), &left, &top, &right, &bottom); |
| 127 std::vector<TileMapKey> invalid_tile_keys; | 126 std::vector<TileMapKey> invalid_tile_keys; |
| 128 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | 127 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
| 129 if (it->first.first > right || it->first.second > bottom) | 128 if (it->first.first > right || it->first.second > bottom) |
| 130 invalid_tile_keys.push_back(it->first); | 129 invalid_tile_keys.push_back(it->first); |
| 131 } | 130 } |
| 132 for (size_t i = 0; i < invalid_tile_keys.size(); ++i) | 131 for (size_t i = 0; i < invalid_tile_keys.size(); ++i) |
| 133 tiles_.erase(invalid_tile_keys[i]); | 132 tiles_.erase(invalid_tile_keys[i]); |
| 134 } | 133 } |
| 135 | 134 |
| 136 } // namespace cc | 135 } // namespace cc |
| OLD | NEW |