下面列出了android.graphics.Region#Op ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Draw the {@link EdgeDetail} for this View. Note that on API 11 - 17 clipPath is only available
* if HardwareAcceleration is disable. A function {@link DecoView#enableCompatibilityMode()}
* is provided which will disable on affected platforms however this needs to be explicitly
* called by the user, otherwise EdgeDetails will not be drawn
*/
protected void drawClippedArc(@NonNull Canvas canvas, @NonNull Path path, int color, @NonNull Region.Op combine) {
canvas.save();
try {
canvas.clipPath(path, combine);
} catch (UnsupportedOperationException e) {
Log.w(TAG, "clipPath unavailable on API 11 - 17 without disabling hardware acceleration. (EdgeDetail functionality requires clipPath). Call DecoView.enableCompatibilityMode() to enable");
canvas.restore();
return;
}
int colorOld = mPaint.getColor();
Shader shaderOld = mPaint.getShader();
mPaint.setColor(color);
mPaint.setShader(null);
drawArc(canvas);
mPaint.setColor(colorOld);
mPaint.setShader(shaderOld);
canvas.restore();
}
/**
* Draw the {@link EdgeDetail} for this View. Note that on API 11 - 17 clipPath is only available
* if HardwareAcceleration is disable. A function {@link DecoView#enableCompatibilityMode()}
* is provided which will disable on affected platforms however this needs to be explicitly
* called by the user, otherwise EdgeDetails will not be drawn
*/
protected void drawClippedArc(@NonNull Canvas canvas, @NonNull Path path, int color, @NonNull Region.Op combine) {
canvas.save();
try {
canvas.clipPath(path, combine);
} catch (UnsupportedOperationException e) {
Log.w(TAG, "clipPath unavailable on API 11 - 17 without disabling hardware acceleration. (EdgeDetail functionality requires clipPath). Call DecoView.enableCompatibilityMode() to enable");
canvas.restore();
return;
}
int colorOld = mPaint.getColor();
mPaint.setColor(color);
drawArc(canvas);
mPaint.setColor(colorOld);
canvas.restore();
}
private void clipCanvasSoftware(Canvas canvas, Region.Op op) {
mPath.reset();
float r = getScaledRadius();
mPath.addCircle(r + getOffsetX(), r + getOffsetY(), r, Path.Direction.CW);
canvas.clipPath(mPath, op);
}
/** @see Canvas#clipPath(Path, Region.Op) */
public Region.Op op() {
return op;
}
@Override public boolean clipRect(RectF rect, Region.Op op) {
return delegate.clipRect(rect, op);
}
@Override public boolean clipRect(Rect rect, Region.Op op) {
return delegate.clipRect(rect, op);
}
@Override
public boolean clipRect(float left, float top, float right, float bottom, Region.Op op) {
return delegate.clipRect(left, top, right, bottom, op);
}
@Override public boolean clipPath(Path path, Region.Op op) {
return delegate.clipPath(path, op);
}
@Override public boolean clipRegion(Region region, Region.Op op) {
return delegate.clipRegion(region, op);
}
/**
* Modify the current clip with the specified rectangle, which is expressed in local
* coordinates.
*
* @param rect The rectangle to intersect with the current clip.
* @param op How the clip is modified
* @return true if the resulting clip is non-empty
*/
public abstract boolean clipRect(Rect rect, Region.Op op);
/**
* Modify the current clip with the specified rectangle, which is expressed in local
* coordinates.
*
* @param left The left side of the rectangle to intersect with the current clip
* @param top The top of the rectangle to intersect with the current clip
* @param right The right side of the rectangle to intersect with the current clip
* @param bottom The bottom of the rectangle to intersect with the current clip
* @param op How the clip is modified
* @return true if the resulting clip is non-empty
*/
public abstract boolean clipRect(double left, double top, double right, double bottom,
Region.Op op);
/**
* Modify the current clip with the specified path.
*
* @param path The path to operate on the current clip
* @param op How the clip is modified
* @return true if the resulting is non-empty
*/
public abstract boolean clipPath(SafeTranslatedPath path, Region.Op op);
/**
* Modify the current clip with the specified region. Note that unlike clipRect() and
* clipPath()
* which transform their arguments by the current matrix, clipRegion() assumes its argument is
* already in the coordinate system of the current layer's bitmap, and so not transformation is
* performed.
*
* @param region The region to operate on the current clip, based on op
* @param op How the clip is modified
* @return true if the resulting is non-empty
*/
public abstract boolean clipRegion(Region region, Region.Op op);