Modify savelayer to save matrix and clip for Skia pipeline
Modify SkiaCanvas::saveLayer to always save matrix and clip and
match HWUI behaviour. Also ensure android state tracking
behavior matches that of the Skia API (partial saves not
supported). This change is fixing SaveLayerAnimation
macrobench when buffer age is disabled.
Add a HWUI unit test that verifies clip and matrix are restored.
Test: built and ran angler-eng, ran hwui unit tests
bug:33429678
Change-Id: I62e429f9746518fef67663b0dd99ac499bf31af3
diff --git a/libs/hwui/SkiaCanvas.cpp b/libs/hwui/SkiaCanvas.cpp
index 8ab57c9d..8cae771 100644
--- a/libs/hwui/SkiaCanvas.cpp
+++ b/libs/hwui/SkiaCanvas.cpp
@@ -199,11 +199,11 @@
int SkiaCanvas::saveLayer(float left, float top, float right, float bottom,
const SkPaint* paint, SaveFlags::Flags flags) {
const SkRect bounds = SkRect::MakeLTRB(left, top, right, bottom);
- const SkCanvas::SaveLayerRec rec(&bounds, paint, layerFlags(flags));
+ //always save matrix and clip to match the behaviour of Skia and HWUI pipelines and to ensure
+ //android state tracking behavior matches that of the Skia API (partial save is not supported)
+ const SkCanvas::SaveLayerRec rec(&bounds, paint, layerFlags(flags | SaveFlags::MatrixClip));
- int count = mCanvas->saveLayer(rec);
- recordPartialSave(flags);
- return count;
+ return mCanvas->saveLayer(rec);
}
int SkiaCanvas::saveLayerAlpha(float left, float top, float right, float bottom,