Example usage for android.graphics Canvas clipRegion

List of usage examples for android.graphics Canvas clipRegion

Introduction

In this page you can find the example usage for android.graphics Canvas clipRegion.

Prototype

@Deprecated
public boolean clipRegion(@NonNull Region region) 

Source Link

Document

Intersect the current clip with the specified region.

Usage

From source file:com.mylikes.likes.etchasketch.Slate.java

@Override
protected void onDraw(Canvas canvas) {
    if (mTiledCanvas != null) {
        canvas.save(Canvas.MATRIX_SAVE_FLAG);

        if (mPanX != 0 || mPanY != 0 || !mZoomMatrix.isIdentity()) {
            canvas.translate(mPanX, mPanY);
            canvas.concat(mZoomMatrix);/*from   w  ww  . jav  a  2s.  c om*/

            canvas.drawRect(-20000, -20000, 20000, 0, mWorkspacePaint);
            canvas.drawRect(-20000, 0, 0, mTiledCanvas.getHeight(), mWorkspacePaint);
            canvas.drawRect(mTiledCanvas.getWidth(), 0, 20000, mTiledCanvas.getHeight(), mWorkspacePaint);
            canvas.drawRect(-20000, mTiledCanvas.getHeight(), 20000, 20000, mWorkspacePaint);
        }

        if (!mDirtyRegion.isEmpty()) {
            canvas.clipRegion(mDirtyRegion);
            mDirtyRegion.setEmpty();
        }
        // TODO: tune this threshold based on the device density
        mBlitPaint.setFilterBitmap(getScale(mZoomMatrix) < 3f);
        mTiledCanvas.drawTo(canvas, 0, 0, mBlitPaint, false); // @@ set to true for dirty tile updates
        if (0 != (mDebugFlags & FLAG_DEBUG_STROKES)) {
            drawStrokeDebugInfo(canvas);
        }
        for (MoveableDrawing drawing : overlays) {
            drawing.renderInto(canvas, moveMode && drawing == selectedDrawing);
        }

        canvas.restore();

        if (0 != (mDebugFlags & FLAG_DEBUG_PRESSURE)) {
            mPressureCooker.drawDebug(canvas);
        }
    }
}