Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(697)

Unified Diff: sky/engine/core/painting/Canvas.h

Issue 1190123003: Decouple Canvas from DisplayList and map Picture and PictureRecorder more directly to their Skia co… (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..d76e3f412b6b933ee629d1c1d980f81b8f19e40d 100644
--- a/sky/engine/core/painting/Canvas.h
+++ b/sky/engine/core/painting/Canvas.h
@@ -15,21 +15,20 @@
#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));
+ }
- // 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 +58,16 @@ public:
const Paint* paint);
SkCanvas* skCanvas() { return m_canvas; }
+ void clearSkCanvas() { m_canvas = nullptr; }
protected:
- PassRefPtr<DisplayList> finishRecording();
-
bool isRecording() const { return m_canvas; }
+ Canvas(SkCanvas* skCanvas);
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;
};

Powered by Google App Engine
This is Rietveld 408576698