| Index: src/core/SkPictureRecorder.cpp
|
| diff --git a/src/core/SkPictureRecorder.cpp b/src/core/SkPictureRecorder.cpp
|
| index b6bb34d5b451d3ef87d7d169fff71d36f1ac0789..1ea912f9157218c18eb19a68b9717bce60b36139 100644
|
| --- a/src/core/SkPictureRecorder.cpp
|
| +++ b/src/core/SkPictureRecorder.cpp
|
| @@ -9,6 +9,8 @@
|
| #include "SkData.h"
|
| #include "SkDrawable.h"
|
| #include "SkLayerInfo.h"
|
| +#include "SkPictureData.h"
|
| +#include "SkPictureRecord.h"
|
| #include "SkPictureRecorder.h"
|
| #include "SkPictureUtils.h"
|
| #include "SkRecord.h"
|
| @@ -16,6 +18,7 @@
|
| #include "SkRecordOpts.h"
|
| #include "SkRecorder.h"
|
| #include "SkTypes.h"
|
| +#include "SkWriteBuffer.h"
|
|
|
| SkPictureRecorder::SkPictureRecorder() {
|
| fActivelyRecording = false;
|
| @@ -175,6 +178,39 @@ protected:
|
| return new SkBigPicture(fBounds, SkRef(fRecord.get()), pictList, SkSafeRef(fBBH.get()),
|
| saveLayerData.release(), subPictureBytes);
|
| }
|
| +
|
| + void flatten(SkWriteBuffer& buffer) const {
|
| + // Write the bounds.
|
| + buffer.writeRect(fBounds);
|
| +
|
| + // Create an SkPictureRecord to record the draw commands.
|
| + SkPictInfo info;
|
| + SkPictureRecord pictureRecord(SkISize::Make(fBounds.width(), fBounds.height()), 0);
|
| +
|
| + // If the query contains the whole picture, don't bother with the bounding box hierarchy.
|
| + SkRect clipBounds;
|
| + pictureRecord.getClipBounds(&clipBounds);
|
| + SkBBoxHierarchy* bbh;
|
| + if (clipBounds.contains(fBounds)) {
|
| + bbh = nullptr;
|
| + } else {
|
| + bbh = fBBH.get();
|
| + }
|
| +
|
| + // Record the draw commands.
|
| + pictureRecord.beginRecording();
|
| + SkRecordDraw(*fRecord, &pictureRecord, nullptr, fDrawableList->begin(),
|
| + fDrawableList->count(), bbh, nullptr);
|
| + pictureRecord.endRecording();
|
| +
|
| + // Flatten the recorded commands and drawables.
|
| + SkPictureData pictureData(pictureRecord, info, false);
|
| + pictureData.flatten(buffer);
|
| + }
|
| +
|
| + const char* getTypeName() const override {
|
| + return "SkRecordedDrawable";
|
| + }
|
| };
|
|
|
| sk_sp<SkDrawable> SkPictureRecorder::finishRecordingAsDrawable() {
|
|
|