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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "cc/resources/resource_pool.h" | 9 #include "cc/resources/resource_pool.h" |
10 #include "cc/resources/resource_provider.h" | 10 #include "cc/resources/resource_provider.h" |
11 #include "cc/test/fake_output_surface.h" | 11 #include "cc/test/fake_output_surface.h" |
12 #include "cc/test/fake_picture_layer_tiling_client.h" | 12 #include "cc/test/fake_picture_layer_tiling_client.h" |
13 #include "cc/test/fake_tile_manager_client.h" | 13 #include "cc/test/fake_tile_manager_client.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "ui/gfx/size_conversions.h" | 15 #include "ui/gfx/size_conversions.h" |
16 | 16 |
17 namespace cc { | 17 namespace cc { |
18 namespace { | 18 namespace { |
19 | 19 |
20 TEST(PictureLayerTilingSetTest, NoResources) { | 20 TEST(PictureLayerTilingSetTest, NoResources) { |
21 FakePictureLayerTilingClient client; | 21 FakePictureLayerTilingClient client; |
22 PictureLayerTilingSet set(&client); | 22 gfx::Size layer_bounds(1000, 800); |
| 23 PictureLayerTilingSet set(&client, layer_bounds); |
23 client.SetTileSize(gfx::Size(256, 256)); | 24 client.SetTileSize(gfx::Size(256, 256)); |
24 | 25 |
25 gfx::Size layer_bounds(1000, 800); | |
26 set.SetLayerBounds(layer_bounds); | |
27 | |
28 set.AddTiling(1.0); | 26 set.AddTiling(1.0); |
29 set.AddTiling(1.5); | 27 set.AddTiling(1.5); |
30 set.AddTiling(2.0); | 28 set.AddTiling(2.0); |
31 | 29 |
32 float contents_scale = 2.0; | 30 float contents_scale = 2.0; |
33 gfx::Size content_bounds( | 31 gfx::Size content_bounds( |
34 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale))); | 32 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale))); |
35 gfx::Rect content_rect(content_bounds); | 33 gfx::Rect content_rect(content_bounds); |
36 | 34 |
37 Region remaining(content_rect); | 35 Region remaining(content_rect); |
(...skipping 22 matching lines...) Expand all Loading... |
60 float scale_increment, | 58 float scale_increment, |
61 float ideal_contents_scale, | 59 float ideal_contents_scale, |
62 float expected_scale) { | 60 float expected_scale) { |
63 scoped_ptr<FakeOutputSurface> output_surface = | 61 scoped_ptr<FakeOutputSurface> output_surface = |
64 FakeOutputSurface::Create3d(); | 62 FakeOutputSurface::Create3d(); |
65 scoped_ptr<ResourceProvider> resource_provider = | 63 scoped_ptr<ResourceProvider> resource_provider = |
66 ResourceProvider::Create(output_surface.get(), 0); | 64 ResourceProvider::Create(output_surface.get(), 0); |
67 | 65 |
68 FakePictureLayerTilingClient client; | 66 FakePictureLayerTilingClient client; |
69 client.SetTileSize(gfx::Size(256, 256)); | 67 client.SetTileSize(gfx::Size(256, 256)); |
70 PictureLayerTilingSet set(&client); | |
71 | |
72 gfx::Size layer_bounds(1000, 800); | 68 gfx::Size layer_bounds(1000, 800); |
73 set.SetLayerBounds(layer_bounds); | 69 PictureLayerTilingSet set(&client, layer_bounds); |
74 | 70 |
75 float scale = min_scale; | 71 float scale = min_scale; |
76 for (int i = 0; i < num_tilings; ++i, scale += scale_increment) { | 72 for (int i = 0; i < num_tilings; ++i, scale += scale_increment) { |
77 PictureLayerTiling* tiling = set.AddTiling(scale); | 73 PictureLayerTiling* tiling = set.AddTiling(scale); |
| 74 tiling->CreateAllTilesForTesting(); |
78 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); | 75 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
79 for (size_t i = 0; i < tiles.size(); ++i) { | 76 for (size_t i = 0; i < tiles.size(); ++i) { |
80 EXPECT_FALSE(tiles[i]->drawing_info().GetResourceForTesting()); | 77 EXPECT_FALSE(tiles[i]->drawing_info().GetResourceForTesting()); |
81 | 78 |
82 tiles[i]->drawing_info().GetResourceForTesting() = | 79 tiles[i]->drawing_info().GetResourceForTesting() = |
83 make_scoped_ptr(new ResourcePool::Resource( | 80 make_scoped_ptr(new ResourcePool::Resource( |
84 resource_provider.get(), | 81 resource_provider.get(), |
85 gfx::Size(1, 1), | 82 gfx::Size(1, 1), |
86 resource_provider->best_texture_format())); | 83 resource_provider->best_texture_format())); |
87 } | 84 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 TEST_F(PictureLayerTilingSetTestWithResources, ManyTilings_Equal) { | 141 TEST_F(PictureLayerTilingSetTestWithResources, ManyTilings_Equal) { |
145 runTest(10, 1.f, 1.f, 5.f, 5.f); | 142 runTest(10, 1.f, 1.f, 5.f, 5.f); |
146 } | 143 } |
147 | 144 |
148 TEST_F(PictureLayerTilingSetTestWithResources, ManyTilings_NotEqual) { | 145 TEST_F(PictureLayerTilingSetTestWithResources, ManyTilings_NotEqual) { |
149 runTest(10, 1.f, 1.f, 4.5f, 5.f); | 146 runTest(10, 1.f, 1.f, 4.5f, 5.f); |
150 } | 147 } |
151 | 148 |
152 } // namespace | 149 } // namespace |
153 } // namespace cc | 150 } // namespace cc |
OLD | NEW |