Turn on the save-layer optimization.

BUG=skia:
R=robertphillips@google.com, mtklein@google.com

Author: mtklein@chromium.org

Review URL: https://codereview.chromium.org/551853002
This commit is contained in:
mtklein 2014-09-08 08:41:37 -07:00 committed by Commit bot
parent 95fd68e5cc
commit 93f52a6944
3 changed files with 18 additions and 13 deletions

View File

@ -639,18 +639,21 @@ uint32_t SkPicture::uniqueID() const {
return fUniqueID;
}
static SkRecord* optimized(SkRecord* r) {
SkRecordOptimize(r);
return r;
}
// fRecord OK
SkPicture::SkPicture(SkScalar width, SkScalar height, SkRecord* record, SkBBoxHierarchy* bbh)
: fCullWidth(width)
, fCullHeight(height)
, fRecord(record)
, fRecord(optimized(record))
, fBBH(SkSafeRef(bbh))
, fAnalysis(*record) {
// TODO: move optimization before we construct fAnalysis?
SkRecordOptimize(record);
, fAnalysis(*fRecord) {
// TODO: delay as much of this work until just before first playback?
if (fBBH.get()) {
SkRecordFillBounds(*record, fBBH.get());
SkRecordFillBounds(*fRecord, fBBH.get());
}
this->needsNewGenID();
}

View File

@ -14,8 +14,7 @@
using namespace SkRecords;
void SkRecordOptimize(SkRecord* record) {
// TODO(mtklein): rebaseline and re-enable
//SkRecordNoopSaveLayerDrawRestores(record);
SkRecordNoopSaveLayerDrawRestores(record);
SkRecordNoopSaveRestores(record);
SkRecordReduceDrawPosTextStrength(record);
}

View File

@ -935,20 +935,23 @@ static void test_gpu_picture_optimization(skiatest::Reporter* reporter,
c->saveLayer(NULL, &p); // layer #3
c->restore();
}
SkPaint layerPaint;
layerPaint.setColor(SK_ColorRED); // Non-alpha only to avoid SaveLayerDrawRestoreNooper
// 4)
{
c->saveLayer(NULL, NULL); // layer #4
c->saveLayer(NULL, &layerPaint); // layer #4
c->drawPicture(child); // layer #5 inside picture
c->restore();
}
// 5
{
SkPaint p;
SkPaint picturePaint;
SkMatrix trans;
trans.setTranslate(10, 10);
c->saveLayer(NULL, NULL); // layer #6
c->drawPicture(child, &trans, &p); // layer #7 inside picture
c->saveLayer(NULL, &layerPaint); // layer #6
c->drawPicture(child, &trans, &picturePaint); // layer #7 inside picture
c->restore();
}
@ -1032,7 +1035,7 @@ static void test_gpu_picture_optimization(skiatest::Reporter* reporter,
kHeight == info4.fSize.fHeight);
REPORTER_ASSERT(reporter, 0 == info4.fOffset.fX && 0 == info4.fOffset.fY);
REPORTER_ASSERT(reporter, info4.fOriginXform.isIdentity());
REPORTER_ASSERT(reporter, NULL == info4.fPaint);
REPORTER_ASSERT(reporter, info4.fPaint);
REPORTER_ASSERT(reporter, !info4.fIsNested &&
info4.fHasNestedLayers); // has a nested SL
@ -1051,7 +1054,7 @@ static void test_gpu_picture_optimization(skiatest::Reporter* reporter,
kHeight == info6.fSize.fHeight);
REPORTER_ASSERT(reporter, 0 == info6.fOffset.fX && 0 == info6.fOffset.fY);
REPORTER_ASSERT(reporter, info6.fOriginXform.isIdentity());
REPORTER_ASSERT(reporter, NULL == info6.fPaint);
REPORTER_ASSERT(reporter, info6.fPaint);
REPORTER_ASSERT(reporter, !info6.fIsNested &&
info6.fHasNestedLayers); // has a nested SL