cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / cc / playback / picture_pile_impl_unittest.cc
blob4ea3ba5434d0cb2c1adb1c6a4a2eb59cf568aaea
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(400, 400), solid_paint);
34 recording_source->Rerecord();
36 scoped_refptr<FakePicturePileImpl> pile =
37 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
39 // Ensure everything is solid.
40 for (int y = 0; y <= 300; y += 100) {
41 for (int x = 0; x <= 300; x += 100) {
42 RasterSource::SolidColorAnalysis analysis;
43 gfx::Rect rect(x, y, 100, 100);
44 pile->PerformSolidColorAnalysis(rect, 1.0, &analysis);
45 EXPECT_TRUE(analysis.is_solid_color) << rect.ToString();
46 EXPECT_EQ(analysis.solid_color, solid_color) << rect.ToString();
50 // Add one non-solid pixel and recreate the raster source.
51 recording_source->add_draw_rect_with_paint(gfx::Rect(50, 50, 1, 1),
52 non_solid_paint);
53 recording_source->Rerecord();
54 pile = FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
56 RasterSource::SolidColorAnalysis analysis;
57 pile->PerformSolidColorAnalysis(gfx::Rect(0, 0, 100, 100), 1.0, &analysis);
58 EXPECT_FALSE(analysis.is_solid_color);
60 pile->PerformSolidColorAnalysis(gfx::Rect(100, 0, 100, 100), 1.0, &analysis);
61 EXPECT_TRUE(analysis.is_solid_color);
62 EXPECT_EQ(analysis.solid_color, solid_color);
64 // Boundaries should be clipped.
65 analysis.is_solid_color = false;
66 pile->PerformSolidColorAnalysis(gfx::Rect(350, 0, 100, 100), 1.0, &analysis);
67 EXPECT_TRUE(analysis.is_solid_color);
68 EXPECT_EQ(analysis.solid_color, solid_color);
70 analysis.is_solid_color = false;
71 pile->PerformSolidColorAnalysis(gfx::Rect(0, 350, 100, 100), 1.0, &analysis);
72 EXPECT_TRUE(analysis.is_solid_color);
73 EXPECT_EQ(analysis.solid_color, solid_color);
75 analysis.is_solid_color = false;
76 pile->PerformSolidColorAnalysis(gfx::Rect(350, 350, 100, 100), 1.0,
77 &analysis);
78 EXPECT_TRUE(analysis.is_solid_color);
79 EXPECT_EQ(analysis.solid_color, solid_color);
82 TEST(PicturePileImplTest, AnalyzeIsSolidScaled) {
83 gfx::Size tile_size(100, 100);
84 gfx::Size layer_bounds(400, 400);
86 scoped_ptr<FakePicturePile> recording_source =
87 FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
89 SkColor solid_color = SkColorSetARGB(255, 12, 23, 34);
90 SkPaint solid_paint;
91 solid_paint.setColor(solid_color);
93 SkColor non_solid_color = SkColorSetARGB(128, 45, 56, 67);
94 SkPaint non_solid_paint;
95 non_solid_paint.setColor(non_solid_color);
97 recording_source->add_draw_rect_with_paint(gfx::Rect(400, 400), solid_paint);
98 recording_source->Rerecord();
100 scoped_refptr<FakePicturePileImpl> pile =
101 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
103 // Ensure everything is solid.
104 for (int y = 0; y <= 30; y += 10) {
105 for (int x = 0; x <= 30; x += 10) {
106 RasterSource::SolidColorAnalysis analysis;
107 gfx::Rect rect(x, y, 10, 10);
108 pile->PerformSolidColorAnalysis(rect, 0.1f, &analysis);
109 EXPECT_TRUE(analysis.is_solid_color) << rect.ToString();
110 EXPECT_EQ(analysis.solid_color, solid_color) << rect.ToString();
114 // Add one non-solid pixel and recreate the raster source.
115 recording_source->add_draw_rect_with_paint(gfx::Rect(50, 50, 1, 1),
116 non_solid_paint);
117 recording_source->Rerecord();
118 pile = FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
120 RasterSource::SolidColorAnalysis analysis;
121 pile->PerformSolidColorAnalysis(gfx::Rect(0, 0, 10, 10), 0.1f, &analysis);
122 EXPECT_FALSE(analysis.is_solid_color);
124 pile->PerformSolidColorAnalysis(gfx::Rect(10, 0, 10, 10), 0.1f, &analysis);
125 EXPECT_TRUE(analysis.is_solid_color);
126 EXPECT_EQ(analysis.solid_color, solid_color);
128 // Boundaries should be clipped.
129 analysis.is_solid_color = false;
130 pile->PerformSolidColorAnalysis(gfx::Rect(35, 0, 10, 10), 0.1f, &analysis);
131 EXPECT_TRUE(analysis.is_solid_color);
132 EXPECT_EQ(analysis.solid_color, solid_color);
134 analysis.is_solid_color = false;
135 pile->PerformSolidColorAnalysis(gfx::Rect(0, 35, 10, 10), 0.1f, &analysis);
136 EXPECT_TRUE(analysis.is_solid_color);
137 EXPECT_EQ(analysis.solid_color, solid_color);
139 analysis.is_solid_color = false;
140 pile->PerformSolidColorAnalysis(gfx::Rect(35, 35, 10, 10), 0.1f, &analysis);
141 EXPECT_TRUE(analysis.is_solid_color);
142 EXPECT_EQ(analysis.solid_color, solid_color);
145 TEST(PicturePileImplTest, AnalyzeIsSolidEmpty) {
146 gfx::Size tile_size(100, 100);
147 gfx::Size layer_bounds(400, 400);
149 scoped_refptr<FakePicturePileImpl> pile =
150 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
151 RasterSource::SolidColorAnalysis analysis;
152 EXPECT_FALSE(analysis.is_solid_color);
154 pile->PerformSolidColorAnalysis(gfx::Rect(0, 0, 400, 400), 1.f, &analysis);
156 EXPECT_TRUE(analysis.is_solid_color);
157 EXPECT_EQ(analysis.solid_color, SkColorSetARGB(0, 0, 0, 0));
160 TEST(PicturePileImplTest, PixelRefIteratorDiscardableRefsOneTile) {
161 gfx::Size tile_size(256, 256);
162 gfx::Size layer_bounds(512, 512);
164 scoped_ptr<FakePicturePile> recording_source =
165 FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
167 SkBitmap discardable_bitmap[2][2];
168 CreateDiscardableBitmap(gfx::Size(32, 32), &discardable_bitmap[0][0]);
169 CreateDiscardableBitmap(gfx::Size(32, 32), &discardable_bitmap[0][1]);
170 CreateDiscardableBitmap(gfx::Size(32, 32), &discardable_bitmap[1][1]);
172 // Discardable pixel refs are found in the following cells:
173 // |---|---|
174 // | x | x |
175 // |---|---|
176 // | | x |
177 // |---|---|
178 recording_source->add_draw_bitmap(discardable_bitmap[0][0], gfx::Point(0, 0));
179 recording_source->add_draw_bitmap(discardable_bitmap[0][1],
180 gfx::Point(260, 0));
181 recording_source->add_draw_bitmap(discardable_bitmap[1][1],
182 gfx::Point(260, 260));
183 recording_source->SetGatherPixelRefs(true);
184 recording_source->Rerecord();
186 scoped_refptr<FakePicturePileImpl> pile =
187 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
189 // Tile sized iterators. These should find only one pixel ref.
191 PicturePileImpl::PixelRefIterator iterator(gfx::Rect(0, 0, 256, 256),
192 pile.get());
193 EXPECT_TRUE(iterator);
194 EXPECT_TRUE(iterator->pixel_ref == discardable_bitmap[0][0].pixelRef());
195 EXPECT_EQ(gfx::SkRectToRectF(iterator->pixel_ref_rect).ToString(),
196 gfx::RectF(32, 32).ToString());
197 EXPECT_FALSE(++iterator);
199 // Shifted tile sized iterators. These should find only one pixel ref.
201 PicturePileImpl::PixelRefIterator iterator(gfx::Rect(260, 260, 256, 256),
202 pile.get());
203 EXPECT_TRUE(iterator);
204 EXPECT_TRUE(iterator->pixel_ref == discardable_bitmap[1][1].pixelRef());
205 EXPECT_EQ(gfx::SkRectToRectF(iterator->pixel_ref_rect).ToString(),
206 gfx::RectF(260, 260, 32, 32).ToString());
207 EXPECT_FALSE(++iterator);
209 // Ensure there's no discardable pixel refs in the empty cell
211 PicturePileImpl::PixelRefIterator iterator(gfx::Rect(0, 256, 256, 256),
212 pile.get());
213 EXPECT_FALSE(iterator);
215 // Layer sized iterators. These should find three pixel ref.
217 PicturePileImpl::PixelRefIterator iterator(gfx::Rect(0, 0, 512, 512),
218 pile.get());
219 EXPECT_TRUE(iterator);
220 EXPECT_TRUE(iterator->pixel_ref == discardable_bitmap[0][0].pixelRef());
221 EXPECT_EQ(gfx::SkRectToRectF(iterator->pixel_ref_rect).ToString(),
222 gfx::RectF(32, 32).ToString());
223 EXPECT_TRUE(++iterator);
224 EXPECT_TRUE(iterator->pixel_ref == discardable_bitmap[0][1].pixelRef());
225 EXPECT_EQ(gfx::SkRectToRectF(iterator->pixel_ref_rect).ToString(),
226 gfx::RectF(260, 0, 32, 32).ToString());
227 EXPECT_TRUE(++iterator);
228 EXPECT_TRUE(iterator->pixel_ref == discardable_bitmap[1][1].pixelRef());
229 EXPECT_EQ(gfx::SkRectToRectF(iterator->pixel_ref_rect).ToString(),
230 gfx::RectF(260, 260, 32, 32).ToString());
231 EXPECT_FALSE(++iterator);
235 // Copy test.
236 PicturePileImpl::PixelRefIterator iterator(gfx::Rect(0, 0, 512, 512),
237 pile.get());
238 EXPECT_TRUE(iterator);
239 EXPECT_TRUE(iterator->pixel_ref == discardable_bitmap[0][0].pixelRef());
240 EXPECT_EQ(gfx::RectF(32, 32).ToString(),
241 gfx::SkRectToRectF(iterator->pixel_ref_rect).ToString());
242 EXPECT_TRUE(++iterator);
243 EXPECT_TRUE(iterator->pixel_ref == discardable_bitmap[0][1].pixelRef());
244 EXPECT_EQ(gfx::RectF(260, 0, 32, 32).ToString(),
245 gfx::SkRectToRectF(iterator->pixel_ref_rect).ToString());
247 // copy now points to the same spot as iterator,
248 // but both can be incremented independently.
249 PicturePileImpl::PixelRefIterator copy = iterator;
250 EXPECT_TRUE(++iterator);
251 EXPECT_TRUE(iterator->pixel_ref == discardable_bitmap[1][1].pixelRef());
252 EXPECT_EQ(gfx::RectF(260, 260, 32, 32).ToString(),
253 gfx::SkRectToRectF(iterator->pixel_ref_rect).ToString());
254 EXPECT_FALSE(++iterator);
256 EXPECT_TRUE(copy);
257 EXPECT_TRUE(copy->pixel_ref == discardable_bitmap[0][1].pixelRef());
258 EXPECT_EQ(gfx::RectF(260, 0, 32, 32).ToString(),
259 gfx::SkRectToRectF(copy->pixel_ref_rect).ToString());
260 EXPECT_TRUE(++copy);
261 EXPECT_TRUE(copy->pixel_ref == discardable_bitmap[1][1].pixelRef());
262 EXPECT_EQ(gfx::RectF(260, 260, 32, 32).ToString(),
263 gfx::SkRectToRectF(copy->pixel_ref_rect).ToString());
264 EXPECT_FALSE(++copy);
268 TEST(PicturePileImplTest, RasterFullContents) {
269 gfx::Size tile_size(1000, 1000);
270 gfx::Size layer_bounds(3, 5);
271 float contents_scale = 1.5f;
272 float raster_divisions = 2.f;
274 scoped_ptr<FakePicturePile> recording_source =
275 FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
276 recording_source->SetBackgroundColor(SK_ColorBLACK);
277 recording_source->SetIsSolidColor(false);
278 recording_source->SetRequiresClear(false);
279 recording_source->SetClearCanvasWithDebugColor(false);
281 // Because the caller sets content opaque, it also promises that it
282 // has at least filled in layer_bounds opaquely.
283 SkPaint white_paint;
284 white_paint.setColor(SK_ColorWHITE);
285 recording_source->add_draw_rect_with_paint(gfx::Rect(layer_bounds),
286 white_paint);
288 recording_source->SetMinContentsScale(contents_scale);
289 recording_source->Rerecord();
291 scoped_refptr<FakePicturePileImpl> pile =
292 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
294 gfx::Size content_bounds(
295 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale)));
297 // Simulate drawing into different tiles at different offsets.
298 int step_x = std::ceil(content_bounds.width() / raster_divisions);
299 int step_y = std::ceil(content_bounds.height() / raster_divisions);
300 for (int offset_x = 0; offset_x < content_bounds.width();
301 offset_x += step_x) {
302 for (int offset_y = 0; offset_y < content_bounds.height();
303 offset_y += step_y) {
304 gfx::Rect content_rect(offset_x, offset_y, step_x, step_y);
305 content_rect.Intersect(gfx::Rect(content_bounds));
307 // Simulate a canvas rect larger than the content rect. Every pixel
308 // up to one pixel outside the content rect is guaranteed to be opaque.
309 // Outside of that is undefined.
310 gfx::Rect canvas_rect(content_rect);
311 canvas_rect.Inset(0, 0, -1, -1);
313 SkBitmap bitmap;
314 bitmap.allocN32Pixels(canvas_rect.width(), canvas_rect.height());
315 SkCanvas canvas(bitmap);
316 canvas.clear(SK_ColorTRANSPARENT);
318 pile->PlaybackToCanvas(&canvas, canvas_rect, canvas_rect, contents_scale);
320 SkColor* pixels = reinterpret_cast<SkColor*>(bitmap.getPixels());
321 int num_pixels = bitmap.width() * bitmap.height();
322 bool all_white = true;
323 for (int i = 0; i < num_pixels; ++i) {
324 EXPECT_EQ(SkColorGetA(pixels[i]), 255u);
325 all_white &= (SkColorGetR(pixels[i]) == 255);
326 all_white &= (SkColorGetG(pixels[i]) == 255);
327 all_white &= (SkColorGetB(pixels[i]) == 255);
330 // If the canvas doesn't extend past the edge of the content,
331 // it should be entirely white. Otherwise, the edge of the content
332 // will be non-white.
333 EXPECT_EQ(all_white, gfx::Rect(content_bounds).Contains(canvas_rect));
338 TEST(PicturePileImpl, RasterContentsTransparent) {
339 gfx::Size tile_size(1000, 1000);
340 gfx::Size layer_bounds(5, 3);
341 float contents_scale = 0.5f;
343 scoped_ptr<FakePicturePile> recording_source =
344 FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
345 recording_source->SetBackgroundColor(SK_ColorTRANSPARENT);
346 recording_source->SetRequiresClear(true);
347 recording_source->SetMinContentsScale(contents_scale);
348 recording_source->SetClearCanvasWithDebugColor(false);
349 recording_source->Rerecord();
351 scoped_refptr<FakePicturePileImpl> pile =
352 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
353 gfx::Size content_bounds(
354 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale)));
356 gfx::Rect canvas_rect(content_bounds);
357 canvas_rect.Inset(0, 0, -1, -1);
359 SkBitmap bitmap;
360 bitmap.allocN32Pixels(canvas_rect.width(), canvas_rect.height());
361 SkCanvas canvas(bitmap);
363 pile->PlaybackToCanvas(&canvas, canvas_rect, canvas_rect, contents_scale);
365 SkColor* pixels = reinterpret_cast<SkColor*>(bitmap.getPixels());
366 int num_pixels = bitmap.width() * bitmap.height();
367 for (int i = 0; i < num_pixels; ++i) {
368 EXPECT_EQ(SkColorGetA(pixels[i]), 0u);
372 class OverlapTest : public ::testing::TestWithParam<float> {
373 public:
374 static float MinContentsScale() { return 1.f / 4.f; }
377 TEST_P(OverlapTest, NoOverlap) {
378 gfx::Size tile_size(10, 10);
379 gfx::Size layer_bounds(30, 30);
380 gfx::Size bigger_than_layer_bounds(300, 300);
381 float contents_scale = GetParam();
382 // Pick an opaque color to not have to deal with premultiplication off-by-one.
383 SkColor test_color = SkColorSetARGB(255, 45, 56, 67);
385 scoped_ptr<FakePicturePile> recording_source =
386 FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
387 recording_source->SetBackgroundColor(SK_ColorTRANSPARENT);
388 recording_source->SetRequiresClear(true);
389 recording_source->SetMinContentsScale(MinContentsScale());
390 recording_source->SetClearCanvasWithDebugColor(true);
392 SkPaint color_paint;
393 color_paint.setColor(test_color);
394 // Additive paint, so that if two paints overlap, the color will change.
395 color_paint.setXfermodeMode(SkXfermode::kPlus_Mode);
396 // Paint outside the layer to make sure that blending works.
397 recording_source->add_draw_rect_with_paint(
398 gfx::Rect(bigger_than_layer_bounds), color_paint);
399 recording_source->Rerecord();
401 scoped_refptr<FakePicturePileImpl> pile =
402 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
403 gfx::Size content_bounds(
404 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale)));
406 SkBitmap bitmap;
407 bitmap.allocN32Pixels(content_bounds.width(), content_bounds.height());
408 SkCanvas canvas(bitmap);
410 pile->PlaybackToCanvas(&canvas, gfx::Rect(content_bounds),
411 gfx::Rect(content_bounds), contents_scale);
413 for (int y = 0; y < bitmap.height(); y++) {
414 for (int x = 0; x < bitmap.width(); x++) {
415 SkColor color = bitmap.getColor(x, y);
416 EXPECT_EQ(SkColorGetR(test_color), SkColorGetR(color)) << "x: " << x
417 << ", y: " << y;
418 EXPECT_EQ(SkColorGetG(test_color), SkColorGetG(color)) << "x: " << x
419 << ", y: " << y;
420 EXPECT_EQ(SkColorGetB(test_color), SkColorGetB(color)) << "x: " << x
421 << ", y: " << y;
422 EXPECT_EQ(SkColorGetA(test_color), SkColorGetA(color)) << "x: " << x
423 << ", y: " << y;
424 if (test_color != color)
425 break;
430 INSTANTIATE_TEST_CASE_P(PicturePileImpl,
431 OverlapTest,
432 ::testing::Values(1.f, 0.873f, 1.f / 4.f, 4.f));
434 TEST(PicturePileImplTest, PixelRefIteratorBorders) {
435 // 3 tile width / 1 tile height pile
436 gfx::Size tile_size(128, 128);
437 gfx::Size layer_bounds(320, 128);
439 // Fake picture pile uses a tile grid the size of the tile. So,
440 // any iteration that intersects with a tile will return all pixel refs
441 // inside of it.
442 scoped_ptr<FakePicturePile> recording_source =
443 FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
444 recording_source->SetMinContentsScale(0.5f);
446 // Bitmaps 0-2 are exactly on tiles 0-2, so that they overlap the borders
447 // of adjacent tiles.
448 gfx::Rect bitmap_rects[] = {
449 recording_source->tiling().TileBounds(0, 0),
450 recording_source->tiling().TileBounds(1, 0),
451 recording_source->tiling().TileBounds(2, 0),
453 gfx::RectF expected_rects[] = {
454 gfx::RectF(recording_source->tiling().TileBounds(0, 0)),
455 gfx::RectF(recording_source->tiling().TileBounds(1, 0)),
456 gfx::RectF(recording_source->tiling().TileBounds(2, 0)),
458 SkBitmap discardable_bitmap[arraysize(bitmap_rects)];
460 for (size_t i = 0; i < arraysize(bitmap_rects); ++i) {
461 CreateDiscardableBitmap(bitmap_rects[i].size(), &discardable_bitmap[i]);
462 recording_source->add_draw_bitmap(discardable_bitmap[i],
463 bitmap_rects[i].origin());
466 recording_source->SetGatherPixelRefs(true);
467 recording_source->Rerecord();
469 scoped_refptr<FakePicturePileImpl> pile =
470 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
472 // Sanity check that bitmaps 0-2 intersect the borders of their adjacent
473 // tiles, but not the actual tiles.
474 EXPECT_TRUE(
475 bitmap_rects[0].Intersects(pile->tiling().TileBoundsWithBorder(1, 0)));
476 EXPECT_FALSE(bitmap_rects[0].Intersects(pile->tiling().TileBounds(1, 0)));
477 EXPECT_TRUE(
478 bitmap_rects[1].Intersects(pile->tiling().TileBoundsWithBorder(0, 0)));
479 EXPECT_FALSE(bitmap_rects[1].Intersects(pile->tiling().TileBounds(0, 0)));
480 EXPECT_TRUE(
481 bitmap_rects[1].Intersects(pile->tiling().TileBoundsWithBorder(2, 0)));
482 EXPECT_FALSE(bitmap_rects[1].Intersects(pile->tiling().TileBounds(2, 0)));
483 EXPECT_TRUE(
484 bitmap_rects[2].Intersects(pile->tiling().TileBoundsWithBorder(1, 0)));
485 EXPECT_FALSE(bitmap_rects[2].Intersects(pile->tiling().TileBounds(1, 0)));
487 // Tile-sized iterators.
489 // Because tile 0's borders extend onto tile 1, it will include both
490 // bitmap 0 and 1. However, it should *not* include bitmap 2.
491 PicturePileImpl::PixelRefIterator iterator(pile->tiling().TileBounds(0, 0),
492 pile.get());
493 EXPECT_TRUE(iterator);
494 EXPECT_TRUE(iterator->pixel_ref == discardable_bitmap[0].pixelRef());
495 EXPECT_EQ(expected_rects[0].ToString(),
496 gfx::SkRectToRectF(iterator->pixel_ref_rect).ToString());
497 EXPECT_TRUE(++iterator);
498 EXPECT_TRUE(iterator->pixel_ref == discardable_bitmap[1].pixelRef());
499 EXPECT_EQ(expected_rects[1].ToString(),
500 gfx::SkRectToRectF(iterator->pixel_ref_rect).ToString());
501 EXPECT_FALSE(++iterator);
504 // Tile 1 + borders hits all bitmaps.
505 PicturePileImpl::PixelRefIterator iterator(pile->tiling().TileBounds(1, 0),
506 pile.get());
507 EXPECT_TRUE(iterator);
508 EXPECT_TRUE(iterator->pixel_ref == discardable_bitmap[0].pixelRef());
509 EXPECT_EQ(expected_rects[0].ToString(),
510 gfx::SkRectToRectF(iterator->pixel_ref_rect).ToString());
511 EXPECT_TRUE(++iterator);
512 EXPECT_TRUE(iterator->pixel_ref == discardable_bitmap[1].pixelRef());
513 EXPECT_EQ(expected_rects[1].ToString(),
514 gfx::SkRectToRectF(iterator->pixel_ref_rect).ToString());
515 EXPECT_TRUE(++iterator);
516 EXPECT_TRUE(iterator->pixel_ref == discardable_bitmap[2].pixelRef());
517 EXPECT_EQ(expected_rects[2].ToString(),
518 gfx::SkRectToRectF(iterator->pixel_ref_rect).ToString());
519 EXPECT_FALSE(++iterator);
522 // Tile 2 should not include bitmap 0, which is only on tile 0 and the
523 // borders of tile 1.
524 PicturePileImpl::PixelRefIterator iterator(pile->tiling().TileBounds(2, 0),
525 pile.get());
526 EXPECT_TRUE(iterator);
527 EXPECT_TRUE(iterator->pixel_ref == discardable_bitmap[1].pixelRef());
528 EXPECT_EQ(expected_rects[1].ToString(),
529 gfx::SkRectToRectF(iterator->pixel_ref_rect).ToString());
530 EXPECT_TRUE(++iterator);
531 EXPECT_TRUE(iterator->pixel_ref == discardable_bitmap[2].pixelRef());
532 EXPECT_EQ(expected_rects[2].ToString(),
533 gfx::SkRectToRectF(iterator->pixel_ref_rect).ToString());
534 EXPECT_FALSE(++iterator);
538 } // namespace
539 } // namespace cc