summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/view/DisplayList.java25
-rw-r--r--core/java/android/view/View.java65
-rw-r--r--core/java/android/view/ViewGroup.java2
3 files changed, 89 insertions, 3 deletions
diff --git a/core/java/android/view/DisplayList.java b/core/java/android/view/DisplayList.java
index a96d46ce7dde..9aecbead73fe 100644
--- a/core/java/android/view/DisplayList.java
+++ b/core/java/android/view/DisplayList.java
@@ -468,6 +468,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.)
*
@@ -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);
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index d017d56608fc..fbeddc89cb91 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -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;
@@ -10828,6 +10839,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
/**
* @hide
*/
+ public final boolean getClipToOutline() {
+ return ((mPrivateFlags3 & PFLAG3_CLIP_TO_OUTLINE) != 0);
+ }
+
+ /**
+ * @hide
+ */
public void setClipToOutline(boolean clipToOutline) {
// TODO : Add a fast invalidation here.
if (getClipToOutline() != clipToOutline) {
@@ -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);
+ }
+ }
}
/**
@@ -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) {
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index 7aa568b4edbc..c3bf5338415f 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -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) {