| 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 "SkBBoxHierarchyRecord.h" | 8 #include "SkBBoxHierarchyRecord.h" |
| 9 #include "SkPictureRecord.h" | 9 #include "SkPictureRecord.h" |
| 10 #include "SkPictureRecorder.h" | 10 #include "SkPictureRecorder.h" |
| 11 #include "SkRecord.h" | 11 #include "SkRecord.h" |
| 12 #include "SkRecordDraw.h" | 12 #include "SkRecordDraw.h" |
| 13 #include "SkRecorder.h" | 13 #include "SkRecorder.h" |
| 14 #include "SkTypes.h" | 14 #include "SkTypes.h" |
| 15 | 15 |
| 16 SkPictureRecorder::SkPictureRecorder() {} | 16 SkPictureRecorder::SkPictureRecorder() {} |
| 17 | 17 |
| 18 SkPictureRecorder::~SkPictureRecorder() {} | 18 SkPictureRecorder::~SkPictureRecorder() {} |
| 19 | 19 |
| 20 SkCanvas* SkPictureRecorder::beginRecording(SkScalar width, SkScalar height, | 20 SkCanvas* SkPictureRecorder::beginRecording(SkScalar width, SkScalar height, |
| 21 SkBBHFactory* bbhFactory /* = NULL *
/, | 21 SkBBHFactory* bbhFactory /* = NULL *
/, |
| 22 uint32_t recordFlags /* = 0 */) { | 22 uint32_t recordFlags /* = 0 */) { |
| 23 #ifdef SK_PICTURE_USE_SK_RECORD | |
| 24 return EXPERIMENTAL_beginRecording(width, height, bbhFactory); | 23 return EXPERIMENTAL_beginRecording(width, height, bbhFactory); |
| 25 #else | |
| 26 return DEPRECATED_beginRecording(width, height, bbhFactory, recordFlags); | |
| 27 #endif | |
| 28 } | 24 } |
| 29 | 25 |
| 30 SkCanvas* SkPictureRecorder::DEPRECATED_beginRecording(SkScalar width, SkScalar
height, | 26 SkCanvas* SkPictureRecorder::DEPRECATED_beginRecording(SkScalar width, SkScalar
height, |
| 31 SkBBHFactory* bbhFactory
/* = NULL */, | 27 SkBBHFactory* bbhFactory
/* = NULL */, |
| 32 uint32_t recordFlags /* =
0 */) { | 28 uint32_t recordFlags /* =
0 */) { |
| 33 fCullWidth = width; | 29 fCullWidth = width; |
| 34 fCullHeight = height; | 30 fCullHeight = height; |
| 35 | 31 |
| 36 const SkISize size = SkISize::Make(width, height); | 32 const SkISize size = SkISize::Make(width, height); |
| 37 | 33 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 68 if (fRecorder.get()) { | 64 if (fRecorder.get()) { |
| 69 return fRecorder.get(); | 65 return fRecorder.get(); |
| 70 } | 66 } |
| 71 return fPictureRecord.get(); | 67 return fPictureRecord.get(); |
| 72 } | 68 } |
| 73 | 69 |
| 74 SkPicture* SkPictureRecorder::endRecording() { | 70 SkPicture* SkPictureRecorder::endRecording() { |
| 75 SkPicture* picture = NULL; | 71 SkPicture* picture = NULL; |
| 76 | 72 |
| 77 if (fRecord.get()) { | 73 if (fRecord.get()) { |
| 78 picture = SkNEW_ARGS(SkPicture, (fCullWidth, fCullHeight, | 74 picture = SkNEW_ARGS(SkPicture, (fCullWidth, fCullHeight, |
| 79 fRecord.detach(), fBBH.get())); | 75 fRecord.detach(), fBBH.get())); |
| 80 } | 76 } |
| 81 | 77 |
| 82 if (fPictureRecord.get()) { | 78 if (fPictureRecord.get()) { |
| 83 fPictureRecord->endRecording(); | 79 fPictureRecord->endRecording(); |
| 84 const bool deepCopyOps = false; | 80 const bool deepCopyOps = false; |
| 85 picture = SkNEW_ARGS(SkPicture, (fCullWidth, fCullHeight, | 81 picture = SkNEW_ARGS(SkPicture, (fCullWidth, fCullHeight, |
| 86 *fPictureRecord.get(), deepCopyOps)); | 82 *fPictureRecord.get(), deepCopyOps)); |
| 87 } | 83 } |
| 88 | 84 |
| 89 return picture; | 85 return picture; |
| 90 } | 86 } |
| 91 | 87 |
| 92 void SkPictureRecorder::internalOnly_EnableOpts(bool enableOpts) { | 88 void SkPictureRecorder::internalOnly_EnableOpts(bool enableOpts) { |
| 93 if (fPictureRecord.get()) { | 89 if (fPictureRecord.get()) { |
| 94 fPictureRecord->internalOnly_EnableOpts(enableOpts); | 90 fPictureRecord->internalOnly_EnableOpts(enableOpts); |
| 95 } | 91 } |
| 96 } | 92 } |
| 97 | 93 |
| 98 void SkPictureRecorder::partialReplay(SkCanvas* canvas) const { | 94 void SkPictureRecorder::partialReplay(SkCanvas* canvas) const { |
| 99 if (NULL == canvas) { | 95 if (NULL == canvas) { |
| 100 return; | 96 return; |
| 101 } | 97 } |
| 102 | 98 |
| 103 if (fRecord.get()) { | 99 if (fRecord.get()) { |
| 104 SkRecordDraw(*fRecord, canvas, NULL/*bbh*/, NULL/*callback*/); | 100 SkRecordDraw(*fRecord, canvas, NULL/*bbh*/, NULL/*callback*/); |
| 105 } | 101 } |
| 106 | 102 |
| 107 if (fPictureRecord.get()) { | 103 if (fPictureRecord.get()) { |
| 108 const bool deepCopyOps = true; | 104 const bool deepCopyOps = true; |
| 109 SkPicture picture(fCullWidth, fCullHeight, | 105 SkPicture picture(fCullWidth, fCullHeight, |
| 110 *fPictureRecord.get(), deepCopyOps); | 106 *fPictureRecord.get(), deepCopyOps); |
| 111 picture.playback(canvas); | 107 picture.playback(canvas); |
| 112 } | 108 } |
| 113 } | 109 } |
| OLD | NEW |