mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
0d21baf604
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
34 lines
967 B
Java
34 lines
967 B
Java
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*/
|
|
|
|
package com.facebook.react.flat;
|
|
|
|
import android.graphics.Canvas;
|
|
|
|
/* package */ final class DrawView extends AbstractClippingDrawCommand {
|
|
|
|
/* package */ static final DrawView INSTANCE = new DrawView(0, 0, 0, 0);
|
|
|
|
public DrawView(float clipLeft, float clipTop, float clipRight, float clipBottom) {
|
|
setClipBounds(clipLeft, clipTop, clipRight, clipBottom);
|
|
}
|
|
|
|
@Override
|
|
public void draw(FlatViewGroup parent, Canvas canvas) {
|
|
if (mNeedsClipping) {
|
|
canvas.save(Canvas.CLIP_SAVE_FLAG);
|
|
applyClipping(canvas);
|
|
parent.drawNextChild(canvas);
|
|
canvas.restore();
|
|
} else {
|
|
parent.drawNextChild(canvas);
|
|
}
|
|
}
|
|
}
|