Chromium Code Reviews| Index: cc/playback/display_item_list_unittest.cc |
| diff --git a/cc/playback/display_item_list_unittest.cc b/cc/playback/display_item_list_unittest.cc |
| index 9196dfcc52e2df34f98657bc7c608678c72232f0..dcc2d05038925f54052af082e5d6cb593360a83b 100644 |
| --- a/cc/playback/display_item_list_unittest.cc |
| +++ b/cc/playback/display_item_list_unittest.cc |
| @@ -11,6 +11,9 @@ |
| #include "base/memory/ptr_util.h" |
| #include "cc/output/filter_operation.h" |
| #include "cc/output/filter_operations.h" |
| +#include "cc/paint/paint_canvas.h" |
| +#include "cc/paint/paint_flags.h" |
| +#include "cc/paint/paint_recorder.h" |
| #include "cc/playback/clip_display_item.h" |
| #include "cc/playback/clip_path_display_item.h" |
| #include "cc/playback/compositing_display_item.h" |
| @@ -28,14 +31,11 @@ |
| #include "testing/gmock/include/gmock/gmock.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| #include "third_party/skia/include/core/SkBitmap.h" |
| -#include "third_party/skia/include/core/SkCanvas.h" |
| #include "third_party/skia/include/core/SkColor.h" |
| -#include "third_party/skia/include/core/SkPictureRecorder.h" |
| #include "third_party/skia/include/core/SkSurface.h" |
| #include "third_party/skia/include/effects/SkColorMatrixFilter.h" |
| #include "third_party/skia/include/effects/SkImageSource.h" |
| -#include "third_party/skia/include/utils/SkPictureUtils.h" |
| #include "ui/gfx/geometry/rect.h" |
| #include "ui/gfx/geometry/rect_conversions.h" |
| #include "ui/gfx/skia_util.h" |
| @@ -50,24 +50,25 @@ scoped_refptr<DisplayItemList> CreateDefaultList() { |
| return DisplayItemList::Create(DisplayItemListSettings()); |
| } |
| -sk_sp<const SkPicture> CreateRectPicture(const gfx::Rect& bounds) { |
| - SkPictureRecorder recorder; |
| - SkCanvas* canvas = recorder.beginRecording(bounds.width(), bounds.height()); |
| +sk_sp<const PaintRecord> CreateRectPicture(const gfx::Rect& bounds) { |
| + PaintRecorder recorder; |
| + PaintCanvas* canvas = |
| + recorder.beginRecording(bounds.width(), bounds.height()); |
| canvas->drawRect( |
| SkRect::MakeXYWH(bounds.x(), bounds.y(), bounds.width(), bounds.height()), |
| - SkPaint()); |
| + PaintFlags()); |
| return recorder.finishRecordingAsPicture(); |
| } |
| void AppendFirstSerializationTestPicture(scoped_refptr<DisplayItemList> list, |
| const gfx::Size& layer_size) { |
| gfx::PointF offset(2.f, 3.f); |
| - SkPictureRecorder recorder; |
| + PaintRecorder recorder; |
| - SkPaint red_paint; |
| + PaintFlags red_paint; |
| red_paint.setColor(SK_ColorRED); |
| - SkCanvas* canvas = recorder.beginRecording(SkRect::MakeXYWH( |
| + PaintCanvas* canvas = recorder.beginRecording(SkRect::MakeXYWH( |
| offset.x(), offset.y(), layer_size.width(), layer_size.height())); |
| canvas->translate(offset.x(), offset.y()); |
| canvas->drawRectCoords(0.f, 0.f, 4.f, 4.f, red_paint); |
| @@ -78,12 +79,12 @@ void AppendFirstSerializationTestPicture(scoped_refptr<DisplayItemList> list, |
| void AppendSecondSerializationTestPicture(scoped_refptr<DisplayItemList> list, |
| const gfx::Size& layer_size) { |
| gfx::PointF offset(2.f, 2.f); |
| - SkPictureRecorder recorder; |
| + PaintRecorder recorder; |
| - SkPaint blue_paint; |
| + PaintFlags blue_paint; |
| blue_paint.setColor(SK_ColorBLUE); |
| - SkCanvas* canvas = recorder.beginRecording(SkRect::MakeXYWH( |
| + PaintCanvas* canvas = recorder.beginRecording(SkRect::MakeXYWH( |
| offset.x(), offset.y(), layer_size.width(), layer_size.height())); |
| canvas->translate(offset.x(), offset.y()); |
| canvas->drawRectCoords(3.f, 3.f, 7.f, 7.f, blue_paint); |
| @@ -289,10 +290,10 @@ TEST(DisplayItemListTest, SerializeTransformItem) { |
| TEST(DisplayItemListTest, SingleDrawingItem) { |
| gfx::Rect layer_rect(100, 100); |
| - SkPictureRecorder recorder; |
| - SkPaint blue_paint; |
| + PaintRecorder recorder; |
| + PaintFlags blue_paint; |
| blue_paint.setColor(SK_ColorBLUE); |
| - SkPaint red_paint; |
| + PaintFlags red_paint; |
| red_paint.setColor(SK_ColorRED); |
| unsigned char pixels[4 * 100 * 100] = {0}; |
| DisplayItemListSettings settings; |
| @@ -301,7 +302,7 @@ TEST(DisplayItemListTest, SingleDrawingItem) { |
| gfx::PointF offset(8.f, 9.f); |
| gfx::RectF recording_rect(offset, gfx::SizeF(layer_rect.size())); |
| - SkCanvas* canvas = |
| + PaintCanvas* canvas = |
| recorder.beginRecording(gfx::RectFToSkRect(recording_rect)); |
| canvas->translate(offset.x(), offset.y()); |
| canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint); |
| @@ -316,7 +317,7 @@ TEST(DisplayItemListTest, SingleDrawingItem) { |
| SkImageInfo info = |
| SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); |
| expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); |
| - SkCanvas expected_canvas(expected_bitmap); |
| + PaintCanvas expected_canvas(expected_bitmap); |
|
danakj
2017/01/20 23:34:13
This should stay SkCanvas right
enne (OOO)
2017/01/24 01:51:27
Good catch, thanks.
|
| expected_canvas.clipRect(gfx::RectToSkRect(layer_rect)); |
| expected_canvas.drawRectCoords(0.f + offset.x(), 0.f + offset.y(), |
| 60.f + offset.x(), 60.f + offset.y(), |
| @@ -330,10 +331,10 @@ TEST(DisplayItemListTest, SingleDrawingItem) { |
| TEST(DisplayItemListTest, ClipItem) { |
| gfx::Rect layer_rect(100, 100); |
| - SkPictureRecorder recorder; |
| - SkPaint blue_paint; |
| + PaintRecorder recorder; |
| + PaintFlags blue_paint; |
| blue_paint.setColor(SK_ColorBLUE); |
| - SkPaint red_paint; |
| + PaintFlags red_paint; |
| red_paint.setColor(SK_ColorRED); |
| unsigned char pixels[4 * 100 * 100] = {0}; |
| DisplayItemListSettings settings; |
| @@ -342,7 +343,7 @@ TEST(DisplayItemListTest, ClipItem) { |
| gfx::PointF first_offset(8.f, 9.f); |
| gfx::RectF first_recording_rect(first_offset, gfx::SizeF(layer_rect.size())); |
| - SkCanvas* canvas = |
| + PaintCanvas* canvas = |
| recorder.beginRecording(gfx::RectFToSkRect(first_recording_rect)); |
| canvas->translate(first_offset.x(), first_offset.y()); |
| canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint); |
| @@ -372,7 +373,7 @@ TEST(DisplayItemListTest, ClipItem) { |
| SkImageInfo info = |
| SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); |
| expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); |
| - SkCanvas expected_canvas(expected_bitmap); |
| + PaintCanvas expected_canvas(expected_bitmap); |
|
danakj
2017/01/20 23:34:13
same
|
| expected_canvas.clipRect(gfx::RectToSkRect(layer_rect)); |
| expected_canvas.drawRectCoords(0.f + first_offset.x(), 0.f + first_offset.y(), |
| 60.f + first_offset.x(), |
| @@ -387,10 +388,10 @@ TEST(DisplayItemListTest, ClipItem) { |
| TEST(DisplayItemListTest, TransformItem) { |
| gfx::Rect layer_rect(100, 100); |
| - SkPictureRecorder recorder; |
| - SkPaint blue_paint; |
| + PaintRecorder recorder; |
| + PaintFlags blue_paint; |
| blue_paint.setColor(SK_ColorBLUE); |
| - SkPaint red_paint; |
| + PaintFlags red_paint; |
| red_paint.setColor(SK_ColorRED); |
| unsigned char pixels[4 * 100 * 100] = {0}; |
| DisplayItemListSettings settings; |
| @@ -399,7 +400,7 @@ TEST(DisplayItemListTest, TransformItem) { |
| gfx::PointF first_offset(8.f, 9.f); |
| gfx::RectF first_recording_rect(first_offset, gfx::SizeF(layer_rect.size())); |
| - SkCanvas* canvas = |
| + PaintCanvas* canvas = |
| recorder.beginRecording(gfx::RectFToSkRect(first_recording_rect)); |
| canvas->translate(first_offset.x(), first_offset.y()); |
| canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint); |
| @@ -429,7 +430,7 @@ TEST(DisplayItemListTest, TransformItem) { |
| SkImageInfo info = |
| SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); |
| expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); |
| - SkCanvas expected_canvas(expected_bitmap); |
| + PaintCanvas expected_canvas(expected_bitmap); |
|
danakj
2017/01/20 23:34:13
same
|
| expected_canvas.clipRect(gfx::RectToSkRect(layer_rect)); |
| expected_canvas.drawRectCoords(0.f + first_offset.x(), 0.f + first_offset.y(), |
| 60.f + first_offset.x(), |
| @@ -450,7 +451,7 @@ TEST(DisplayItemListTest, FilterItem) { |
| DisplayItemList::Create(DisplayItemListSettings()); |
| sk_sp<SkSurface> source_surface = SkSurface::MakeRasterN32Premul(50, 50); |
| - SkCanvas* source_canvas = source_surface->getCanvas(); |
| + PaintCanvas* source_canvas = source_surface->getCanvas(); |
| source_canvas->clear(SkColorSetRGB(128, 128, 128)); |
| sk_sp<SkImage> source_image = source_surface->makeImageSnapshot(); |
| @@ -474,12 +475,12 @@ TEST(DisplayItemListTest, FilterItem) { |
| // Include a rect drawing so that filter is actually applied to something. |
| { |
| - SkPictureRecorder recorder; |
| + PaintRecorder recorder; |
| - SkPaint red_paint; |
| + PaintFlags red_paint; |
| red_paint.setColor(SK_ColorRED); |
| - SkCanvas* canvas = recorder.beginRecording( |
| + PaintCanvas* canvas = recorder.beginRecording( |
| SkRect::MakeXYWH(0, 0, layer_rect.width(), layer_rect.height())); |
| canvas->drawRectCoords(filter_bounds.x(), filter_bounds.y(), |
| filter_bounds.right(), filter_bounds.bottom(), |
| @@ -495,12 +496,12 @@ TEST(DisplayItemListTest, FilterItem) { |
| SkBitmap expected_bitmap; |
| unsigned char expected_pixels[4 * 100 * 100] = {0}; |
| - SkPaint paint; |
| + PaintFlags paint; |
| paint.setColor(SkColorSetRGB(64, 64, 64)); |
| SkImageInfo info = |
| SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); |
| expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); |
| - SkCanvas expected_canvas(expected_bitmap); |
| + PaintCanvas expected_canvas(expected_bitmap); |
|
danakj
2017/01/20 23:34:13
same
|
| expected_canvas.drawRect(RectFToSkRect(filter_bounds), paint); |
| EXPECT_EQ(0, memcmp(pixels, expected_pixels, 4 * 100 * 100)); |
| @@ -508,10 +509,10 @@ TEST(DisplayItemListTest, FilterItem) { |
| TEST(DisplayItemListTest, CompactingItems) { |
| gfx::Rect layer_rect(100, 100); |
| - SkPictureRecorder recorder; |
| - SkPaint blue_paint; |
| + PaintRecorder recorder; |
| + PaintFlags blue_paint; |
| blue_paint.setColor(SK_ColorBLUE); |
| - SkPaint red_paint; |
| + PaintFlags red_paint; |
| red_paint.setColor(SK_ColorRED); |
| unsigned char pixels[4 * 100 * 100] = {0}; |
| @@ -522,12 +523,12 @@ TEST(DisplayItemListTest, CompactingItems) { |
| scoped_refptr<DisplayItemList> list_without_caching = |
| DisplayItemList::Create(no_caching_settings); |
| - SkCanvas* canvas = |
| + PaintCanvas* canvas = |
| recorder.beginRecording(gfx::RectFToSkRect(recording_rect)); |
| canvas->translate(offset.x(), offset.y()); |
| canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint); |
| canvas->drawRectCoords(50.f, 50.f, 75.f, 75.f, blue_paint); |
| - sk_sp<SkPicture> picture = recorder.finishRecordingAsPicture(); |
| + sk_sp<PaintRecord> picture = recorder.finishRecordingAsPicture(); |
| list_without_caching->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
| kVisualRect, picture); |
| list_without_caching->Finalize(); |
| @@ -547,21 +548,21 @@ TEST(DisplayItemListTest, CompactingItems) { |
| } |
| TEST(DisplayItemListTest, ApproximateMemoryUsage) { |
| - const int kNumCommandsInTestSkPicture = 1000; |
| + const int kNumCommandsInTestPaintRecord = 1000; |
| scoped_refptr<DisplayItemList> list; |
| size_t memory_usage; |
| - // Make an SkPicture whose size is known. |
| + // Make an PaintRecord whose size is known. |
|
danakj
2017/01/20 23:34:13
a
|
| gfx::Rect layer_rect(100, 100); |
| - SkPictureRecorder recorder; |
| - SkPaint blue_paint; |
| + PaintRecorder recorder; |
| + PaintFlags blue_paint; |
| blue_paint.setColor(SK_ColorBLUE); |
| - SkCanvas* canvas = recorder.beginRecording(gfx::RectToSkRect(layer_rect)); |
| - for (int i = 0; i < kNumCommandsInTestSkPicture; i++) |
| + PaintCanvas* canvas = recorder.beginRecording(gfx::RectToSkRect(layer_rect)); |
| + for (int i = 0; i < kNumCommandsInTestPaintRecord; i++) |
| canvas->drawPaint(blue_paint); |
| - sk_sp<SkPicture> picture = recorder.finishRecordingAsPicture(); |
| + sk_sp<PaintRecord> picture = recorder.finishRecordingAsPicture(); |
| size_t picture_size = SkPictureUtils::ApproximateBytesUsed(picture.get()); |
| - ASSERT_GE(picture_size, kNumCommandsInTestSkPicture * sizeof(blue_paint)); |
| + ASSERT_GE(picture_size, kNumCommandsInTestPaintRecord * sizeof(blue_paint)); |
| // Using a cached picture, we should get about the right size. |
| DisplayItemListSettings caching_settings; |