Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 40de9f28 authored by Chris Craik's avatar Chris Craik
Browse files

Add fast path for roundrect Outline changes

bug:22724385

Additionally, move all outline/related methods on RenderNode to use
fast JNI.

Change-Id: Idc462099638bdae0391d35975f3161a2f0540b9b
parent c42940bb
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -484,13 +484,13 @@ static JNINativeMethod gMethods[] = {
    { "nSetProjectBackwards",  "!(JZ)Z",  (void*) android_view_RenderNode_setProjectBackwards },
    { "nSetProjectionReceiver","!(JZ)Z",  (void*) android_view_RenderNode_setProjectionReceiver },

    { "nSetOutlineRoundRect",  "(JIIIIFF)Z", (void*) android_view_RenderNode_setOutlineRoundRect },
    { "nSetOutlineConvexPath", "(JJF)Z", (void*) android_view_RenderNode_setOutlineConvexPath },
    { "nSetOutlineEmpty",      "(J)Z",   (void*) android_view_RenderNode_setOutlineEmpty },
    { "nSetOutlineNone",       "(J)Z",   (void*) android_view_RenderNode_setOutlineNone },
    { "nSetOutlineRoundRect",  "!(JIIIIFF)Z", (void*) android_view_RenderNode_setOutlineRoundRect },
    { "nSetOutlineConvexPath", "!(JJF)Z", (void*) android_view_RenderNode_setOutlineConvexPath },
    { "nSetOutlineEmpty",      "!(J)Z",   (void*) android_view_RenderNode_setOutlineEmpty },
    { "nSetOutlineNone",       "!(J)Z",   (void*) android_view_RenderNode_setOutlineNone },
    { "nHasShadow",            "!(J)Z",   (void*) android_view_RenderNode_hasShadow },
    { "nSetClipToOutline",     "!(JZ)Z",  (void*) android_view_RenderNode_setClipToOutline },
    { "nSetRevealClip",        "(JZFFF)Z", (void*) android_view_RenderNode_setRevealClip },
    { "nSetRevealClip",        "!(JZFFF)Z", (void*) android_view_RenderNode_setRevealClip },

    { "nSetAlpha",             "!(JF)Z",  (void*) android_view_RenderNode_setAlpha },
    { "nSetHasOverlappingRendering", "!(JZ)Z",
+19 −3
Original line number Diff line number Diff line
@@ -33,13 +33,29 @@ public:
            , 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();
        if (MathUtils::isPositive(radius)) {
            mPath.addRoundRect(SkRect::MakeLTRB(left, top, right, bottom),
                    radius, radius);
        mAlpha = alpha;
        } else {
            mPath.addRect(left, top, right, bottom);
        }
    }

    void setConvexPath(const SkPath* outline, float alpha) {