| 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 2fdf3b414ccc9580525eddc8bb7e4eb5acd5b6b1..75e8cafed2e794db3c6698fdef00162e0a2b6bad 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"
|
| @@ -24,14 +27,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"
|
| @@ -46,24 +46,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);
|
| @@ -75,10 +76,10 @@ void AppendFirstSerializationTestPicture(scoped_refptr<DisplayItemList> list,
|
|
|
| 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;
|
| @@ -87,7 +88,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);
|
| @@ -116,10 +117,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;
|
| @@ -128,7 +129,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);
|
| @@ -173,10 +174,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;
|
| @@ -185,7 +186,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);
|
| @@ -236,7 +237,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();
|
|
|
| @@ -260,12 +261,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(),
|
| @@ -281,7 +282,7 @@ 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());
|
| @@ -294,10 +295,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};
|
|
|
| @@ -308,12 +309,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();
|
| @@ -333,21 +334,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 a PaintRecord whose size is known.
|
| 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;
|
|
|