Disabling certain effects (wallpaper transition, holographic icons in AllApps) if HW acceleration is not enabled.
Change-Id: I7926d5c3ba95c6d57999189677ff79f67b05434f
diff --git a/src/com/android/launcher2/HolographicPagedViewIcon.java b/src/com/android/launcher2/HolographicPagedViewIcon.java
index 5e18169..7123e2a 100644
--- a/src/com/android/launcher2/HolographicPagedViewIcon.java
+++ b/src/com/android/launcher2/HolographicPagedViewIcon.java
@@ -41,7 +41,6 @@
@Override
protected void onDraw(Canvas canvas) {
Bitmap overlay = mOriginalIcon.getHolographicOutline();
-
if (overlay != null) {
final int offset = getScrollX();
final int compoundPaddingLeft = getCompoundPaddingLeft();
diff --git a/src/com/android/launcher2/PagedViewIcon.java b/src/com/android/launcher2/PagedViewIcon.java
index f1b8a01..95bb72f 100644
--- a/src/com/android/launcher2/PagedViewIcon.java
+++ b/src/com/android/launcher2/PagedViewIcon.java
@@ -57,6 +57,7 @@
private int mAlpha = 255;
private int mHolographicAlpha;
+ private boolean mHolographicEffectsEnabled;
private boolean mIsChecked;
private ObjectAnimator mCheckedAlphaAnimator;
private float mCheckedAlpha = 1.0f;
@@ -132,6 +133,7 @@
}
mHolographicOutlineView = new HolographicPagedViewIcon(context, this);
+ mHolographicEffectsEnabled = isHardwareAccelerated();
}
protected HolographicPagedViewIcon getHolographicOutlineView() {
@@ -164,7 +166,7 @@
mIconCache = cache;
mIconCacheKey = new PagedViewIconCache.Key(info);
mHolographicOutline = mIconCache.getOutline(mIconCacheKey);
- if (!queueHolographicOutlineCreation()) {
+ if (mHolographicEffectsEnabled && !queueHolographicOutlineCreation()) {
getHolographicOutlineView().invalidate();
}
}
@@ -182,7 +184,7 @@
mIconCache = cache;
mIconCacheKey = new PagedViewIconCache.Key(info);
mHolographicOutline = mIconCache.getOutline(mIconCacheKey);
- if (!queueHolographicOutlineCreation()) {
+ if (mHolographicEffectsEnabled && !queueHolographicOutlineCreation()) {
getHolographicOutlineView().invalidate();
}
}
@@ -218,7 +220,8 @@
// draw any blended overlays
if (mCheckedOutline == null) {
- if (mHolographicOutline != null && mHolographicAlpha > 0) {
+ if (mHolographicEffectsEnabled && mHolographicOutline != null
+ && mHolographicAlpha > 0) {
mPaint.setAlpha(mHolographicAlpha);
overlay = mHolographicOutline;
}
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 49cab80..cc656bc 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -760,7 +760,8 @@
return offset;
}
private void syncWallpaperOffsetWithScroll() {
- if (LauncherApplication.isScreenXLarge()) {
+ final boolean enableWallpaperEffects = isHardwareAccelerated();
+ if (enableWallpaperEffects) {
mWallpaperOffset.setFinalX(wallpaperOffsetForCurrentScroll());
}
}
@@ -1544,30 +1545,35 @@
float offsetFromCenter = (wallpaperTravelHeight / (float) mWallpaperHeight) / 2f;
boolean isLandscape = display.getWidth() > display.getHeight();
- switch (shrinkState) {
- // animating in
- case TOP:
- // customize
- wallpaperOffset = 0.5f + offsetFromCenter;
- mWallpaperOffset.setVerticalCatchupConstant(isLandscape ? 0.46f : 0.44f);
- break;
- case MIDDLE:
- case SPRING_LOADED:
- wallpaperOffset = 0.5f;
- mWallpaperOffset.setVerticalCatchupConstant(isLandscape ? 0.34f : 0.32f);
- break;
- case BOTTOM_HIDDEN:
- case BOTTOM_VISIBLE:
- // allapps
- wallpaperOffset = 0.5f - offsetFromCenter;
- mWallpaperOffset.setVerticalCatchupConstant(isLandscape ? 0.34f : 0.32f);
- break;
+ final boolean enableWallpaperEffects = isHardwareAccelerated();
+ if (enableWallpaperEffects) {
+ switch (shrinkState) {
+ // animating in
+ case TOP:
+ // customize
+ wallpaperOffset = 0.5f + offsetFromCenter;
+ mWallpaperOffset.setVerticalCatchupConstant(isLandscape ? 0.46f : 0.44f);
+ break;
+ case MIDDLE:
+ case SPRING_LOADED:
+ wallpaperOffset = 0.5f;
+ mWallpaperOffset.setVerticalCatchupConstant(isLandscape ? 0.34f : 0.32f);
+ break;
+ case BOTTOM_HIDDEN:
+ case BOTTOM_VISIBLE:
+ // allapps
+ wallpaperOffset = 0.5f - offsetFromCenter;
+ mWallpaperOffset.setVerticalCatchupConstant(isLandscape ? 0.34f : 0.32f);
+ break;
+ }
}
setLayoutScale(1.0f);
if (animated) {
- mWallpaperOffset.setHorizontalCatchupConstant(0.46f);
- mWallpaperOffset.setOverrideHorizontalCatchupConstant(true);
+ if (enableWallpaperEffects) {
+ mWallpaperOffset.setHorizontalCatchupConstant(0.46f);
+ mWallpaperOffset.setOverrideHorizontalCatchupConstant(true);
+ }
mSyncWallpaperOffsetWithScroll = false;
@@ -1586,10 +1592,12 @@
return;
}
fastInvalidate();
- setHorizontalWallpaperOffset(
+ if (enableWallpaperEffects) {
+ setHorizontalWallpaperOffset(
a * oldHorizontalWallpaperOffset + b * newHorizontalWallpaperOffset);
- setVerticalWallpaperOffset(
+ setVerticalWallpaperOffset(
a * oldVerticalWallpaperOffset + b * newVerticalWallpaperOffset);
+ }
for (int i = 0; i < screenCount; i++) {
final CellLayout cl = (CellLayout) getChildAt(i);
cl.fastInvalidate();
@@ -1607,7 +1615,7 @@
mAnimator.playTogether(animWithInterpolator);
mAnimator.addListener(mShrinkAnimationListener);
mAnimator.start();
- } else {
+ } else if (enableWallpaperEffects) {
setVerticalWallpaperOffset(wallpaperOffset);
setHorizontalWallpaperOffset(0.5f);
updateWallpaperOffsetImmediately();
@@ -1906,33 +1914,36 @@
}
Display display = mLauncher.getWindowManager().getDefaultDisplay();
boolean isLandscape = display.getWidth() > display.getHeight();
- switch (mShrinkState) {
- // animating out
- case TOP:
- // customize
- if (animated) {
- mWallpaperOffset.setHorizontalCatchupConstant(isLandscape ? 0.65f : 0.62f);
- mWallpaperOffset.setVerticalCatchupConstant(isLandscape ? 0.65f : 0.62f);
- mWallpaperOffset.setOverrideHorizontalCatchupConstant(true);
- }
- break;
- case MIDDLE:
- case SPRING_LOADED:
- if (animated) {
- mWallpaperOffset.setHorizontalCatchupConstant(isLandscape ? 0.49f : 0.46f);
- mWallpaperOffset.setVerticalCatchupConstant(isLandscape ? 0.49f : 0.46f);
- mWallpaperOffset.setOverrideHorizontalCatchupConstant(true);
- }
- break;
- case BOTTOM_HIDDEN:
- case BOTTOM_VISIBLE:
- // all apps
- if (animated) {
- mWallpaperOffset.setHorizontalCatchupConstant(isLandscape ? 0.65f : 0.65f);
- mWallpaperOffset.setVerticalCatchupConstant(isLandscape ? 0.65f : 0.65f);
- mWallpaperOffset.setOverrideHorizontalCatchupConstant(true);
- }
- break;
+ final boolean enableWallpaperEffects = isHardwareAccelerated();
+ if (enableWallpaperEffects) {
+ switch (mShrinkState) {
+ // animating out
+ case TOP:
+ // customize
+ if (animated) {
+ mWallpaperOffset.setHorizontalCatchupConstant(isLandscape ? 0.65f : 0.62f);
+ mWallpaperOffset.setVerticalCatchupConstant(isLandscape ? 0.65f : 0.62f);
+ mWallpaperOffset.setOverrideHorizontalCatchupConstant(true);
+ }
+ break;
+ case MIDDLE:
+ case SPRING_LOADED:
+ if (animated) {
+ mWallpaperOffset.setHorizontalCatchupConstant(isLandscape ? 0.49f : 0.46f);
+ mWallpaperOffset.setVerticalCatchupConstant(isLandscape ? 0.49f : 0.46f);
+ mWallpaperOffset.setOverrideHorizontalCatchupConstant(true);
+ }
+ break;
+ case BOTTOM_HIDDEN:
+ case BOTTOM_VISIBLE:
+ // all apps
+ if (animated) {
+ mWallpaperOffset.setHorizontalCatchupConstant(isLandscape ? 0.65f : 0.65f);
+ mWallpaperOffset.setVerticalCatchupConstant(isLandscape ? 0.65f : 0.65f);
+ mWallpaperOffset.setOverrideHorizontalCatchupConstant(true);
+ }
+ break;
+ }
}
if (animated) {
ValueAnimator animWithInterpolator =
@@ -1950,10 +1961,12 @@
return;
}
fastInvalidate();
- setHorizontalWallpaperOffset(
- a * oldHorizontalWallpaperOffset + b * newHorizontalWallpaperOffset);
- setVerticalWallpaperOffset(
- a * oldVerticalWallpaperOffset + b * newVerticalWallpaperOffset);
+ if (enableWallpaperEffects) {
+ setHorizontalWallpaperOffset(a * oldHorizontalWallpaperOffset
+ + b * newHorizontalWallpaperOffset);
+ setVerticalWallpaperOffset(a * oldVerticalWallpaperOffset
+ + b * newVerticalWallpaperOffset);
+ }
for (int i = 0; i < screenCount; i++) {
final CellLayout cl = (CellLayout) getChildAt(i);
cl.fastInvalidate();
@@ -1995,9 +2008,11 @@
mAnimator.addListener(mUnshrinkAnimationListener);
mAnimator.start();
} else {
- setHorizontalWallpaperOffset(wallpaperOffsetForCurrentScroll());
- setVerticalWallpaperOffset(0.5f);
- updateWallpaperOffsetImmediately();
+ if (enableWallpaperEffects) {
+ setHorizontalWallpaperOffset(wallpaperOffsetForCurrentScroll());
+ setVerticalWallpaperOffset(0.5f);
+ updateWallpaperOffsetImmediately();
+ }
}
}