Commit 979c57f8 authored by ajuma's avatar ajuma Committed by Commit bot

cc: Implement PictureImageLayer::PaintContentsToDisplayList

This allows PictureImageLayers to be rendered when running with
--enable-slimming-paint.

BUG=448447

Review URL: https://codereview.chromium.org/853463004

Cr-Commit-Position: refs/heads/master@{#311491}
parent f4aadf3f
...@@ -756,6 +756,7 @@ test("cc_unittests") { ...@@ -756,6 +756,7 @@ test("cc_unittests") {
"layers/nine_patch_layer_unittest.cc", "layers/nine_patch_layer_unittest.cc",
"layers/painted_scrollbar_layer_impl_unittest.cc", "layers/painted_scrollbar_layer_impl_unittest.cc",
"layers/picture_image_layer_impl_unittest.cc", "layers/picture_image_layer_impl_unittest.cc",
"layers/picture_image_layer_unittest.cc",
"layers/picture_layer_impl_unittest.cc", "layers/picture_layer_impl_unittest.cc",
"layers/picture_layer_unittest.cc", "layers/picture_layer_unittest.cc",
"layers/render_surface_unittest.cc", "layers/render_surface_unittest.cc",
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
'layers/nine_patch_layer_unittest.cc', 'layers/nine_patch_layer_unittest.cc',
'layers/painted_scrollbar_layer_impl_unittest.cc', 'layers/painted_scrollbar_layer_impl_unittest.cc',
'layers/picture_image_layer_impl_unittest.cc', 'layers/picture_image_layer_impl_unittest.cc',
'layers/picture_image_layer_unittest.cc',
'layers/picture_layer_impl_unittest.cc', 'layers/picture_layer_impl_unittest.cc',
'layers/picture_layer_unittest.cc', 'layers/picture_layer_unittest.cc',
'layers/render_surface_unittest.cc', 'layers/render_surface_unittest.cc',
......
...@@ -5,7 +5,10 @@ ...@@ -5,7 +5,10 @@
#include "cc/layers/picture_image_layer.h" #include "cc/layers/picture_image_layer.h"
#include "cc/layers/picture_image_layer_impl.h" #include "cc/layers/picture_image_layer_impl.h"
#include "cc/resources/drawing_display_item.h"
#include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkPictureRecorder.h"
#include "ui/gfx/skia_util.h"
namespace cc { namespace cc {
...@@ -63,8 +66,16 @@ void PictureImageLayer::PaintContents( ...@@ -63,8 +66,16 @@ void PictureImageLayer::PaintContents(
scoped_refptr<DisplayItemList> PictureImageLayer::PaintContentsToDisplayList( scoped_refptr<DisplayItemList> PictureImageLayer::PaintContentsToDisplayList(
const gfx::Rect& clip, const gfx::Rect& clip,
GraphicsContextStatus gc_status) { GraphicsContextStatus gc_status) {
NOTIMPLEMENTED(); scoped_refptr<DisplayItemList> display_item_list = DisplayItemList::Create();
return DisplayItemList::Create();
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(gfx::RectToSkRect(clip));
PaintContents(canvas, clip, gc_status);
skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording());
display_item_list->AppendItem(
DrawingDisplayItem::Create(picture, gfx::Point()));
return display_item_list;
} }
bool PictureImageLayer::FillsBoundsCompletely() const { bool PictureImageLayer::FillsBoundsCompletely() const {
......
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cc/layers/picture_image_layer.h"
#include "cc/resources/display_item.h"
#include "cc/test/skia_common.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"
namespace cc {
namespace {
TEST(PictureImageLayerTest, PaintContentsToDisplayList) {
scoped_refptr<PictureImageLayer> layer = PictureImageLayer::Create();
gfx::Rect layer_rect(200, 200);
SkBitmap image_bitmap;
unsigned char image_pixels[4 * 200 * 200] = {0};
SkImageInfo info =
SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height());
image_bitmap.installPixels(info, image_pixels, info.minRowBytes());
SkCanvas image_canvas(image_bitmap);
image_canvas.clear(SK_ColorRED);
SkPaint blue_paint;
blue_paint.setColor(SK_ColorBLUE);
image_canvas.drawRectCoords(0.f, 0.f, 100.f, 100.f, blue_paint);
image_canvas.drawRectCoords(100.f, 100.f, 200.f, 200.f, blue_paint);
layer->SetBitmap(image_bitmap);
layer->SetBounds(gfx::Size(layer_rect.width(), layer_rect.height()));
scoped_refptr<DisplayItemList> display_list =
layer->PaintContentsToDisplayList(
layer_rect, ContentLayerClient::GRAPHICS_CONTEXT_ENABLED);
unsigned char actual_pixels[4 * 200 * 200] = {0};
DrawDisplayList(actual_pixels, layer_rect, display_list);
EXPECT_EQ(0, memcmp(actual_pixels, image_pixels, 4 * 200 * 200));
}
} // namespace
} // namespace cc
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment