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

Commit fad4593a authored by ztenghui's avatar ztenghui
Browse files

Add the clipToOutline by just using the clipPathOp

Change-Id: I6ba23b589e579599d018600d0744be0efe2028c1
parent 8852ab43
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -442,7 +442,8 @@ public class DisplayList {
    }

    /**
     * Sets the outline, defining the shape that casts a shadow.
     * Sets the outline, defining the shape that casts a shadow, and the path to
     * be clipped if setClipToOutline is set.
     *
     * Deep copies the native path to simplify reference ownership.
     *
@@ -455,6 +456,17 @@ public class DisplayList {
        }
    }

    /**
     * Enables or disables clipping to the outline.
     *
     * @param clipToOutline true if clipping to the outline.
     */
    public void setClipToOutline(boolean clipToOutline) {
        if (hasNativeDisplayList()) {
            nSetClipToOutline(mFinalizer.mNativeDisplayList, clipToOutline);
        }
    }

    /**
     * Set the static matrix on the display list. The specified matrix is combined with other
     * transforms (such as {@link #setScaleX(float)}, {@link #setRotation(float)}, etc.)
@@ -1079,6 +1091,7 @@ public class DisplayList {
    private static native void nSetProjectionReceiver(long displayList, boolean shouldRecieve);
    private static native void nSetIsolatedZVolume(long displayList, boolean isolateZVolume);
    private static native void nSetOutline(long displayList, long nativePath);
    private static native void nSetClipToOutline(long displayList, boolean clipToOutline);
    private static native void nSetAlpha(long displayList, float alpha);
    private static native void nSetHasOverlappingRendering(long displayList,
            boolean hasOverlappingRendering);
+33 −2
Original line number Diff line number Diff line
@@ -2370,6 +2370,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
    static final int PFLAG3_CALLED_SUPER = 0x10;
    /**
     * Flag indicating that an view will be clipped to its outline.
     */
    static final int PFLAG3_CLIP_TO_OUTLINE = 0x20;
    /**
     * Flag indicating that we're in the process of applying window insets.
     */
@@ -3327,7 +3332,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    private int[] mDrawableState = null;
    /**
     * Stores the outline of the view, passed down to the DisplayList level for shadow shape.
     * Stores the outline of the view, passed down to the DisplayList level for
     * defining shadow shape and clipping.
     */
    private Path mOutline;
@@ -10819,6 +10825,30 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        }
    }
    /**
     * @hide
     */
    public void setClipToOutline(boolean clipToOutline) {
        // TODO : Add a fast invalidation here.
        if (getClipToOutline() != clipToOutline) {
            if (clipToOutline) {
                mPrivateFlags3 |= PFLAG3_CLIP_TO_OUTLINE;
            } else {
                mPrivateFlags3 &= ~PFLAG3_CLIP_TO_OUTLINE;
            }
            if (mDisplayList != null) {
                mDisplayList.setClipToOutline(clipToOutline);
            }
        }
    }
    /**
     * @hide
     */
    public final boolean getClipToOutline() {
        return ((mPrivateFlags3 & PFLAG3_CLIP_TO_OUTLINE) != 0);
    }
    /**
     * Hit rectangle in parent's coordinates
     *
@@ -14471,6 +14501,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                        (((ViewGroup) this).mGroupFlags & ViewGroup.FLAG_ISOLATED_Z_VOLUME) != 0);
            }
            displayList.setOutline(mOutline);
            displayList.setClipToOutline(getClipToOutline());
            float alpha = 1;
            if (mParent instanceof ViewGroup && (((ViewGroup) mParent).mGroupFlags &
                    ViewGroup.FLAG_SUPPORT_STATIC_TRANSFORMATIONS) != 0) {
+7 −0
Original line number Diff line number Diff line
@@ -130,6 +130,12 @@ static void android_view_DisplayList_setOutline(JNIEnv* env,
    displayList->setOutline(outline);
}

static void android_view_DisplayList_setClipToOutline(JNIEnv* env,
        jobject clazz, jlong displayListPtr, jboolean clipToOutline) {
    DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListPtr);
    displayList->setClipToOutline(clipToOutline);
}

static void android_view_DisplayList_setAlpha(JNIEnv* env,
        jobject clazz, jlong displayListPtr, float alpha) {
    DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListPtr);
@@ -400,6 +406,7 @@ static JNINativeMethod gMethods[] = {
    { "nSetProjectBackwards",  "(JZ)V",  (void*) android_view_DisplayList_setProjectBackwards },
    { "nSetProjectionReceiver","(JZ)V",  (void*) android_view_DisplayList_setProjectionReceiver },
    { "nSetOutline",           "(JJ)V",  (void*) android_view_DisplayList_setOutline },
    { "nSetClipToOutline",     "(JZ)V",  (void*) android_view_DisplayList_setClipToOutline },
    { "nSetAlpha",             "(JF)V",  (void*) android_view_DisplayList_setAlpha },
    { "nSetHasOverlappingRendering", "(JZ)V",
            (void*) android_view_DisplayList_setHasOverlappingRendering },
+5 −0
Original line number Diff line number Diff line
@@ -242,6 +242,7 @@ void DisplayList::init() {
    mProjectBackwards = false;
    mProjectionReceiver = false;
    mOutline.rewind();
    mClipToOutline = false;
    mAlpha = 1;
    mHasOverlappingRendering = true;
    mTranslationX = 0;
@@ -465,6 +466,10 @@ void DisplayList::setViewProperties(OpenGLRenderer& renderer, T& handler,
                mRight - mLeft, mBottom - mTop, SkRegion::kIntersect_Op);
        handler(op, PROPERTY_SAVECOUNT, mClipToBounds);
    }
    if (CC_UNLIKELY(mClipToOutline && !mOutline.isEmpty())) {
        ClipPathOp* op = new (handler.allocator()) ClipPathOp(&mOutline, SkRegion::kIntersect_Op);
        handler(op, PROPERTY_SAVECOUNT, mClipToBounds);
    }
}

/**
+5 −0
Original line number Diff line number Diff line
@@ -213,6 +213,10 @@ public:
        }
    }

    void setClipToOutline(bool clipToOutline) {
        mClipToOutline = clipToOutline;
    }

    void setStaticMatrix(SkMatrix* matrix) {
        delete mStaticMatrix;
        mStaticMatrix = new SkMatrix(*matrix);
@@ -609,6 +613,7 @@ private:
    bool mProjectBackwards;
    bool mProjectionReceiver;
    SkPath mOutline;
    bool mClipToOutline;
    float mAlpha;
    bool mHasOverlappingRendering;
    float mTranslationX, mTranslationY, mTranslationZ;