提交 8dd65afb 编写于 作者: I Ian Fischer

Add APIs for dynamic display lists, using SkDrawable and SkPictureRecorder::endRecordingAsDrawable.

R=abarth@chromium.org, abarth@google.com, ianh@google.com

Review URL: https://codereview.chromium.org/1221583003.
上级 783630b6
......@@ -848,6 +848,8 @@ sky_core_files = [
"painting/CanvasPath.h",
"painting/ColorFilter.cpp",
"painting/ColorFilter.h",
"painting/Drawable.cpp",
"painting/Drawable.h",
"painting/DrawLooper.cpp",
"painting/DrawLooper.h",
"painting/DrawLooperAddLayerCallback.cpp",
......@@ -1144,6 +1146,7 @@ core_idl_files = get_path_info([
"loader/ImageDecoderCallback.idl",
"painting/Canvas.idl",
"painting/ColorFilter.idl",
"painting/Drawable.idl",
"painting/DrawLooper.idl",
"painting/DrawLooperAddLayerCallback.idl",
"painting/DrawLooperLayerInfo.idl",
......
......@@ -127,14 +127,6 @@ void Canvas::drawLine(const Point& p1, const Point& p2, const Paint* paint)
m_canvas->drawLine(p1.sk_point.x(), p1.sk_point.y(), p2.sk_point.x(), p2.sk_point.y(), paint->paint());
}
void Canvas::drawPicture(Picture* picture)
{
if (!m_canvas)
return;
ASSERT(picture);
m_canvas->drawPicture(picture->toSkia());
}
void Canvas::drawPaint(const Paint* paint)
{
if (!m_canvas)
......@@ -199,4 +191,20 @@ void Canvas::drawImageRect(const CanvasImage* image, Rect& src, Rect& dst, Paint
m_canvas->drawBitmapRectToRect(image->bitmap(), &src.sk_rect, dst.sk_rect, &paint->paint());
}
void Canvas::drawPicture(Picture* picture)
{
if (!m_canvas)
return;
ASSERT(picture);
m_canvas->drawPicture(picture->toSkia());
}
void Canvas::drawDrawable(Drawable* drawable)
{
if (!m_canvas)
return;
ASSERT(drawable);
m_canvas->drawDrawable(drawable->toSkia());
}
} // namespace blink
......@@ -7,6 +7,7 @@
#include "sky/engine/bindings/exception_state.h"
#include "sky/engine/core/painting/CanvasPath.h"
#include "sky/engine/core/painting/Drawable.h"
#include "sky/engine/core/painting/Offset.h"
#include "sky/engine/core/painting/Paint.h"
#include "sky/engine/core/painting/Picture.h"
......@@ -72,7 +73,6 @@ public:
void clipPath(const CanvasPath* path);
void drawLine(const Point& p1, const Point& p2, const Paint* paint);
void drawPicture(Picture* picture);
void drawPaint(const Paint* paint);
void drawRect(const Rect& rect, const Paint* paint);
void drawRRect(const RRect* rrect, const Paint* paint);
......@@ -81,6 +81,8 @@ public:
void drawPath(const CanvasPath* path, const Paint* paint);
void drawImage(const CanvasImage* image, const Point& p, const Paint* paint);
void drawImageRect(const CanvasImage* image, Rect& src, Rect& dst, Paint* paint);
void drawPicture(Picture* picture);
void drawDrawable(Drawable* drawable);
SkCanvas* skCanvas() { return m_canvas; }
void clearSkCanvas() { m_canvas = nullptr; }
......
......@@ -23,7 +23,6 @@
void clipPath(Path path);
void drawLine(Point p1, Point p2, Paint paint);
void drawPicture(Picture picture);
void drawPaint(Paint paint);
void drawRect(Rect rect, Paint paint);
void drawRRect(RRect rrect, Paint paint);
......@@ -32,4 +31,6 @@
void drawPath(Path path, Paint paint);
void drawImage(Image image, Point p, Paint paint);
void drawImageRect(Image image, Rect src, Rect dst, Paint paint);
void drawPicture(Picture picture);
void drawDrawable(Drawable drawable);
};
// 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 "sky/engine/core/painting/Drawable.h"
#include "sky/engine/core/painting/Picture.h"
namespace blink {
PassRefPtr<Drawable> Drawable::create(PassRefPtr<SkDrawable> skDrawable)
{
ASSERT(skDrawable);
return adoptRef(new Drawable(skDrawable));
}
Drawable::Drawable(PassRefPtr<SkDrawable> skDrawable)
: m_drawable(skDrawable)
{
}
PassRefPtr<Picture> Drawable::newPictureSnapshot()
{
if (!m_drawable)
return nullptr;
return Picture::create(
adoptRef(m_drawable->newPictureSnapshot()));
}
Drawable::~Drawable()
{
}
} // namespace blink
// 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.
#ifndef SKY_ENGINE_CORE_DRAWABLE_PICTURE_H_
#define SKY_ENGINE_CORE_DRAWABLE_PICTURE_H_
#include "sky/engine/core/painting/Picture.h"
#include "sky/engine/tonic/dart_wrappable.h"
#include "sky/engine/wtf/PassRefPtr.h"
#include "sky/engine/wtf/RefCounted.h"
#include "third_party/skia/include/core/SkDrawable.h"
namespace blink {
class Drawable : public RefCounted<Drawable>, public DartWrappable {
DEFINE_WRAPPERTYPEINFO();
public:
static PassRefPtr<Drawable> create(PassRefPtr<SkDrawable> skDrawable);
~Drawable() override;
PassRefPtr<Picture> newPictureSnapshot();
SkDrawable* toSkia() const { return m_drawable.get(); }
private:
explicit Drawable(PassRefPtr<SkDrawable> skDrawable);
RefPtr<SkDrawable> m_drawable;
};
} // namespace blink
#endif // SKY_ENGINE_CORE_DRAWABLE_PICTURE_H_
// 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.
interface Drawable {
Picture newPictureSnapshot();
};
......@@ -4,8 +4,6 @@
#include "sky/engine/core/painting/Picture.h"
#include "base/logging.h"
namespace blink {
PassRefPtr<Picture> Picture::create(PassRefPtr<SkPicture> skPicture)
......
......@@ -21,7 +21,7 @@ public:
SkPicture* toSkia() const { return m_picture.get(); }
private:
Picture(PassRefPtr<SkPicture> skPicture);
explicit Picture(PassRefPtr<SkPicture> skPicture);
RefPtr<SkPicture> m_picture;
};
......
......@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "sky/engine/core/painting/Canvas.h"
#include "sky/engine/core/painting/Drawable.h"
#include "sky/engine/core/painting/Picture.h"
#include "sky/engine/core/painting/PictureRecorder.h"
......@@ -37,6 +38,17 @@ PassRefPtr<Picture> PictureRecorder::endRecording()
return picture.release();
}
PassRefPtr<Drawable> PictureRecorder::endRecordingAsDrawable()
{
if (!isRecording())
return nullptr;
RefPtr<Drawable> drawable = Drawable::create(
adoptRef(m_pictureRecorder->endRecordingAsDrawable()));
m_canvas->clearSkCanvas();
m_canvas = nullptr;
return drawable.release();
}
void PictureRecorder::set_canvas(PassRefPtr<Canvas> canvas) { m_canvas = canvas; }
} // namespace blink
......@@ -12,8 +12,9 @@
namespace blink {
class Picture;
class Canvas;
class Drawable;
class Picture;
class PictureRecorder : public RefCounted<PictureRecorder>,
public DartWrappable {
......@@ -29,6 +30,7 @@ public:
// PassRefPtr<Canvas> beginRecording(double width, double height);
SkCanvas* beginRecording(double width, double height);
PassRefPtr<Picture> endRecording();
PassRefPtr<Drawable> endRecordingAsDrawable();
bool isRecording();
void set_canvas(PassRefPtr<Canvas> canvas);
......
......@@ -6,4 +6,5 @@
] interface PictureRecorder {
readonly attribute boolean isRecording;
Picture endRecording();
Drawable endRecordingAsDrawable();
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册