Loading core/java/android/view/DisplayList.java +25 −0 Original line number Diff line number Diff line Loading @@ -467,6 +467,29 @@ public class DisplayList { } } /** * Set whether the DisplayList should cast a shadow. * * The shape of the shadow casting area is defined by the outline of the display list, if set * and non-empty, otherwise it will be the bounds rect. */ public void setCastsShadow(boolean castsShadow) { if (hasNativeDisplayList()) { nSetCastsShadow(mFinalizer.mNativeDisplayList, castsShadow); } } /** * Sets whether the DisplayList should be drawn with perspective applied from the global camera. * * If set to true, camera distance will be ignored. Defaults to false. */ public void setSharesGlobalCamera(boolean sharesGlobalCamera) { if (hasNativeDisplayList()) { nSetSharesGlobalCamera(mFinalizer.mNativeDisplayList, sharesGlobalCamera); } } /** * 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.) Loading Loading @@ -1092,6 +1115,8 @@ public class DisplayList { 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 nSetCastsShadow(long displayList, boolean castsShadow); private static native void nSetSharesGlobalCamera(long displayList, boolean sharesGlobalCamera); private static native void nSetAlpha(long displayList, float alpha); private static native void nSetHasOverlappingRendering(long displayList, boolean hasOverlappingRendering); Loading core/java/android/view/View.java +63 −2 Original line number Diff line number Diff line Loading @@ -2385,6 +2385,17 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ static final int PFLAG3_FITTING_SYSTEM_WINDOWS = 0x80; /** * Flag indicating that an view will cast a shadow onto the Z=0 plane if elevated. */ static final int PFLAG3_CASTS_SHADOW = 0x100; /** * Flag indicating that view will be transformed by the global camera if rotated in 3d, or given * a non-0 Z translation. */ static final int PFLAG3_SHARES_GLOBAL_CAMERA = 0x200; /* End of masks for mPrivateFlags3 */ static final int DRAG_MASK = PFLAG2_DRAG_CAN_ACCEPT | PFLAG2_DRAG_HOVERED; Loading Loading @@ -10825,6 +10836,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } } /** * @hide */ public final boolean getClipToOutline() { return ((mPrivateFlags3 & PFLAG3_CLIP_TO_OUTLINE) != 0); } /** * @hide */ Loading @@ -10845,8 +10863,49 @@ public class View implements Drawable.Callback, KeyEvent.Callback, /** * @hide */ public final boolean getClipToOutline() { return ((mPrivateFlags3 & PFLAG3_CLIP_TO_OUTLINE) != 0); public final boolean getCastsShadow() { return ((mPrivateFlags3 & PFLAG3_CASTS_SHADOW) != 0); } /** * @hide */ public void setCastsShadow(boolean castsShadow) { // TODO : Add a fast invalidation here. if (getCastsShadow() != castsShadow) { if (castsShadow) { mPrivateFlags3 |= PFLAG3_CASTS_SHADOW; } else { mPrivateFlags3 &= ~PFLAG3_CASTS_SHADOW; } if (mDisplayList != null) { mDisplayList.setCastsShadow(castsShadow); } } } /** * @hide */ public final boolean getSharesGlobalCamera() { return ((mPrivateFlags3 & PFLAG3_SHARES_GLOBAL_CAMERA) != 0); } /** * @hide */ public void setSharesGlobalCamera(boolean sharesGlobalCamera) { // TODO : Add a fast invalidation here. if (getSharesGlobalCamera() != sharesGlobalCamera) { if (sharesGlobalCamera) { mPrivateFlags3 |= PFLAG3_SHARES_GLOBAL_CAMERA; } else { mPrivateFlags3 &= ~PFLAG3_SHARES_GLOBAL_CAMERA; } if (mDisplayList != null) { mDisplayList.setSharesGlobalCamera(sharesGlobalCamera); } } } /** Loading Loading @@ -14502,6 +14561,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } displayList.setOutline(mOutline); displayList.setClipToOutline(getClipToOutline()); displayList.setCastsShadow(getCastsShadow()); displayList.setSharesGlobalCamera(getSharesGlobalCamera()); float alpha = 1; if (mParent instanceof ViewGroup && (((ViewGroup) mParent).mGroupFlags & ViewGroup.FLAG_SUPPORT_STATIC_TRANSFORMATIONS) != 0) { core/java/android/view/ViewGroup.java +1 −1 Original line number Diff line number Diff line Loading @@ -3178,7 +3178,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager * inherited Z ordering volume. */ public void setIsolatedZVolume(boolean isolateZVolume) { boolean previousValue = (mGroupFlags & FLAG_ISOLATED_Z_VOLUME) == FLAG_ISOLATED_Z_VOLUME; boolean previousValue = (mGroupFlags & FLAG_ISOLATED_Z_VOLUME) != 0; if (isolateZVolume != previousValue) { setBooleanFlag(FLAG_ISOLATED_Z_VOLUME, isolateZVolume); if (mDisplayList != null) { Loading core/jni/android_view_DisplayList.cpp +14 −0 Original line number Diff line number Diff line Loading @@ -136,6 +136,18 @@ static void android_view_DisplayList_setClipToOutline(JNIEnv* env, displayList->setClipToOutline(clipToOutline); } static void android_view_DisplayList_setCastsShadow(JNIEnv* env, jobject clazz, jlong displayListPtr, jboolean castsShadow) { DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListPtr); displayList->setCastsShadow(castsShadow); } static void android_view_DisplayList_setSharesGlobalCamera(JNIEnv* env, jobject clazz, jlong displayListPtr, jboolean sharesGlobalCamera) { DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListPtr); displayList->setSharesGlobalCamera(sharesGlobalCamera); } static void android_view_DisplayList_setAlpha(JNIEnv* env, jobject clazz, jlong displayListPtr, float alpha) { DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListPtr); Loading Loading @@ -407,6 +419,8 @@ static JNINativeMethod gMethods[] = { { "nSetProjectionReceiver","(JZ)V", (void*) android_view_DisplayList_setProjectionReceiver }, { "nSetOutline", "(JJ)V", (void*) android_view_DisplayList_setOutline }, { "nSetClipToOutline", "(JZ)V", (void*) android_view_DisplayList_setClipToOutline }, { "nSetCastsShadow", "(JZ)V", (void*) android_view_DisplayList_setCastsShadow }, { "nSetSharesGlobalCamera","(JZ)V", (void*) android_view_DisplayList_setSharesGlobalCamera }, { "nSetAlpha", "(JF)V", (void*) android_view_DisplayList_setAlpha }, { "nSetHasOverlappingRendering", "(JZ)V", (void*) android_view_DisplayList_setHasOverlappingRendering }, Loading libs/hwui/DisplayList.cpp +6 −7 Original line number Diff line number Diff line Loading @@ -243,6 +243,8 @@ void DisplayList::init() { mProjectionReceiver = false; mOutline.rewind(); mClipToOutline = false; mCastsShadow = false; mSharesGlobalCamera = false; mAlpha = 1; mHasOverlappingRendering = true; mTranslationX = 0; Loading Loading @@ -670,16 +672,13 @@ void DisplayList::iterate3dChildren(ChildrenSelectMode mode, OpenGLRenderer& ren if (mode == kPositiveZChildren && zValue < 0.0f) continue; if (mode == kNegativeZChildren && zValue > 0.0f) break; if (mode == kPositiveZChildren && zValue > 0.0f) { DisplayList* child = childOp->mDisplayList; if (mode == kPositiveZChildren && zValue > 0.0f && child->mCastsShadow) { /* draw shadow with parent matrix applied, passing in the child's total matrix * * TODO: * -view must opt-in to shadows * -consider depth in more complex scenarios (neg z, added shadow depth) * TODO: consider depth in more complex scenarios (neg z, added shadow depth) */ mat4 shadowMatrix(childOp->mTransformFromCompositingAncestor); childOp->mDisplayList->applyViewPropertyTransforms(shadowMatrix); DisplayList* child = childOp->mDisplayList; child->applyViewPropertyTransforms(shadowMatrix); DisplayListOp* shadowOp = new (alloc) DrawShadowOp(shadowMatrix, child->mAlpha, &(child->mOutline), child->mWidth, child->mHeight); Loading Loading
core/java/android/view/DisplayList.java +25 −0 Original line number Diff line number Diff line Loading @@ -467,6 +467,29 @@ public class DisplayList { } } /** * Set whether the DisplayList should cast a shadow. * * The shape of the shadow casting area is defined by the outline of the display list, if set * and non-empty, otherwise it will be the bounds rect. */ public void setCastsShadow(boolean castsShadow) { if (hasNativeDisplayList()) { nSetCastsShadow(mFinalizer.mNativeDisplayList, castsShadow); } } /** * Sets whether the DisplayList should be drawn with perspective applied from the global camera. * * If set to true, camera distance will be ignored. Defaults to false. */ public void setSharesGlobalCamera(boolean sharesGlobalCamera) { if (hasNativeDisplayList()) { nSetSharesGlobalCamera(mFinalizer.mNativeDisplayList, sharesGlobalCamera); } } /** * 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.) Loading Loading @@ -1092,6 +1115,8 @@ public class DisplayList { 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 nSetCastsShadow(long displayList, boolean castsShadow); private static native void nSetSharesGlobalCamera(long displayList, boolean sharesGlobalCamera); private static native void nSetAlpha(long displayList, float alpha); private static native void nSetHasOverlappingRendering(long displayList, boolean hasOverlappingRendering); Loading
core/java/android/view/View.java +63 −2 Original line number Diff line number Diff line Loading @@ -2385,6 +2385,17 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ static final int PFLAG3_FITTING_SYSTEM_WINDOWS = 0x80; /** * Flag indicating that an view will cast a shadow onto the Z=0 plane if elevated. */ static final int PFLAG3_CASTS_SHADOW = 0x100; /** * Flag indicating that view will be transformed by the global camera if rotated in 3d, or given * a non-0 Z translation. */ static final int PFLAG3_SHARES_GLOBAL_CAMERA = 0x200; /* End of masks for mPrivateFlags3 */ static final int DRAG_MASK = PFLAG2_DRAG_CAN_ACCEPT | PFLAG2_DRAG_HOVERED; Loading Loading @@ -10825,6 +10836,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } } /** * @hide */ public final boolean getClipToOutline() { return ((mPrivateFlags3 & PFLAG3_CLIP_TO_OUTLINE) != 0); } /** * @hide */ Loading @@ -10845,8 +10863,49 @@ public class View implements Drawable.Callback, KeyEvent.Callback, /** * @hide */ public final boolean getClipToOutline() { return ((mPrivateFlags3 & PFLAG3_CLIP_TO_OUTLINE) != 0); public final boolean getCastsShadow() { return ((mPrivateFlags3 & PFLAG3_CASTS_SHADOW) != 0); } /** * @hide */ public void setCastsShadow(boolean castsShadow) { // TODO : Add a fast invalidation here. if (getCastsShadow() != castsShadow) { if (castsShadow) { mPrivateFlags3 |= PFLAG3_CASTS_SHADOW; } else { mPrivateFlags3 &= ~PFLAG3_CASTS_SHADOW; } if (mDisplayList != null) { mDisplayList.setCastsShadow(castsShadow); } } } /** * @hide */ public final boolean getSharesGlobalCamera() { return ((mPrivateFlags3 & PFLAG3_SHARES_GLOBAL_CAMERA) != 0); } /** * @hide */ public void setSharesGlobalCamera(boolean sharesGlobalCamera) { // TODO : Add a fast invalidation here. if (getSharesGlobalCamera() != sharesGlobalCamera) { if (sharesGlobalCamera) { mPrivateFlags3 |= PFLAG3_SHARES_GLOBAL_CAMERA; } else { mPrivateFlags3 &= ~PFLAG3_SHARES_GLOBAL_CAMERA; } if (mDisplayList != null) { mDisplayList.setSharesGlobalCamera(sharesGlobalCamera); } } } /** Loading Loading @@ -14502,6 +14561,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } displayList.setOutline(mOutline); displayList.setClipToOutline(getClipToOutline()); displayList.setCastsShadow(getCastsShadow()); displayList.setSharesGlobalCamera(getSharesGlobalCamera()); float alpha = 1; if (mParent instanceof ViewGroup && (((ViewGroup) mParent).mGroupFlags & ViewGroup.FLAG_SUPPORT_STATIC_TRANSFORMATIONS) != 0) {
core/java/android/view/ViewGroup.java +1 −1 Original line number Diff line number Diff line Loading @@ -3178,7 +3178,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager * inherited Z ordering volume. */ public void setIsolatedZVolume(boolean isolateZVolume) { boolean previousValue = (mGroupFlags & FLAG_ISOLATED_Z_VOLUME) == FLAG_ISOLATED_Z_VOLUME; boolean previousValue = (mGroupFlags & FLAG_ISOLATED_Z_VOLUME) != 0; if (isolateZVolume != previousValue) { setBooleanFlag(FLAG_ISOLATED_Z_VOLUME, isolateZVolume); if (mDisplayList != null) { Loading
core/jni/android_view_DisplayList.cpp +14 −0 Original line number Diff line number Diff line Loading @@ -136,6 +136,18 @@ static void android_view_DisplayList_setClipToOutline(JNIEnv* env, displayList->setClipToOutline(clipToOutline); } static void android_view_DisplayList_setCastsShadow(JNIEnv* env, jobject clazz, jlong displayListPtr, jboolean castsShadow) { DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListPtr); displayList->setCastsShadow(castsShadow); } static void android_view_DisplayList_setSharesGlobalCamera(JNIEnv* env, jobject clazz, jlong displayListPtr, jboolean sharesGlobalCamera) { DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListPtr); displayList->setSharesGlobalCamera(sharesGlobalCamera); } static void android_view_DisplayList_setAlpha(JNIEnv* env, jobject clazz, jlong displayListPtr, float alpha) { DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListPtr); Loading Loading @@ -407,6 +419,8 @@ static JNINativeMethod gMethods[] = { { "nSetProjectionReceiver","(JZ)V", (void*) android_view_DisplayList_setProjectionReceiver }, { "nSetOutline", "(JJ)V", (void*) android_view_DisplayList_setOutline }, { "nSetClipToOutline", "(JZ)V", (void*) android_view_DisplayList_setClipToOutline }, { "nSetCastsShadow", "(JZ)V", (void*) android_view_DisplayList_setCastsShadow }, { "nSetSharesGlobalCamera","(JZ)V", (void*) android_view_DisplayList_setSharesGlobalCamera }, { "nSetAlpha", "(JF)V", (void*) android_view_DisplayList_setAlpha }, { "nSetHasOverlappingRendering", "(JZ)V", (void*) android_view_DisplayList_setHasOverlappingRendering }, Loading
libs/hwui/DisplayList.cpp +6 −7 Original line number Diff line number Diff line Loading @@ -243,6 +243,8 @@ void DisplayList::init() { mProjectionReceiver = false; mOutline.rewind(); mClipToOutline = false; mCastsShadow = false; mSharesGlobalCamera = false; mAlpha = 1; mHasOverlappingRendering = true; mTranslationX = 0; Loading Loading @@ -670,16 +672,13 @@ void DisplayList::iterate3dChildren(ChildrenSelectMode mode, OpenGLRenderer& ren if (mode == kPositiveZChildren && zValue < 0.0f) continue; if (mode == kNegativeZChildren && zValue > 0.0f) break; if (mode == kPositiveZChildren && zValue > 0.0f) { DisplayList* child = childOp->mDisplayList; if (mode == kPositiveZChildren && zValue > 0.0f && child->mCastsShadow) { /* draw shadow with parent matrix applied, passing in the child's total matrix * * TODO: * -view must opt-in to shadows * -consider depth in more complex scenarios (neg z, added shadow depth) * TODO: consider depth in more complex scenarios (neg z, added shadow depth) */ mat4 shadowMatrix(childOp->mTransformFromCompositingAncestor); childOp->mDisplayList->applyViewPropertyTransforms(shadowMatrix); DisplayList* child = childOp->mDisplayList; child->applyViewPropertyTransforms(shadowMatrix); DisplayListOp* shadowOp = new (alloc) DrawShadowOp(shadowMatrix, child->mAlpha, &(child->mOutline), child->mWidth, child->mHeight); Loading