From bdb5c5342adc550559fd723af461e53248f2fba8 Mon Sep 17 00:00:00 2001 From: Michael Jurka Date: Tue, 1 Feb 2011 15:05:06 -0800 Subject: [PATCH] Turning on hardware layers for the workspace - Obsoletes need for CachedViewGroup and CachedTextView on workspace as well Bug #3413433 --- src/com/android/launcher2/BubbleTextView.java | 63 ++++++++----------- src/com/android/launcher2/CellLayout.java | 2 +- .../android/launcher2/CellLayoutChildren.java | 1 + src/com/android/launcher2/Workspace.java | 23 ------- 4 files changed, 28 insertions(+), 61 deletions(-) diff --git a/src/com/android/launcher2/BubbleTextView.java b/src/com/android/launcher2/BubbleTextView.java index f3aa3426d6..a842d78ac9 100644 --- a/src/com/android/launcher2/BubbleTextView.java +++ b/src/com/android/launcher2/BubbleTextView.java @@ -31,13 +31,14 @@ import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; +import android.widget.TextView; /** * TextView that draws a bubble behind the text. We cannot use a LineBackgroundSpan * because we want to make the bubble taller than the text and TextView's clip is * too aggressive. */ -public class BubbleTextView extends CachedTextView implements VisibilityChangedBroadcaster { +public class BubbleTextView extends TextView implements VisibilityChangedBroadcaster { static final float CORNER_RADIUS = 4.0f; static final float SHADOW_LARGE_RADIUS = 4.0f; static final float SHADOW_SMALL_RADIUS = 1.75f; @@ -98,19 +99,6 @@ public class BubbleTextView extends CachedTextView implements VisibilityChangedB mPressedGlowColor = res.getColor(R.color.workspace_item_pressed_glow_color); } - protected int getCacheTopPadding() { - return (int) PADDING_V; - } - protected int getCacheBottomPadding() { - return (int) (PADDING_V + SHADOW_LARGE_RADIUS + SHADOW_Y_OFFSET); - } - protected int getCacheLeftPadding() { - return (int) (PADDING_H + SHADOW_LARGE_RADIUS); - } - protected int getCacheRightPadding() { - return (int) (PADDING_H + SHADOW_LARGE_RADIUS); - } - public void applyFromShortcutInfo(ShortcutInfo info, IconCache iconCache) { Bitmap b = info.getIcon(iconCache); @@ -269,33 +257,34 @@ public class BubbleTextView extends CachedTextView implements VisibilityChangedB mScrollX - padding, mScrollY - padding, mTempPaint); canvas.restore(); } - if (isBuildingCache()) { - // We enhance the shadow by drawing the shadow twice - this.setShadowLayer(SHADOW_LARGE_RADIUS, 0.0f, SHADOW_Y_OFFSET, SHADOW_LARGE_COLOUR); - super.draw(canvas); - this.setShadowLayer(SHADOW_SMALL_RADIUS, 0.0f, 0.0f, SHADOW_SMALL_COLOUR); - super.draw(canvas); - } else { - final Drawable background = mBackground; - if (background != null) { - final int scrollX = mScrollX; - final int scrollY = mScrollY; - if (mBackgroundSizeChanged) { - background.setBounds(0, 0, mRight - mLeft, mBottom - mTop); - mBackgroundSizeChanged = false; - } + final Drawable background = mBackground; + if (background != null) { + final int scrollX = mScrollX; + final int scrollY = mScrollY; - if ((scrollX | scrollY) == 0) { - background.draw(canvas); - } else { - canvas.translate(scrollX, scrollY); - background.draw(canvas); - canvas.translate(-scrollX, -scrollY); - } + if (mBackgroundSizeChanged) { + background.setBounds(0, 0, mRight - mLeft, mBottom - mTop); + mBackgroundSizeChanged = false; + } + + if ((scrollX | scrollY) == 0) { + background.draw(canvas); + } else { + canvas.translate(scrollX, scrollY); + background.draw(canvas); + canvas.translate(-scrollX, -scrollY); } - super.draw(canvas); } + // We enhance the shadow by drawing the shadow twice + setShadowLayer(SHADOW_LARGE_RADIUS, 0.0f, SHADOW_Y_OFFSET, SHADOW_LARGE_COLOUR); + super.draw(canvas); + canvas.save(Canvas.CLIP_SAVE_FLAG); + canvas.clipRect(mScrollX, mScrollY + getExtendedPaddingTop(), mScrollX + getWidth(), + mScrollY + getHeight(), Region.Op.REPLACE); + setShadowLayer(SHADOW_SMALL_RADIUS, 0.0f, 0.0f, SHADOW_SMALL_COLOUR); + super.draw(canvas); + canvas.restore(); } @Override diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java index 6767cf1bff..b27770c254 100644 --- a/src/com/android/launcher2/CellLayout.java +++ b/src/com/android/launcher2/CellLayout.java @@ -50,7 +50,7 @@ import android.view.animation.LayoutAnimationController; import java.util.Arrays; -public class CellLayout extends CachedViewGroup { +public class CellLayout extends ViewGroup { static final String TAG = "CellLayout"; private int mCellWidth; diff --git a/src/com/android/launcher2/CellLayoutChildren.java b/src/com/android/launcher2/CellLayoutChildren.java index a6f7f42143..76a6900943 100644 --- a/src/com/android/launcher2/CellLayoutChildren.java +++ b/src/com/android/launcher2/CellLayoutChildren.java @@ -44,6 +44,7 @@ public class CellLayoutChildren extends ViewGroup { public CellLayoutChildren(Context context) { super(context); mWallpaperManager = WallpaperManager.getInstance(context); + setLayerType(LAYER_TYPE_HARDWARE, null); } public void setCellDimensions(int cellWidth, int cellHeight, diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 890bde8d24..765e4d637d 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -281,7 +281,6 @@ public class Workspace extends SmoothPagedView @Override public void onAnimationStart(Animator animation) { mIsInUnshrinkAnimation = true; - disableCacheUpdates(); } @Override @@ -299,19 +298,13 @@ public class Workspace extends SmoothPagedView mDrawCustomizeTrayBackground = false; } mWallpaperOffset.setOverrideHorizontalCatchupConstant(false); - enableCacheUpdates(); mAnimator = null; } }; mShrinkAnimationListener = new AnimatorListenerAdapter() { - @Override - public void onAnimationStart(Animator animation) { - disableCacheUpdates(); - } @Override public void onAnimationEnd(Animator animation) { mWallpaperOffset.setOverrideHorizontalCatchupConstant(false); - enableCacheUpdates(); mAnimator = null; } }; @@ -1039,22 +1032,6 @@ public class Workspace extends SmoothPagedView } } - public void enableCacheUpdates() { - final int pageCount = getChildCount(); - for (int i = 0; i < pageCount; i++) { - final CellLayout page = (CellLayout) getChildAt(i); - page.enableCacheUpdates(); - } - } - - public void disableCacheUpdates() { - final int pageCount = getChildCount(); - for (int i = 0; i < pageCount; i++) { - final CellLayout page = (CellLayout) getChildAt(i); - page.disableCacheUpdates(); - } - } - @Override protected void onDraw(Canvas canvas) { updateWallpaperOffsets();