| 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 #include "SkCanvasDrawable.h" | 8 #include "SkCanvasDrawable.h" |
| 9 #include "SkData.h" | 9 #include "SkData.h" |
| 10 #include "SkLayerInfo.h" | 10 #include "SkLayerInfo.h" |
| 11 #include "SkPictureRecorder.h" | 11 #include "SkPictureRecorder.h" |
| 12 #include "SkRecord.h" | 12 #include "SkRecord.h" |
| 13 #include "SkRecordDraw.h" | 13 #include "SkRecordDraw.h" |
| 14 #include "SkRecorder.h" | 14 #include "SkRecorder.h" |
| 15 #include "SkRecordOpts.h" | 15 #include "SkRecordOpts.h" |
| 16 #include "SkTypes.h" | 16 #include "SkTypes.h" |
| 17 | 17 |
| 18 SkPictureRecorder::SkPictureRecorder() : fBBHFactory(NULL) {} | 18 SkPictureRecorder::SkPictureRecorder() {} |
| 19 | 19 |
| 20 SkPictureRecorder::~SkPictureRecorder() {} | 20 SkPictureRecorder::~SkPictureRecorder() {} |
| 21 | 21 |
| 22 SkCanvas* SkPictureRecorder::beginRecording(const SkRect& cullRect, | 22 SkCanvas* SkPictureRecorder::beginRecording(const SkRect& cullRect, |
| 23 SkBBHFactory* bbhFactory /* = NULL *
/, | 23 SkBBHFactory* bbhFactory /* = NULL *
/, |
| 24 uint32_t recordFlags /* = 0 */) { | 24 uint32_t recordFlags /* = 0 */) { |
| 25 fCullRect = cullRect; | 25 fCullRect = cullRect; |
| 26 fBBHFactory = bbhFactory; | |
| 27 fFlags = recordFlags; | 26 fFlags = recordFlags; |
| 28 | 27 |
| 29 if (bbhFactory) { | 28 if (bbhFactory) { |
| 30 fBBH.reset((*bbhFactory)(cullRect)); | 29 fBBH.reset((*bbhFactory)(cullRect)); |
| 31 SkASSERT(fBBH.get()); | 30 SkASSERT(fBBH.get()); |
| 32 } | 31 } |
| 33 | 32 |
| 34 fRecord.reset(SkNEW(SkRecord)); | 33 fRecord.reset(SkNEW(SkRecord)); |
| 35 fRecorder.reset(SkNEW_ARGS(SkRecorder, (fRecord.get(), cullRect))); | 34 fRecorder.reset(SkNEW_ARGS(SkRecorder, (fRecord.get(), cullRect))); |
| 36 return this->getRecordingCanvas(); | 35 return this->getRecordingCanvas(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 61 } else { | 60 } else { |
| 62 SkRecordFillBounds(fCullRect, *fRecord, fBBH.get()); | 61 SkRecordFillBounds(fCullRect, *fRecord, fBBH.get()); |
| 63 } | 62 } |
| 64 } | 63 } |
| 65 | 64 |
| 66 SkPicture* pict = SkNEW_ARGS(SkPicture, (fCullRect, fRecord, pictList, fBBH)
); | 65 SkPicture* pict = SkNEW_ARGS(SkPicture, (fCullRect, fRecord, pictList, fBBH)
); |
| 67 | 66 |
| 68 if (saveLayerData) { | 67 if (saveLayerData) { |
| 69 pict->EXPERIMENTAL_addAccelData(saveLayerData); | 68 pict->EXPERIMENTAL_addAccelData(saveLayerData); |
| 70 } | 69 } |
| 71 | 70 |
| 71 // release our refs now, so only the picture will be the owner. |
| 72 fRecorder.reset(NULL); |
| 73 fRecord.reset(NULL); |
| 74 fBBH.reset(NULL); |
| 75 |
| 72 return pict; | 76 return pict; |
| 73 } | 77 } |
| 74 | 78 |
| 75 void SkPictureRecorder::partialReplay(SkCanvas* canvas) const { | 79 void SkPictureRecorder::partialReplay(SkCanvas* canvas) const { |
| 76 if (NULL == canvas) { | 80 if (NULL == canvas) { |
| 77 return; | 81 return; |
| 78 } | 82 } |
| 79 | 83 |
| 80 int drawableCount = 0; | 84 int drawableCount = 0; |
| 81 SkCanvasDrawable* const* drawables = NULL; | 85 SkCanvasDrawable* const* drawables = NULL; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 }; | 154 }; |
| 151 | 155 |
| 152 SkCanvasDrawable* SkPictureRecorder::EXPERIMENTAL_endRecordingAsDrawable() { | 156 SkCanvasDrawable* SkPictureRecorder::EXPERIMENTAL_endRecordingAsDrawable() { |
| 153 // TODO: delay as much of this work until just before first playback? | 157 // TODO: delay as much of this work until just before first playback? |
| 154 SkRecordOptimize(fRecord); | 158 SkRecordOptimize(fRecord); |
| 155 | 159 |
| 156 if (fBBH.get()) { | 160 if (fBBH.get()) { |
| 157 SkRecordFillBounds(fCullRect, *fRecord, fBBH.get()); | 161 SkRecordFillBounds(fCullRect, *fRecord, fBBH.get()); |
| 158 } | 162 } |
| 159 | 163 |
| 160 return SkNEW_ARGS(SkRecordedDrawable, (fRecord, fBBH, fRecorder->detachDrawa
bleList(), | 164 SkCanvasDrawable* drawable = SkNEW_ARGS(SkRecordedDrawable, |
| 161 fCullRect, | 165 (fRecord, fBBH, fRecorder->detachDra
wableList(), |
| 162 SkToBool(fFlags & kComputeSaveLayerIn
fo_RecordFlag))); | 166 fCullRect, |
| 167 SkToBool(fFlags & kComputeSaveLayer
Info_RecordFlag))); |
| 168 |
| 169 // release our refs now, so only the drawable will be the owner. |
| 170 fRecorder.reset(NULL); |
| 171 fRecord.reset(NULL); |
| 172 fBBH.reset(NULL); |
| 173 |
| 174 return drawable; |
| 163 } | 175 } |
| OLD | NEW |