summaryrefslogtreecommitdiff
path: root/libs/hwui/SkiaCanvas.cpp
diff options
context:
space:
mode:
author Michael Ludwig <michaelludwig@google.com> 2021-07-21 17:02:39 +0000
committer Michael Ludwig <michaelludwig@google.com> 2021-08-03 15:46:04 +0000
commit70cf50c24ac86efe373ab035c656c811344b0f0c (patch)
tree80d0e3983d7804451092f61259baf19609853740 /libs/hwui/SkiaCanvas.cpp
parent311da53f2123b396846434ffbb473a8e8049d1a7 (diff)
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
Diffstat (limited to 'libs/hwui/SkiaCanvas.cpp')
-rw-r--r--libs/hwui/SkiaCanvas.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/libs/hwui/SkiaCanvas.cpp b/libs/hwui/SkiaCanvas.cpp
index d6b6e162757c..53c6db0cdf3a 100644
--- a/libs/hwui/SkiaCanvas.cpp
+++ b/libs/hwui/SkiaCanvas.cpp
@@ -396,6 +396,22 @@ bool SkiaCanvas::clipPath(const SkPath* path, SkClipOp op) {
return !mCanvas->isClipEmpty();
}
+bool SkiaCanvas::replaceClipRect_deprecated(float left, float top, float right, float bottom) {
+ SkRect rect = SkRect::MakeLTRB(left, top, right, bottom);
+
+ // Emulated clip rects are not recorded for partial saves, since
+ // partial saves have been removed from the public API.
+ SkAndroidFrameworkUtils::ResetClip(mCanvas);
+ mCanvas->clipRect(rect, SkClipOp::kIntersect);
+ return !mCanvas->isClipEmpty();
+}
+
+bool SkiaCanvas::replaceClipPath_deprecated(const SkPath* path) {
+ SkAndroidFrameworkUtils::ResetClip(mCanvas);
+ mCanvas->clipPath(*path, SkClipOp::kIntersect, true);
+ return !mCanvas->isClipEmpty();
+}
+
// ----------------------------------------------------------------------------
// Canvas state operations: Filters
// ----------------------------------------------------------------------------