Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: src/core/SkPictureRecorder.cpp

Issue 718443002: Change where layer hoisting data is gathered (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix no-GPU build Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkPicture.cpp ('k') | src/gpu/GrPictureUtils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
« no previous file with comments | « src/core/SkPicture.cpp ('k') | src/gpu/GrPictureUtils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698