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

Side by Side Diff: cc/playback/discardable_image_map_unittest.cc

Issue 2656983006: cc: Add image to rect map in DiscardableImageMap. (Closed)
Patch Set: rebase Created 3 years, 10 months 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/playback/discardable_image_map.h" 5 #include "cc/playback/discardable_image_map.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 for (int y = 0; y < 4; ++y) { 104 for (int y = 0; y < 4; ++y) {
105 for (int x = 0; x < 4; ++x) { 105 for (int x = 0; x < 4; ++x) {
106 std::vector<PositionScaleDrawImage> images = GetDiscardableImagesInRect( 106 std::vector<PositionScaleDrawImage> images = GetDiscardableImagesInRect(
107 image_map, gfx::Rect(x * 512, y * 512, 500, 500)); 107 image_map, gfx::Rect(x * 512, y * 512, 500, 500));
108 if ((x + y) & 1) { 108 if ((x + y) & 1) {
109 EXPECT_EQ(1u, images.size()) << x << " " << y; 109 EXPECT_EQ(1u, images.size()) << x << " " << y;
110 EXPECT_TRUE(images[0].image == discardable_image[y][x]) << x << " " 110 EXPECT_TRUE(images[0].image == discardable_image[y][x]) << x << " "
111 << y; 111 << y;
112 EXPECT_EQ(gfx::Rect(x * 512 + 6, y * 512 + 6, 500, 500), 112 EXPECT_EQ(gfx::Rect(x * 512 + 6, y * 512 + 6, 500, 500),
113 images[0].image_rect); 113 images[0].image_rect);
114 EXPECT_EQ(images[0].image_rect,
115 image_map.GetRectForImage(images[0].image->uniqueID()));
114 } else { 116 } else {
115 EXPECT_EQ(0u, images.size()) << x << " " << y; 117 EXPECT_EQ(0u, images.size()) << x << " " << y;
116 } 118 }
117 } 119 }
118 } 120 }
119 121
120 // Capture 4 pixel refs. 122 // Capture 4 pixel refs.
121 std::vector<PositionScaleDrawImage> images = 123 std::vector<PositionScaleDrawImage> images =
122 GetDiscardableImagesInRect(image_map, gfx::Rect(512, 512, 2048, 2048)); 124 GetDiscardableImagesInRect(image_map, gfx::Rect(512, 512, 2048, 2048));
123 EXPECT_EQ(4u, images.size()); 125 EXPECT_EQ(4u, images.size());
126
124 EXPECT_TRUE(images[0].image == discardable_image[1][2]); 127 EXPECT_TRUE(images[0].image == discardable_image[1][2]);
125 EXPECT_EQ(gfx::Rect(2 * 512 + 6, 512 + 6, 500, 500), images[0].image_rect); 128 EXPECT_EQ(gfx::Rect(2 * 512 + 6, 512 + 6, 500, 500), images[0].image_rect);
129 EXPECT_EQ(images[0].image_rect,
130 image_map.GetRectForImage(images[0].image->uniqueID()));
131
126 EXPECT_TRUE(images[1].image == discardable_image[2][1]); 132 EXPECT_TRUE(images[1].image == discardable_image[2][1]);
127 EXPECT_EQ(gfx::Rect(512 + 6, 2 * 512 + 6, 500, 500), images[1].image_rect); 133 EXPECT_EQ(gfx::Rect(512 + 6, 2 * 512 + 6, 500, 500), images[1].image_rect);
134 EXPECT_EQ(images[1].image_rect,
135 image_map.GetRectForImage(images[1].image->uniqueID()));
136
128 EXPECT_TRUE(images[2].image == discardable_image[2][3]); 137 EXPECT_TRUE(images[2].image == discardable_image[2][3]);
129 EXPECT_EQ(gfx::Rect(3 * 512 + 6, 2 * 512 + 6, 500, 500), 138 EXPECT_EQ(gfx::Rect(3 * 512 + 6, 2 * 512 + 6, 500, 500),
130 images[2].image_rect); 139 images[2].image_rect);
140 EXPECT_EQ(images[2].image_rect,
141 image_map.GetRectForImage(images[2].image->uniqueID()));
142
131 EXPECT_TRUE(images[3].image == discardable_image[3][2]); 143 EXPECT_TRUE(images[3].image == discardable_image[3][2]);
132 EXPECT_EQ(gfx::Rect(2 * 512 + 6, 3 * 512 + 6, 500, 500), 144 EXPECT_EQ(gfx::Rect(2 * 512 + 6, 3 * 512 + 6, 500, 500),
133 images[3].image_rect); 145 images[3].image_rect);
146 EXPECT_EQ(images[3].image_rect,
147 image_map.GetRectForImage(images[3].image->uniqueID()));
134 } 148 }
135 149
136 TEST_F(DiscardableImageMapTest, GetDiscardableImagesInRectNonZeroLayer) { 150 TEST_F(DiscardableImageMapTest, GetDiscardableImagesInRectNonZeroLayer) {
137 gfx::Rect visible_rect(1024, 0, 2048, 2048); 151 gfx::Rect visible_rect(1024, 0, 2048, 2048);
138 // Make sure visible rect fits into the layer size. 152 // Make sure visible rect fits into the layer size.
139 gfx::Size layer_size(visible_rect.right(), visible_rect.bottom()); 153 gfx::Size layer_size(visible_rect.right(), visible_rect.bottom());
140 FakeContentLayerClient content_layer_client; 154 FakeContentLayerClient content_layer_client;
141 content_layer_client.set_bounds(layer_size); 155 content_layer_client.set_bounds(layer_size);
142 156
143 // Discardable pixel refs are found in the following grids: 157 // Discardable pixel refs are found in the following grids:
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 for (int y = 0; y < 4; ++y) { 191 for (int y = 0; y < 4; ++y) {
178 for (int x = 0; x < 4; ++x) { 192 for (int x = 0; x < 4; ++x) {
179 std::vector<PositionScaleDrawImage> images = GetDiscardableImagesInRect( 193 std::vector<PositionScaleDrawImage> images = GetDiscardableImagesInRect(
180 image_map, gfx::Rect(1024 + x * 512, y * 512, 500, 500)); 194 image_map, gfx::Rect(1024 + x * 512, y * 512, 500, 500));
181 if ((x + y) & 1) { 195 if ((x + y) & 1) {
182 EXPECT_EQ(1u, images.size()) << x << " " << y; 196 EXPECT_EQ(1u, images.size()) << x << " " << y;
183 EXPECT_TRUE(images[0].image == discardable_image[y][x]) << x << " " 197 EXPECT_TRUE(images[0].image == discardable_image[y][x]) << x << " "
184 << y; 198 << y;
185 EXPECT_EQ(gfx::Rect(1024 + x * 512 + 6, y * 512 + 6, 500, 500), 199 EXPECT_EQ(gfx::Rect(1024 + x * 512 + 6, y * 512 + 6, 500, 500),
186 images[0].image_rect); 200 images[0].image_rect);
201 EXPECT_EQ(images[0].image_rect,
202 image_map.GetRectForImage(images[0].image->uniqueID()));
187 } else { 203 } else {
188 EXPECT_EQ(0u, images.size()) << x << " " << y; 204 EXPECT_EQ(0u, images.size()) << x << " " << y;
189 } 205 }
190 } 206 }
191 } 207 }
192 // Capture 4 pixel refs. 208 // Capture 4 pixel refs.
193 { 209 {
194 std::vector<PositionScaleDrawImage> images = GetDiscardableImagesInRect( 210 std::vector<PositionScaleDrawImage> images = GetDiscardableImagesInRect(
195 image_map, gfx::Rect(1024 + 512, 512, 2048, 2048)); 211 image_map, gfx::Rect(1024 + 512, 512, 2048, 2048));
196 EXPECT_EQ(4u, images.size()); 212 EXPECT_EQ(4u, images.size());
213
197 EXPECT_TRUE(images[0].image == discardable_image[1][2]); 214 EXPECT_TRUE(images[0].image == discardable_image[1][2]);
198 EXPECT_EQ(gfx::Rect(1024 + 2 * 512 + 6, 512 + 6, 500, 500), 215 EXPECT_EQ(gfx::Rect(1024 + 2 * 512 + 6, 512 + 6, 500, 500),
199 images[0].image_rect); 216 images[0].image_rect);
217 EXPECT_EQ(images[0].image_rect,
218 image_map.GetRectForImage(images[0].image->uniqueID()));
219
200 EXPECT_TRUE(images[1].image == discardable_image[2][1]); 220 EXPECT_TRUE(images[1].image == discardable_image[2][1]);
201 EXPECT_EQ(gfx::Rect(1024 + 512 + 6, 2 * 512 + 6, 500, 500), 221 EXPECT_EQ(gfx::Rect(1024 + 512 + 6, 2 * 512 + 6, 500, 500),
202 images[1].image_rect); 222 images[1].image_rect);
223 EXPECT_EQ(images[1].image_rect,
224 image_map.GetRectForImage(images[1].image->uniqueID()));
225
203 EXPECT_TRUE(images[2].image == discardable_image[2][3]); 226 EXPECT_TRUE(images[2].image == discardable_image[2][3]);
204 EXPECT_EQ(gfx::Rect(1024 + 3 * 512 + 6, 2 * 512 + 6, 500, 500), 227 EXPECT_EQ(gfx::Rect(1024 + 3 * 512 + 6, 2 * 512 + 6, 500, 500),
205 images[2].image_rect); 228 images[2].image_rect);
229 EXPECT_EQ(images[2].image_rect,
230 image_map.GetRectForImage(images[2].image->uniqueID()));
231
206 EXPECT_TRUE(images[3].image == discardable_image[3][2]); 232 EXPECT_TRUE(images[3].image == discardable_image[3][2]);
207 EXPECT_EQ(gfx::Rect(1024 + 2 * 512 + 6, 3 * 512 + 6, 500, 500), 233 EXPECT_EQ(gfx::Rect(1024 + 2 * 512 + 6, 3 * 512 + 6, 500, 500),
208 images[3].image_rect); 234 images[3].image_rect);
235 EXPECT_EQ(images[3].image_rect,
236 image_map.GetRectForImage(images[3].image->uniqueID()));
209 } 237 }
210 238
211 // Non intersecting rects 239 // Non intersecting rects
212 { 240 {
213 std::vector<PositionScaleDrawImage> images = 241 std::vector<PositionScaleDrawImage> images =
214 GetDiscardableImagesInRect(image_map, gfx::Rect(0, 0, 1000, 1000)); 242 GetDiscardableImagesInRect(image_map, gfx::Rect(0, 0, 1000, 1000));
215 EXPECT_EQ(0u, images.size()); 243 EXPECT_EQ(0u, images.size());
216 } 244 }
217 { 245 {
218 std::vector<PositionScaleDrawImage> images = 246 std::vector<PositionScaleDrawImage> images =
219 GetDiscardableImagesInRect(image_map, gfx::Rect(3500, 0, 1000, 1000)); 247 GetDiscardableImagesInRect(image_map, gfx::Rect(3500, 0, 1000, 1000));
220 EXPECT_EQ(0u, images.size()); 248 EXPECT_EQ(0u, images.size());
221 } 249 }
222 { 250 {
223 std::vector<PositionScaleDrawImage> images = 251 std::vector<PositionScaleDrawImage> images =
224 GetDiscardableImagesInRect(image_map, gfx::Rect(0, 1100, 1000, 1000)); 252 GetDiscardableImagesInRect(image_map, gfx::Rect(0, 1100, 1000, 1000));
225 EXPECT_EQ(0u, images.size()); 253 EXPECT_EQ(0u, images.size());
226 } 254 }
227 { 255 {
228 std::vector<PositionScaleDrawImage> images = GetDiscardableImagesInRect( 256 std::vector<PositionScaleDrawImage> images = GetDiscardableImagesInRect(
229 image_map, gfx::Rect(3500, 1100, 1000, 1000)); 257 image_map, gfx::Rect(3500, 1100, 1000, 1000));
230 EXPECT_EQ(0u, images.size()); 258 EXPECT_EQ(0u, images.size());
231 } 259 }
260
261 // Image not present in the list.
262 {
263 sk_sp<SkImage> image = CreateDiscardableImage(gfx::Size(500, 500));
264 EXPECT_EQ(gfx::Rect(), image_map.GetRectForImage(image->uniqueID()));
265 }
232 } 266 }
233 267
234 TEST_F(DiscardableImageMapTest, GetDiscardableImagesInRectOnePixelQuery) { 268 TEST_F(DiscardableImageMapTest, GetDiscardableImagesInRectOnePixelQuery) {
235 gfx::Rect visible_rect(2048, 2048); 269 gfx::Rect visible_rect(2048, 2048);
236 FakeContentLayerClient content_layer_client; 270 FakeContentLayerClient content_layer_client;
237 content_layer_client.set_bounds(visible_rect.size()); 271 content_layer_client.set_bounds(visible_rect.size());
238 272
239 // Discardable pixel refs are found in the following grids: 273 // Discardable pixel refs are found in the following grids:
240 // |---|---|---|---| 274 // |---|---|---|---|
241 // | | x | | x | 275 // | | x | | x |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 for (int y = 0; y < 4; ++y) { 307 for (int y = 0; y < 4; ++y) {
274 for (int x = 0; x < 4; ++x) { 308 for (int x = 0; x < 4; ++x) {
275 std::vector<PositionScaleDrawImage> images = GetDiscardableImagesInRect( 309 std::vector<PositionScaleDrawImage> images = GetDiscardableImagesInRect(
276 image_map, gfx::Rect(x * 512 + 256, y * 512 + 256, 1, 1)); 310 image_map, gfx::Rect(x * 512 + 256, y * 512 + 256, 1, 1));
277 if ((x + y) & 1) { 311 if ((x + y) & 1) {
278 EXPECT_EQ(1u, images.size()) << x << " " << y; 312 EXPECT_EQ(1u, images.size()) << x << " " << y;
279 EXPECT_TRUE(images[0].image == discardable_image[y][x]) << x << " " 313 EXPECT_TRUE(images[0].image == discardable_image[y][x]) << x << " "
280 << y; 314 << y;
281 EXPECT_EQ(gfx::Rect(x * 512 + 6, y * 512 + 6, 500, 500), 315 EXPECT_EQ(gfx::Rect(x * 512 + 6, y * 512 + 6, 500, 500),
282 images[0].image_rect); 316 images[0].image_rect);
317 EXPECT_EQ(images[0].image_rect,
318 image_map.GetRectForImage(images[0].image->uniqueID()));
283 } else { 319 } else {
284 EXPECT_EQ(0u, images.size()) << x << " " << y; 320 EXPECT_EQ(0u, images.size()) << x << " " << y;
285 } 321 }
286 } 322 }
287 } 323 }
288 } 324 }
289 325
290 TEST_F(DiscardableImageMapTest, GetDiscardableImagesInRectMassiveImage) { 326 TEST_F(DiscardableImageMapTest, GetDiscardableImagesInRectMassiveImage) {
291 gfx::Rect visible_rect(2048, 2048); 327 gfx::Rect visible_rect(2048, 2048);
292 FakeContentLayerClient content_layer_client; 328 FakeContentLayerClient content_layer_client;
(...skipping 13 matching lines...) Expand all
306 { 342 {
307 DiscardableImageMap::ScopedMetadataGenerator generator(&image_map, 343 DiscardableImageMap::ScopedMetadataGenerator generator(&image_map,
308 visible_rect.size()); 344 visible_rect.size());
309 display_list->Raster(generator.canvas(), nullptr, gfx::Rect(), 1.f); 345 display_list->Raster(generator.canvas(), nullptr, gfx::Rect(), 1.f);
310 } 346 }
311 std::vector<PositionScaleDrawImage> images = 347 std::vector<PositionScaleDrawImage> images =
312 GetDiscardableImagesInRect(image_map, gfx::Rect(0, 0, 1, 1)); 348 GetDiscardableImagesInRect(image_map, gfx::Rect(0, 0, 1, 1));
313 EXPECT_EQ(1u, images.size()); 349 EXPECT_EQ(1u, images.size());
314 EXPECT_TRUE(images[0].image == discardable_image); 350 EXPECT_TRUE(images[0].image == discardable_image);
315 EXPECT_EQ(gfx::Rect(0, 0, 2048, 2048), images[0].image_rect); 351 EXPECT_EQ(gfx::Rect(0, 0, 2048, 2048), images[0].image_rect);
352 EXPECT_EQ(images[0].image_rect,
353 image_map.GetRectForImage(images[0].image->uniqueID()));
316 } 354 }
317 355
318 TEST_F(DiscardableImageMapTest, PaintDestroyedWhileImageIsDrawn) { 356 TEST_F(DiscardableImageMapTest, PaintDestroyedWhileImageIsDrawn) {
319 gfx::Rect visible_rect(2048, 2048); 357 gfx::Rect visible_rect(2048, 2048);
320 FakeContentLayerClient content_layer_client; 358 FakeContentLayerClient content_layer_client;
321 content_layer_client.set_bounds(visible_rect.size()); 359 content_layer_client.set_bounds(visible_rect.size());
322 360
323 sk_sp<SkImage> discardable_image = CreateDiscardableImage(gfx::Size(10, 10)); 361 sk_sp<SkImage> discardable_image = CreateDiscardableImage(gfx::Size(10, 10));
324 362
325 DiscardableImageMap image_map; 363 DiscardableImageMap image_map;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 { 399 {
362 DiscardableImageMap::ScopedMetadataGenerator generator(&image_map, 400 DiscardableImageMap::ScopedMetadataGenerator generator(&image_map,
363 visible_rect.size()); 401 visible_rect.size());
364 display_list->Raster(generator.canvas(), nullptr, visible_rect, 1.f); 402 display_list->Raster(generator.canvas(), nullptr, visible_rect, 1.f);
365 } 403 }
366 std::vector<PositionScaleDrawImage> images = 404 std::vector<PositionScaleDrawImage> images =
367 GetDiscardableImagesInRect(image_map, gfx::Rect(42, 42, 1, 1)); 405 GetDiscardableImagesInRect(image_map, gfx::Rect(42, 42, 1, 1));
368 EXPECT_EQ(1u, images.size()); 406 EXPECT_EQ(1u, images.size());
369 EXPECT_TRUE(images[0].image == discardable_image); 407 EXPECT_TRUE(images[0].image == discardable_image);
370 EXPECT_EQ(gfx::Rect(42, 42, 2006, 2006), images[0].image_rect); 408 EXPECT_EQ(gfx::Rect(42, 42, 2006, 2006), images[0].image_rect);
409 EXPECT_EQ(images[0].image_rect,
410 image_map.GetRectForImage(images[0].image->uniqueID()));
371 } 411 }
372 412
373 TEST_F(DiscardableImageMapTest, GetDiscardableImagesInRectMaxImageMaxLayer) { 413 TEST_F(DiscardableImageMapTest, GetDiscardableImagesInRectMaxImageMaxLayer) {
374 // At large values of integer x, x != static_cast<int>(static_cast<float>(x)). 414 // At large values of integer x, x != static_cast<int>(static_cast<float>(x)).
375 // So, make sure the dimension can be converted back and forth for the 415 // So, make sure the dimension can be converted back and forth for the
376 // purposes of the unittest. Also, at near max int values, Skia seems to skip 416 // purposes of the unittest. Also, at near max int values, Skia seems to skip
377 // some draw calls, so we subtract 64 since we only care about "really large" 417 // some draw calls, so we subtract 64 since we only care about "really large"
378 // values, not necessarily max int values. 418 // values, not necessarily max int values.
379 int dimension = static_cast<int>( 419 int dimension = static_cast<int>(
380 static_cast<float>(std::numeric_limits<int>::max() - 64)); 420 static_cast<float>(std::numeric_limits<int>::max() - 64));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 // Since we adjust negative offsets before using ToEnclosingRect, the expected 456 // Since we adjust negative offsets before using ToEnclosingRect, the expected
417 // width will be converted to float, which means that we lose some precision. 457 // width will be converted to float, which means that we lose some precision.
418 // The expected value is whatever the value is converted to float and then 458 // The expected value is whatever the value is converted to float and then
419 // back to int. 459 // back to int.
420 int expected10k = static_cast<int>(static_cast<float>(dimension - 10000)); 460 int expected10k = static_cast<int>(static_cast<float>(dimension - 10000));
421 images = GetDiscardableImagesInRect(image_map, gfx::Rect(0, 500, 1, 1)); 461 images = GetDiscardableImagesInRect(image_map, gfx::Rect(0, 500, 1, 1));
422 EXPECT_EQ(2u, images.size()); 462 EXPECT_EQ(2u, images.size());
423 EXPECT_EQ(gfx::Rect(0, 500, expected10k, dimension - 500), 463 EXPECT_EQ(gfx::Rect(0, 500, expected10k, dimension - 500),
424 images[1].image_rect); 464 images[1].image_rect);
425 EXPECT_EQ(gfx::Rect(0, 0, dimension, dimension), images[0].image_rect); 465 EXPECT_EQ(gfx::Rect(0, 0, dimension, dimension), images[0].image_rect);
466
467 EXPECT_EQ(gfx::Rect(0, 0, dimension, dimension),
468 image_map.GetRectForImage(discardable_image->uniqueID()));
426 } 469 }
427 470
428 TEST_F(DiscardableImageMapTest, GetDiscardableImagesRectInBounds) { 471 TEST_F(DiscardableImageMapTest, GetDiscardableImagesRectInBounds) {
429 gfx::Rect visible_rect(1000, 1000); 472 gfx::Rect visible_rect(1000, 1000);
430 FakeContentLayerClient content_layer_client; 473 FakeContentLayerClient content_layer_client;
431 content_layer_client.set_bounds(visible_rect.size()); 474 content_layer_client.set_bounds(visible_rect.size());
432 475
433 sk_sp<SkImage> discardable_image = 476 sk_sp<SkImage> discardable_image =
434 CreateDiscardableImage(gfx::Size(100, 100)); 477 CreateDiscardableImage(gfx::Size(100, 100));
435 sk_sp<SkImage> long_discardable_image = 478 sk_sp<SkImage> long_discardable_image =
(...skipping 22 matching lines...) Expand all
458 EXPECT_EQ(1u, images.size()); 501 EXPECT_EQ(1u, images.size());
459 EXPECT_EQ(gfx::Rect(0, 0, 90, 89), images[0].image_rect); 502 EXPECT_EQ(gfx::Rect(0, 0, 90, 89), images[0].image_rect);
460 503
461 images = GetDiscardableImagesInRect(image_map, gfx::Rect(999, 999, 1, 1)); 504 images = GetDiscardableImagesInRect(image_map, gfx::Rect(999, 999, 1, 1));
462 EXPECT_EQ(1u, images.size()); 505 EXPECT_EQ(1u, images.size());
463 EXPECT_EQ(gfx::Rect(950, 951, 50, 49), images[0].image_rect); 506 EXPECT_EQ(gfx::Rect(950, 951, 50, 49), images[0].image_rect);
464 507
465 images = GetDiscardableImagesInRect(image_map, gfx::Rect(0, 500, 1, 1)); 508 images = GetDiscardableImagesInRect(image_map, gfx::Rect(0, 500, 1, 1));
466 EXPECT_EQ(1u, images.size()); 509 EXPECT_EQ(1u, images.size());
467 EXPECT_EQ(gfx::Rect(0, 500, 1000, 100), images[0].image_rect); 510 EXPECT_EQ(gfx::Rect(0, 500, 1000, 100), images[0].image_rect);
511
512 gfx::Rect discardable_image_rect;
513 discardable_image_rect.Union(gfx::Rect(0, 0, 90, 89));
514 discardable_image_rect.Union(gfx::Rect(950, 951, 50, 49));
515 EXPECT_EQ(discardable_image_rect,
516 image_map.GetRectForImage(discardable_image->uniqueID()));
517
518 EXPECT_EQ(gfx::Rect(0, 500, 1000, 100),
519 image_map.GetRectForImage(long_discardable_image->uniqueID()));
468 } 520 }
469 521
470 TEST_F(DiscardableImageMapTest, GetDiscardableImagesInShader) { 522 TEST_F(DiscardableImageMapTest, GetDiscardableImagesInShader) {
471 gfx::Rect visible_rect(2048, 2048); 523 gfx::Rect visible_rect(2048, 2048);
472 FakeContentLayerClient content_layer_client; 524 FakeContentLayerClient content_layer_client;
473 content_layer_client.set_bounds(visible_rect.size()); 525 content_layer_client.set_bounds(visible_rect.size());
474 526
475 // Discardable pixel refs are found in the following grids: 527 // Discardable pixel refs are found in the following grids:
476 // |---|---|---|---| 528 // |---|---|---|---|
477 // | | x | | x | 529 // | | x | | x |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 EXPECT_EQ(gfx::Rect(512 + 6, 2 * 512 + 6, 500, 500), images[1].image_rect); 588 EXPECT_EQ(gfx::Rect(512 + 6, 2 * 512 + 6, 500, 500), images[1].image_rect);
537 EXPECT_TRUE(images[2].image == discardable_image[2][3]); 589 EXPECT_TRUE(images[2].image == discardable_image[2][3]);
538 EXPECT_EQ(gfx::Rect(3 * 512 + 6, 2 * 512 + 6, 500, 500), 590 EXPECT_EQ(gfx::Rect(3 * 512 + 6, 2 * 512 + 6, 500, 500),
539 images[2].image_rect); 591 images[2].image_rect);
540 EXPECT_TRUE(images[3].image == discardable_image[3][2]); 592 EXPECT_TRUE(images[3].image == discardable_image[3][2]);
541 EXPECT_EQ(gfx::Rect(2 * 512 + 6, 3 * 512 + 6, 500, 500), 593 EXPECT_EQ(gfx::Rect(2 * 512 + 6, 3 * 512 + 6, 500, 500),
542 images[3].image_rect); 594 images[3].image_rect);
543 } 595 }
544 596
545 } // namespace cc 597 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698