| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkPictureRecorder_DEFINED | 8 #ifndef SkPictureRecorder_DEFINED |
| 9 #define SkPictureRecorder_DEFINED | 9 #define SkPictureRecorder_DEFINED |
| 10 | 10 |
| 11 #include "SkBBHFactory.h" | 11 #include "SkBBHFactory.h" |
| 12 #include "SkPicture.h" | 12 #include "SkPicture.h" |
| 13 #include "SkRefCnt.h" | 13 #include "SkRefCnt.h" |
| 14 | 14 |
| 15 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 15 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
| 16 namespace android { | 16 namespace android { |
| 17 class Picture; | 17 class Picture; |
| 18 }; | 18 }; |
| 19 #endif | 19 #endif |
| 20 | 20 |
| 21 class SkCanvas; | 21 class SkCanvas; |
| 22 class SkCanvasDrawable; |
| 22 class SkPictureRecord; | 23 class SkPictureRecord; |
| 23 class SkRecord; | 24 class SkRecord; |
| 24 class SkRecorder; | 25 class SkRecorder; |
| 25 | 26 |
| 26 class SK_API SkPictureRecorder : SkNoncopyable { | 27 class SK_API SkPictureRecorder : SkNoncopyable { |
| 27 public: | 28 public: |
| 28 SkPictureRecorder(); | 29 SkPictureRecorder(); |
| 29 ~SkPictureRecorder(); | 30 ~SkPictureRecorder(); |
| 30 | 31 |
| 31 #ifdef SK_LEGACY_PICTURE_SIZE_API | 32 #ifdef SK_LEGACY_PICTURE_SIZE_API |
| (...skipping 26 matching lines...) Expand all Loading... |
| 58 SkBBHFactory* bbhFactory = NULL, | 59 SkBBHFactory* bbhFactory = NULL, |
| 59 uint32_t recordFlags = 0) { | 60 uint32_t recordFlags = 0) { |
| 60 return this->beginRecording(SkRect::MakeWH(width, height), bbhFactory, r
ecordFlags); | 61 return this->beginRecording(SkRect::MakeWH(width, height), bbhFactory, r
ecordFlags); |
| 61 } | 62 } |
| 62 | 63 |
| 63 /** Returns the recording canvas if one is active, or NULL if recording is | 64 /** Returns the recording canvas if one is active, or NULL if recording is |
| 64 not active. This does not alter the refcnt on the canvas (if present). | 65 not active. This does not alter the refcnt on the canvas (if present). |
| 65 */ | 66 */ |
| 66 SkCanvas* getRecordingCanvas(); | 67 SkCanvas* getRecordingCanvas(); |
| 67 | 68 |
| 68 /** Signal that the caller is done recording. This invalidates the canvas | 69 /** |
| 69 returned by beginRecording/getRecordingCanvas, and returns the | 70 * Signal that the caller is done recording. This invalidates the canvas re
turned by |
| 70 created SkPicture. Note that the returned picture has its creation | 71 * beginRecording/getRecordingCanvas. Ownership of the object is passed to
the caller, who |
| 71 ref which the caller must take ownership of. | 72 * must call unref() when they are done using it. |
| 72 */ | 73 * |
| 73 SkPicture* endRecording(); | 74 * The returned picture is immutable. If during recording drawables were ad
ded to the canvas, |
| 75 * these will have been "drawn" into a recording canvas, so that this resul
ting picture will |
| 76 * reflect their current state, but will not contain a live reference to th
e drawables |
| 77 * themselves. |
| 78 */ |
| 79 SkPicture* endRecordingAsPicture(); |
| 80 |
| 81 /** |
| 82 * Signal that the caller is done recording. This invalidates the canvas re
turned by |
| 83 * beginRecording/getRecordingCanvas. Ownership of the object is passed to
the caller, who |
| 84 * must call unref() when they are done using it. |
| 85 * |
| 86 * Unlike endRecordingAsPicture(), which returns an immutable picture, the
returned drawable |
| 87 * may contain live references to other drawables (if they were added to th
e recording canvas) |
| 88 * and therefore this drawable will reflect the current state of those nest
ed drawables anytime |
| 89 * it is drawn or a new picture is snapped from it (by calling drawable->ne
wPictureSnapshot()). |
| 90 */ |
| 91 SkCanvasDrawable* EXPERIMENTAL_endRecordingAsDrawable(); |
| 92 |
| 93 // Legacy API -- use endRecordingAsPicture instead. |
| 94 SkPicture* endRecording() { return this->endRecordingAsPicture(); } |
| 74 | 95 |
| 75 private: | 96 private: |
| 76 void reset(); | 97 void reset(); |
| 77 | 98 |
| 78 /** Replay the current (partially recorded) operation stream into | 99 /** Replay the current (partially recorded) operation stream into |
| 79 canvas. This call doesn't close the current recording. | 100 canvas. This call doesn't close the current recording. |
| 80 */ | 101 */ |
| 81 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 102 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
| 82 friend class android::Picture; | 103 friend class android::Picture; |
| 83 #endif | 104 #endif |
| 84 friend class SkPictureRecorderReplayTester; // for unit testing | 105 friend class SkPictureRecorderReplayTester; // for unit testing |
| 85 void partialReplay(SkCanvas* canvas) const; | 106 void partialReplay(SkCanvas* canvas) const; |
| 86 | 107 |
| 87 uint32_t fFlags; | 108 uint32_t fFlags; |
| 88 SkRect fCullRect; | 109 SkRect fCullRect; |
| 89 SkAutoTUnref<SkBBoxHierarchy> fBBH; | 110 SkAutoTUnref<SkBBoxHierarchy> fBBH; |
| 90 SkAutoTUnref<SkRecorder> fRecorder; | 111 SkAutoTUnref<SkRecorder> fRecorder; |
| 91 SkAutoTDelete<SkRecord> fRecord; | 112 SkAutoTUnref<SkRecord> fRecord; |
| 113 SkBBHFactory* fBBHFactory; |
| 92 | 114 |
| 93 typedef SkNoncopyable INHERITED; | 115 typedef SkNoncopyable INHERITED; |
| 94 }; | 116 }; |
| 95 | 117 |
| 96 #endif | 118 #endif |
| OLD | NEW |