Index: sky/engine/core/painting/Canvas.h |
diff --git a/sky/engine/core/painting/Canvas.h b/sky/engine/core/painting/Canvas.h |
index abd325643ec8188ffcf6a0feb467d3ef19f0d020..a4327449bc4fd6f78992e631f846653ef0e5630a 100644 |
--- a/sky/engine/core/painting/Canvas.h |
+++ b/sky/engine/core/painting/Canvas.h |
@@ -15,21 +15,25 @@ |
#include "sky/engine/tonic/float32_list.h" |
#include "sky/engine/wtf/PassRefPtr.h" |
#include "sky/engine/wtf/RefCounted.h" |
+#include "third_party/skia/include/core/SkCanvas.h" |
namespace blink { |
-class Element; |
class CanvasImage; |
class Canvas : public RefCounted<Canvas>, public DartWrappable { |
DEFINE_WRAPPERTYPEINFO(); |
public: |
- Canvas(const FloatSize& size); |
- ~Canvas() override; |
+ static PassRefPtr<Canvas> create(SkCanvas* skCanvas) { |
+ ASSERT(skCanvas); |
+ return adoptRef(new Canvas(skCanvas)); |
+ } |
+ |
+ static PassRefPtr<Canvas> create(PassRefPtr<Canvas> canvas) { |
+ ASSERT(canvas); |
+ return create(canvas->m_canvas); |
+ } |
- // Width/Height define a culling rect which Skia may use for optimizing |
- // out draw calls issued outside the rect. |
- float width() const { return m_size.width(); } |
- float height() const { return m_size.height(); } |
+ ~Canvas() override; |
void save(); |
void saveLayer(const Rect& bounds, const Paint* paint = nullptr); |
@@ -59,15 +63,16 @@ public: |
const Paint* paint); |
SkCanvas* skCanvas() { return m_canvas; } |
+ void clearSkCanvas() { m_canvas = nullptr; } |
abarth-chromium
2015/06/20 00:50:29
How does this mechanism work with the create(PassR
|
+ bool isRecording() const { return m_canvas != nullptr; } |
abarth-chromium
2015/06/20 00:50:29
Does anyone call this function anymore? If not, w
|
protected: |
- PassRefPtr<DisplayList> finishRecording(); |
- |
- bool isRecording() const { return m_canvas; } |
+ Canvas(SkCanvas* skCanvas); |
abarth-chromium
2015/06/20 00:50:29
Please mark one-argument constructors explicit.
|
private: |
- FloatSize m_size; |
- RefPtr<DisplayList> m_displayList; |
+ // The SkCanvas is supplied by a call to SkPictureRecorder::beginRecording, |
+ // which does not transfer ownership. For this reason, we hold a raw |
+ // pointer and manually set the SkCanvas to null in clearSkCanvas. |
SkCanvas* m_canvas; |
}; |