aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrPictureUtils.cpp
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2014-11-11 04:54:49 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-11 04:54:49 -0800
commit81f71b6630a9b7398bf983689436cccdd8dd3ff7 (patch)
tree0c7f9ad995dd1ecd400af5da639c433fdda68f92 /src/gpu/GrPictureUtils.cpp
parentbffcb52ffe9b8bb4ae7f6eda0c55719d8e3be7b6 (diff)
Change where layer hoisting data is gathered
This CL: 1) removes the EXPERIMENTAL_optimize on SkCanvas & SkDevice 2) moves the saveLayer gathering step to endRecording 3) Replaces GPUOptimize with SkRecordComputeLayers 4) Update bench_pictures & render_pictures to provide the new flag #2 also necessitated moving the BBH computation (and record optimization) out of SkPicture's ctor (and into endRecording) Review URL: https://codereview.chromium.org/718443002
Diffstat (limited to 'src/gpu/GrPictureUtils.cpp')
-rw-r--r--src/gpu/GrPictureUtils.cpp35
1 files changed, 12 insertions, 23 deletions
diff --git a/src/gpu/GrPictureUtils.cpp b/src/gpu/GrPictureUtils.cpp
index e1a70ab6eb..c0b53f9665 100644
--- a/src/gpu/GrPictureUtils.cpp
+++ b/src/gpu/GrPictureUtils.cpp
@@ -7,6 +7,7 @@
#include "GrPictureUtils.h"
+#include "SkBBoxHierarchy.h"
#include "SkPaintPriv.h"
#include "SkPatchUtils.h"
#include "SkRecord.h"
@@ -61,6 +62,10 @@ public:
this->popSaveLayerInfo();
}
//--------- LAYER HOISTING
+
+ // Finally feed all stored bounds into the BBH. They'll be returned in this order.
+ SkASSERT(bbh);
+ bbh->insert(&fBounds, record.count());
}
template <typename T> void operator()(const T& op) {
@@ -425,7 +430,13 @@ private:
const GrAccelData* childData =
static_cast<const GrAccelData*>(dp.picture->EXPERIMENTAL_getAccelData(key));
if (!childData) {
- childData = GPUOptimize(dp.picture);
+ // If the child layer hasn't been generated with saveLayer data we
+ // assume the worst (i.e., that it does contain layers which nest
+ // inside existing layers). Layers within sub-pictures that don't
+ // have saveLayer data cannot be hoisted.
+ // TODO: could the analysis data be use to fine tune this?
+ this->updateStackForSaveLayer();
+ return;
}
for (int i = 0; i < childData->numSaveLayers(); ++i) {
@@ -587,31 +598,9 @@ private:
} // namespace SkRecords
-
void SkRecordComputeLayers(const SkRect& cullRect, const SkRecord& record,
SkBBoxHierarchy* bbh, GrAccelData* data) {
-
SkRecords::CollectLayers collector(cullRect, record, bbh, data);
}
-const GrAccelData* GPUOptimize(const SkPicture* pict) {
- if (NULL == pict || pict->cullRect().isEmpty()) {
- return NULL;
- }
-
- SkPicture::AccelData::Key key = GrAccelData::ComputeAccelDataKey();
- const GrAccelData* existing =
- static_cast<const GrAccelData*>(pict->EXPERIMENTAL_getAccelData(key));
- if (existing) {
- return existing;
- }
-
- SkAutoTUnref<GrAccelData> data(SkNEW_ARGS(GrAccelData, (key)));
-
- pict->EXPERIMENTAL_addAccelData(data);
-
- SkRecordComputeLayers(pict->cullRect(), *pict->fRecord, NULL, data);
-
- return data;
-}