Improve performance of unclipped save layers.

Instead of allocating a separate renderTarget and switching
between them on each draw the new implementation follows the same
pattern that the old HWUI renderer used. The area of the layer is
now copied to a buffer on the GPU, the area is then cleared, rendered
as normal, and finally the texture is redrawn using dst_over blending.

This results in no render target switches and is considerably faster
on some hardware.

Test: CtsGraphicsTestCases, CtsUiRenderingTestCases
Bug: 119222339
Change-Id: I716aac1fc31e4c7a171373d37dee82034c01cf18
This commit is contained in:
Derek Sollenberger
2018-12-07 14:12:12 -05:00
parent e8a25e3dbc
commit 24fc901e5f
8 changed files with 39 additions and 1 deletions

View File

@@ -556,7 +556,7 @@ public class Canvas extends BaseCanvas {
* @hide
*/
public int saveUnclippedLayer(int left, int top, int right, int bottom) {
return nSaveLayer(mNativeCanvasWrapper, left, top, right, bottom, 0, 0);
return nSaveUnclippedLayer(mNativeCanvasWrapper, left, top, right, bottom);
}
/**
@@ -1395,6 +1395,8 @@ public class Canvas extends BaseCanvas {
private static native int nSaveLayerAlpha(long nativeCanvas, float l, float t, float r, float b,
int alpha, int layerFlags);
@CriticalNative
private static native int nSaveUnclippedLayer(long nativeCanvas, int l, int t, int r, int b);
@CriticalNative
private static native boolean nRestore(long canvasHandle);
@CriticalNative
private static native void nRestoreToCount(long canvasHandle, int saveCount);