Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: cc/resources/picture_layer_tiling_set_unittest.cc

Issue 732423002: Update from chromium https://crrev.com/304586 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/resources/picture_layer_tiling_set.cc ('k') | cc/resources/picture_layer_tiling_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_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_output_surface_client.h" 12 #include "cc/test/fake_output_surface_client.h"
13 #include "cc/test/fake_picture_layer_tiling_client.h" 13 #include "cc/test/fake_picture_layer_tiling_client.h"
14 #include "cc/test/test_shared_bitmap_manager.h" 14 #include "cc/test/test_shared_bitmap_manager.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "ui/gfx/geometry/size_conversions.h" 16 #include "ui/gfx/geometry/size_conversions.h"
17 17
18 namespace cc { 18 namespace cc {
19 namespace { 19 namespace {
20 20
21 TEST(PictureLayerTilingSetTest, NoResources) { 21 TEST(PictureLayerTilingSetTest, NoResources) {
22 FakePictureLayerTilingClient client; 22 FakePictureLayerTilingClient client;
23 gfx::Size layer_bounds(1000, 800); 23 gfx::Size layer_bounds(1000, 800);
24 PictureLayerTilingSet set(&client); 24 auto set = PictureLayerTilingSet::Create(&client);
25 client.SetTileSize(gfx::Size(256, 256)); 25 client.SetTileSize(gfx::Size(256, 256));
26 26
27 set.AddTiling(1.0, layer_bounds); 27 set->AddTiling(1.0, layer_bounds);
28 set.AddTiling(1.5, layer_bounds); 28 set->AddTiling(1.5, layer_bounds);
29 set.AddTiling(2.0, layer_bounds); 29 set->AddTiling(2.0, layer_bounds);
30 30
31 float contents_scale = 2.0; 31 float contents_scale = 2.0;
32 gfx::Size content_bounds( 32 gfx::Size content_bounds(
33 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale))); 33 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale)));
34 gfx::Rect content_rect(content_bounds); 34 gfx::Rect content_rect(content_bounds);
35 35
36 Region remaining(content_rect); 36 Region remaining(content_rect);
37 PictureLayerTilingSet::CoverageIterator iter( 37 PictureLayerTilingSet::CoverageIterator iter(set.get(), contents_scale,
38 &set, 38 content_rect, contents_scale);
39 contents_scale,
40 content_rect,
41 contents_scale);
42 for (; iter; ++iter) { 39 for (; iter; ++iter) {
43 gfx::Rect geometry_rect = iter.geometry_rect(); 40 gfx::Rect geometry_rect = iter.geometry_rect();
44 EXPECT_TRUE(content_rect.Contains(geometry_rect)); 41 EXPECT_TRUE(content_rect.Contains(geometry_rect));
45 ASSERT_TRUE(remaining.Contains(geometry_rect)); 42 ASSERT_TRUE(remaining.Contains(geometry_rect));
46 remaining.Subtract(geometry_rect); 43 remaining.Subtract(geometry_rect);
47 44
48 // No tiles have resources, so no iter represents a real tile. 45 // No tiles have resources, so no iter represents a real tile.
49 EXPECT_FALSE(*iter); 46 EXPECT_FALSE(*iter);
50 } 47 }
51 EXPECT_TRUE(remaining.IsEmpty()); 48 EXPECT_TRUE(remaining.IsEmpty());
52 } 49 }
53 50
54 TEST(PictureLayerTilingSetTest, TilingRange) { 51 TEST(PictureLayerTilingSetTest, TilingRange) {
55 FakePictureLayerTilingClient client; 52 FakePictureLayerTilingClient client;
56 gfx::Size layer_bounds(10, 10); 53 gfx::Size layer_bounds(10, 10);
57 PictureLayerTilingSet::TilingRange higher_than_high_res_range(0, 0); 54 PictureLayerTilingSet::TilingRange higher_than_high_res_range(0, 0);
58 PictureLayerTilingSet::TilingRange high_res_range(0, 0); 55 PictureLayerTilingSet::TilingRange high_res_range(0, 0);
59 PictureLayerTilingSet::TilingRange between_high_and_low_res_range(0, 0); 56 PictureLayerTilingSet::TilingRange between_high_and_low_res_range(0, 0);
60 PictureLayerTilingSet::TilingRange low_res_range(0, 0); 57 PictureLayerTilingSet::TilingRange low_res_range(0, 0);
61 PictureLayerTilingSet::TilingRange lower_than_low_res_range(0, 0); 58 PictureLayerTilingSet::TilingRange lower_than_low_res_range(0, 0);
62 PictureLayerTiling* high_res_tiling; 59 PictureLayerTiling* high_res_tiling;
63 PictureLayerTiling* low_res_tiling; 60 PictureLayerTiling* low_res_tiling;
64 61
65 PictureLayerTilingSet set(&client); 62 auto set = PictureLayerTilingSet::Create(&client);
66 set.AddTiling(2.0, layer_bounds); 63 set->AddTiling(2.0, layer_bounds);
67 high_res_tiling = set.AddTiling(1.0, layer_bounds); 64 high_res_tiling = set->AddTiling(1.0, layer_bounds);
68 high_res_tiling->set_resolution(HIGH_RESOLUTION); 65 high_res_tiling->set_resolution(HIGH_RESOLUTION);
69 set.AddTiling(0.5, layer_bounds); 66 set->AddTiling(0.5, layer_bounds);
70 low_res_tiling = set.AddTiling(0.25, layer_bounds); 67 low_res_tiling = set->AddTiling(0.25, layer_bounds);
71 low_res_tiling->set_resolution(LOW_RESOLUTION); 68 low_res_tiling->set_resolution(LOW_RESOLUTION);
72 set.AddTiling(0.125, layer_bounds); 69 set->AddTiling(0.125, layer_bounds);
73 70
74 higher_than_high_res_range = 71 higher_than_high_res_range =
75 set.GetTilingRange(PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); 72 set->GetTilingRange(PictureLayerTilingSet::HIGHER_THAN_HIGH_RES);
76 EXPECT_EQ(0u, higher_than_high_res_range.start); 73 EXPECT_EQ(0u, higher_than_high_res_range.start);
77 EXPECT_EQ(1u, higher_than_high_res_range.end); 74 EXPECT_EQ(1u, higher_than_high_res_range.end);
78 75
79 high_res_range = set.GetTilingRange(PictureLayerTilingSet::HIGH_RES); 76 high_res_range = set->GetTilingRange(PictureLayerTilingSet::HIGH_RES);
80 EXPECT_EQ(1u, high_res_range.start); 77 EXPECT_EQ(1u, high_res_range.start);
81 EXPECT_EQ(2u, high_res_range.end); 78 EXPECT_EQ(2u, high_res_range.end);
82 79
83 between_high_and_low_res_range = 80 between_high_and_low_res_range =
84 set.GetTilingRange(PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); 81 set->GetTilingRange(PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES);
85 EXPECT_EQ(2u, between_high_and_low_res_range.start); 82 EXPECT_EQ(2u, between_high_and_low_res_range.start);
86 EXPECT_EQ(3u, between_high_and_low_res_range.end); 83 EXPECT_EQ(3u, between_high_and_low_res_range.end);
87 84
88 low_res_range = set.GetTilingRange(PictureLayerTilingSet::LOW_RES); 85 low_res_range = set->GetTilingRange(PictureLayerTilingSet::LOW_RES);
89 EXPECT_EQ(3u, low_res_range.start); 86 EXPECT_EQ(3u, low_res_range.start);
90 EXPECT_EQ(4u, low_res_range.end); 87 EXPECT_EQ(4u, low_res_range.end);
91 88
92 lower_than_low_res_range = 89 lower_than_low_res_range =
93 set.GetTilingRange(PictureLayerTilingSet::LOWER_THAN_LOW_RES); 90 set->GetTilingRange(PictureLayerTilingSet::LOWER_THAN_LOW_RES);
94 EXPECT_EQ(4u, lower_than_low_res_range.start); 91 EXPECT_EQ(4u, lower_than_low_res_range.start);
95 EXPECT_EQ(5u, lower_than_low_res_range.end); 92 EXPECT_EQ(5u, lower_than_low_res_range.end);
96 93
97 PictureLayerTilingSet set_without_low_res(&client); 94 auto set_without_low_res = PictureLayerTilingSet::Create(&client);
98 set_without_low_res.AddTiling(2.0, layer_bounds); 95 set_without_low_res->AddTiling(2.0, layer_bounds);
99 high_res_tiling = set_without_low_res.AddTiling(1.0, layer_bounds); 96 high_res_tiling = set_without_low_res->AddTiling(1.0, layer_bounds);
100 high_res_tiling->set_resolution(HIGH_RESOLUTION); 97 high_res_tiling->set_resolution(HIGH_RESOLUTION);
101 set_without_low_res.AddTiling(0.5, layer_bounds); 98 set_without_low_res->AddTiling(0.5, layer_bounds);
102 set_without_low_res.AddTiling(0.25, layer_bounds); 99 set_without_low_res->AddTiling(0.25, layer_bounds);
103 100
104 higher_than_high_res_range = set_without_low_res.GetTilingRange( 101 higher_than_high_res_range = set_without_low_res->GetTilingRange(
105 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); 102 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES);
106 EXPECT_EQ(0u, higher_than_high_res_range.start); 103 EXPECT_EQ(0u, higher_than_high_res_range.start);
107 EXPECT_EQ(1u, higher_than_high_res_range.end); 104 EXPECT_EQ(1u, higher_than_high_res_range.end);
108 105
109 high_res_range = 106 high_res_range =
110 set_without_low_res.GetTilingRange(PictureLayerTilingSet::HIGH_RES); 107 set_without_low_res->GetTilingRange(PictureLayerTilingSet::HIGH_RES);
111 EXPECT_EQ(1u, high_res_range.start); 108 EXPECT_EQ(1u, high_res_range.start);
112 EXPECT_EQ(2u, high_res_range.end); 109 EXPECT_EQ(2u, high_res_range.end);
113 110
114 between_high_and_low_res_range = set_without_low_res.GetTilingRange( 111 between_high_and_low_res_range = set_without_low_res->GetTilingRange(
115 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); 112 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES);
116 EXPECT_EQ(2u, between_high_and_low_res_range.start); 113 EXPECT_EQ(2u, between_high_and_low_res_range.start);
117 EXPECT_EQ(4u, between_high_and_low_res_range.end); 114 EXPECT_EQ(4u, between_high_and_low_res_range.end);
118 115
119 low_res_range = 116 low_res_range =
120 set_without_low_res.GetTilingRange(PictureLayerTilingSet::LOW_RES); 117 set_without_low_res->GetTilingRange(PictureLayerTilingSet::LOW_RES);
121 EXPECT_EQ(0u, low_res_range.end - low_res_range.start); 118 EXPECT_EQ(0u, low_res_range.end - low_res_range.start);
122 119
123 lower_than_low_res_range = set_without_low_res.GetTilingRange( 120 lower_than_low_res_range = set_without_low_res->GetTilingRange(
124 PictureLayerTilingSet::LOWER_THAN_LOW_RES); 121 PictureLayerTilingSet::LOWER_THAN_LOW_RES);
125 EXPECT_EQ(0u, lower_than_low_res_range.end - lower_than_low_res_range.start); 122 EXPECT_EQ(0u, lower_than_low_res_range.end - lower_than_low_res_range.start);
126 123
127 PictureLayerTilingSet set_with_only_high_and_low_res(&client); 124 auto set_with_only_high_and_low_res = PictureLayerTilingSet::Create(&client);
128 high_res_tiling = set_with_only_high_and_low_res.AddTiling(1.0, layer_bounds); 125 high_res_tiling =
126 set_with_only_high_and_low_res->AddTiling(1.0, layer_bounds);
129 high_res_tiling->set_resolution(HIGH_RESOLUTION); 127 high_res_tiling->set_resolution(HIGH_RESOLUTION);
130 low_res_tiling = set_with_only_high_and_low_res.AddTiling(0.5, layer_bounds); 128 low_res_tiling = set_with_only_high_and_low_res->AddTiling(0.5, layer_bounds);
131 low_res_tiling->set_resolution(LOW_RESOLUTION); 129 low_res_tiling->set_resolution(LOW_RESOLUTION);
132 130
133 higher_than_high_res_range = set_with_only_high_and_low_res.GetTilingRange( 131 higher_than_high_res_range = set_with_only_high_and_low_res->GetTilingRange(
134 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); 132 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES);
135 EXPECT_EQ(0u, 133 EXPECT_EQ(0u,
136 higher_than_high_res_range.end - higher_than_high_res_range.start); 134 higher_than_high_res_range.end - higher_than_high_res_range.start);
137 135
138 high_res_range = set_with_only_high_and_low_res.GetTilingRange( 136 high_res_range = set_with_only_high_and_low_res->GetTilingRange(
139 PictureLayerTilingSet::HIGH_RES); 137 PictureLayerTilingSet::HIGH_RES);
140 EXPECT_EQ(0u, high_res_range.start); 138 EXPECT_EQ(0u, high_res_range.start);
141 EXPECT_EQ(1u, high_res_range.end); 139 EXPECT_EQ(1u, high_res_range.end);
142 140
143 between_high_and_low_res_range = 141 between_high_and_low_res_range =
144 set_with_only_high_and_low_res.GetTilingRange( 142 set_with_only_high_and_low_res->GetTilingRange(
145 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); 143 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES);
146 EXPECT_EQ(0u, 144 EXPECT_EQ(0u, between_high_and_low_res_range.end -
147 between_high_and_low_res_range.end - 145 between_high_and_low_res_range.start);
148 between_high_and_low_res_range.start);
149 146
150 low_res_range = set_with_only_high_and_low_res.GetTilingRange( 147 low_res_range = set_with_only_high_and_low_res->GetTilingRange(
151 PictureLayerTilingSet::LOW_RES); 148 PictureLayerTilingSet::LOW_RES);
152 EXPECT_EQ(1u, low_res_range.start); 149 EXPECT_EQ(1u, low_res_range.start);
153 EXPECT_EQ(2u, low_res_range.end); 150 EXPECT_EQ(2u, low_res_range.end);
154 151
155 lower_than_low_res_range = set_with_only_high_and_low_res.GetTilingRange( 152 lower_than_low_res_range = set_with_only_high_and_low_res->GetTilingRange(
156 PictureLayerTilingSet::LOWER_THAN_LOW_RES); 153 PictureLayerTilingSet::LOWER_THAN_LOW_RES);
157 EXPECT_EQ(0u, lower_than_low_res_range.end - lower_than_low_res_range.start); 154 EXPECT_EQ(0u, lower_than_low_res_range.end - lower_than_low_res_range.start);
158 155
159 PictureLayerTilingSet set_with_only_high_res(&client); 156 auto set_with_only_high_res = PictureLayerTilingSet::Create(&client);
160 high_res_tiling = set_with_only_high_res.AddTiling(1.0, layer_bounds); 157 high_res_tiling = set_with_only_high_res->AddTiling(1.0, layer_bounds);
161 high_res_tiling->set_resolution(HIGH_RESOLUTION); 158 high_res_tiling->set_resolution(HIGH_RESOLUTION);
162 159
163 higher_than_high_res_range = set_with_only_high_res.GetTilingRange( 160 higher_than_high_res_range = set_with_only_high_res->GetTilingRange(
164 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); 161 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES);
165 EXPECT_EQ(0u, 162 EXPECT_EQ(0u,
166 higher_than_high_res_range.end - higher_than_high_res_range.start); 163 higher_than_high_res_range.end - higher_than_high_res_range.start);
167 164
168 high_res_range = 165 high_res_range =
169 set_with_only_high_res.GetTilingRange(PictureLayerTilingSet::HIGH_RES); 166 set_with_only_high_res->GetTilingRange(PictureLayerTilingSet::HIGH_RES);
170 EXPECT_EQ(0u, high_res_range.start); 167 EXPECT_EQ(0u, high_res_range.start);
171 EXPECT_EQ(1u, high_res_range.end); 168 EXPECT_EQ(1u, high_res_range.end);
172 169
173 between_high_and_low_res_range = set_with_only_high_res.GetTilingRange( 170 between_high_and_low_res_range = set_with_only_high_res->GetTilingRange(
174 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); 171 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES);
175 EXPECT_EQ(0u, 172 EXPECT_EQ(0u, between_high_and_low_res_range.end -
176 between_high_and_low_res_range.end - 173 between_high_and_low_res_range.start);
177 between_high_and_low_res_range.start);
178 174
179 low_res_range = 175 low_res_range =
180 set_with_only_high_res.GetTilingRange(PictureLayerTilingSet::LOW_RES); 176 set_with_only_high_res->GetTilingRange(PictureLayerTilingSet::LOW_RES);
181 EXPECT_EQ(0u, low_res_range.end - low_res_range.start); 177 EXPECT_EQ(0u, low_res_range.end - low_res_range.start);
182 178
183 lower_than_low_res_range = set_with_only_high_res.GetTilingRange( 179 lower_than_low_res_range = set_with_only_high_res->GetTilingRange(
184 PictureLayerTilingSet::LOWER_THAN_LOW_RES); 180 PictureLayerTilingSet::LOWER_THAN_LOW_RES);
185 EXPECT_EQ(0u, lower_than_low_res_range.end - lower_than_low_res_range.start); 181 EXPECT_EQ(0u, lower_than_low_res_range.end - lower_than_low_res_range.start);
186 } 182 }
187 183
188 class PictureLayerTilingSetTestWithResources : public testing::Test { 184 class PictureLayerTilingSetTestWithResources : public testing::Test {
189 public: 185 public:
190 void runTest( 186 void runTest(
191 int num_tilings, 187 int num_tilings,
192 float min_scale, 188 float min_scale,
193 float scale_increment, 189 float scale_increment,
(...skipping 12 matching lines...) Expand all
206 NULL, 202 NULL,
207 NULL, 203 NULL,
208 0, 204 0,
209 false, 205 false,
210 1); 206 1);
211 207
212 FakePictureLayerTilingClient client(resource_provider.get()); 208 FakePictureLayerTilingClient client(resource_provider.get());
213 client.SetTileSize(gfx::Size(256, 256)); 209 client.SetTileSize(gfx::Size(256, 256));
214 client.set_tree(PENDING_TREE); 210 client.set_tree(PENDING_TREE);
215 gfx::Size layer_bounds(1000, 800); 211 gfx::Size layer_bounds(1000, 800);
216 PictureLayerTilingSet set(&client); 212 auto set = PictureLayerTilingSet::Create(&client);
217 213
218 float scale = min_scale; 214 float scale = min_scale;
219 for (int i = 0; i < num_tilings; ++i, scale += scale_increment) { 215 for (int i = 0; i < num_tilings; ++i, scale += scale_increment) {
220 PictureLayerTiling* tiling = set.AddTiling(scale, layer_bounds); 216 PictureLayerTiling* tiling = set->AddTiling(scale, layer_bounds);
221 tiling->CreateAllTilesForTesting(); 217 tiling->CreateAllTilesForTesting();
222 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); 218 std::vector<Tile*> tiles = tiling->AllTilesForTesting();
223 client.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); 219 client.tile_manager()->InitializeTilesWithResourcesForTesting(tiles);
224 } 220 }
225 221
226 float max_contents_scale = scale; 222 float max_contents_scale = scale;
227 gfx::Size content_bounds( 223 gfx::Size content_bounds(
228 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, max_contents_scale))); 224 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, max_contents_scale)));
229 gfx::Rect content_rect(content_bounds); 225 gfx::Rect content_rect(content_bounds);
230 226
231 Region remaining(content_rect); 227 Region remaining(content_rect);
232 PictureLayerTilingSet::CoverageIterator iter( 228 PictureLayerTilingSet::CoverageIterator iter(
233 &set, 229 set.get(), max_contents_scale, content_rect, ideal_contents_scale);
234 max_contents_scale,
235 content_rect,
236 ideal_contents_scale);
237 for (; iter; ++iter) { 230 for (; iter; ++iter) {
238 gfx::Rect geometry_rect = iter.geometry_rect(); 231 gfx::Rect geometry_rect = iter.geometry_rect();
239 EXPECT_TRUE(content_rect.Contains(geometry_rect)); 232 EXPECT_TRUE(content_rect.Contains(geometry_rect));
240 ASSERT_TRUE(remaining.Contains(geometry_rect)); 233 ASSERT_TRUE(remaining.Contains(geometry_rect));
241 remaining.Subtract(geometry_rect); 234 remaining.Subtract(geometry_rect);
242 235
243 float scale = iter.CurrentTiling()->contents_scale(); 236 float scale = iter.CurrentTiling()->contents_scale();
244 EXPECT_EQ(expected_scale, scale); 237 EXPECT_EQ(expected_scale, scale);
245 238
246 if (num_tilings) 239 if (num_tilings)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 class PictureLayerTilingSetSyncTest : public testing::Test { 281 class PictureLayerTilingSetSyncTest : public testing::Test {
289 public: 282 public:
290 PictureLayerTilingSetSyncTest() 283 PictureLayerTilingSetSyncTest()
291 : tile_size_(gfx::Size(10, 10)), 284 : tile_size_(gfx::Size(10, 10)),
292 source_bounds_(gfx::Size(30, 20)), 285 source_bounds_(gfx::Size(30, 20)),
293 target_bounds_(gfx::Size(30, 30)) { 286 target_bounds_(gfx::Size(30, 30)) {
294 source_client_.SetTileSize(tile_size_); 287 source_client_.SetTileSize(tile_size_);
295 source_client_.set_tree(PENDING_TREE); 288 source_client_.set_tree(PENDING_TREE);
296 target_client_.SetTileSize(tile_size_); 289 target_client_.SetTileSize(tile_size_);
297 target_client_.set_tree(PENDING_TREE); 290 target_client_.set_tree(PENDING_TREE);
298 source_.reset(new PictureLayerTilingSet(&source_client_)); 291 source_ = PictureLayerTilingSet::Create(&source_client_);
299 target_.reset(new PictureLayerTilingSet(&target_client_)); 292 target_ = PictureLayerTilingSet::Create(&target_client_);
300 } 293 }
301 294
302 // Sync from source to target. 295 // Sync from source to target.
303 void SyncTilings(const gfx::Size& new_bounds, 296 void SyncTilings(const gfx::Size& new_bounds,
304 const Region& invalidation, 297 const Region& invalidation,
305 float minimum_scale) { 298 float minimum_scale) {
306 for (size_t i = 0; i < source_->num_tilings(); ++i) 299 for (size_t i = 0; i < source_->num_tilings(); ++i)
307 source_->tiling_at(i)->CreateAllTilesForTesting(); 300 source_->tiling_at(i)->CreateAllTilesForTesting();
308 for (size_t i = 0; i < target_->num_tilings(); ++i) 301 for (size_t i = 0; i < target_->num_tilings(); ++i)
309 target_->tiling_at(i)->CreateAllTilesForTesting(); 302 target_->tiling_at(i)->CreateAllTilesForTesting();
310 303
311 target_->SyncTilings( 304 target_->SyncTilings(*source_.get(), new_bounds, invalidation,
312 *source_.get(), new_bounds, invalidation, minimum_scale); 305 minimum_scale, target_client_.raster_source());
313 } 306 }
314 void SyncTilings(const gfx::Size& new_bounds) { 307 void SyncTilings(const gfx::Size& new_bounds) {
315 Region invalidation; 308 Region invalidation;
316 SyncTilings(new_bounds, invalidation, 0.f); 309 SyncTilings(new_bounds, invalidation, 0.f);
317 } 310 }
318 void SyncTilings(const gfx::Size& new_bounds, const Region& invalidation) { 311 void SyncTilings(const gfx::Size& new_bounds, const Region& invalidation) {
319 SyncTilings(new_bounds, invalidation, 0.f); 312 SyncTilings(new_bounds, invalidation, 0.f);
320 } 313 }
321 void SyncTilings(const gfx::Size& new_bounds, float minimum_scale) { 314 void SyncTilings(const gfx::Size& new_bounds, float minimum_scale) {
322 Region invalidation; 315 Region invalidation;
(...skipping 24 matching lines...) Expand all
347 if (target_->num_tilings() > 0) { 340 if (target_->num_tilings() > 0) {
348 float last_scale = target_->tiling_at(0)->contents_scale(); 341 float last_scale = target_->tiling_at(0)->contents_scale();
349 for (size_t i = 1; i < target_->num_tilings(); ++i) { 342 for (size_t i = 1; i < target_->num_tilings(); ++i) {
350 const PictureLayerTiling* target_tiling = target_->tiling_at(i); 343 const PictureLayerTiling* target_tiling = target_->tiling_at(i);
351 EXPECT_LT(target_tiling->contents_scale(), last_scale); 344 EXPECT_LT(target_tiling->contents_scale(), last_scale);
352 last_scale = target_tiling->contents_scale(); 345 last_scale = target_tiling->contents_scale();
353 } 346 }
354 } 347 }
355 348
356 for (size_t i = 0; i < target_->num_tilings(); ++i) 349 for (size_t i = 0; i < target_->num_tilings(); ++i)
357 ValidateTiling(target_->tiling_at(i), target_client_.GetRasterSource()); 350 ValidateTiling(target_->tiling_at(i), target_client_.raster_source());
358 } 351 }
359 352
360 void ValidateTiling(const PictureLayerTiling* tiling, 353 void ValidateTiling(const PictureLayerTiling* tiling,
361 const RasterSource* raster_source) { 354 const RasterSource* raster_source) {
362 if (tiling->tiling_size().IsEmpty()) { 355 if (tiling->tiling_size().IsEmpty()) {
363 EXPECT_TRUE(tiling->live_tiles_rect().IsEmpty()); 356 EXPECT_TRUE(tiling->live_tiles_rect().IsEmpty());
364 } else if (!tiling->live_tiles_rect().IsEmpty()) { 357 } else if (!tiling->live_tiles_rect().IsEmpty()) {
365 gfx::Rect tiling_rect(tiling->tiling_size()); 358 gfx::Rect tiling_rect(tiling->tiling_size());
366 EXPECT_TRUE(tiling_rect.Contains(tiling->live_tiles_rect())); 359 EXPECT_TRUE(tiling_rect.Contains(tiling->live_tiles_rect()));
367 } 360 }
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 std::vector<Tile*> new_tiles = target_->tiling_at(0)->AllTilesForTesting(); 546 std::vector<Tile*> new_tiles = target_->tiling_at(0)->AllTilesForTesting();
554 for (size_t i = 0; i < original_tiles.size(); ++i) { 547 for (size_t i = 0; i < original_tiles.size(); ++i) {
555 std::vector<Tile*>::iterator find = 548 std::vector<Tile*>::iterator find =
556 std::find(new_tiles.begin(), new_tiles.end(), original_tiles[i]); 549 std::find(new_tiles.begin(), new_tiles.end(), original_tiles[i]);
557 EXPECT_TRUE(find == new_tiles.end()); 550 EXPECT_TRUE(find == new_tiles.end());
558 } 551 }
559 } 552 }
560 553
561 } // namespace 554 } // namespace
562 } // namespace cc 555 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_layer_tiling_set.cc ('k') | cc/resources/picture_layer_tiling_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698