OLD | NEW |
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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "cc/playback/display_list_raster_source.h" | 7 #include "cc/playback/display_list_raster_source.h" |
8 #include "cc/test/fake_display_list_recording_source.h" | 8 #include "cc/test/fake_display_list_recording_source.h" |
9 #include "cc/test/fake_picture_pile.h" | 9 #include "cc/test/fake_picture_pile.h" |
10 #include "cc/test/fake_picture_pile_impl.h" | 10 #include "cc/test/fake_picture_pile_impl.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 gfx::Size grid_cell_size(128, 128); | 154 gfx::Size grid_cell_size(128, 128); |
155 gfx::Rect recorded_viewport(0, 0, 256, 256); | 155 gfx::Rect recorded_viewport(0, 0, 256, 256); |
156 | 156 |
157 scoped_ptr<TypeParam> recording_source = | 157 scoped_ptr<TypeParam> recording_source = |
158 CreateRecordingSource<TypeParam>(recorded_viewport, grid_cell_size); | 158 CreateRecordingSource<TypeParam>(recorded_viewport, grid_cell_size); |
159 | 159 |
160 SkPaint simple_paint; | 160 SkPaint simple_paint; |
161 simple_paint.setColor(SkColorSetARGB(255, 12, 23, 34)); | 161 simple_paint.setColor(SkColorSetARGB(255, 12, 23, 34)); |
162 | 162 |
163 SkBitmap non_discardable_bitmap; | 163 SkBitmap non_discardable_bitmap; |
164 CreateBitmap(gfx::Size(128, 128), "notdiscardable", &non_discardable_bitmap); | 164 non_discardable_bitmap.allocN32Pixels(128, 128); |
| 165 non_discardable_bitmap.setImmutable(); |
165 | 166 |
166 recording_source->add_draw_rect_with_paint(gfx::Rect(0, 0, 256, 256), | 167 recording_source->add_draw_rect_with_paint(gfx::Rect(0, 0, 256, 256), |
167 simple_paint); | 168 simple_paint); |
168 recording_source->add_draw_rect_with_paint(gfx::Rect(128, 128, 512, 512), | 169 recording_source->add_draw_rect_with_paint(gfx::Rect(128, 128, 512, 512), |
169 simple_paint); | 170 simple_paint); |
170 recording_source->add_draw_rect_with_paint(gfx::Rect(512, 0, 256, 256), | 171 recording_source->add_draw_rect_with_paint(gfx::Rect(512, 0, 256, 256), |
171 simple_paint); | 172 simple_paint); |
172 recording_source->add_draw_rect_with_paint(gfx::Rect(0, 512, 256, 256), | 173 recording_source->add_draw_rect_with_paint(gfx::Rect(0, 512, 256, 256), |
173 simple_paint); | 174 simple_paint); |
174 recording_source->add_draw_bitmap(non_discardable_bitmap, gfx::Point(128, 0)); | 175 recording_source->add_draw_bitmap(non_discardable_bitmap, gfx::Point(128, 0)); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 } | 235 } |
235 | 236 |
236 TYPED_TEST(RecordingSourceTest, DiscardablePixelRefs) { | 237 TYPED_TEST(RecordingSourceTest, DiscardablePixelRefs) { |
237 gfx::Size grid_cell_size(128, 128); | 238 gfx::Size grid_cell_size(128, 128); |
238 gfx::Rect recorded_viewport(0, 0, 256, 256); | 239 gfx::Rect recorded_viewport(0, 0, 256, 256); |
239 | 240 |
240 scoped_ptr<TypeParam> recording_source = | 241 scoped_ptr<TypeParam> recording_source = |
241 CreateRecordingSource<TypeParam>(recorded_viewport, grid_cell_size); | 242 CreateRecordingSource<TypeParam>(recorded_viewport, grid_cell_size); |
242 | 243 |
243 SkBitmap discardable_bitmap[2][2]; | 244 SkBitmap discardable_bitmap[2][2]; |
244 CreateBitmap(gfx::Size(32, 32), "discardable", &discardable_bitmap[0][0]); | 245 CreateDiscardableBitmap(gfx::Size(32, 32), &discardable_bitmap[0][0]); |
245 CreateBitmap(gfx::Size(32, 32), "discardable", &discardable_bitmap[1][0]); | 246 CreateDiscardableBitmap(gfx::Size(32, 32), &discardable_bitmap[1][0]); |
246 CreateBitmap(gfx::Size(32, 32), "discardable", &discardable_bitmap[1][1]); | 247 CreateDiscardableBitmap(gfx::Size(32, 32), &discardable_bitmap[1][1]); |
247 | 248 |
248 // Discardable pixel refs are found in the following cells: | 249 // Discardable pixel refs are found in the following cells: |
249 // |---|---| | 250 // |---|---| |
250 // | x | | | 251 // | x | | |
251 // |---|---| | 252 // |---|---| |
252 // | x | x | | 253 // | x | x | |
253 // |---|---| | 254 // |---|---| |
254 recording_source->add_draw_bitmap(discardable_bitmap[0][0], gfx::Point(0, 0)); | 255 recording_source->add_draw_bitmap(discardable_bitmap[0][0], gfx::Point(0, 0)); |
255 recording_source->add_draw_bitmap(discardable_bitmap[1][0], | 256 recording_source->add_draw_bitmap(discardable_bitmap[1][0], |
256 gfx::Point(0, 130)); | 257 gfx::Point(0, 130)); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 } | 371 } |
371 | 372 |
372 TYPED_TEST(RecordingSourceTest, DiscardablePixelRefsBaseNonDiscardable) { | 373 TYPED_TEST(RecordingSourceTest, DiscardablePixelRefsBaseNonDiscardable) { |
373 gfx::Size grid_cell_size(256, 256); | 374 gfx::Size grid_cell_size(256, 256); |
374 gfx::Rect recorded_viewport(0, 0, 512, 512); | 375 gfx::Rect recorded_viewport(0, 0, 512, 512); |
375 | 376 |
376 scoped_ptr<TypeParam> recording_source = | 377 scoped_ptr<TypeParam> recording_source = |
377 CreateRecordingSource<TypeParam>(recorded_viewport, grid_cell_size); | 378 CreateRecordingSource<TypeParam>(recorded_viewport, grid_cell_size); |
378 | 379 |
379 SkBitmap non_discardable_bitmap; | 380 SkBitmap non_discardable_bitmap; |
380 CreateBitmap(gfx::Size(512, 512), "notdiscardable", &non_discardable_bitmap); | 381 non_discardable_bitmap.allocN32Pixels(512, 512); |
| 382 non_discardable_bitmap.setImmutable(); |
381 | 383 |
382 SkBitmap discardable_bitmap[2][2]; | 384 SkBitmap discardable_bitmap[2][2]; |
383 CreateBitmap(gfx::Size(128, 128), "discardable", &discardable_bitmap[0][0]); | 385 CreateDiscardableBitmap(gfx::Size(128, 128), &discardable_bitmap[0][0]); |
384 CreateBitmap(gfx::Size(128, 128), "discardable", &discardable_bitmap[0][1]); | 386 CreateDiscardableBitmap(gfx::Size(128, 128), &discardable_bitmap[0][1]); |
385 CreateBitmap(gfx::Size(128, 128), "discardable", &discardable_bitmap[1][1]); | 387 CreateDiscardableBitmap(gfx::Size(128, 128), &discardable_bitmap[1][1]); |
386 | 388 |
387 // One large non-discardable bitmap covers the whole grid. | 389 // One large non-discardable bitmap covers the whole grid. |
388 // Discardable pixel refs are found in the following cells: | 390 // Discardable pixel refs are found in the following cells: |
389 // |---|---| | 391 // |---|---| |
390 // | x | x | | 392 // | x | x | |
391 // |---|---| | 393 // |---|---| |
392 // | | x | | 394 // | | x | |
393 // |---|---| | 395 // |---|---| |
394 recording_source->add_draw_bitmap(non_discardable_bitmap, gfx::Point(0, 0)); | 396 recording_source->add_draw_bitmap(non_discardable_bitmap, gfx::Point(0, 0)); |
395 recording_source->add_draw_bitmap(discardable_bitmap[0][0], gfx::Point(0, 0)); | 397 recording_source->add_draw_bitmap(discardable_bitmap[0][0], gfx::Point(0, 0)); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); | 506 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); |
505 EXPECT_EQ(gfx::RectF(260, 0, 128, 128).ToString(), | 507 EXPECT_EQ(gfx::RectF(260, 0, 128, 128).ToString(), |
506 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect).ToString()); | 508 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect).ToString()); |
507 EXPECT_EQ(gfx::RectF(260, 260, 128, 128).ToString(), | 509 EXPECT_EQ(gfx::RectF(260, 260, 128, 128).ToString(), |
508 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect).ToString()); | 510 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect).ToString()); |
509 } | 511 } |
510 } | 512 } |
511 | 513 |
512 } // namespace | 514 } // namespace |
513 } // namespace cc | 515 } // namespace cc |
OLD | NEW |