| 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/tiles/picture_layer_tiling_set.h" | 5 #include "cc/tiles/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_provider.h" | 10 #include "cc/resources/resource_provider.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 scoped_refptr<FakeDisplayListRasterSource> raster_source = | 39 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
| 40 FakeDisplayListRasterSource::CreateEmpty(layer_bounds); | 40 FakeDisplayListRasterSource::CreateEmpty(layer_bounds); |
| 41 | 41 |
| 42 set->AddTiling(1.0, raster_source); | 42 set->AddTiling(1.0, raster_source); |
| 43 set->AddTiling(1.5, raster_source); | 43 set->AddTiling(1.5, raster_source); |
| 44 set->AddTiling(2.0, raster_source); | 44 set->AddTiling(2.0, raster_source); |
| 45 | 45 |
| 46 float contents_scale = 2.0; | 46 float contents_scale = 2.0; |
| 47 gfx::Size content_bounds( | 47 gfx::Size content_bounds( |
| 48 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale))); | 48 gfx::ScaleToCeiledSize(layer_bounds, contents_scale)); |
| 49 gfx::Rect content_rect(content_bounds); | 49 gfx::Rect content_rect(content_bounds); |
| 50 | 50 |
| 51 Region remaining(content_rect); | 51 Region remaining(content_rect); |
| 52 PictureLayerTilingSet::CoverageIterator iter(set.get(), contents_scale, | 52 PictureLayerTilingSet::CoverageIterator iter(set.get(), contents_scale, |
| 53 content_rect, contents_scale); | 53 content_rect, contents_scale); |
| 54 for (; iter; ++iter) { | 54 for (; iter; ++iter) { |
| 55 gfx::Rect geometry_rect = iter.geometry_rect(); | 55 gfx::Rect geometry_rect = iter.geometry_rect(); |
| 56 EXPECT_TRUE(content_rect.Contains(geometry_rect)); | 56 EXPECT_TRUE(content_rect.Contains(geometry_rect)); |
| 57 ASSERT_TRUE(remaining.Contains(geometry_rect)); | 57 ASSERT_TRUE(remaining.Contains(geometry_rect)); |
| 58 remaining.Subtract(geometry_rect); | 58 remaining.Subtract(geometry_rect); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 for (int i = 0; i < num_tilings; ++i, scale += scale_increment) { | 232 for (int i = 0; i < num_tilings; ++i, scale += scale_increment) { |
| 233 PictureLayerTiling* tiling = set->AddTiling(scale, raster_source); | 233 PictureLayerTiling* tiling = set->AddTiling(scale, raster_source); |
| 234 tiling->set_resolution(HIGH_RESOLUTION); | 234 tiling->set_resolution(HIGH_RESOLUTION); |
| 235 tiling->CreateAllTilesForTesting(); | 235 tiling->CreateAllTilesForTesting(); |
| 236 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); | 236 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
| 237 client.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); | 237 client.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); |
| 238 } | 238 } |
| 239 | 239 |
| 240 float max_contents_scale = scale; | 240 float max_contents_scale = scale; |
| 241 gfx::Size content_bounds( | 241 gfx::Size content_bounds( |
| 242 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, max_contents_scale))); | 242 gfx::ScaleToCeiledSize(layer_bounds, max_contents_scale)); |
| 243 gfx::Rect content_rect(content_bounds); | 243 gfx::Rect content_rect(content_bounds); |
| 244 | 244 |
| 245 Region remaining(content_rect); | 245 Region remaining(content_rect); |
| 246 PictureLayerTilingSet::CoverageIterator iter( | 246 PictureLayerTilingSet::CoverageIterator iter( |
| 247 set.get(), max_contents_scale, content_rect, ideal_contents_scale); | 247 set.get(), max_contents_scale, content_rect, ideal_contents_scale); |
| 248 for (; iter; ++iter) { | 248 for (; iter; ++iter) { |
| 249 gfx::Rect geometry_rect = iter.geometry_rect(); | 249 gfx::Rect geometry_rect = iter.geometry_rect(); |
| 250 EXPECT_TRUE(content_rect.Contains(geometry_rect)); | 250 EXPECT_TRUE(content_rect.Contains(geometry_rect)); |
| 251 ASSERT_TRUE(remaining.Contains(geometry_rect)); | 251 ASSERT_TRUE(remaining.Contains(geometry_rect)); |
| 252 remaining.Subtract(geometry_rect); | 252 remaining.Subtract(geometry_rect); |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 | 451 |
| 452 // Clone from the pending to the active tree with the same max content size. | 452 // Clone from the pending to the active tree with the same max content size. |
| 453 active_set->UpdateTilingsToCurrentRasterSourceForActivation( | 453 active_set->UpdateTilingsToCurrentRasterSourceForActivation( |
| 454 raster_source.get(), pending_set.get(), Region(), 1.f, max_content_scale); | 454 raster_source.get(), pending_set.get(), Region(), 1.f, max_content_scale); |
| 455 // All the tilings are on the active tree. | 455 // All the tilings are on the active tree. |
| 456 EXPECT_EQ(2u, active_set->num_tilings()); | 456 EXPECT_EQ(2u, active_set->num_tilings()); |
| 457 } | 457 } |
| 458 | 458 |
| 459 } // namespace | 459 } // namespace |
| 460 } // namespace cc | 460 } // namespace cc |
| OLD | NEW |