summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
authorRomain Guy <romainguy@android.com>2009-10-07 13:38:55 -0700
committerRomain Guy <romainguy@android.com>2009-10-07 14:08:24 -0700
commit35b38cefcc92f1ed599a652ac5736ab9e9e75039 (patch)
tree4e5497d95e96909056aa564ac0562c2d1dc83307 /core/java/android
parent64dd5be583bab8218e54068bbf70edc5fc6087c8 (diff)
downloadframeworks_base-35b38cefcc92f1ed599a652ac5736ab9e9e75039.zip
frameworks_base-35b38cefcc92f1ed599a652ac5736ab9e9e75039.tar.gz
frameworks_base-35b38cefcc92f1ed599a652ac5736ab9e9e75039.tar.bz2
Improve drawing cache speed by selecting the correct opacity and keeping a 32 bits
format when the window is 32 bits. Change-Id: I46762def67fa7d6a331a75fa8660c6422394ccf2
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/view/View.java22
-rw-r--r--core/java/android/view/ViewRoot.java5
2 files changed, 18 insertions, 9 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 7d821b5..4c91b6b 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -6188,11 +6188,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
}
final int drawingCacheBackgroundColor = mDrawingCacheBackgroundColor;
- final boolean opaque = drawingCacheBackgroundColor != 0 ||
- (mBGDrawable != null && mBGDrawable.getOpacity() == PixelFormat.OPAQUE);
+ final boolean opaque = drawingCacheBackgroundColor != 0 || isOpaque();
+ final boolean translucentWindow = attachInfo.mTranslucentWindow;
if (width <= 0 || height <= 0 ||
- (width * height * (opaque ? 2 : 4) > // Projected bitmap size in bytes
+ // Projected bitmap size in bytes
+ (width * height * (opaque && !translucentWindow ? 2 : 4) >
ViewConfiguration.get(mContext).getScaledMaximumDrawingCacheSize())) {
destroyDrawingCache();
return;
@@ -6203,7 +6204,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
(mUnscaledDrawingCache == null ? null : mUnscaledDrawingCache.get());
if (bitmap == null || bitmap.getWidth() != width || bitmap.getHeight() != height) {
-
Bitmap.Config quality;
if (!opaque) {
switch (mViewFlags & DRAWING_CACHE_QUALITY_MASK) {
@@ -6221,7 +6221,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
break;
}
} else {
- quality = Bitmap.Config.RGB_565;
+ // Optimization for translucent windows
+ // If the window is translucent, use a 32 bits bitmap to benefit from memcpy()
+ quality = translucentWindow ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565;
}
// Try to cleanup memory
@@ -6235,6 +6237,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
} else {
mUnscaledDrawingCache = new SoftReference<Bitmap>(bitmap);
}
+ if (opaque && translucentWindow) bitmap.setHasAlpha(false);
} catch (OutOfMemoryError e) {
// If there is not enough memory to create the bitmap cache, just
// ignore the issue as bitmap caches are not required to draw the
@@ -8821,6 +8824,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
int mWindowTop;
/**
+ * Indicates whether the window is translucent/transparent
+ */
+ boolean mTranslucentWindow;
+
+ /**
* For windows that are full-screen but using insets to layout inside
* of the screen decorations, these are the current insets for the
* content of the window.
@@ -9033,8 +9041,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
public ScrollabilityCache(ViewConfiguration configuration, View host) {
fadingEdgeLength = configuration.getScaledFadingEdgeLength();
scrollBarSize = configuration.getScaledScrollBarSize();
- scrollBarDefaultDelayBeforeFade = configuration.getScrollDefaultDelay();
- scrollBarFadeDuration = configuration.getScrollBarFadeDuration();
+ scrollBarDefaultDelayBeforeFade = ViewConfiguration.getScrollDefaultDelay();
+ scrollBarFadeDuration = ViewConfiguration.getScrollBarFadeDuration();
paint = new Paint();
matrix = new Matrix();
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index dba2e04..a6d644b 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -408,7 +408,7 @@ public final class ViewRoot extends Handler implements ViewParent,
}
boolean restore = false;
- if (attrs != null && mTranslator != null) {
+ if (mTranslator != null) {
restore = true;
attrs.backup();
mTranslator.translateWindowLayout(attrs);
@@ -422,7 +422,7 @@ public final class ViewRoot extends Handler implements ViewParent,
mSoftInputMode = attrs.softInputMode;
mWindowAttributesChanged = true;
mAttachInfo.mRootView = view;
- mAttachInfo.mScalingRequired = mTranslator == null ? false : true;
+ mAttachInfo.mScalingRequired = mTranslator != null;
mAttachInfo.mApplicationScale =
mTranslator == null ? 1.0f : mTranslator.applicationScale;
if (panelParentView != null) {
@@ -680,6 +680,7 @@ public final class ViewRoot extends Handler implements ViewParent,
// object is not initialized to its backing store, but soon it
// will be (assuming the window is visible).
attachInfo.mSurface = mSurface;
+ attachInfo.mTranslucentWindow = lp.format != PixelFormat.OPAQUE;
attachInfo.mHasWindowFocus = false;
attachInfo.mWindowVisibility = viewVisibility;
attachInfo.mRecomputeGlobalAttributes = false;