diff options
author | Michael Jurka <mikejurka@google.com> | 2011-11-18 13:01:04 -0800 |
---|---|---|
committer | Michael Jurka <mikejurka@google.com> | 2011-11-18 17:07:51 -0800 |
commit | dfab7f0285eea71abd7fa64e893541fdf831c73b (patch) | |
tree | 0776567d77d7e73109dc7efd40f6ca0cd112f189 | |
parent | b0736fac73b0df95f18234a0494aea3f3fc6c735 (diff) | |
download | android_packages_apps_Trebuchet-dfab7f0285eea71abd7fa64e893541fdf831c73b.tar.gz android_packages_apps_Trebuchet-dfab7f0285eea71abd7fa64e893541fdf831c73b.tar.bz2 android_packages_apps_Trebuchet-dfab7f0285eea71abd7fa64e893541fdf831c73b.zip |
Potential fix for out-of-date hardware layers
Might also further help bug where IMG GPU slows
down when rendering into hardware layers that are
not rendered to framebuffer
Bugs # 5614712, 5616414, 5628998
Change-Id: I85ff11889aa28f6985dd68e7f1e57d0da2150aa5
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 0598cd968..fd5a3fcd9 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -57,6 +57,7 @@ import android.view.Display; import android.view.DragEvent; import android.view.MotionEvent; import android.view.View; +import android.view.ViewConfiguration; import android.view.ViewGroup; import android.view.animation.DecelerateInterpolator; import android.widget.ImageView; @@ -1280,21 +1281,34 @@ public class Workspace extends SmoothPagedView return (mBackground != null && mBackgroundAlpha > 0.0f && mDrawBackground); } - @Override - protected void dispatchDraw(Canvas canvas) { + public void scrollTo (int x, int y) { + super.scrollTo(x, y); + syncChildrenLayersEnabledOnVisiblePages(); + } + + // This method just applies the value mChildrenLayersEnabled to all the pages that + // will be rendered on the next frame. + // We do this because calling setChildrenLayersEnabled on a view that's not + // visible/rendered causes slowdowns on some graphics cards + private void syncChildrenLayersEnabledOnVisiblePages() { if (mChildrenLayersEnabled) { getVisiblePages(mTempVisiblePagesRange); final int leftScreen = mTempVisiblePagesRange[0]; final int rightScreen = mTempVisiblePagesRange[1]; if (leftScreen != -1 && rightScreen != -1) { - // calling setChildrenLayersEnabled on a view that's not visible/rendered - // causes slowdowns on some graphics cards, so we set it here to be sure - // it's only called when it's safe (ie when the view will be rendered) for (int i = leftScreen; i <= rightScreen; i++) { - ((ViewGroup)getPageAt(i)).setChildrenLayersEnabled(true); + ViewGroup page = (ViewGroup) getPageAt(i); + if (page.getVisibility() == VISIBLE && + page.getAlpha() > ViewConfiguration.ALPHA_THRESHOLD) { + ((ViewGroup)getPageAt(i)).setChildrenLayersEnabled(true); + } } } } + } + + @Override + protected void dispatchDraw(Canvas canvas) { super.dispatchDraw(canvas); if (mInScrollArea && !LauncherApplication.isScreenLarge()) { @@ -1723,6 +1737,7 @@ public class Workspace extends SmoothPagedView b * mNewBackgroundAlphaMultipliers[i]); cl.setFastAlpha(a * mOldAlphas[i] + b * mNewAlphas[i]); } + syncChildrenLayersEnabledOnVisiblePages(); } }); @@ -1760,6 +1775,7 @@ public class Workspace extends SmoothPagedView // Fade the background gradient away animateBackgroundGradient(0f, true); } + syncChildrenLayersEnabledOnVisiblePages(); } /** |