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 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 /** | 65 /** |
66 * Signal that the caller is done recording. This invalidates the canvas re
turned by | 66 * Signal that the caller is done recording. This invalidates the canvas re
turned by |
67 * beginRecording/getRecordingCanvas. Ownership of the object is passed to
the caller, who | 67 * beginRecording/getRecordingCanvas. Ownership of the object is passed to
the caller, who |
68 * must call unref() when they are done using it. | 68 * must call unref() when they are done using it. |
69 * | 69 * |
70 * The returned picture is immutable. If during recording drawables were ad
ded to the canvas, | 70 * The returned picture is immutable. If during recording drawables were ad
ded to the canvas, |
71 * these will have been "drawn" into a recording canvas, so that this resul
ting picture will | 71 * these will have been "drawn" into a recording canvas, so that this resul
ting picture will |
72 * reflect their current state, but will not contain a live reference to th
e drawables | 72 * reflect their current state, but will not contain a live reference to th
e drawables |
73 * themselves. | 73 * themselves. |
74 */ | 74 */ |
75 SkPicture* SK_WARN_UNUSED_RESULT endRecordingAsPicture(); | 75 sk_sp<SkPicture> finishRecordingAsPicture(); |
76 | 76 |
77 /** | 77 /** |
78 * Signal that the caller is done recording, and update the cull rect to us
e for bounding | 78 * Signal that the caller is done recording, and update the cull rect to us
e for bounding |
79 * box hierarchy (BBH) generation. The behavior is the same as calling | 79 * box hierarchy (BBH) generation. The behavior is the same as calling |
80 * endRecordingAsPicture(), except that this method updates the cull rect i
nitially passed | 80 * endRecordingAsPicture(), except that this method updates the cull rect i
nitially passed |
81 * into beginRecording. | 81 * into beginRecording. |
82 * @param cullRect the new culling rectangle to use as the overall bound fo
r BBH generation | 82 * @param cullRect the new culling rectangle to use as the overall bound fo
r BBH generation |
83 * and subsequent culling operations. | 83 * and subsequent culling operations. |
84 * @return the picture containing the recorded content. | 84 * @return the picture containing the recorded content. |
85 */ | 85 */ |
86 SkPicture* SK_WARN_UNUSED_RESULT endRecordingAsPicture(const SkRect& cullRec
t); | 86 sk_sp<SkPicture> finishRecordingAsPictureWithCull(const SkRect& cullRect); |
87 | 87 |
88 /** | 88 /** |
89 * Signal that the caller is done recording. This invalidates the canvas re
turned by | 89 * Signal that the caller is done recording. This invalidates the canvas re
turned by |
90 * beginRecording/getRecordingCanvas. Ownership of the object is passed to
the caller, who | 90 * beginRecording/getRecordingCanvas. Ownership of the object is passed to
the caller, who |
91 * must call unref() when they are done using it. | 91 * must call unref() when they are done using it. |
92 * | 92 * |
93 * Unlike endRecordingAsPicture(), which returns an immutable picture, the
returned drawable | 93 * Unlike endRecordingAsPicture(), which returns an immutable picture, the
returned drawable |
94 * may contain live references to other drawables (if they were added to th
e recording canvas) | 94 * may contain live references to other drawables (if they were added to th
e recording canvas) |
95 * and therefore this drawable will reflect the current state of those nest
ed drawables anytime | 95 * and therefore this drawable will reflect the current state of those nest
ed drawables anytime |
96 * it is drawn or a new picture is snapped from it (by calling drawable->ne
wPictureSnapshot()). | 96 * it is drawn or a new picture is snapped from it (by calling drawable->ne
wPictureSnapshot()). |
97 */ | 97 */ |
98 SkDrawable* SK_WARN_UNUSED_RESULT endRecordingAsDrawable(); | 98 sk_sp<SkDrawable> finishRecordingAsDrawable(); |
99 | 99 |
100 // Legacy API -- use endRecordingAsPicture instead. | 100 #ifdef SK_SUPPORT_LEGACY_PICTURE_PTR |
| 101 SkPicture* SK_WARN_UNUSED_RESULT endRecordingAsPicture() { |
| 102 return this->finishRecordingAsPicture().release(); |
| 103 } |
| 104 SkPicture* SK_WARN_UNUSED_RESULT endRecordingAsPicture(const SkRect& cullRec
t) { |
| 105 return this->finishRecordingAsPictureWithCull(cullRect).release(); |
| 106 } |
| 107 SkDrawable* SK_WARN_UNUSED_RESULT endRecordingAsDrawable() { |
| 108 return this->finishRecordingAsDrawable().release(); |
| 109 } |
101 SkPicture* SK_WARN_UNUSED_RESULT endRecording() { return this->endRecordingA
sPicture(); } | 110 SkPicture* SK_WARN_UNUSED_RESULT endRecording() { return this->endRecordingA
sPicture(); } |
| 111 #endif |
102 | 112 |
103 private: | 113 private: |
104 void reset(); | 114 void reset(); |
105 | 115 |
106 /** Replay the current (partially recorded) operation stream into | 116 /** Replay the current (partially recorded) operation stream into |
107 canvas. This call doesn't close the current recording. | 117 canvas. This call doesn't close the current recording. |
108 */ | 118 */ |
109 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 119 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
110 friend class android::Picture; | 120 friend class android::Picture; |
111 #endif | 121 #endif |
112 friend class SkPictureRecorderReplayTester; // for unit testing | 122 friend class SkPictureRecorderReplayTester; // for unit testing |
113 void partialReplay(SkCanvas* canvas) const; | 123 void partialReplay(SkCanvas* canvas) const; |
114 | 124 |
115 bool fActivelyRecording; | 125 bool fActivelyRecording; |
116 uint32_t fFlags; | 126 uint32_t fFlags; |
117 SkRect fCullRect; | 127 SkRect fCullRect; |
118 SkAutoTUnref<SkBBoxHierarchy> fBBH; | 128 SkAutoTUnref<SkBBoxHierarchy> fBBH; |
119 SkAutoTUnref<SkRecorder> fRecorder; | 129 SkAutoTUnref<SkRecorder> fRecorder; |
120 SkAutoTUnref<SkRecord> fRecord; | 130 SkAutoTUnref<SkRecord> fRecord; |
121 SkMiniRecorder fMiniRecorder; | 131 SkMiniRecorder fMiniRecorder; |
122 | 132 |
123 typedef SkNoncopyable INHERITED; | 133 typedef SkNoncopyable INHERITED; |
124 }; | 134 }; |
125 | 135 |
126 #endif | 136 #endif |
OLD | NEW |