Emulate replace clip ops using SkAndroidFrameworkUtils::ResetClip
At the JNI bridge, Region::Op::kReplace_Op is detected and sent
to new functions on Canvas.h -> emulateReplaceClip[Rect|Path].
The SkiaCanvas implementation calls
SkAndroidFrameworkUtils::ResetClip to turn the SkCanvas' clip
wide open (modulo the device clip restriction), followed by
an intersect op with the actual clip geometry.
SkiaCanvas is also updated to record the replace ops in its
Clip struct for partial saves.
This should result in no visible behavioral change at the Java
Canvas level, but allows the removal of the
SK_SUPPORT_DEPRECATED_CLIPOPS flag.
Test: Updated SkiaPipeline.clip_replace unit test to use the new
emulateReplaceClipRect function instead of SkClipOp::kReplace.
Builds and recently added CTS tests for clip ops pass.
Bug: b/151725198
Bug: b/143352151
Change-Id: I8fb8765b4ead92bbe8eceadb52710a5673b6cf6b
diff --git a/libs/hwui/canvas/CanvasFrontend.cpp b/libs/hwui/canvas/CanvasFrontend.cpp
index 8f261c83..dd01a5b 100644
--- a/libs/hwui/canvas/CanvasFrontend.cpp
+++ b/libs/hwui/canvas/CanvasFrontend.cpp
@@ -54,13 +54,10 @@
return false;
}
-// Assert that the cast from SkClipOp to SkRegion::Op is valid
+// Assert that the cast from SkClipOp to SkRegion::Op is valid.
+// SkClipOp is a subset of SkRegion::Op and only supports difference and intersect.
static_assert(static_cast<int>(SkClipOp::kDifference) == SkRegion::Op::kDifference_Op);
static_assert(static_cast<int>(SkClipOp::kIntersect) == SkRegion::Op::kIntersect_Op);
-static_assert(static_cast<int>(SkClipOp::kUnion_deprecated) == SkRegion::Op::kUnion_Op);
-static_assert(static_cast<int>(SkClipOp::kXOR_deprecated) == SkRegion::Op::kXOR_Op);
-static_assert(static_cast<int>(SkClipOp::kReverseDifference_deprecated) == SkRegion::Op::kReverseDifference_Op);
-static_assert(static_cast<int>(SkClipOp::kReplace_deprecated) == SkRegion::Op::kReplace_Op);
void CanvasStateHelper::internalClipRect(const SkRect& rect, SkClipOp op) {
clip().opRect(rect, transform(), mInitialBounds, (SkRegion::Op)op, false);