Chromium Code Reviews| 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 15 matching lines...) Expand all Loading... | |
| 26 class SkRecorder; | 26 class SkRecorder; |
| 27 | 27 |
| 28 class SK_API SkPictureRecorder : SkNoncopyable { | 28 class SK_API SkPictureRecorder : SkNoncopyable { |
| 29 public: | 29 public: |
| 30 SkPictureRecorder(); | 30 SkPictureRecorder(); |
| 31 ~SkPictureRecorder(); | 31 ~SkPictureRecorder(); |
| 32 | 32 |
| 33 enum RecordFlags { | 33 enum RecordFlags { |
| 34 // This flag indicates that, if some BHH is being computed, saveLayer | 34 // This flag indicates that, if some BHH is being computed, saveLayer |
| 35 // information should also be extracted at the same time. | 35 // information should also be extracted at the same time. |
| 36 kComputeSaveLayerInfo_RecordFlag = 0x01, | 36 kComputeSaveLayerInfo_RecordFlag = 1 << 0, |
| 37 | 37 |
| 38 // If you call drawPicture() or drawDrawable() on the recording canvas, this flag forces | 38 // If you call drawPicture() or drawDrawable() on the recording canvas, this flag forces |
| 39 // that object to playback its contents immediately rather than reffing the object. | 39 // that object to playback its contents immediately rather than reffing the object. |
| 40 kPlaybackDrawPicture_RecordFlag = 0x02, | 40 kPlaybackDrawPicture_RecordFlag = 1 << 1, |
|
liyuqian
2016/07/06 15:39:03
Just curious: is 1 << 1 faster than 0x02? (In case
| |
| 41 }; | |
| 42 | |
| 43 enum FinishFlags { | |
| 44 kReturnNullForEmpty_FinishFlag = 1 << 0, // no draw-ops will return n ullptr | |
| 41 }; | 45 }; |
| 42 | 46 |
| 43 /** Returns the canvas that records the drawing commands. | 47 /** Returns the canvas that records the drawing commands. |
| 44 @param bounds the cull rect used when recording this picture. Any drawin g the falls outside | 48 @param bounds the cull rect used when recording this picture. Any drawin g the falls outside |
| 45 of this rect is undefined, and may be drawn or it may not. | 49 of this rect is undefined, and may be drawn or it may not. |
| 46 @param bbhFactory factory to create desired acceleration structure | 50 @param bbhFactory factory to create desired acceleration structure |
| 47 @param recordFlags optional flags that control recording. | 51 @param recordFlags optional flags that control recording. |
| 48 @return the canvas. | 52 @return the canvas. |
| 49 */ | 53 */ |
| 50 SkCanvas* beginRecording(const SkRect& bounds, | 54 SkCanvas* beginRecording(const SkRect& bounds, |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 65 /** | 69 /** |
| 66 * Signal that the caller is done recording. This invalidates the canvas re turned by | 70 * 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 | 71 * beginRecording/getRecordingCanvas. Ownership of the object is passed to the caller, who |
| 68 * must call unref() when they are done using it. | 72 * must call unref() when they are done using it. |
| 69 * | 73 * |
| 70 * The returned picture is immutable. If during recording drawables were ad ded to the canvas, | 74 * 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 | 75 * 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 | 76 * reflect their current state, but will not contain a live reference to th e drawables |
| 73 * themselves. | 77 * themselves. |
| 74 */ | 78 */ |
| 75 sk_sp<SkPicture> finishRecordingAsPicture(); | 79 sk_sp<SkPicture> finishRecordingAsPicture(uint32_t endFlags = 0); |
| 76 | 80 |
| 77 /** | 81 /** |
| 78 * Signal that the caller is done recording, and update the cull rect to us e for bounding | 82 * 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 | 83 * box hierarchy (BBH) generation. The behavior is the same as calling |
| 80 * endRecordingAsPicture(), except that this method updates the cull rect i nitially passed | 84 * endRecordingAsPicture(), except that this method updates the cull rect i nitially passed |
| 81 * into beginRecording. | 85 * into beginRecording. |
| 82 * @param cullRect the new culling rectangle to use as the overall bound fo r BBH generation | 86 * @param cullRect the new culling rectangle to use as the overall bound fo r BBH generation |
| 83 * and subsequent culling operations. | 87 * and subsequent culling operations. |
| 84 * @return the picture containing the recorded content. | 88 * @return the picture containing the recorded content. |
| 85 */ | 89 */ |
| 86 sk_sp<SkPicture> finishRecordingAsPictureWithCull(const SkRect& cullRect); | 90 sk_sp<SkPicture> finishRecordingAsPictureWithCull(const SkRect& cullRect, |
| 91 uint32_t endFlags = 0); | |
| 87 | 92 |
| 88 /** | 93 /** |
| 89 * Signal that the caller is done recording. This invalidates the canvas re turned by | 94 * 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 | 95 * beginRecording/getRecordingCanvas. Ownership of the object is passed to the caller, who |
| 91 * must call unref() when they are done using it. | 96 * must call unref() when they are done using it. |
| 92 * | 97 * |
| 93 * Unlike endRecordingAsPicture(), which returns an immutable picture, the returned drawable | 98 * 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) | 99 * 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 | 100 * 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()). | 101 * it is drawn or a new picture is snapped from it (by calling drawable->ne wPictureSnapshot()). |
| 97 */ | 102 */ |
| 98 sk_sp<SkDrawable> finishRecordingAsDrawable(); | 103 sk_sp<SkDrawable> finishRecordingAsDrawable(uint32_t endFlags = 0); |
| 99 | 104 |
| 100 #ifdef SK_SUPPORT_LEGACY_PICTURE_PTR | 105 #ifdef SK_SUPPORT_LEGACY_PICTURE_PTR |
| 101 SkPicture* SK_WARN_UNUSED_RESULT endRecordingAsPicture() { | 106 SkPicture* SK_WARN_UNUSED_RESULT endRecordingAsPicture() { |
| 102 return this->finishRecordingAsPicture().release(); | 107 return this->finishRecordingAsPicture().release(); |
| 103 } | 108 } |
| 104 SkPicture* SK_WARN_UNUSED_RESULT endRecordingAsPicture(const SkRect& cullRec t) { | 109 SkPicture* SK_WARN_UNUSED_RESULT endRecordingAsPicture(const SkRect& cullRec t) { |
| 105 return this->finishRecordingAsPictureWithCull(cullRect).release(); | 110 return this->finishRecordingAsPictureWithCull(cullRect).release(); |
| 106 } | 111 } |
| 107 SkDrawable* SK_WARN_UNUSED_RESULT endRecordingAsDrawable() { | 112 SkDrawable* SK_WARN_UNUSED_RESULT endRecordingAsDrawable() { |
| 108 return this->finishRecordingAsDrawable().release(); | 113 return this->finishRecordingAsDrawable().release(); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 127 SkRect fCullRect; | 132 SkRect fCullRect; |
| 128 SkAutoTUnref<SkBBoxHierarchy> fBBH; | 133 SkAutoTUnref<SkBBoxHierarchy> fBBH; |
| 129 SkAutoTUnref<SkRecorder> fRecorder; | 134 SkAutoTUnref<SkRecorder> fRecorder; |
| 130 SkAutoTUnref<SkRecord> fRecord; | 135 SkAutoTUnref<SkRecord> fRecord; |
| 131 SkMiniRecorder fMiniRecorder; | 136 SkMiniRecorder fMiniRecorder; |
| 132 | 137 |
| 133 typedef SkNoncopyable INHERITED; | 138 typedef SkNoncopyable INHERITED; |
| 134 }; | 139 }; |
| 135 | 140 |
| 136 #endif | 141 #endif |
| OLD | NEW |