summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/content/pm/ApplicationInfo.java20
-rw-r--r--core/java/android/content/pm/PackageParser.java6
-rw-r--r--core/java/android/view/DisplayList.java9
-rw-r--r--core/java/android/view/GLES20DisplayList.java11
-rw-r--r--core/java/android/view/HardwareRenderer.java6
-rw-r--r--core/java/android/view/View.java170
-rw-r--r--core/java/android/view/ViewPropertyAnimator.java13
-rw-r--r--core/java/android/widget/ImageView.java11
-rw-r--r--core/java/android/widget/TextView.java12
9 files changed, 180 insertions, 78 deletions
diff --git a/core/java/android/content/pm/ApplicationInfo.java b/core/java/android/content/pm/ApplicationInfo.java
index 65a8750..cbabc7c 100644
--- a/core/java/android/content/pm/ApplicationInfo.java
+++ b/core/java/android/content/pm/ApplicationInfo.java
@@ -291,6 +291,17 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
public static final int FLAG_STOPPED = 1<<21;
/**
+ * Value for {@link #flags}: true when the application is willing to support
+ * RTL (right to left). All activities will inherit this value.
+ *
+ * Set from the {@link android.R.attr#supportsRtl} attribute in the
+ * activity's manifest.
+ *
+ * Default value is false (no support for RTL).
+ */
+ public static final int FLAG_SUPPORTS_RTL = 1<<22;
+
+ /**
* Value for {@link #flags}: Set to true if the application has been
* installed using the forward lock option.
*
@@ -466,8 +477,17 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
if (uiOptions != 0) {
pw.println(prefix + "uiOptions=0x" + Integer.toHexString(uiOptions));
}
+ pw.println(prefix + "supportsRtl=" + (hasRtlSupport() ? "true" : "false"));
super.dumpBack(pw, prefix);
}
+
+ /**
+ * @return true if "supportsRtl" has been set to true in the AndroidManifest
+ * @hide
+ */
+ public boolean hasRtlSupport() {
+ return (flags & FLAG_SUPPORTS_RTL) == FLAG_SUPPORTS_RTL;
+ }
public static class DisplayNameComparator
implements Comparator<ApplicationInfo> {
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index eb8536f..a79b86a 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -1761,6 +1761,12 @@ public class PackageParser {
ai.flags |= ApplicationInfo.FLAG_LARGE_HEAP;
}
+ if (sa.getBoolean(
+ com.android.internal.R.styleable.AndroidManifestApplication_supportsRtl,
+ false /* default is no RTL support*/)) {
+ ai.flags |= ApplicationInfo.FLAG_SUPPORTS_RTL;
+ }
+
String str;
str = sa.getNonConfigurationString(
com.android.internal.R.styleable.AndroidManifestApplication_permission, 0);
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 69d7655..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>
*
@@ -9998,6 +10015,13 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
}
/**
+ * Return true if the application tag in the AndroidManifest has set "supportRtl" to true
+ */
+ private boolean hasRtlSupport() {
+ return mContext.getApplicationInfo().hasRtlSupport();
+ }
+
+ /**
* Resolve and cache the layout direction. LTR is set initially. This is implicitly supposing
* that the parent directionality can and will be resolved before its children.
* Will call {@link View#onResolvedLayoutDirectionChanged} when resolution is done.
@@ -10006,30 +10030,32 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
// Clear any previous layout direction resolution
mPrivateFlags2 &= ~LAYOUT_DIRECTION_RESOLVED_MASK;
- // Set resolved depending on layout direction
- switch (getLayoutDirection()) {
- case LAYOUT_DIRECTION_INHERIT:
- // If this is root view, no need to look at parent's layout dir.
- if (canResolveLayoutDirection()) {
- ViewGroup viewGroup = ((ViewGroup) mParent);
+ if (hasRtlSupport()) {
+ // Set resolved depending on layout direction
+ switch (getLayoutDirection()) {
+ case LAYOUT_DIRECTION_INHERIT:
+ // If this is root view, no need to look at parent's layout dir.
+ if (canResolveLayoutDirection()) {
+ ViewGroup viewGroup = ((ViewGroup) mParent);
- if (viewGroup.getResolvedLayoutDirection() == LAYOUT_DIRECTION_RTL) {
+ if (viewGroup.getResolvedLayoutDirection() == LAYOUT_DIRECTION_RTL) {
+ mPrivateFlags2 |= LAYOUT_DIRECTION_RESOLVED_RTL;
+ }
+ } else {
+ // Nothing to do, LTR by default
+ }
+ break;
+ case LAYOUT_DIRECTION_RTL:
+ mPrivateFlags2 |= LAYOUT_DIRECTION_RESOLVED_RTL;
+ break;
+ case LAYOUT_DIRECTION_LOCALE:
+ if(isLayoutDirectionRtl(Locale.getDefault())) {
mPrivateFlags2 |= LAYOUT_DIRECTION_RESOLVED_RTL;
}
- } else {
+ break;
+ default:
// Nothing to do, LTR by default
- }
- break;
- case LAYOUT_DIRECTION_RTL:
- mPrivateFlags2 |= LAYOUT_DIRECTION_RESOLVED_RTL;
- break;
- case LAYOUT_DIRECTION_LOCALE:
- if(isLayoutDirectionRtl(Locale.getDefault())) {
- mPrivateFlags2 |= LAYOUT_DIRECTION_RESOLVED_RTL;
- }
- break;
- default:
- // Nothing to do, LTR by default
+ }
}
// Set to resolved
@@ -11525,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);
@@ -14809,44 +14836,49 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
// Reset any previous text direction resolution
mPrivateFlags2 &= ~(TEXT_DIRECTION_RESOLVED | TEXT_DIRECTION_RESOLVED_MASK);
- // Set resolved text direction flag depending on text direction flag
- final int textDirection = getTextDirection();
- switch(textDirection) {
- case TEXT_DIRECTION_INHERIT:
- if (canResolveTextDirection()) {
- ViewGroup viewGroup = ((ViewGroup) mParent);
-
- // Set current resolved direction to the same value as the parent's one
- final int parentResolvedDirection = viewGroup.getResolvedTextDirection();
- switch (parentResolvedDirection) {
- case TEXT_DIRECTION_FIRST_STRONG:
- case TEXT_DIRECTION_ANY_RTL:
- case TEXT_DIRECTION_LTR:
- case TEXT_DIRECTION_RTL:
- case TEXT_DIRECTION_LOCALE:
- mPrivateFlags2 |=
- (parentResolvedDirection << TEXT_DIRECTION_RESOLVED_MASK_SHIFT);
- break;
- default:
- // Default resolved direction is "first strong" heuristic
- mPrivateFlags2 |= TEXT_DIRECTION_RESOLVED_DEFAULT;
+ if (hasRtlSupport()) {
+ // Set resolved text direction flag depending on text direction flag
+ final int textDirection = getTextDirection();
+ switch(textDirection) {
+ case TEXT_DIRECTION_INHERIT:
+ if (canResolveTextDirection()) {
+ ViewGroup viewGroup = ((ViewGroup) mParent);
+
+ // Set current resolved direction to the same value as the parent's one
+ final int parentResolvedDirection = viewGroup.getResolvedTextDirection();
+ switch (parentResolvedDirection) {
+ case TEXT_DIRECTION_FIRST_STRONG:
+ case TEXT_DIRECTION_ANY_RTL:
+ case TEXT_DIRECTION_LTR:
+ case TEXT_DIRECTION_RTL:
+ case TEXT_DIRECTION_LOCALE:
+ mPrivateFlags2 |=
+ (parentResolvedDirection << TEXT_DIRECTION_RESOLVED_MASK_SHIFT);
+ break;
+ default:
+ // Default resolved direction is "first strong" heuristic
+ mPrivateFlags2 |= TEXT_DIRECTION_RESOLVED_DEFAULT;
+ }
+ } else {
+ // We cannot do the resolution if there is no parent, so use the default one
+ mPrivateFlags2 |= TEXT_DIRECTION_RESOLVED_DEFAULT;
}
- } else {
- // We cannot do the resolution if there is no parent, so use the default one
+ break;
+ case TEXT_DIRECTION_FIRST_STRONG:
+ case TEXT_DIRECTION_ANY_RTL:
+ case TEXT_DIRECTION_LTR:
+ case TEXT_DIRECTION_RTL:
+ case TEXT_DIRECTION_LOCALE:
+ // Resolved direction is the same as text direction
+ mPrivateFlags2 |= (textDirection << TEXT_DIRECTION_RESOLVED_MASK_SHIFT);
+ break;
+ default:
+ // Default resolved direction is "first strong" heuristic
mPrivateFlags2 |= TEXT_DIRECTION_RESOLVED_DEFAULT;
- }
- break;
- case TEXT_DIRECTION_FIRST_STRONG:
- case TEXT_DIRECTION_ANY_RTL:
- case TEXT_DIRECTION_LTR:
- case TEXT_DIRECTION_RTL:
- case TEXT_DIRECTION_LOCALE:
- // Resolved direction is the same as text direction
- mPrivateFlags2 |= (textDirection << TEXT_DIRECTION_RESOLVED_MASK_SHIFT);
- break;
- default:
- // Default resolved direction is "first strong" heuristic
- mPrivateFlags2 |= TEXT_DIRECTION_RESOLVED_DEFAULT;
+ }
+ } else {
+ // Default resolved direction is "first strong" heuristic
+ mPrivateFlags2 |= TEXT_DIRECTION_RESOLVED_DEFAULT;
}
// Set to resolved
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();
}
/**
diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java
index b1a75e1..91e2e49 100644
--- a/core/java/android/widget/ImageView.java
+++ b/core/java/android/widget/ImageView.java
@@ -201,7 +201,7 @@ public class ImageView extends View {
@Override
protected boolean onSetAlpha(int alpha) {
- if (getBackground() == null) {
+ if (!USE_DISPLAY_LIST_PROPERTIES && getBackground() == null) {
int scale = alpha + (alpha >> 7);
if (mViewAlphaScale != scale) {
mViewAlphaScale = scale;
@@ -214,6 +214,15 @@ public class ImageView extends View {
}
@Override
+ public boolean hasOverlappingRendering() {
+ if (!USE_DISPLAY_LIST_PROPERTIES) {
+ return super.hasOverlappingRendering();
+ } else {
+ return (getBackground() != null);
+ }
+ }
+
+ @Override
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
super.onPopulateAccessibilityEvent(event);
CharSequence contentDescription = getContentDescription();
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 2a81f08..d2a1755 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -4268,7 +4268,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
protected boolean onSetAlpha(int alpha) {
// Alpha is supported if and only if the drawing can be done in one pass.
// TODO text with spans with a background color currently do not respect this alpha.
- if (getBackground() == null) {
+ if (!USE_DISPLAY_LIST_PROPERTIES &&
+ (getBackground() != null || mText instanceof Spannable || hasSelection())) {
if (mCurrentAlpha != alpha) {
mCurrentAlpha = alpha;
final Drawables dr = mDrawables;
@@ -4292,6 +4293,15 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
return false;
}
+ @Override
+ public boolean hasOverlappingRendering() {
+ if (!USE_DISPLAY_LIST_PROPERTIES) {
+ return super.hasOverlappingRendering();
+ } else {
+ return (getBackground() != null || mText instanceof Spannable || hasSelection());
+ }
+ }
+
/**
* When a TextView is used to display a useful piece of information to the user (such as a
* contact's address), it should be made selectable, so that the user can select and copy this