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 // Need to include SkTypes first, so that SK_BUILD_FOR_ANDROID is defined. | 8 #include "SkBBoxHierarchyRecord.h" |
| 9 #include "SkTypes.h" | |
| 10 #ifdef SK_BUILD_FOR_ANDROID | |
| 11 #include "SkPicturePlayback.h" | 9 #include "SkPicturePlayback.h" |
| 12 #endif | 10 #include "SkPictureRecord.h" |
| 13 #include "SkPictureRecorder.h" | 11 #include "SkPictureRecorder.h" |
| 12 #include "SkTypes.h" | |
| 14 | 13 |
| 15 SkCanvas* SkPictureRecorder::beginRecording(int width, int height, | 14 SkCanvas* SkPictureRecorder::beginRecording(int width, int height, |
| 16 SkBBHFactory* bbhFactory /* = NULL * /, | 15 SkBBHFactory* bbhFactory /* = NULL * /, |
| 17 uint32_t recordFlags /* = 0 */) { | 16 uint32_t recordFlags /* = 0 */) { |
| 17 fCanvas.reset(NULL); | |
|
mtklein
2014/06/04 22:22:17
You can probably drop this? Either way, you're go
robertphillips
2014/06/05 20:29:44
This will eventually go away when SkPictureRecord
| |
| 18 fPicture.reset(SkNEW(SkPicture)); | 18 fPicture.reset(SkNEW(SkPicture)); |
| 19 return fPicture->beginRecording(width, height, bbhFactory, recordFlags); | 19 |
| 20 fPicture->fWidth = width; | |
| 21 fPicture->fHeight = height; | |
| 22 | |
| 23 const SkISize size = SkISize::Make(width, height); | |
| 24 | |
| 25 SkPictureRecord* record = NULL; | |
|
mtklein
2014/06/04 22:22:17
Might skip this and just call fCanvas.reset inside
robertphillips
2014/06/05 20:29:44
All this goofiness was b.c. SkPictureRecord.h is p
| |
| 26 | |
| 27 if (NULL != bbhFactory) { | |
| 28 SkAutoTUnref<SkBBoxHierarchy> tree((*bbhFactory)(width, height)); | |
| 29 SkASSERT(NULL != tree); | |
| 30 record = SkNEW_ARGS(SkBBoxHierarchyRecord, (fPicture, size, recordFlags, tree.get())); | |
| 31 } else { | |
| 32 record = SkNEW_ARGS(SkPictureRecord, (fPicture, size, recordFlags)); | |
| 33 } | |
| 34 fCanvas.reset(record); | |
| 35 record->beginRecording(); | |
| 36 | |
| 37 return fCanvas; | |
| 38 } | |
| 39 | |
| 40 SkPicture* SkPictureRecorder::endRecording() { | |
| 41 if (NULL != fPicture.get()) { | |
|
mtklein
2014/06/04 22:22:17
I'd probably invert this so the normal case is out
robertphillips
2014/06/05 20:29:44
Done.
| |
| 42 SkASSERT(NULL == fPicture->fPlayback); | |
| 43 SkASSERT(NULL != fCanvas); | |
| 44 | |
| 45 SkPictureRecord* record = static_cast<SkPictureRecord*>(fCanvas.get()); | |
|
mtklein
2014/06/04 22:22:17
Store fCanvas as SkAutoTUnref<SkPictureRecord>?
robertphillips
2014/06/05 20:29:44
SkPictureRecord.h is private.
| |
| 46 record->endRecording(); | |
| 47 | |
| 48 SkPictInfo info; | |
| 49 fPicture->createHeader(&info); | |
| 50 fPicture->fPlayback = SkNEW_ARGS(SkPicturePlayback, (fPicture, *record, info)); | |
|
mtklein
2014/06/04 22:22:17
In the future this goes away too right? Sort of s
robertphillips
2014/06/05 20:29:44
Right. At this point SkPictureRecorder should just
| |
| 51 | |
| 52 fCanvas.reset(NULL); | |
| 53 | |
| 54 return fPicture.detach(); | |
| 55 } | |
| 56 return NULL; | |
| 57 } | |
| 58 | |
| 59 void SkPictureRecorder::internalOnly_EnableOpts(bool enableOpts) { | |
| 60 if (NULL == fCanvas) { | |
| 61 return; | |
| 62 } | |
| 63 | |
| 64 SkPictureRecord* record = static_cast<SkPictureRecord*>(fCanvas.get()); | |
| 65 record->internalOnly_EnableOpts(enableOpts); | |
| 20 } | 66 } |
| 21 | 67 |
| 22 #ifdef SK_BUILD_FOR_ANDROID | 68 #ifdef SK_BUILD_FOR_ANDROID |
| 23 void SkPictureRecorder::partialReplay(SkCanvas* canvas) const { | 69 void SkPictureRecorder::partialReplay(SkCanvas* canvas) const { |
| 24 if (NULL == fPicture.get() || NULL == canvas) { | 70 if (NULL == fPicture.get() || NULL == canvas) { |
| 25 // Not recording or nothing to replay into | 71 // Not recording or nothing to replay into |
| 26 return; | 72 return; |
| 27 } | 73 } |
| 28 | 74 |
| 29 SkASSERT(NULL != fPicture->fRecord); | 75 SkASSERT(NULL != fCanvas.get()); |
| 76 SkPictureRecord* record = static_cast<SkPictureRecord*>(fCanvas.get()); | |
| 30 | 77 |
| 31 SkAutoTDelete<SkPicturePlayback> playback(SkPicture::FakeEndRecording(fPictu re.get(), | 78 SkAutoTDelete<SkPicturePlayback> playback(SkPicture::FakeEndRecording(fPictu re.get(), |
| 32 *fPict ure->fRecord, | 79 *recor d, |
| 33 false) ); | 80 false) ); |
| 34 playback->draw(*canvas, NULL); | 81 playback->draw(*canvas, NULL); |
| 35 } | 82 } |
| 36 #endif | 83 #endif |
| OLD | NEW |