Chromium Code Reviews| Index: src/core/SkPictureRecorder.cpp |
| diff --git a/src/core/SkPictureRecorder.cpp b/src/core/SkPictureRecorder.cpp |
| index 1589ec0536a0cb64e07690c0db419fe815046957..4637a7f8be8239412284fe94c80acc926d879787 100644 |
| --- a/src/core/SkPictureRecorder.cpp |
| +++ b/src/core/SkPictureRecorder.cpp |
| @@ -5,18 +5,64 @@ |
| * found in the LICENSE file. |
| */ |
| -// Need to include SkTypes first, so that SK_BUILD_FOR_ANDROID is defined. |
| -#include "SkTypes.h" |
| -#ifdef SK_BUILD_FOR_ANDROID |
| +#include "SkBBoxHierarchyRecord.h" |
| #include "SkPicturePlayback.h" |
| -#endif |
| +#include "SkPictureRecord.h" |
| #include "SkPictureRecorder.h" |
| +#include "SkTypes.h" |
| SkCanvas* SkPictureRecorder::beginRecording(int width, int height, |
| SkBBHFactory* bbhFactory /* = NULL */, |
| uint32_t recordFlags /* = 0 */) { |
| + 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
|
| fPicture.reset(SkNEW(SkPicture)); |
| - return fPicture->beginRecording(width, height, bbhFactory, recordFlags); |
| + |
| + fPicture->fWidth = width; |
| + fPicture->fHeight = height; |
| + |
| + const SkISize size = SkISize::Make(width, height); |
| + |
| + 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
|
| + |
| + if (NULL != bbhFactory) { |
| + SkAutoTUnref<SkBBoxHierarchy> tree((*bbhFactory)(width, height)); |
| + SkASSERT(NULL != tree); |
| + record = SkNEW_ARGS(SkBBoxHierarchyRecord, (fPicture, size, recordFlags, tree.get())); |
| + } else { |
| + record = SkNEW_ARGS(SkPictureRecord, (fPicture, size, recordFlags)); |
| + } |
| + fCanvas.reset(record); |
| + record->beginRecording(); |
| + |
| + return fCanvas; |
| +} |
| + |
| +SkPicture* SkPictureRecorder::endRecording() { |
| + 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.
|
| + SkASSERT(NULL == fPicture->fPlayback); |
| + SkASSERT(NULL != fCanvas); |
| + |
| + 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.
|
| + record->endRecording(); |
| + |
| + SkPictInfo info; |
| + fPicture->createHeader(&info); |
| + 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
|
| + |
| + fCanvas.reset(NULL); |
| + |
| + return fPicture.detach(); |
| + } |
| + return NULL; |
| +} |
| + |
| +void SkPictureRecorder::internalOnly_EnableOpts(bool enableOpts) { |
| + if (NULL == fCanvas) { |
| + return; |
| + } |
| + |
| + SkPictureRecord* record = static_cast<SkPictureRecord*>(fCanvas.get()); |
| + record->internalOnly_EnableOpts(enableOpts); |
| } |
| #ifdef SK_BUILD_FOR_ANDROID |
| @@ -26,10 +72,11 @@ void SkPictureRecorder::partialReplay(SkCanvas* canvas) const { |
| return; |
| } |
| - SkASSERT(NULL != fPicture->fRecord); |
| + SkASSERT(NULL != fCanvas.get()); |
| + SkPictureRecord* record = static_cast<SkPictureRecord*>(fCanvas.get()); |
| SkAutoTDelete<SkPicturePlayback> playback(SkPicture::FakeEndRecording(fPicture.get(), |
| - *fPicture->fRecord, |
| + *record, |
| false)); |
| playback->draw(*canvas, NULL); |
| } |