| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright 2014 Google Inc. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license that can be | |
| 5 * found in the LICENSE file. | |
| 6 */ | |
| 7 | |
| 8 #ifndef SkRecording_DEFINED | |
| 9 #define SkRecording_DEFINED | |
| 10 | |
| 11 #include "SkCanvas.h" // SkCanvas | |
| 12 #include "SkRefCnt.h" // SkAutoTUnref | |
| 13 #include "SkTemplates.h" // SkAutoTDelete | |
| 14 #include "SkTypes.h" // SkNoncopyable | |
| 15 | |
| 16 // These are intentionally left opaque. | |
| 17 class SkRecord; | |
| 18 class SkRecorder; | |
| 19 | |
| 20 namespace EXPERIMENTAL { | |
| 21 | |
| 22 /** Easy mode interface to SkRecord-based SkCanvas recording. | |
| 23 * | |
| 24 * scoped_ptr<SkRecording> recording(new SkRecording(1920, 1080)); | |
| 25 * skia::RefPtr<SkCanvas> canvas(skia::SharePtr(recording->canvas())); | |
| 26 * | |
| 27 * canvas->drawThis(); | |
| 28 * canvas->clipThat(); | |
| 29 * ... | |
| 30 * | |
| 31 * canvas.clear(); // You must deref the canvas before you may call releasePla
yback(). | |
| 32 * scoped_ptr<const SkPlayback> playback(recording->releasePlayback()); | |
| 33 * playback->draw(&someCanvas); | |
| 34 * playback->draw(&someOtherCanvas); | |
| 35 * | |
| 36 * SkPlayback is thread safe; SkRecording is not. | |
| 37 */ | |
| 38 | |
| 39 class SK_API SkPlayback : SkNoncopyable { | |
| 40 public: | |
| 41 // Remember, if you've got an SkPlayback*, you probably own it. Don't forge
t to delete it! | |
| 42 ~SkPlayback(); | |
| 43 | |
| 44 // Draw recorded commands into a canvas. | |
| 45 void draw(SkCanvas*) const; | |
| 46 | |
| 47 private: | |
| 48 explicit SkPlayback(const SkRecord*); | |
| 49 | |
| 50 SkAutoTDelete<const SkRecord> fRecord; | |
| 51 | |
| 52 friend class SkRecording; | |
| 53 }; | |
| 54 | |
| 55 class SK_API SkRecording : SkNoncopyable { | |
| 56 public: | |
| 57 SkRecording(int width, int height); | |
| 58 ~SkRecording(); | |
| 59 | |
| 60 // Draws issued to this canvas will be replayed by SkPlayback::draw(). | |
| 61 // Any refs held on canvas() must be dropped before you may call releasePlay
back(). | |
| 62 SkCanvas* canvas(); | |
| 63 | |
| 64 // Release exclusive ownership of an SkPlayback to the caller. | |
| 65 // Any refs held on canvas() must be dropped before you may call releasePlay
back(). | |
| 66 SkPlayback* releasePlayback(); | |
| 67 | |
| 68 private: | |
| 69 SkAutoTDelete<SkRecord> fRecord; | |
| 70 SkAutoTUnref<SkRecorder> fRecorder; | |
| 71 }; | |
| 72 | |
| 73 } // namespace EXPERIMENTAL | |
| 74 | |
| 75 #endif//SkRecording_DEFINED | |
| OLD | NEW |