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_set.h" | 5 #include "cc/resources/picture_layer_tiling_set.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "cc/resources/resource_pool.h" | 10 #include "cc/resources/resource_pool.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 : tile_size_(gfx::Size(10, 10)), | 150 : tile_size_(gfx::Size(10, 10)), |
151 source_bounds_(gfx::Size(30, 20)), | 151 source_bounds_(gfx::Size(30, 20)), |
152 target_bounds_(gfx::Size(30, 30)) { | 152 target_bounds_(gfx::Size(30, 30)) { |
153 source_client_.SetTileSize(tile_size_); | 153 source_client_.SetTileSize(tile_size_); |
154 target_client_.SetTileSize(tile_size_); | 154 target_client_.SetTileSize(tile_size_); |
155 source_.reset(new PictureLayerTilingSet(&source_client_, source_bounds_)); | 155 source_.reset(new PictureLayerTilingSet(&source_client_, source_bounds_)); |
156 target_.reset(new PictureLayerTilingSet(&target_client_, target_bounds_)); | 156 target_.reset(new PictureLayerTilingSet(&target_client_, target_bounds_)); |
157 } | 157 } |
158 | 158 |
159 // Sync from source to target. | 159 // Sync from source to target. |
160 void SyncTilings(const gfx::Size& new_bounds, | 160 void SyncTilings(gfx::Size new_bounds, |
161 const Region& invalidation, | 161 const Region& invalidation, |
162 float minimum_scale) { | 162 float minimum_scale) { |
163 for (size_t i = 0; i < source_->num_tilings(); ++i) | 163 for (size_t i = 0; i < source_->num_tilings(); ++i) |
164 source_->tiling_at(i)->CreateAllTilesForTesting(); | 164 source_->tiling_at(i)->CreateAllTilesForTesting(); |
165 for (size_t i = 0; i < target_->num_tilings(); ++i) | 165 for (size_t i = 0; i < target_->num_tilings(); ++i) |
166 target_->tiling_at(i)->CreateAllTilesForTesting(); | 166 target_->tiling_at(i)->CreateAllTilesForTesting(); |
167 | 167 |
168 target_->SyncTilings( | 168 target_->SyncTilings( |
169 *source_.get(), new_bounds, invalidation, minimum_scale); | 169 *source_.get(), new_bounds, invalidation, minimum_scale); |
170 } | 170 } |
171 void SyncTilings(const gfx::Size& new_bounds) { | 171 void SyncTilings(gfx::Size new_bounds) { |
172 Region invalidation; | 172 Region invalidation; |
173 SyncTilings(new_bounds, invalidation, 0.f); | 173 SyncTilings(new_bounds, invalidation, 0.f); |
174 } | 174 } |
175 void SyncTilings(const gfx::Size& new_bounds, const Region& invalidation) { | 175 void SyncTilings(gfx::Size new_bounds, const Region& invalidation) { |
176 SyncTilings(new_bounds, invalidation, 0.f); | 176 SyncTilings(new_bounds, invalidation, 0.f); |
177 } | 177 } |
178 void SyncTilings(const gfx::Size& new_bounds, float minimum_scale) { | 178 void SyncTilings(gfx::Size new_bounds, float minimum_scale) { |
179 Region invalidation; | 179 Region invalidation; |
180 SyncTilings(new_bounds, invalidation, minimum_scale); | 180 SyncTilings(new_bounds, invalidation, minimum_scale); |
181 } | 181 } |
182 | 182 |
183 void VerifyTargetEqualsSource(const gfx::Size& new_bounds) const { | 183 void VerifyTargetEqualsSource(gfx::Size new_bounds) const { |
184 ASSERT_FALSE(new_bounds.IsEmpty()); | 184 ASSERT_FALSE(new_bounds.IsEmpty()); |
185 EXPECT_EQ(target_->num_tilings(), source_->num_tilings()); | 185 EXPECT_EQ(target_->num_tilings(), source_->num_tilings()); |
186 EXPECT_EQ(target_->layer_bounds().ToString(), new_bounds.ToString()); | 186 EXPECT_EQ(target_->layer_bounds().ToString(), new_bounds.ToString()); |
187 | 187 |
188 for (size_t i = 0; i < target_->num_tilings(); ++i) { | 188 for (size_t i = 0; i < target_->num_tilings(); ++i) { |
189 ASSERT_GT(source_->num_tilings(), i); | 189 ASSERT_GT(source_->num_tilings(), i); |
190 const PictureLayerTiling* source_tiling = source_->tiling_at(i); | 190 const PictureLayerTiling* source_tiling = source_->tiling_at(i); |
191 const PictureLayerTiling* target_tiling = target_->tiling_at(i); | 191 const PictureLayerTiling* target_tiling = target_->tiling_at(i); |
192 EXPECT_EQ(target_tiling->layer_bounds().ToString(), | 192 EXPECT_EQ(target_tiling->layer_bounds().ToString(), |
193 new_bounds.ToString()); | 193 new_bounds.ToString()); |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 std::vector<Tile*> new_tiles = target_->tiling_at(0)->AllTilesForTesting(); | 407 std::vector<Tile*> new_tiles = target_->tiling_at(0)->AllTilesForTesting(); |
408 for (size_t i = 0; i < original_tiles.size(); ++i) { | 408 for (size_t i = 0; i < original_tiles.size(); ++i) { |
409 std::vector<Tile*>::iterator find = | 409 std::vector<Tile*>::iterator find = |
410 std::find(new_tiles.begin(), new_tiles.end(), original_tiles[i]); | 410 std::find(new_tiles.begin(), new_tiles.end(), original_tiles[i]); |
411 EXPECT_TRUE(find == new_tiles.end()); | 411 EXPECT_TRUE(find == new_tiles.end()); |
412 } | 412 } |
413 } | 413 } |
414 | 414 |
415 } // namespace | 415 } // namespace |
416 } // namespace cc | 416 } // namespace cc |
OLD | NEW |