Update V8 to version 4.6.55.
[chromium-blink-merge.git] / cc / playback / picture_pile_impl_unittest.cc
blob81c2aec4713a28234e8438e4fd216c7f2bb4e013
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/memory/scoped_ptr.h"
6 #include "cc/test/fake_picture_pile_impl.h"
7 #include "cc/test/skia_common.h"
8 #include "skia/ext/refptr.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/skia/include/core/SkPixelRef.h"
11 #include "third_party/skia/include/core/SkShader.h"
12 #include "ui/gfx/geometry/rect.h"
13 #include "ui/gfx/geometry/size_conversions.h"
15 namespace cc {
16 namespace {
18 TEST(PicturePileImplTest, AnalyzeIsSolidUnscaled) {
19 gfx::Size tile_size(100, 100);
20 gfx::Size layer_bounds(400, 400);
22 scoped_ptr<FakePicturePile> recording_source =
23 FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
25 SkPaint solid_paint;
26 SkColor solid_color = SkColorSetARGB(255, 12, 23, 34);
27 solid_paint.setColor(solid_color);
29 SkColor non_solid_color = SkColorSetARGB(128, 45, 56, 67);
30 SkPaint non_solid_paint;
31 non_solid_paint.setColor(non_solid_color);
33 recording_source->add_draw_rect_with_paint(gfx::Rect(0, 0, 400, 400),
34 solid_paint);
35 recording_source->Rerecord();
37 scoped_refptr<FakePicturePileImpl> pile =
38 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
40 // Ensure everything is solid.
41 for (int y = 0; y <= 300; y += 100) {
42 for (int x = 0; x <= 300; x += 100) {
43 RasterSource::SolidColorAnalysis analysis;
44 gfx::Rect rect(x, y, 100, 100);
45 pile->PerformSolidColorAnalysis(rect, 1.0, &analysis);
46 EXPECT_TRUE(analysis.is_solid_color) << rect.ToString();
47 EXPECT_EQ(analysis.solid_color, solid_color) << rect.ToString();
51 // Add one non-solid pixel and recreate the raster source.
52 recording_source->add_draw_rect_with_paint(gfx::Rect(50, 50, 1, 1),
53 non_solid_paint);
54 recording_source->Rerecord();
55 pile = FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
57 RasterSource::SolidColorAnalysis analysis;
58 pile->PerformSolidColorAnalysis(gfx::Rect(0, 0, 100, 100), 1.0, &analysis);
59 EXPECT_FALSE(analysis.is_solid_color);
61 pile->PerformSolidColorAnalysis(gfx::Rect(100, 0, 100, 100), 1.0, &analysis);
62 EXPECT_TRUE(analysis.is_solid_color);
63 EXPECT_EQ(analysis.solid_color, solid_color);
65 // Boundaries should be clipped.
66 analysis.is_solid_color = false;
67 pile->PerformSolidColorAnalysis(gfx::Rect(350, 0, 100, 100), 1.0, &analysis);
68 EXPECT_TRUE(analysis.is_solid_color);
69 EXPECT_EQ(analysis.solid_color, solid_color);
71 analysis.is_solid_color = false;
72 pile->PerformSolidColorAnalysis(gfx::Rect(0, 350, 100, 100), 1.0, &analysis);
73 EXPECT_TRUE(analysis.is_solid_color);
74 EXPECT_EQ(analysis.solid_color, solid_color);
76 analysis.is_solid_color = false;
77 pile->PerformSolidColorAnalysis(gfx::Rect(350, 350, 100, 100), 1.0,
78 &analysis);
79 EXPECT_TRUE(analysis.is_solid_color);
80 EXPECT_EQ(analysis.solid_color, solid_color);
83 TEST(PicturePileImplTest, AnalyzeIsSolidScaled) {
84 gfx::Size tile_size(100, 100);
85 gfx::Size layer_bounds(400, 400);
87 scoped_ptr<FakePicturePile> recording_source =
88 FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
90 SkColor solid_color = SkColorSetARGB(255, 12, 23, 34);
91 SkPaint solid_paint;
92 solid_paint.setColor(solid_color);
94 SkColor non_solid_color = SkColorSetARGB(128, 45, 56, 67);
95 SkPaint non_solid_paint;
96 non_solid_paint.setColor(non_solid_color);
98 recording_source->add_draw_rect_with_paint(gfx::Rect(0, 0, 400, 400),
99 solid_paint);
100 recording_source->Rerecord();
102 scoped_refptr<FakePicturePileImpl> pile =
103 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
105 // Ensure everything is solid.
106 for (int y = 0; y <= 30; y += 10) {
107 for (int x = 0; x <= 30; x += 10) {
108 RasterSource::SolidColorAnalysis analysis;
109 gfx::Rect rect(x, y, 10, 10);
110 pile->PerformSolidColorAnalysis(rect, 0.1f, &analysis);
111 EXPECT_TRUE(analysis.is_solid_color) << rect.ToString();
112 EXPECT_EQ(analysis.solid_color, solid_color) << rect.ToString();
116 // Add one non-solid pixel and recreate the raster source.
117 recording_source->add_draw_rect_with_paint(gfx::Rect(50, 50, 1, 1),
118 non_solid_paint);
119 recording_source->Rerecord();
120 pile = FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
122 RasterSource::SolidColorAnalysis analysis;
123 pile->PerformSolidColorAnalysis(gfx::Rect(0, 0, 10, 10), 0.1f, &analysis);
124 EXPECT_FALSE(analysis.is_solid_color);
126 pile->PerformSolidColorAnalysis(gfx::Rect(10, 0, 10, 10), 0.1f, &analysis);
127 EXPECT_TRUE(analysis.is_solid_color);
128 EXPECT_EQ(analysis.solid_color, solid_color);
130 // Boundaries should be clipped.
131 analysis.is_solid_color = false;
132 pile->PerformSolidColorAnalysis(gfx::Rect(35, 0, 10, 10), 0.1f, &analysis);
133 EXPECT_TRUE(analysis.is_solid_color);
134 EXPECT_EQ(analysis.solid_color, solid_color);
136 analysis.is_solid_color = false;
137 pile->PerformSolidColorAnalysis(gfx::Rect(0, 35, 10, 10), 0.1f, &analysis);
138 EXPECT_TRUE(analysis.is_solid_color);
139 EXPECT_EQ(analysis.solid_color, solid_color);
141 analysis.is_solid_color = false;
142 pile->PerformSolidColorAnalysis(gfx::Rect(35, 35, 10, 10), 0.1f, &analysis);
143 EXPECT_TRUE(analysis.is_solid_color);
144 EXPECT_EQ(analysis.solid_color, solid_color);
147 TEST(PicturePileImplTest, AnalyzeIsSolidEmpty) {
148 gfx::Size tile_size(100, 100);
149 gfx::Size layer_bounds(400, 400);
151 scoped_refptr<FakePicturePileImpl> pile =
152 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
153 RasterSource::SolidColorAnalysis analysis;
154 EXPECT_FALSE(analysis.is_solid_color);
156 pile->PerformSolidColorAnalysis(gfx::Rect(0, 0, 400, 400), 1.f, &analysis);
158 EXPECT_TRUE(analysis.is_solid_color);
159 EXPECT_EQ(analysis.solid_color, SkColorSetARGB(0, 0, 0, 0));
162 TEST(PicturePileImplTest, PixelRefIteratorDiscardableRefsOneTile) {
163 gfx::Size tile_size(256, 256);
164 gfx::Size layer_bounds(512, 512);
166 scoped_ptr<FakePicturePile> recording_source =
167 FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
169 SkBitmap discardable_bitmap[2][2];
170 CreateBitmap(gfx::Size(32, 32), "discardable", &discardable_bitmap[0][0]);
171 CreateBitmap(gfx::Size(32, 32), "discardable", &discardable_bitmap[0][1]);
172 CreateBitmap(gfx::Size(32, 32), "discardable", &discardable_bitmap[1][1]);
174 // Discardable pixel refs are found in the following cells:
175 // |---|---|
176 // | x | x |
177 // |---|---|
178 // | | x |
179 // |---|---|
180 recording_source->add_draw_bitmap(discardable_bitmap[0][0], gfx::Point(0, 0));
181 recording_source->add_draw_bitmap(discardable_bitmap[0][1],
182 gfx::Point(260, 0));
183 recording_source->add_draw_bitmap(discardable_bitmap[1][1],
184 gfx::Point(260, 260));
185 recording_source->SetGatherPixelRefs(true);
186 recording_source->Rerecord();
188 scoped_refptr<FakePicturePileImpl> pile =
189 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
191 // Tile sized iterators. These should find only one pixel ref.
193 PicturePileImpl::PixelRefIterator iterator(
194 gfx::Rect(0, 0, 256, 256), 1.0, pile.get());
195 EXPECT_TRUE(iterator);
196 EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef());
197 EXPECT_FALSE(++iterator);
200 PicturePileImpl::PixelRefIterator iterator(
201 gfx::Rect(0, 0, 512, 512), 2.0, pile.get());
202 EXPECT_TRUE(iterator);
203 EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef());
204 EXPECT_FALSE(++iterator);
207 PicturePileImpl::PixelRefIterator iterator(
208 gfx::Rect(0, 0, 128, 128), 0.5, pile.get());
209 EXPECT_TRUE(iterator);
210 EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef());
211 EXPECT_FALSE(++iterator);
213 // Shifted tile sized iterators. These should find only one pixel ref.
215 PicturePileImpl::PixelRefIterator iterator(
216 gfx::Rect(260, 260, 256, 256), 1.0, pile.get());
217 EXPECT_TRUE(iterator);
218 EXPECT_TRUE(*iterator == discardable_bitmap[1][1].pixelRef());
219 EXPECT_FALSE(++iterator);
222 PicturePileImpl::PixelRefIterator iterator(
223 gfx::Rect(520, 520, 512, 512), 2.0, pile.get());
224 EXPECT_TRUE(iterator);
225 EXPECT_TRUE(*iterator == discardable_bitmap[1][1].pixelRef());
226 EXPECT_FALSE(++iterator);
229 PicturePileImpl::PixelRefIterator iterator(
230 gfx::Rect(130, 130, 128, 128), 0.5, pile.get());
231 EXPECT_TRUE(iterator);
232 EXPECT_TRUE(*iterator == discardable_bitmap[1][1].pixelRef());
233 EXPECT_FALSE(++iterator);
235 // Ensure there's no discardable pixel refs in the empty cell
237 PicturePileImpl::PixelRefIterator iterator(
238 gfx::Rect(0, 256, 256, 256), 1.0, pile.get());
239 EXPECT_FALSE(iterator);
241 // Layer sized iterators. These should find three pixel ref.
243 PicturePileImpl::PixelRefIterator iterator(
244 gfx::Rect(0, 0, 512, 512), 1.0, pile.get());
245 EXPECT_TRUE(iterator);
246 EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef());
247 EXPECT_TRUE(++iterator);
248 EXPECT_TRUE(*iterator == discardable_bitmap[0][1].pixelRef());
249 EXPECT_TRUE(++iterator);
250 EXPECT_TRUE(*iterator == discardable_bitmap[1][1].pixelRef());
251 EXPECT_FALSE(++iterator);
254 PicturePileImpl::PixelRefIterator iterator(
255 gfx::Rect(0, 0, 1024, 1024), 2.0, pile.get());
256 EXPECT_TRUE(iterator);
257 EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef());
258 EXPECT_TRUE(++iterator);
259 EXPECT_TRUE(*iterator == discardable_bitmap[0][1].pixelRef());
260 EXPECT_TRUE(++iterator);
261 EXPECT_TRUE(*iterator == discardable_bitmap[1][1].pixelRef());
262 EXPECT_FALSE(++iterator);
265 PicturePileImpl::PixelRefIterator iterator(
266 gfx::Rect(0, 0, 256, 256), 0.5, pile.get());
267 EXPECT_TRUE(iterator);
268 EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef());
269 EXPECT_TRUE(++iterator);
270 EXPECT_TRUE(*iterator == discardable_bitmap[0][1].pixelRef());
271 EXPECT_TRUE(++iterator);
272 EXPECT_TRUE(*iterator == discardable_bitmap[1][1].pixelRef());
273 EXPECT_FALSE(++iterator);
276 // Copy test.
277 PicturePileImpl::PixelRefIterator iterator(
278 gfx::Rect(0, 0, 512, 512), 1.0, pile.get());
279 EXPECT_TRUE(iterator);
280 EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef());
281 EXPECT_TRUE(++iterator);
282 EXPECT_TRUE(*iterator == discardable_bitmap[0][1].pixelRef());
284 // copy now points to the same spot as iterator,
285 // but both can be incremented independently.
286 PicturePileImpl::PixelRefIterator copy = iterator;
287 EXPECT_TRUE(++iterator);
288 EXPECT_TRUE(*iterator == discardable_bitmap[1][1].pixelRef());
289 EXPECT_FALSE(++iterator);
291 EXPECT_TRUE(copy);
292 EXPECT_TRUE(*copy == discardable_bitmap[0][1].pixelRef());
293 EXPECT_TRUE(++copy);
294 EXPECT_TRUE(*copy == discardable_bitmap[1][1].pixelRef());
295 EXPECT_FALSE(++copy);
298 TEST(PicturePileImplTest, RasterFullContents) {
299 gfx::Size tile_size(1000, 1000);
300 gfx::Size layer_bounds(3, 5);
301 float contents_scale = 1.5f;
302 float raster_divisions = 2.f;
304 scoped_ptr<FakePicturePile> recording_source =
305 FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
306 recording_source->SetBackgroundColor(SK_ColorBLACK);
307 recording_source->SetIsSolidColor(false);
308 recording_source->SetRequiresClear(false);
309 recording_source->SetClearCanvasWithDebugColor(false);
311 // Because the caller sets content opaque, it also promises that it
312 // has at least filled in layer_bounds opaquely.
313 SkPaint white_paint;
314 white_paint.setColor(SK_ColorWHITE);
315 recording_source->add_draw_rect_with_paint(gfx::Rect(layer_bounds),
316 white_paint);
318 recording_source->SetMinContentsScale(contents_scale);
319 recording_source->Rerecord();
321 scoped_refptr<FakePicturePileImpl> pile =
322 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
324 gfx::Size content_bounds(
325 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale)));
327 // Simulate drawing into different tiles at different offsets.
328 int step_x = std::ceil(content_bounds.width() / raster_divisions);
329 int step_y = std::ceil(content_bounds.height() / raster_divisions);
330 for (int offset_x = 0; offset_x < content_bounds.width();
331 offset_x += step_x) {
332 for (int offset_y = 0; offset_y < content_bounds.height();
333 offset_y += step_y) {
334 gfx::Rect content_rect(offset_x, offset_y, step_x, step_y);
335 content_rect.Intersect(gfx::Rect(content_bounds));
337 // Simulate a canvas rect larger than the content rect. Every pixel
338 // up to one pixel outside the content rect is guaranteed to be opaque.
339 // Outside of that is undefined.
340 gfx::Rect canvas_rect(content_rect);
341 canvas_rect.Inset(0, 0, -1, -1);
343 SkBitmap bitmap;
344 bitmap.allocN32Pixels(canvas_rect.width(), canvas_rect.height());
345 SkCanvas canvas(bitmap);
346 canvas.clear(SK_ColorTRANSPARENT);
348 pile->PlaybackToCanvas(&canvas, canvas_rect, canvas_rect, contents_scale);
350 SkColor* pixels = reinterpret_cast<SkColor*>(bitmap.getPixels());
351 int num_pixels = bitmap.width() * bitmap.height();
352 bool all_white = true;
353 for (int i = 0; i < num_pixels; ++i) {
354 EXPECT_EQ(SkColorGetA(pixels[i]), 255u);
355 all_white &= (SkColorGetR(pixels[i]) == 255);
356 all_white &= (SkColorGetG(pixels[i]) == 255);
357 all_white &= (SkColorGetB(pixels[i]) == 255);
360 // If the canvas doesn't extend past the edge of the content,
361 // it should be entirely white. Otherwise, the edge of the content
362 // will be non-white.
363 EXPECT_EQ(all_white, gfx::Rect(content_bounds).Contains(canvas_rect));
368 TEST(PicturePileImpl, RasterContentsTransparent) {
369 gfx::Size tile_size(1000, 1000);
370 gfx::Size layer_bounds(5, 3);
371 float contents_scale = 0.5f;
373 scoped_ptr<FakePicturePile> recording_source =
374 FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
375 recording_source->SetBackgroundColor(SK_ColorTRANSPARENT);
376 recording_source->SetRequiresClear(true);
377 recording_source->SetMinContentsScale(contents_scale);
378 recording_source->SetClearCanvasWithDebugColor(false);
379 recording_source->Rerecord();
381 scoped_refptr<FakePicturePileImpl> pile =
382 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
383 gfx::Size content_bounds(
384 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale)));
386 gfx::Rect canvas_rect(content_bounds);
387 canvas_rect.Inset(0, 0, -1, -1);
389 SkBitmap bitmap;
390 bitmap.allocN32Pixels(canvas_rect.width(), canvas_rect.height());
391 SkCanvas canvas(bitmap);
393 pile->PlaybackToCanvas(&canvas, canvas_rect, canvas_rect, contents_scale);
395 SkColor* pixels = reinterpret_cast<SkColor*>(bitmap.getPixels());
396 int num_pixels = bitmap.width() * bitmap.height();
397 for (int i = 0; i < num_pixels; ++i) {
398 EXPECT_EQ(SkColorGetA(pixels[i]), 0u);
402 class OverlapTest : public ::testing::TestWithParam<float> {
403 public:
404 static float MinContentsScale() { return 1.f / 4.f; }
407 TEST_P(OverlapTest, NoOverlap) {
408 gfx::Size tile_size(10, 10);
409 gfx::Size layer_bounds(30, 30);
410 gfx::Size bigger_than_layer_bounds(300, 300);
411 float contents_scale = GetParam();
412 // Pick an opaque color to not have to deal with premultiplication off-by-one.
413 SkColor test_color = SkColorSetARGB(255, 45, 56, 67);
415 scoped_ptr<FakePicturePile> recording_source =
416 FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
417 recording_source->SetBackgroundColor(SK_ColorTRANSPARENT);
418 recording_source->SetRequiresClear(true);
419 recording_source->SetMinContentsScale(MinContentsScale());
420 recording_source->SetClearCanvasWithDebugColor(true);
422 SkPaint color_paint;
423 color_paint.setColor(test_color);
424 // Additive paint, so that if two paints overlap, the color will change.
425 color_paint.setXfermodeMode(SkXfermode::kPlus_Mode);
426 // Paint outside the layer to make sure that blending works.
427 recording_source->add_draw_rect_with_paint(
428 gfx::RectF(bigger_than_layer_bounds), color_paint);
429 recording_source->Rerecord();
431 scoped_refptr<FakePicturePileImpl> pile =
432 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
433 gfx::Size content_bounds(
434 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale)));
436 SkBitmap bitmap;
437 bitmap.allocN32Pixels(content_bounds.width(), content_bounds.height());
438 SkCanvas canvas(bitmap);
440 pile->PlaybackToCanvas(&canvas, gfx::Rect(content_bounds),
441 gfx::Rect(content_bounds), contents_scale);
443 for (int y = 0; y < bitmap.height(); y++) {
444 for (int x = 0; x < bitmap.width(); x++) {
445 SkColor color = bitmap.getColor(x, y);
446 EXPECT_EQ(SkColorGetR(test_color), SkColorGetR(color)) << "x: " << x
447 << ", y: " << y;
448 EXPECT_EQ(SkColorGetG(test_color), SkColorGetG(color)) << "x: " << x
449 << ", y: " << y;
450 EXPECT_EQ(SkColorGetB(test_color), SkColorGetB(color)) << "x: " << x
451 << ", y: " << y;
452 EXPECT_EQ(SkColorGetA(test_color), SkColorGetA(color)) << "x: " << x
453 << ", y: " << y;
454 if (test_color != color)
455 break;
460 INSTANTIATE_TEST_CASE_P(PicturePileImpl,
461 OverlapTest,
462 ::testing::Values(1.f, 0.873f, 1.f / 4.f, 4.f));
464 TEST(PicturePileImplTest, PixelRefIteratorBorders) {
465 // 3 tile width / 1 tile height pile
466 gfx::Size tile_size(128, 128);
467 gfx::Size layer_bounds(320, 128);
469 // Fake picture pile uses a tile grid the size of the tile. So,
470 // any iteration that intersects with a tile will return all pixel refs
471 // inside of it.
472 scoped_ptr<FakePicturePile> recording_source =
473 FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
474 recording_source->SetMinContentsScale(0.5f);
476 // Bitmaps 0-2 are exactly on tiles 0-2, so that they overlap the borders
477 // of adjacent tiles.
478 gfx::Rect bitmap_rects[] = {
479 recording_source->tiling().TileBounds(0, 0),
480 recording_source->tiling().TileBounds(1, 0),
481 recording_source->tiling().TileBounds(2, 0),
483 SkBitmap discardable_bitmap[arraysize(bitmap_rects)];
485 for (size_t i = 0; i < arraysize(bitmap_rects); ++i) {
486 CreateBitmap(bitmap_rects[i].size(), "discardable", &discardable_bitmap[i]);
487 recording_source->add_draw_bitmap(discardable_bitmap[i],
488 bitmap_rects[i].origin());
491 recording_source->SetGatherPixelRefs(true);
492 recording_source->Rerecord();
494 scoped_refptr<FakePicturePileImpl> pile =
495 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
497 // Sanity check that bitmaps 0-2 intersect the borders of their adjacent
498 // tiles, but not the actual tiles.
499 EXPECT_TRUE(
500 bitmap_rects[0].Intersects(pile->tiling().TileBoundsWithBorder(1, 0)));
501 EXPECT_FALSE(bitmap_rects[0].Intersects(pile->tiling().TileBounds(1, 0)));
502 EXPECT_TRUE(
503 bitmap_rects[1].Intersects(pile->tiling().TileBoundsWithBorder(0, 0)));
504 EXPECT_FALSE(bitmap_rects[1].Intersects(pile->tiling().TileBounds(0, 0)));
505 EXPECT_TRUE(
506 bitmap_rects[1].Intersects(pile->tiling().TileBoundsWithBorder(2, 0)));
507 EXPECT_FALSE(bitmap_rects[1].Intersects(pile->tiling().TileBounds(2, 0)));
508 EXPECT_TRUE(
509 bitmap_rects[2].Intersects(pile->tiling().TileBoundsWithBorder(1, 0)));
510 EXPECT_FALSE(bitmap_rects[2].Intersects(pile->tiling().TileBounds(1, 0)));
512 // Tile-sized iterators.
514 // Because tile 0's borders extend onto tile 1, it will include both
515 // bitmap 0 and 1. However, it should *not* include bitmap 2.
516 PicturePileImpl::PixelRefIterator iterator(
517 pile->tiling().TileBounds(0, 0), 1.f, pile.get());
518 EXPECT_TRUE(iterator);
519 EXPECT_TRUE(*iterator == discardable_bitmap[0].pixelRef());
520 EXPECT_TRUE(++iterator);
521 EXPECT_TRUE(*iterator == discardable_bitmap[1].pixelRef());
522 EXPECT_FALSE(++iterator);
525 // Tile 1 + borders hits all bitmaps.
526 PicturePileImpl::PixelRefIterator iterator(
527 pile->tiling().TileBounds(1, 0), 1.f, pile.get());
528 EXPECT_TRUE(iterator);
529 EXPECT_TRUE(*iterator == discardable_bitmap[0].pixelRef());
530 EXPECT_TRUE(++iterator);
531 EXPECT_TRUE(*iterator == discardable_bitmap[1].pixelRef());
532 EXPECT_TRUE(++iterator);
533 EXPECT_TRUE(*iterator == discardable_bitmap[2].pixelRef());
534 EXPECT_FALSE(++iterator);
537 // Tile 2 should not include bitmap 0, which is only on tile 0 and the
538 // borders of tile 1.
539 PicturePileImpl::PixelRefIterator iterator(
540 pile->tiling().TileBounds(2, 0), 1.f, pile.get());
541 EXPECT_TRUE(iterator);
542 EXPECT_TRUE(*iterator == discardable_bitmap[1].pixelRef());
543 EXPECT_TRUE(++iterator);
544 EXPECT_TRUE(*iterator == discardable_bitmap[2].pixelRef());
545 EXPECT_FALSE(++iterator);
549 } // namespace
550 } // namespace cc