Add fast path for roundrect Outline changes
bug:22724385
Additionally, move all outline/related methods on RenderNode to use
fast JNI.
Change-Id: Idc462099638bdae0391d35975f3161a2f0540b9b
diff --git a/libs/hwui/Outline.h b/libs/hwui/Outline.h
index c98932c..8d4d4f0 100644
--- a/libs/hwui/Outline.h
+++ b/libs/hwui/Outline.h
@@ -33,13 +33,29 @@
, mAlpha(0.0f) {}
void setRoundRect(int left, int top, int right, int bottom, float radius, float alpha) {
+ mAlpha = alpha;
+ if (mType == kOutlineType_RoundRect
+ && left == mBounds.left
+ && right == mBounds.right
+ && top == mBounds.top
+ && bottom == mBounds.bottom
+ && radius == mRadius) {
+ // nothing to change, don't do any work
+ return;
+ }
+
mType = kOutlineType_RoundRect;
mBounds.set(left, top, right, bottom);
mRadius = radius;
+
+ // update mPath to reflect new outline
mPath.reset();
- mPath.addRoundRect(SkRect::MakeLTRB(left, top, right, bottom),
- radius, radius);
- mAlpha = alpha;
+ if (MathUtils::isPositive(radius)) {
+ mPath.addRoundRect(SkRect::MakeLTRB(left, top, right, bottom),
+ radius, radius);
+ } else {
+ mPath.addRect(left, top, right, bottom);
+ }
}
void setConvexPath(const SkPath* outline, float alpha) {