Chromium Code Reviews| Index: include/record/SkRecording.h |
| diff --git a/include/record/SkRecording.h b/include/record/SkRecording.h |
| index 0d04b90ca05f719bb884e872ee8a6e9972a6adf8..2716ea62a1802f88f50ab99b3a82fcb8b1d67693 100644 |
| --- a/include/record/SkRecording.h |
| +++ b/include/record/SkRecording.h |
| @@ -8,8 +8,10 @@ |
| #ifndef SkRecording_DEFINED |
| #define SkRecording_DEFINED |
| -#include "SkCanvas.h" // SkCanvas |
| -#include "SkTypes.h" // SkNoncopyable |
| +#include "SkCanvas.h" // SkCanvas |
| +#include "SkRefCnt.h" // SkAutoTUnref |
| +#include "SkTemplates.h" // SkAutoTDelete |
| +#include "SkTypes.h" // SkNoncopyable |
| // These are intentionally left opaque. |
| class SkRecord; |
| @@ -19,14 +21,15 @@ namespace EXPERIMENTAL { |
| /** Easy mode interface to SkRecord-based SkCanvas recording. |
| * |
| - * SkRecording* recording = SkRecording::Create(1920, 1080); |
| + * scoped_ptr<SkRecording> recording(new SkRecording(1920, 1080)); |
|
reed1
2014/04/23 21:53:30
its not wrong, but I don't think our pseudo code i
mtklein
2014/04/23 22:05:54
It's intended for Chrome readers. Want me to rewr
|
| + * skia::RefPtr<SkCanvas> canvas(skia::SharePtr(recording->canvas())); |
| * |
| - * SkCanvas* canvas = recording->canvas(); |
| * canvas->drawThis(); |
| * canvas->clipThat(); |
| * ... |
| * |
| - * scoped_ptr<const SkPlayback> playback(SkRecording::Delete(recording)); |
| + * canvas.clear(); // You must deref the canvas before you may call releasePlayback(). |
| + * scoped_ptr<const SkPlayback> playback(recording->releasePlayback()); |
| * playback->draw(&someCanvas); |
| * playback->draw(&someOtherCanvas); |
| * |
| @@ -44,29 +47,27 @@ public: |
| private: |
| explicit SkPlayback(const SkRecord*); |
| - const SkRecord* fRecord; |
| + SkAutoTDelete<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*); |
| + SkRecording(int width, int height); |
| + ~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. |
| + // Any refs held on canvas() must be dropped before you may call releasePlayback(). |
| SkCanvas* canvas(); |
| -private: |
| - SkRecording(int width, int height); |
| - ~SkRecording(); |
| + // Release exclusive ownership of an SkPlayback to the caller. |
| + // Any refs held on canvas() must be dropped before you may call releasePlayback(). |
| + SkPlayback* releasePlayback(); |
| - SkRecorder* fRecorder; |
| - SkRecord* fRecord; |
| +private: |
| + SkAutoTDelete<SkRecord> fRecord; |
| + SkAutoTUnref<SkRecorder> fRecorder; |
| }; |
| } // namespace EXPERIMENTAL |