Index: src/core/SkPictureRecorder.cpp |
diff --git a/src/core/SkPictureRecorder.cpp b/src/core/SkPictureRecorder.cpp |
index 9ae5c214847315616a71b05a3574bc73b3e9ac65..2985b2dfff4facbc1a77eba13ab3b19b484e2ba8 100644 |
--- a/src/core/SkPictureRecorder.cpp |
+++ b/src/core/SkPictureRecorder.cpp |
@@ -5,10 +5,15 @@ |
* found in the LICENSE file. |
*/ |
+#if SK_SUPPORT_GPU |
+#include "GrPictureUtils.h" |
+#endif |
+ |
#include "SkPictureRecorder.h" |
#include "SkRecord.h" |
#include "SkRecordDraw.h" |
#include "SkRecorder.h" |
+#include "SkRecordOpts.h" |
#include "SkTypes.h" |
SkPictureRecorder::SkPictureRecorder() {} |
@@ -18,6 +23,7 @@ SkPictureRecorder::~SkPictureRecorder() {} |
SkCanvas* SkPictureRecorder::beginRecording(SkScalar width, SkScalar height, |
SkBBHFactory* bbhFactory /* = NULL */, |
uint32_t recordFlags /* = 0 */) { |
+ fFlags = recordFlags; |
fCullWidth = width; |
fCullHeight = height; |
@@ -36,7 +42,42 @@ SkCanvas* SkPictureRecorder::getRecordingCanvas() { |
} |
SkPicture* SkPictureRecorder::endRecording() { |
- return SkNEW_ARGS(SkPicture, (fCullWidth, fCullHeight, fRecord.detach(), fBBH.get())); |
+ // TODO: delay as much of this work until just before first playback? |
+ SkRecordOptimize(fRecord); |
+ |
+#if SK_SUPPORT_GPU |
+ SkAutoTUnref<GrAccelData> saveLayerData; |
+ |
+ if (fBBH && (fFlags & kComputeSaveLayerInfo_RecordFlag)) { |
+ SkPicture::AccelData::Key key = GrAccelData::ComputeAccelDataKey(); |
+ |
+ saveLayerData.reset(SkNEW_ARGS(GrAccelData, (key))); |
+ } |
+#endif |
+ |
+ if (fBBH.get()) { |
+ SkRect cullRect = SkRect::MakeWH(fCullWidth, fCullHeight); |
+ |
+#if SK_SUPPORT_GPU |
+ if (saveLayerData) { |
+ SkRecordComputeLayers(cullRect, *fRecord, fBBH.get(), saveLayerData); |
+ } else { |
+#endif |
+ SkRecordFillBounds(cullRect, *fRecord, fBBH.get()); |
+#if SK_SUPPORT_GPU |
+ } |
+#endif |
+ } |
+ |
+ SkPicture* pict = SkNEW_ARGS(SkPicture, (fCullWidth, fCullHeight, fRecord.detach(), fBBH.get())); |
+ |
+#if SK_SUPPORT_GPU |
+ if (saveLayerData) { |
+ pict->EXPERIMENTAL_addAccelData(saveLayerData); |
+ } |
+#endif |
+ |
+ return pict; |
} |
void SkPictureRecorder::partialReplay(SkCanvas* canvas) const { |