androidFramework_replaceClip proposal

Expose a android framework-only function to reset the saved clip geometry
a device-space pixel rect (e.g. the device clip restriction). Using a
regular intersect clip operation after this call should match the
behavior of the legacy replace operation with a clip restriction.

This is a step to removing the separate device clip
restriction API and the deprecated expanding clip ops, as part of the
plan described here: https://docs.google.com/document/d/1ddIk74A1rL5Kj5kGcnInOYKVAXs3J2IsSgU5BLit0Ng/edit?usp=sharing

Bug: skia:10207
Bug: skia:10209

Change-Id: I57d3bcc7b5b257935eb2bf2099d472f2ef354d5b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/298824
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
diff --git a/src/android/SkAndroidFrameworkUtils.cpp b/src/android/SkAndroidFrameworkUtils.cpp
index a7ea2ea..2b2787a 100644
--- a/src/android/SkAndroidFrameworkUtils.cpp
+++ b/src/android/SkAndroidFrameworkUtils.cpp
@@ -35,6 +35,20 @@
     return canvas->only_axis_aligned_saveBehind(subset);
 }
 
+void SkAndroidFrameworkUtils::ReplaceClip(SkCanvas* canvas, const SkIRect* rect) {
+    SkIRect deviceRestriction;
+    if (!rect) {
+        if (canvas->fClipRestrictionRect.isEmpty()) {
+            deviceRestriction = canvas->imageInfo().bounds();
+        } else {
+            deviceRestriction = canvas->fClipRestrictionRect;
+        }
+    } else {
+        deviceRestriction = *rect;
+    }
+    canvas->androidFramework_replaceClip(deviceRestriction);
+}
+
 SkCanvas* SkAndroidFrameworkUtils::getBaseWrappedCanvas(SkCanvas* canvas) {
     auto pfc = canvas->internal_private_asPaintFilterCanvas();
     auto result = canvas;
@@ -45,4 +59,3 @@
     return result;
 }
 #endif // SK_BUILD_FOR_ANDROID_FRAMEWORK
-