diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp index f595f74e4e..408901bebe 100644 --- a/src/core/SkPicture.cpp +++ b/src/core/SkPicture.cpp @@ -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(); } diff --git a/src/core/SkRecordOpts.cpp b/src/core/SkRecordOpts.cpp index 428d1ca428..3302d0cb4d 100644 --- a/src/core/SkRecordOpts.cpp +++ b/src/core/SkRecordOpts.cpp @@ -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); } diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp index 8755440e0b..05aec092c3 100644 --- a/tests/PictureTest.cpp +++ b/tests/PictureTest.cpp @@ -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