| Index: src/core/SkPictureRecorder.cpp
|
| diff --git a/src/core/SkPictureRecorder.cpp b/src/core/SkPictureRecorder.cpp
|
| index 1589ec0536a0cb64e07690c0db419fe815046957..31302d0cbc00e0c289cf015d2ccf3d4849d4301c 100644
|
| --- a/src/core/SkPictureRecorder.cpp
|
| +++ b/src/core/SkPictureRecorder.cpp
|
| @@ -5,18 +5,67 @@
|
| * 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"
|
| +
|
| +SkPictureRecorder::~SkPictureRecorder() {
|
| + SkSafeSetNull(fCanvas);
|
| +}
|
|
|
| SkCanvas* SkPictureRecorder::beginRecording(int width, int height,
|
| SkBBHFactory* bbhFactory /* = NULL */,
|
| uint32_t recordFlags /* = 0 */) {
|
| + SkSafeSetNull(fCanvas);
|
| fPicture.reset(SkNEW(SkPicture));
|
| - return fPicture->beginRecording(width, height, bbhFactory, recordFlags);
|
| +
|
| + fPicture->fWidth = width;
|
| + fPicture->fHeight = height;
|
| +
|
| + const SkISize size = SkISize::Make(width, height);
|
| +
|
| + if (NULL != bbhFactory) {
|
| + SkAutoTUnref<SkBBoxHierarchy> tree((*bbhFactory)(width, height));
|
| + SkASSERT(NULL != tree);
|
| + fCanvas = SkNEW_ARGS(SkBBoxHierarchyRecord, (fPicture, size, recordFlags, tree.get()));
|
| + } else {
|
| + fCanvas = SkNEW_ARGS(SkPictureRecord, (fPicture, size, recordFlags));
|
| + }
|
| +
|
| + fCanvas->beginRecording();
|
| +
|
| + return fCanvas;
|
| +}
|
| +
|
| +SkCanvas* SkPictureRecorder::getRecordingCanvas() {
|
| + return fCanvas;
|
| +}
|
| +
|
| +SkPicture* SkPictureRecorder::endRecording() {
|
| + if (NULL == fPicture.get()) {
|
| + return NULL;
|
| + }
|
| +
|
| + SkASSERT(NULL == fPicture->fPlayback);
|
| + SkASSERT(NULL != fCanvas);
|
| +
|
| + fCanvas->endRecording();
|
| +
|
| + SkPictInfo info;
|
| + fPicture->createHeader(&info);
|
| + fPicture->fPlayback = SkNEW_ARGS(SkPicturePlayback, (fPicture, *fCanvas, info));
|
| +
|
| + SkSafeSetNull(fCanvas);
|
| +
|
| + return fPicture.detach();
|
| +}
|
| +
|
| +void SkPictureRecorder::internalOnly_EnableOpts(bool enableOpts) {
|
| + if (NULL != fCanvas) {
|
| + fCanvas->internalOnly_EnableOpts(enableOpts);
|
| + }
|
| }
|
|
|
| #ifdef SK_BUILD_FOR_ANDROID
|
| @@ -26,10 +75,10 @@ void SkPictureRecorder::partialReplay(SkCanvas* canvas) const {
|
| return;
|
| }
|
|
|
| - SkASSERT(NULL != fPicture->fRecord);
|
| + SkASSERT(NULL != fCanvas);
|
|
|
| SkAutoTDelete<SkPicturePlayback> playback(SkPicture::FakeEndRecording(fPicture.get(),
|
| - *fPicture->fRecord,
|
| + *fCanvas,
|
| false));
|
| playback->draw(*canvas, NULL);
|
| }
|
|
|