Revert "Fix broken channel icon in chrome://help on CrOS" and try again
[chromium-blink-merge.git] / cc / playback / recording_source_unittest.cc
blob107c0f0e769580a347d150c923b196e62ae1343b
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
3 // found in the LICENSE file.
5 #include <vector>
7 #include "cc/playback/display_list_raster_source.h"
8 #include "cc/test/fake_display_list_recording_source.h"
9 #include "cc/test/fake_picture_pile.h"
10 #include "cc/test/fake_picture_pile_impl.h"
11 #include "cc/test/skia_common.h"
12 #include "testing/gtest/include/gtest/gtest.h"
14 namespace cc {
15 namespace {
17 template <class T>
18 scoped_ptr<T> CreateRecordingSource(const gfx::Rect& viewport,
19 const gfx::Size& grid_cell_size);
21 template <>
22 scoped_ptr<FakePicturePile> CreateRecordingSource<FakePicturePile>(
23 const gfx::Rect& viewport,
24 const gfx::Size& grid_cell_size) {
25 return FakePicturePile::CreateFilledPile(grid_cell_size, viewport.size());
28 template <>
29 scoped_ptr<FakeDisplayListRecordingSource> CreateRecordingSource<
30 FakeDisplayListRecordingSource>(const gfx::Rect& viewport,
31 const gfx::Size& grid_cell_size) {
32 gfx::Rect layer_rect(viewport.right(), viewport.bottom());
33 scoped_ptr<FakeDisplayListRecordingSource> recording_source =
34 FakeDisplayListRecordingSource::CreateRecordingSource(viewport,
35 layer_rect.size());
36 recording_source->SetGridCellSize(grid_cell_size);
38 return recording_source.Pass();
41 template <class T>
42 scoped_refptr<RasterSource> CreateRasterSource(T* recording_source);
44 template <>
45 scoped_refptr<RasterSource> CreateRasterSource(
46 FakePicturePile* recording_source) {
47 return FakePicturePileImpl::CreateFromPile(recording_source, nullptr);
50 template <>
51 scoped_refptr<RasterSource> CreateRasterSource(
52 FakeDisplayListRecordingSource* recording_source) {
53 bool can_use_lcd_text = true;
54 return DisplayListRasterSource::CreateFromDisplayListRecordingSource(
55 recording_source, can_use_lcd_text);
58 template <typename T>
59 class RecordingSourceTest : public testing::Test {};
61 using testing::Types;
63 typedef Types<FakePicturePile, FakeDisplayListRecordingSource>
64 RecordingSourceImplementations;
66 TYPED_TEST_CASE(RecordingSourceTest, RecordingSourceImplementations);
68 TYPED_TEST(RecordingSourceTest, NoGatherPixelRefEmptyPixelRefs) {
69 gfx::Size grid_cell_size(128, 128);
70 gfx::Rect recorded_viewport(0, 0, 256, 256);
72 scoped_ptr<TypeParam> recording_source =
73 CreateRecordingSource<TypeParam>(recorded_viewport, grid_cell_size);
74 recording_source->SetGatherPixelRefs(false);
75 recording_source->Rerecord();
77 scoped_refptr<RasterSource> raster_source =
78 CreateRasterSource<TypeParam>(recording_source.get());
80 // If recording source do not gather pixel ref, raster source is not going to
81 // get pixel refs.
83 std::vector<skia::PositionPixelRef> pixel_refs;
84 raster_source->GatherPixelRefs(recorded_viewport, 1.0, &pixel_refs);
85 EXPECT_TRUE(pixel_refs.empty());
89 TYPED_TEST(RecordingSourceTest, EmptyPixelRefs) {
90 gfx::Size grid_cell_size(128, 128);
91 gfx::Rect recorded_viewport(0, 0, 256, 256);
93 scoped_ptr<TypeParam> recording_source =
94 CreateRecordingSource<TypeParam>(recorded_viewport, grid_cell_size);
95 recording_source->SetGatherPixelRefs(true);
96 recording_source->Rerecord();
98 scoped_refptr<RasterSource> raster_source =
99 CreateRasterSource<TypeParam>(recording_source.get());
101 // Tile sized iterators.
103 std::vector<skia::PositionPixelRef> pixel_refs;
104 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 128, 128), 1.0, &pixel_refs);
105 EXPECT_TRUE(pixel_refs.empty());
108 std::vector<skia::PositionPixelRef> pixel_refs;
109 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 256, 256), 2.0, &pixel_refs);
110 EXPECT_TRUE(pixel_refs.empty());
113 std::vector<skia::PositionPixelRef> pixel_refs;
114 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 64, 64), 0.5, &pixel_refs);
115 EXPECT_TRUE(pixel_refs.empty());
117 // Shifted tile sized iterators.
119 std::vector<skia::PositionPixelRef> pixel_refs;
120 raster_source->GatherPixelRefs(gfx::Rect(140, 140, 128, 128), 1.0,
121 &pixel_refs);
122 EXPECT_TRUE(pixel_refs.empty());
125 std::vector<skia::PositionPixelRef> pixel_refs;
126 raster_source->GatherPixelRefs(gfx::Rect(280, 280, 256, 256), 2.0,
127 &pixel_refs);
128 EXPECT_TRUE(pixel_refs.empty());
131 std::vector<skia::PositionPixelRef> pixel_refs;
132 raster_source->GatherPixelRefs(gfx::Rect(70, 70, 64, 64), 0.5, &pixel_refs);
133 EXPECT_TRUE(pixel_refs.empty());
135 // Layer sized iterators.
137 std::vector<skia::PositionPixelRef> pixel_refs;
138 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 256, 256), 1.0, &pixel_refs);
139 EXPECT_TRUE(pixel_refs.empty());
142 std::vector<skia::PositionPixelRef> pixel_refs;
143 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 512, 512), 2.0, &pixel_refs);
144 EXPECT_TRUE(pixel_refs.empty());
147 std::vector<skia::PositionPixelRef> pixel_refs;
148 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 128, 128), 0.5, &pixel_refs);
149 EXPECT_TRUE(pixel_refs.empty());
153 TYPED_TEST(RecordingSourceTest, NoDiscardablePixelRefs) {
154 gfx::Size grid_cell_size(128, 128);
155 gfx::Rect recorded_viewport(0, 0, 256, 256);
157 scoped_ptr<TypeParam> recording_source =
158 CreateRecordingSource<TypeParam>(recorded_viewport, grid_cell_size);
160 SkPaint simple_paint;
161 simple_paint.setColor(SkColorSetARGB(255, 12, 23, 34));
163 SkBitmap non_discardable_bitmap;
164 non_discardable_bitmap.allocN32Pixels(128, 128);
165 non_discardable_bitmap.setImmutable();
167 recording_source->add_draw_rect_with_paint(gfx::Rect(0, 0, 256, 256),
168 simple_paint);
169 recording_source->add_draw_rect_with_paint(gfx::Rect(128, 128, 512, 512),
170 simple_paint);
171 recording_source->add_draw_rect_with_paint(gfx::Rect(512, 0, 256, 256),
172 simple_paint);
173 recording_source->add_draw_rect_with_paint(gfx::Rect(0, 512, 256, 256),
174 simple_paint);
175 recording_source->add_draw_bitmap(non_discardable_bitmap, gfx::Point(128, 0));
176 recording_source->add_draw_bitmap(non_discardable_bitmap, gfx::Point(0, 128));
177 recording_source->add_draw_bitmap(non_discardable_bitmap,
178 gfx::Point(150, 150));
179 recording_source->SetGatherPixelRefs(true);
180 recording_source->Rerecord();
182 scoped_refptr<RasterSource> raster_source =
183 CreateRasterSource<TypeParam>(recording_source.get());
185 // Tile sized iterators.
187 std::vector<skia::PositionPixelRef> pixel_refs;
188 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 128, 128), 1.0, &pixel_refs);
189 EXPECT_TRUE(pixel_refs.empty());
192 std::vector<skia::PositionPixelRef> pixel_refs;
193 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 256, 256), 2.0, &pixel_refs);
194 EXPECT_TRUE(pixel_refs.empty());
197 std::vector<skia::PositionPixelRef> pixel_refs;
198 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 64, 64), 0.5, &pixel_refs);
199 EXPECT_TRUE(pixel_refs.empty());
201 // Shifted tile sized iterators.
203 std::vector<skia::PositionPixelRef> pixel_refs;
204 raster_source->GatherPixelRefs(gfx::Rect(140, 140, 128, 128), 1.0,
205 &pixel_refs);
206 EXPECT_TRUE(pixel_refs.empty());
209 std::vector<skia::PositionPixelRef> pixel_refs;
210 raster_source->GatherPixelRefs(gfx::Rect(280, 280, 256, 256), 2.0,
211 &pixel_refs);
212 EXPECT_TRUE(pixel_refs.empty());
215 std::vector<skia::PositionPixelRef> pixel_refs;
216 raster_source->GatherPixelRefs(gfx::Rect(70, 70, 64, 64), 0.5, &pixel_refs);
217 EXPECT_TRUE(pixel_refs.empty());
219 // Layer sized iterators.
221 std::vector<skia::PositionPixelRef> pixel_refs;
222 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 256, 256), 1.0, &pixel_refs);
223 EXPECT_TRUE(pixel_refs.empty());
226 std::vector<skia::PositionPixelRef> pixel_refs;
227 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 512, 512), 2.0, &pixel_refs);
228 EXPECT_TRUE(pixel_refs.empty());
231 std::vector<skia::PositionPixelRef> pixel_refs;
232 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 128, 128), 0.5, &pixel_refs);
233 EXPECT_TRUE(pixel_refs.empty());
237 TYPED_TEST(RecordingSourceTest, DiscardablePixelRefs) {
238 gfx::Size grid_cell_size(128, 128);
239 gfx::Rect recorded_viewport(0, 0, 256, 256);
241 scoped_ptr<TypeParam> recording_source =
242 CreateRecordingSource<TypeParam>(recorded_viewport, grid_cell_size);
244 SkBitmap discardable_bitmap[2][2];
245 CreateDiscardableBitmap(gfx::Size(32, 32), &discardable_bitmap[0][0]);
246 CreateDiscardableBitmap(gfx::Size(32, 32), &discardable_bitmap[1][0]);
247 CreateDiscardableBitmap(gfx::Size(32, 32), &discardable_bitmap[1][1]);
249 // Discardable pixel refs are found in the following cells:
250 // |---|---|
251 // | x | |
252 // |---|---|
253 // | x | x |
254 // |---|---|
255 recording_source->add_draw_bitmap(discardable_bitmap[0][0], gfx::Point(0, 0));
256 recording_source->add_draw_bitmap(discardable_bitmap[1][0],
257 gfx::Point(0, 130));
258 recording_source->add_draw_bitmap(discardable_bitmap[1][1],
259 gfx::Point(140, 140));
260 recording_source->SetGatherPixelRefs(true);
261 recording_source->Rerecord();
263 scoped_refptr<RasterSource> raster_source =
264 CreateRasterSource<TypeParam>(recording_source.get());
266 // Tile sized iterators. These should find only one pixel ref.
268 std::vector<skia::PositionPixelRef> pixel_refs;
269 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 128, 128), 1.0, &pixel_refs);
270 EXPECT_EQ(1u, pixel_refs.size());
271 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[0][0].pixelRef());
272 EXPECT_EQ(gfx::RectF(32, 32).ToString(),
273 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString());
276 std::vector<skia::PositionPixelRef> pixel_refs;
277 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 256, 256), 2.0, &pixel_refs);
278 EXPECT_EQ(1u, pixel_refs.size());
279 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[0][0].pixelRef());
280 EXPECT_EQ(gfx::RectF(32, 32).ToString(),
281 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString());
284 std::vector<skia::PositionPixelRef> pixel_refs;
285 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 64, 64), 0.5, &pixel_refs);
286 EXPECT_EQ(1u, pixel_refs.size());
287 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[0][0].pixelRef());
288 EXPECT_EQ(gfx::RectF(32, 32).ToString(),
289 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString());
292 // Shifted tile sized iterators. These should find only one pixel ref.
294 std::vector<skia::PositionPixelRef> pixel_refs;
295 raster_source->GatherPixelRefs(gfx::Rect(140, 140, 128, 128), 1.0,
296 &pixel_refs);
297 EXPECT_EQ(1u, pixel_refs.size());
298 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[1][1].pixelRef());
299 EXPECT_EQ(gfx::RectF(140, 140, 32, 32).ToString(),
300 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString());
303 std::vector<skia::PositionPixelRef> pixel_refs;
304 raster_source->GatherPixelRefs(gfx::Rect(280, 280, 256, 256), 2.0,
305 &pixel_refs);
306 EXPECT_EQ(1u, pixel_refs.size());
307 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[1][1].pixelRef());
308 EXPECT_EQ(gfx::RectF(140, 140, 32, 32).ToString(),
309 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString());
312 std::vector<skia::PositionPixelRef> pixel_refs;
313 raster_source->GatherPixelRefs(gfx::Rect(70, 70, 64, 64), 0.5, &pixel_refs);
314 EXPECT_EQ(1u, pixel_refs.size());
315 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[1][1].pixelRef());
316 EXPECT_EQ(gfx::RectF(140, 140, 32, 32).ToString(),
317 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString());
320 // Ensure there's no discardable pixel refs in the empty cell
322 std::vector<skia::PositionPixelRef> pixel_refs;
323 raster_source->GatherPixelRefs(gfx::Rect(140, 0, 128, 128), 1.0,
324 &pixel_refs);
325 EXPECT_TRUE(pixel_refs.empty());
328 // Layer sized iterators. These should find all 3 pixel refs.
330 std::vector<skia::PositionPixelRef> pixel_refs;
331 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 256, 256), 1.0, &pixel_refs);
332 EXPECT_EQ(3u, pixel_refs.size());
333 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[0][0].pixelRef());
334 EXPECT_TRUE(pixel_refs[1].pixel_ref == discardable_bitmap[1][0].pixelRef());
335 EXPECT_TRUE(pixel_refs[2].pixel_ref == discardable_bitmap[1][1].pixelRef());
336 EXPECT_EQ(gfx::RectF(32, 32).ToString(),
337 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString());
338 EXPECT_EQ(gfx::RectF(0, 130, 32, 32).ToString(),
339 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect).ToString());
340 EXPECT_EQ(gfx::RectF(140, 140, 32, 32).ToString(),
341 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect).ToString());
344 std::vector<skia::PositionPixelRef> pixel_refs;
345 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 512, 512), 2.0, &pixel_refs);
346 EXPECT_EQ(3u, pixel_refs.size());
347 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[0][0].pixelRef());
348 EXPECT_TRUE(pixel_refs[1].pixel_ref == discardable_bitmap[1][0].pixelRef());
349 EXPECT_TRUE(pixel_refs[2].pixel_ref == discardable_bitmap[1][1].pixelRef());
350 EXPECT_EQ(gfx::RectF(32, 32).ToString(),
351 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString());
352 EXPECT_EQ(gfx::RectF(0, 130, 32, 32).ToString(),
353 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect).ToString());
354 EXPECT_EQ(gfx::RectF(140, 140, 32, 32).ToString(),
355 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect).ToString());
358 std::vector<skia::PositionPixelRef> pixel_refs;
359 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 128, 128), 0.5, &pixel_refs);
360 EXPECT_EQ(3u, pixel_refs.size());
361 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[0][0].pixelRef());
362 EXPECT_TRUE(pixel_refs[1].pixel_ref == discardable_bitmap[1][0].pixelRef());
363 EXPECT_TRUE(pixel_refs[2].pixel_ref == discardable_bitmap[1][1].pixelRef());
364 EXPECT_EQ(gfx::RectF(32, 32).ToString(),
365 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString());
366 EXPECT_EQ(gfx::RectF(0, 130, 32, 32).ToString(),
367 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect).ToString());
368 EXPECT_EQ(gfx::RectF(140, 140, 32, 32).ToString(),
369 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect).ToString());
373 TYPED_TEST(RecordingSourceTest, DiscardablePixelRefsBaseNonDiscardable) {
374 gfx::Size grid_cell_size(256, 256);
375 gfx::Rect recorded_viewport(0, 0, 512, 512);
377 scoped_ptr<TypeParam> recording_source =
378 CreateRecordingSource<TypeParam>(recorded_viewport, grid_cell_size);
380 SkBitmap non_discardable_bitmap;
381 non_discardable_bitmap.allocN32Pixels(512, 512);
382 non_discardable_bitmap.setImmutable();
384 SkBitmap discardable_bitmap[2][2];
385 CreateDiscardableBitmap(gfx::Size(128, 128), &discardable_bitmap[0][0]);
386 CreateDiscardableBitmap(gfx::Size(128, 128), &discardable_bitmap[0][1]);
387 CreateDiscardableBitmap(gfx::Size(128, 128), &discardable_bitmap[1][1]);
389 // One large non-discardable bitmap covers the whole grid.
390 // Discardable pixel refs are found in the following cells:
391 // |---|---|
392 // | x | x |
393 // |---|---|
394 // | | x |
395 // |---|---|
396 recording_source->add_draw_bitmap(non_discardable_bitmap, gfx::Point(0, 0));
397 recording_source->add_draw_bitmap(discardable_bitmap[0][0], gfx::Point(0, 0));
398 recording_source->add_draw_bitmap(discardable_bitmap[0][1],
399 gfx::Point(260, 0));
400 recording_source->add_draw_bitmap(discardable_bitmap[1][1],
401 gfx::Point(260, 260));
402 recording_source->SetGatherPixelRefs(true);
403 recording_source->Rerecord();
405 scoped_refptr<RasterSource> raster_source =
406 CreateRasterSource<TypeParam>(recording_source.get());
408 // Tile sized iterators. These should find only one pixel ref.
410 std::vector<skia::PositionPixelRef> pixel_refs;
411 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 256, 256), 1.0, &pixel_refs);
412 EXPECT_EQ(1u, pixel_refs.size());
413 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[0][0].pixelRef());
414 EXPECT_EQ(gfx::RectF(128, 128).ToString(),
415 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString());
418 std::vector<skia::PositionPixelRef> pixel_refs;
419 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 512, 512), 2.0, &pixel_refs);
420 EXPECT_EQ(1u, pixel_refs.size());
421 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[0][0].pixelRef());
422 EXPECT_EQ(gfx::RectF(128, 128).ToString(),
423 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString());
426 std::vector<skia::PositionPixelRef> pixel_refs;
427 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 128, 128), 0.5, &pixel_refs);
428 EXPECT_EQ(1u, pixel_refs.size());
429 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[0][0].pixelRef());
430 EXPECT_EQ(gfx::RectF(128, 128).ToString(),
431 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString());
433 // Shifted tile sized iterators. These should find only one pixel ref.
435 std::vector<skia::PositionPixelRef> pixel_refs;
436 raster_source->GatherPixelRefs(gfx::Rect(260, 260, 256, 256), 1.0,
437 &pixel_refs);
438 EXPECT_EQ(1u, pixel_refs.size());
439 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[1][1].pixelRef());
440 EXPECT_EQ(gfx::RectF(260, 260, 128, 128).ToString(),
441 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString());
444 std::vector<skia::PositionPixelRef> pixel_refs;
445 raster_source->GatherPixelRefs(gfx::Rect(520, 520, 512, 512), 2.0,
446 &pixel_refs);
447 EXPECT_EQ(1u, pixel_refs.size());
448 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[1][1].pixelRef());
449 EXPECT_EQ(gfx::RectF(260, 260, 128, 128).ToString(),
450 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString());
453 std::vector<skia::PositionPixelRef> pixel_refs;
454 raster_source->GatherPixelRefs(gfx::Rect(130, 130, 128, 128), 0.5,
455 &pixel_refs);
456 EXPECT_EQ(1u, pixel_refs.size());
457 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[1][1].pixelRef());
458 EXPECT_EQ(gfx::RectF(260, 260, 128, 128).ToString(),
459 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString());
461 // Ensure there's no discardable pixel refs in the empty cell
463 std::vector<skia::PositionPixelRef> pixel_refs;
464 raster_source->GatherPixelRefs(gfx::Rect(0, 256, 256, 256), 1.0,
465 &pixel_refs);
466 EXPECT_TRUE(pixel_refs.empty());
468 // Layer sized iterators. These should find three pixel ref.
470 std::vector<skia::PositionPixelRef> pixel_refs;
471 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 512, 512), 1.0, &pixel_refs);
472 EXPECT_EQ(3u, pixel_refs.size());
473 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[0][0].pixelRef());
474 EXPECT_TRUE(pixel_refs[1].pixel_ref == discardable_bitmap[0][1].pixelRef());
475 EXPECT_TRUE(pixel_refs[2].pixel_ref == discardable_bitmap[1][1].pixelRef());
476 EXPECT_EQ(gfx::RectF(128, 128).ToString(),
477 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString());
478 EXPECT_EQ(gfx::RectF(260, 0, 128, 128).ToString(),
479 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect).ToString());
480 EXPECT_EQ(gfx::RectF(260, 260, 128, 128).ToString(),
481 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect).ToString());
484 std::vector<skia::PositionPixelRef> pixel_refs;
485 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 1024, 1024), 2.0,
486 &pixel_refs);
487 EXPECT_EQ(3u, pixel_refs.size());
488 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[0][0].pixelRef());
489 EXPECT_TRUE(pixel_refs[1].pixel_ref == discardable_bitmap[0][1].pixelRef());
490 EXPECT_TRUE(pixel_refs[2].pixel_ref == discardable_bitmap[1][1].pixelRef());
491 EXPECT_EQ(gfx::RectF(128, 128).ToString(),
492 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString());
493 EXPECT_EQ(gfx::RectF(260, 0, 128, 128).ToString(),
494 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect).ToString());
495 EXPECT_EQ(gfx::RectF(260, 260, 128, 128).ToString(),
496 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect).ToString());
499 std::vector<skia::PositionPixelRef> pixel_refs;
500 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 256, 256), 0.5, &pixel_refs);
501 EXPECT_EQ(3u, pixel_refs.size());
502 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[0][0].pixelRef());
503 EXPECT_TRUE(pixel_refs[1].pixel_ref == discardable_bitmap[0][1].pixelRef());
504 EXPECT_TRUE(pixel_refs[2].pixel_ref == discardable_bitmap[1][1].pixelRef());
505 EXPECT_EQ(gfx::RectF(128, 128).ToString(),
506 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString());
507 EXPECT_EQ(gfx::RectF(260, 0, 128, 128).ToString(),
508 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect).ToString());
509 EXPECT_EQ(gfx::RectF(260, 260, 128, 128).ToString(),
510 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect).ToString());
514 } // namespace
515 } // namespace cc