Avoid performing the pathOp for clipped shadows if possible.

Bug: 64487466
Test: SystemUiJankTests#testRecentAppsFling
Change-Id: I2ca96bd6adba299cd31e12f005b2529c559740d2
diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp
index 61b3876..36a7475 100644
--- a/libs/hwui/RenderNode.cpp
+++ b/libs/hwui/RenderNode.cpp
@@ -32,6 +32,7 @@
 #include "protos/hwui.pb.h"
 #include "protos/ProtoHelpers.h"
 
+#include <SkPathOps.h>
 #include <algorithm>
 #include <sstream>
 #include <string>
@@ -555,5 +556,23 @@
     }
 }
 
+const SkPath* RenderNode::getClippedOutline(const SkRect& clipRect) const {
+    const SkPath* outlinePath = properties().getOutline().getPath();
+    const uint32_t outlineID = outlinePath->getGenerationID();
+
+    if (outlineID != mClippedOutlineCache.outlineID || clipRect != mClippedOutlineCache.clipRect) {
+        // update the cache keys
+        mClippedOutlineCache.outlineID = outlineID;
+        mClippedOutlineCache.clipRect = clipRect;
+
+        // update the cache value by recomputing a new path
+        SkPath clipPath;
+        clipPath.addRect(clipRect);
+        Op(*outlinePath, clipPath, kIntersect_SkPathOp, &mClippedOutlineCache.clippedOutline);
+
+    }
+    return &mClippedOutlineCache.clippedOutline;
+}
+
 } /* namespace uirenderer */
 } /* namespace android */