Why are we afraid of saveLayer() bounds?
They're only hints. We can ignore them in this optimization. My only hesitation is that this pattern doesn't seem to happen in our .skps. BUG=skia: Review URL: https://codereview.chromium.org/849243002
This commit is contained in:
parent
09544fcf96
commit
0c278972d0
@ -90,13 +90,8 @@ struct SaveLayerDrawRestoreNooper {
|
||||
typedef Pattern3<Is<SaveLayer>, IsDraw, Is<Restore> > Pattern;
|
||||
|
||||
bool onMatch(SkRecord* record, Pattern* pattern, unsigned begin, unsigned end) {
|
||||
SaveLayer* saveLayer = pattern->first<SaveLayer>();
|
||||
if (saveLayer->bounds != NULL) {
|
||||
// SaveLayer with bounds is too tricky for us.
|
||||
return false;
|
||||
}
|
||||
|
||||
SkPaint* layerPaint = saveLayer->paint;
|
||||
// A SaveLayer's bounds field is just a hint, so we should be free to ignore it.
|
||||
SkPaint* layerPaint = pattern->first<SaveLayer>()->paint;
|
||||
if (NULL == layerPaint) {
|
||||
// There wasn't really any point to this SaveLayer at all.
|
||||
return KillSaveLayerAndRestore(record, begin);
|
||||
|
@ -127,16 +127,14 @@ DEF_TEST(RecordOpts_NoopSaveLayerDrawRestore, r) {
|
||||
goodDrawPaint.setColor(0xFF020202); // Opaque.
|
||||
badDrawPaint.setColor( 0x0F020202); // Not opaque.
|
||||
|
||||
// No change: optimization can't handle bounds.
|
||||
recorder.saveLayer(&bounds, NULL);
|
||||
// SaveLayer/Restore removed: No paint = no point.
|
||||
recorder.saveLayer(NULL, NULL);
|
||||
recorder.drawRect(draw, goodDrawPaint);
|
||||
recorder.restore();
|
||||
if (!SkCanvas::Internal_Private_GetIgnoreSaveLayerBounds()) {
|
||||
assert_savelayer_restore(r, &record, 0, false);
|
||||
}
|
||||
assert_savelayer_restore(r, &record, 0, true);
|
||||
|
||||
// SaveLayer/Restore removed: no bounds + no paint = no point.
|
||||
recorder.saveLayer(NULL, NULL);
|
||||
// Bounds don't matter.
|
||||
recorder.saveLayer(&bounds, NULL);
|
||||
recorder.drawRect(draw, goodDrawPaint);
|
||||
recorder.restore();
|
||||
assert_savelayer_restore(r, &record, 3, true);
|
||||
|
Loading…
Reference in New Issue
Block a user