aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-04-10 23:30:59 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-04-10 23:30:59 +0000
commit18fd2b923a5060175ab4e446e73a73cba581c20d (patch)
tree9940e91a8469c085c5b39e202215516353df18d8 /include
parentd923288e50b5a69afb0bdd5c161191b24cab8345 (diff)
Add a focused public API for src/record.
BUG=skia:2378 R=reed@google.com, robertphillips@google.com, mtklein@google.com, fmalita@chromium.org Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/233053005 git-svn-id: http://skia.googlecode.com/svn/trunk@14146 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include')
-rw-r--r--include/record/SkRecording.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/include/record/SkRecording.h b/include/record/SkRecording.h
new file mode 100644
index 0000000000..7024e17469
--- /dev/null
+++ b/include/record/SkRecording.h
@@ -0,0 +1,67 @@
+#ifndef SkRecording_DEFINED
+#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