| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "cc/test/fake_picture_pile_impl.h" | 6 #include "cc/test/fake_picture_pile_impl.h" |
| 7 #include "cc/test/skia_common.h" | 7 #include "cc/test/skia_common.h" |
| 8 #include "skia/ext/refptr.h" | 8 #include "skia/ext/refptr.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "third_party/skia/include/core/SkPixelRef.h" | 10 #include "third_party/skia/include/core/SkPixelRef.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 FakePicturePile::CreateFilledPile(tile_size, layer_bounds); | 23 FakePicturePile::CreateFilledPile(tile_size, layer_bounds); |
| 24 | 24 |
| 25 SkPaint solid_paint; | 25 SkPaint solid_paint; |
| 26 SkColor solid_color = SkColorSetARGB(255, 12, 23, 34); | 26 SkColor solid_color = SkColorSetARGB(255, 12, 23, 34); |
| 27 solid_paint.setColor(solid_color); | 27 solid_paint.setColor(solid_color); |
| 28 | 28 |
| 29 SkColor non_solid_color = SkColorSetARGB(128, 45, 56, 67); | 29 SkColor non_solid_color = SkColorSetARGB(128, 45, 56, 67); |
| 30 SkPaint non_solid_paint; | 30 SkPaint non_solid_paint; |
| 31 non_solid_paint.setColor(non_solid_color); | 31 non_solid_paint.setColor(non_solid_color); |
| 32 | 32 |
| 33 recording_source->add_draw_rect_with_paint(gfx::Rect(0, 0, 400, 400), | 33 recording_source->add_draw_rect_with_paint(gfx::Rect(400, 400), solid_paint); |
| 34 solid_paint); | |
| 35 recording_source->Rerecord(); | 34 recording_source->Rerecord(); |
| 36 | 35 |
| 37 scoped_refptr<FakePicturePileImpl> pile = | 36 scoped_refptr<FakePicturePileImpl> pile = |
| 38 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr); | 37 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr); |
| 39 | 38 |
| 40 // Ensure everything is solid. | 39 // Ensure everything is solid. |
| 41 for (int y = 0; y <= 300; y += 100) { | 40 for (int y = 0; y <= 300; y += 100) { |
| 42 for (int x = 0; x <= 300; x += 100) { | 41 for (int x = 0; x <= 300; x += 100) { |
| 43 RasterSource::SolidColorAnalysis analysis; | 42 RasterSource::SolidColorAnalysis analysis; |
| 44 gfx::Rect rect(x, y, 100, 100); | 43 gfx::Rect rect(x, y, 100, 100); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 FakePicturePile::CreateFilledPile(tile_size, layer_bounds); | 87 FakePicturePile::CreateFilledPile(tile_size, layer_bounds); |
| 89 | 88 |
| 90 SkColor solid_color = SkColorSetARGB(255, 12, 23, 34); | 89 SkColor solid_color = SkColorSetARGB(255, 12, 23, 34); |
| 91 SkPaint solid_paint; | 90 SkPaint solid_paint; |
| 92 solid_paint.setColor(solid_color); | 91 solid_paint.setColor(solid_color); |
| 93 | 92 |
| 94 SkColor non_solid_color = SkColorSetARGB(128, 45, 56, 67); | 93 SkColor non_solid_color = SkColorSetARGB(128, 45, 56, 67); |
| 95 SkPaint non_solid_paint; | 94 SkPaint non_solid_paint; |
| 96 non_solid_paint.setColor(non_solid_color); | 95 non_solid_paint.setColor(non_solid_color); |
| 97 | 96 |
| 98 recording_source->add_draw_rect_with_paint(gfx::Rect(0, 0, 400, 400), | 97 recording_source->add_draw_rect_with_paint(gfx::Rect(400, 400), solid_paint); |
| 99 solid_paint); | |
| 100 recording_source->Rerecord(); | 98 recording_source->Rerecord(); |
| 101 | 99 |
| 102 scoped_refptr<FakePicturePileImpl> pile = | 100 scoped_refptr<FakePicturePileImpl> pile = |
| 103 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr); | 101 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr); |
| 104 | 102 |
| 105 // Ensure everything is solid. | 103 // Ensure everything is solid. |
| 106 for (int y = 0; y <= 30; y += 10) { | 104 for (int y = 0; y <= 30; y += 10) { |
| 107 for (int x = 0; x <= 30; x += 10) { | 105 for (int x = 0; x <= 30; x += 10) { |
| 108 RasterSource::SolidColorAnalysis analysis; | 106 RasterSource::SolidColorAnalysis analysis; |
| 109 gfx::Rect rect(x, y, 10, 10); | 107 gfx::Rect rect(x, y, 10, 10); |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 recording_source->SetRequiresClear(true); | 388 recording_source->SetRequiresClear(true); |
| 391 recording_source->SetMinContentsScale(MinContentsScale()); | 389 recording_source->SetMinContentsScale(MinContentsScale()); |
| 392 recording_source->SetClearCanvasWithDebugColor(true); | 390 recording_source->SetClearCanvasWithDebugColor(true); |
| 393 | 391 |
| 394 SkPaint color_paint; | 392 SkPaint color_paint; |
| 395 color_paint.setColor(test_color); | 393 color_paint.setColor(test_color); |
| 396 // Additive paint, so that if two paints overlap, the color will change. | 394 // Additive paint, so that if two paints overlap, the color will change. |
| 397 color_paint.setXfermodeMode(SkXfermode::kPlus_Mode); | 395 color_paint.setXfermodeMode(SkXfermode::kPlus_Mode); |
| 398 // Paint outside the layer to make sure that blending works. | 396 // Paint outside the layer to make sure that blending works. |
| 399 recording_source->add_draw_rect_with_paint( | 397 recording_source->add_draw_rect_with_paint( |
| 400 gfx::RectF(bigger_than_layer_bounds), color_paint); | 398 gfx::Rect(bigger_than_layer_bounds), color_paint); |
| 401 recording_source->Rerecord(); | 399 recording_source->Rerecord(); |
| 402 | 400 |
| 403 scoped_refptr<FakePicturePileImpl> pile = | 401 scoped_refptr<FakePicturePileImpl> pile = |
| 404 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr); | 402 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr); |
| 405 gfx::Size content_bounds( | 403 gfx::Size content_bounds( |
| 406 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale))); | 404 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale))); |
| 407 | 405 |
| 408 SkBitmap bitmap; | 406 SkBitmap bitmap; |
| 409 bitmap.allocN32Pixels(content_bounds.width(), content_bounds.height()); | 407 bitmap.allocN32Pixels(content_bounds.width(), content_bounds.height()); |
| 410 SkCanvas canvas(bitmap); | 408 SkCanvas canvas(bitmap); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 EXPECT_TRUE(++iterator); | 530 EXPECT_TRUE(++iterator); |
| 533 EXPECT_TRUE(iterator->pixel_ref == discardable_bitmap[2].pixelRef()); | 531 EXPECT_TRUE(iterator->pixel_ref == discardable_bitmap[2].pixelRef()); |
| 534 EXPECT_EQ(expected_rects[2].ToString(), | 532 EXPECT_EQ(expected_rects[2].ToString(), |
| 535 gfx::SkRectToRectF(iterator->pixel_ref_rect).ToString()); | 533 gfx::SkRectToRectF(iterator->pixel_ref_rect).ToString()); |
| 536 EXPECT_FALSE(++iterator); | 534 EXPECT_FALSE(++iterator); |
| 537 } | 535 } |
| 538 } | 536 } |
| 539 | 537 |
| 540 } // namespace | 538 } // namespace |
| 541 } // namespace cc | 539 } // namespace cc |
| OLD | NEW |