Don't save matrix when using canvas.save

Summary:
Canvas.save by default saves both the matrix (for translations,
scaling, etc) and the clip (clipRect) - in most of our cases, we really only
care to save and restore the clip, not the matrix.

Reviewed By: sriramramani

Differential Revision: D3235698
This commit is contained in:
Ahmed El-Helw 2016-04-28 10:44:32 -07:00
parent 118cc4b9b7
commit 0d21baf604
4 changed files with 4 additions and 6 deletions

View File

@ -62,8 +62,6 @@ import android.graphics.Canvas;
// shows up during screenshot testing. Note that checking one side is enough, since if one side
// is infinite, all sides will be infinite, since we only set infinite for all sides at the
// same time - conversely, if one side is finite, all sides will be finite.
if (mNeedsClipping) {
canvas.clipRect(mClipLeft, mClipTop, mClipRight, mClipBottom);
}
canvas.clipRect(mClipLeft, mClipTop, mClipRight, mClipBottom);
}
}

View File

@ -31,7 +31,7 @@ import android.graphics.Canvas;
public final void draw(FlatViewGroup parent, Canvas canvas) {
onPreDraw(parent, canvas);
if (shouldClip()) {
canvas.save();
canvas.save(Canvas.CLIP_SAVE_FLAG);
applyClipping(canvas);
onDraw(canvas);
canvas.restore();

View File

@ -22,7 +22,7 @@ import android.graphics.Canvas;
@Override
public void draw(FlatViewGroup parent, Canvas canvas) {
if (mNeedsClipping) {
canvas.save();
canvas.save(Canvas.CLIP_SAVE_FLAG);
applyClipping(canvas);
parent.drawNextChild(canvas);
canvas.restore();

View File

@ -346,7 +346,7 @@ import com.facebook.react.views.image.ImageLoadEvent;
super.drawChild(canvas, child, getDrawingTime());
} else {
// Make sure non-React Views clip properly.
canvas.save();
canvas.save(Canvas.CLIP_SAVE_FLAG);
child.getHitRect(VIEW_BOUNDS);
canvas.clipRect(VIEW_BOUNDS);
super.drawChild(canvas, child, getDrawingTime());