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

Unified Diff: include/record/SkRecording.h

Issue 233053005: Add a focused public API for src/record. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: wrap in EXPERIMENTAL Created 6 years, 8 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: include/record/SkRecording.h
diff --git a/include/record/SkRecording.h b/include/record/SkRecording.h
new file mode 100644
index 0000000000000000000000000000000000000000..7024e17469ece45a0b8b14f222c3f5edb1c51d31
--- /dev/null
+++ b/include/record/SkRecording.h
@@ -0,0 +1,67 @@
+#ifndef SkRecording_DEFINED
robertphillips 2014/04/11 13:28:08 Header?
+#define SkRecording_DEFINED
+
+#include "SkCanvas.h" // SkCanvas
+#include "SkTypes.h" // SkNoncopyable
+
+// These are intentionally left opaque.
+class SkRecord;
+class SkRecorder;
+
+namespace EXPERIMENTAL {
+
+/** Easy mode interface to SkRecord-based SkCanvas recording.
+ *
+ * SkRecording* recording = SkRecording::Create(1920, 1080);
+ *
+ * SkCanvas* canvas = recording->canvas();
+ * canvas->drawThis();
+ * canvas->clipThat();
+ * ...
+ *
+ * scoped_ptr<const SkPlayback> playback(SkRecording::Delete(recording));
+ * playback->draw(&someCanvas);
+ * playback->draw(&someOtherCanvas);
+ *
+ * SkPlayback is thread safe; SkRecording is not.
+ */
+
+class SkPlayback : SkNoncopyable {
+public:
+ // Remember, if you've got an SkPlayback*, you probably own it. Don't forget to delete it!
+ ~SkPlayback();
+
+ // Draw recorded commands into a canvas.
+ void draw(SkCanvas*) const;
+
+private:
+ explicit SkPlayback(const SkRecord*);
+
+ const SkRecord* fRecord;
+
+ friend class SkRecording;
+};
+
+class SkRecording : SkNoncopyable {
+public:
+ // Result must be returned via SkRecording::Delete.
+ static SkRecording* Create(int width, int height);
+
+ // Caller takes ownership of SkPlayback.
+ static const SkPlayback* Delete(SkRecording*);
+
+ // Draws issued to this canvas will be replayed by SkPlayback::draw().
+ // This pointer is owned by the SkRecording; the caller must not take ownership.
+ SkCanvas* canvas();
+
+private:
+ SkRecording(int width, int height);
+ ~SkRecording();
+
+ SkRecorder* fRecorder;
+ const SkRecord* fRecord;
+};
+
+} // namespace EXPERIMENTAL
+
+#endif//SkRecording_DEFINED
« no previous file with comments | « gyp/tests.gypi ('k') | src/record/SkRecording.cpp » ('j') | src/record/SkRecording.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698