diff options
Diffstat (limited to 'core/java/android/view')
| -rw-r--r-- | core/java/android/view/DisplayList.java | 9 | ||||
| -rw-r--r-- | core/java/android/view/GLES20DisplayList.java | 11 | ||||
| -rw-r--r-- | core/java/android/view/HardwareRenderer.java | 6 | ||||
| -rw-r--r-- | core/java/android/view/View.java | 44 | ||||
| -rw-r--r-- | core/java/android/view/ViewPropertyAnimator.java | 13 |
5 files changed, 63 insertions, 20 deletions
diff --git a/core/java/android/view/DisplayList.java b/core/java/android/view/DisplayList.java index 33631b7..fba73fbd 100644 --- a/core/java/android/view/DisplayList.java +++ b/core/java/android/view/DisplayList.java @@ -149,6 +149,15 @@ public abstract class DisplayList { public abstract void setAlpha(float alpha); /** + * Sets whether the DisplayList renders content which overlaps. Non-overlapping rendering + * can use a fast path for alpha that avoids rendering to an offscreen buffer. + * + * @param hasOverlappingRendering + * @see android.view.View#hasOverlappingRendering() + */ + public abstract void setHasOverlappingRendering(boolean hasOverlappingRendering); + + /** * Sets the translationX value for the DisplayList * * @param translationX The translationX value of the DisplayList diff --git a/core/java/android/view/GLES20DisplayList.java b/core/java/android/view/GLES20DisplayList.java index bc3bce0..f3618eb 100644 --- a/core/java/android/view/GLES20DisplayList.java +++ b/core/java/android/view/GLES20DisplayList.java @@ -147,6 +147,15 @@ class GLES20DisplayList extends DisplayList { } @Override + public void setHasOverlappingRendering(boolean hasOverlappingRendering) { + try { + nSetHasOverlappingRendering(getNativeDisplayList(), hasOverlappingRendering); + } catch (IllegalStateException e) { + // invalid DisplayList okay: we'll set current values the next time we render to it + } + } + + @Override public void setTranslationX(float translationX) { try { nSetTranslationX(getNativeDisplayList(), translationX); @@ -335,6 +344,8 @@ class GLES20DisplayList extends DisplayList { private static native void nSetClipChildren(int displayList, boolean clipChildren); private static native void nSetApplicationScale(int displayList, float scale); private static native void nSetAlpha(int displayList, float alpha); + private static native void nSetHasOverlappingRendering(int displayList, + boolean hasOverlappingRendering); private static native void nSetTranslationX(int displayList, float translationX); private static native void nSetTranslationY(int displayList, float translationY); private static native void nSetRotation(int displayList, float rotation); diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java index b100a0c..9ef2621 100644 --- a/core/java/android/view/HardwareRenderer.java +++ b/core/java/android/view/HardwareRenderer.java @@ -134,7 +134,7 @@ public abstract class HardwareRenderer { /** * Number of frames to profile. */ - private static final int PROFILE_MAX_FRAMES = 64; + private static final int PROFILE_MAX_FRAMES = 120; /** * Number of floats per profiled frame. @@ -1046,10 +1046,6 @@ public abstract class HardwareRenderer { Log.d(ViewDebug.DEBUG_LATENCY_TAG, "- getDisplayList() took " + total + "ms"); } - if (View.USE_DISPLAY_LIST_PROPERTIES) { - Log.d("DLProperties", "getDisplayList():\t" + - mProfileData[mProfileCurrentFrame]); - } } if (displayList != null) { diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index a9421f0..c40a7d5 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -2830,19 +2830,6 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal private boolean mSendingHoverAccessibilityEvents; /** - * Delegate for injecting accessiblity functionality. - */ - AccessibilityDelegate mAccessibilityDelegate; - - /** - * Consistency verifier for debugging purposes. - * @hide - */ - protected final InputEventConsistencyVerifier mInputEventConsistencyVerifier = - InputEventConsistencyVerifier.isInstrumentationEnabled() ? - new InputEventConsistencyVerifier(this, 0) : null; - - /** * Simple constructor to use when creating a view from code. * * @param context The Context the view is running in, through which it can @@ -2863,6 +2850,19 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal } /** + * Delegate for injecting accessiblity functionality. + */ + AccessibilityDelegate mAccessibilityDelegate; + + /** + * Consistency verifier for debugging purposes. + * @hide + */ + protected final InputEventConsistencyVerifier mInputEventConsistencyVerifier = + InputEventConsistencyVerifier.isInstrumentationEnabled() ? + new InputEventConsistencyVerifier(this, 0) : null; + + /** * Constructor that is called when inflating a view from XML. This is called * when a view is being constructed from an XML file, supplying attributes * that were specified in the XML file. This version uses a default style of @@ -7855,6 +7855,23 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal } /** + * Returns whether this View has content which overlaps. This function, intended to be + * overridden by specific View types, is an optimization when alpha is set on a view. If + * rendering overlaps in a view with alpha < 1, that view is drawn to an offscreen buffer + * and then composited it into place, which can be expensive. If the view has no overlapping + * rendering, the view can draw each primitive with the appropriate alpha value directly. + * An example of overlapping rendering is a TextView with a background image, such as a + * Button. An example of non-overlapping rendering is a TextView with no background, or + * an ImageView with only the foreground image. The default implementation returns true; + * subclasses should override if they have cases which can be optimized. + * + * @return true if the content in this view might overlap, false otherwise. + */ + public boolean hasOverlappingRendering() { + return true; + } + + /** * <p>Sets the opacity of the view. This is a value from 0 to 1, where 0 means the view is * completely transparent and 1 means the view is completely opaque.</p> * @@ -11534,6 +11551,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal void setDisplayListProperties(DisplayList displayList) { if (USE_DISPLAY_LIST_PROPERTIES && displayList != null) { displayList.setLeftTopRightBottom(mLeft, mTop, mRight, mBottom); + displayList.setHasOverlappingRendering(hasOverlappingRendering()); if (mParent instanceof ViewGroup) { displayList.setClipChildren( (((ViewGroup)mParent).mGroupFlags & ViewGroup.FLAG_CLIP_CHILDREN) != 0); diff --git a/core/java/android/view/ViewPropertyAnimator.java b/core/java/android/view/ViewPropertyAnimator.java index 623b567..3626aba 100644 --- a/core/java/android/view/ViewPropertyAnimator.java +++ b/core/java/android/view/ViewPropertyAnimator.java @@ -834,40 +834,49 @@ public class ViewPropertyAnimator { */ private void setValue(int propertyConstant, float value) { final View.TransformationInfo info = mView.mTransformationInfo; + DisplayList displayList = View.USE_DISPLAY_LIST_PROPERTIES ? mView.mDisplayList : null; switch (propertyConstant) { case TRANSLATION_X: info.mTranslationX = value; + if (displayList != null) displayList.setTranslationX(value); break; case TRANSLATION_Y: info.mTranslationY = value; + if (displayList != null) displayList.setTranslationY(value); break; case ROTATION: info.mRotation = value; + if (displayList != null) displayList.setRotation(value); break; case ROTATION_X: info.mRotationX = value; + if (displayList != null) displayList.setRotationX(value); break; case ROTATION_Y: info.mRotationY = value; + if (displayList != null) displayList.setRotationY(value); break; case SCALE_X: info.mScaleX = value; + if (displayList != null) displayList.setScaleX(value); break; case SCALE_Y: info.mScaleY = value; + if (displayList != null) displayList.setScaleY(value); break; case X: info.mTranslationX = value - mView.mLeft; + if (displayList != null) displayList.setTranslationX(value - mView.mLeft); break; case Y: info.mTranslationY = value - mView.mTop; + if (displayList != null) displayList.setTranslationY(value - mView.mTop); break; case ALPHA: info.mAlpha = value; + if (displayList != null) displayList.setAlpha(value); break; } - // TODO: optimize to set only the properties that have changed - mView.setDisplayListProperties(); } /** |
