Skip to content

Commit

Permalink
Make ScaledFrameLayout only save matrix
Browse files Browse the repository at this point in the history
Previous versions of ScaledFrameLayout saved the entire layer. This
isn't great for performance reasons, but it also had the side effect
on Android > 8.0 of messing with how WebView draws to the screen since
it is drawing to a back buffer. This change switches to only calling
save(), which saves the various transformations without creating a
secondary buffer. This seems to make the WebView happy again.

Change-Id: I9188e68d943fdc56bca7a57a24d0d17b2f9b49e7
  • Loading branch information
ewpatton authored and jisqyv committed Aug 20, 2019
1 parent 4c3f54b commit e03ae81
Showing 1 changed file with 1 addition and 5 deletions.
Expand Up @@ -58,11 +58,7 @@ public ScaledFrameLayout(Context context, AttributeSet attrs, int defStyle) {

@Override
protected void dispatchDraw(Canvas canvas) {
if (VERSION.SDK_INT < VERSION_CODES.P) {
canvas.saveLayer(0, 0, canvas.getWidth(), canvas.getHeight(), null, MATRIX_SAVE_FLAG);
} else {
canvas.saveLayer(0, 0, canvas.getWidth(), canvas.getHeight(), null);
}
canvas.save();
canvas.scale(mScale, mScale);
super.dispatchDraw(canvas);
canvas.restore();
Expand Down

0 comments on commit e03ae81

Please sign in to comment.