diff options
author | John Reck <jreck@google.com> | 2014-02-21 15:45:10 -0800 |
---|---|---|
committer | John Reck <jreck@google.com> | 2014-02-21 18:12:04 -0800 |
commit | e56e9df5f12b2714d79415e2c5b3f30d58ca7c12 (patch) | |
tree | 4dc57cd3e22dc3eeae5ca1ade1dc50a582d99104 /core/java | |
parent | 8eb91e9f281f876322a25c78f776ea74791eaf1c (diff) | |
download | frameworks_base-e56e9df5f12b2714d79415e2c5b3f30d58ca7c12.zip frameworks_base-e56e9df5f12b2714d79415e2c5b3f30d58ca7c12.tar.gz frameworks_base-e56e9df5f12b2714d79415e2c5b3f30d58ca7c12.tar.bz2 |
Add back resize buffer
Bug: 12825810
Change-Id: Ic2329c30524010f54778101853b30f8f8d9eeb6c
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/view/GLRenderer.java | 1 | ||||
-rw-r--r-- | core/java/android/view/ViewRootImpl.java | 188 |
2 files changed, 86 insertions, 103 deletions
diff --git a/core/java/android/view/GLRenderer.java b/core/java/android/view/GLRenderer.java index b758930..4c92e950 100644 --- a/core/java/android/view/GLRenderer.java +++ b/core/java/android/view/GLRenderer.java @@ -478,6 +478,7 @@ public class GLRenderer extends HardwareRenderer { @Override void flushLayerUpdates() { if (validate()) { + flushLayerChanges(); mGlCanvas.flushLayerUpdates(); } } diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index a13b184..2b32d70 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -264,10 +264,10 @@ public final class ViewRootImpl implements ViewParent, int mScrollY; int mCurScrollY; Scroller mScroller; -// HardwareLayer mResizeBuffer; -// long mResizeBufferStartTime; -// int mResizeBufferDuration; -// static final Interpolator mResizeInterpolator = new AccelerateDecelerateInterpolator(); + HardwareLayer mResizeBuffer; + long mResizeBufferStartTime; + int mResizeBufferDuration; + static final Interpolator mResizeInterpolator = new AccelerateDecelerateInterpolator(); private ArrayList<LayoutTransition> mPendingTransitions; final ViewConfiguration mViewConfiguration; @@ -931,17 +931,12 @@ public final class ViewRootImpl implements ViewParent, return mAppVisible ? mView.getVisibility() : View.GONE; } -// void disposeResizeBuffer() { -// if (mResizeBuffer != null && mAttachInfo.mHardwareRenderer != null) { -// mAttachInfo.mHardwareRenderer.safelyRun(new Runnable() { -// @Override -// public void run() { -// mResizeBuffer.destroy(); -// mResizeBuffer = null; -// } -// }); -// } -// } + void disposeResizeBuffer() { + if (mResizeBuffer != null) { + mResizeBuffer.destroy(); + mResizeBuffer = null; + } + } /** * Add LayoutTransition to the list of transitions to be started in the next traversal. @@ -1452,76 +1447,63 @@ public final class ViewRootImpl implements ViewParent, final boolean visibleInsetsChanged = !mPendingVisibleInsets.equals( mAttachInfo.mVisibleInsets); if (contentInsetsChanged) { -// TODO: Do something with this... -// if (mWidth > 0 && mHeight > 0 && lp != null && -// ((lp.systemUiVisibility|lp.subtreeSystemUiVisibility) -// & View.SYSTEM_UI_LAYOUT_FLAGS) == 0 && -// mSurface != null && mSurface.isValid() && -// !mAttachInfo.mTurnOffWindowResizeAnim && -// mAttachInfo.mHardwareRenderer != null && -// mAttachInfo.mHardwareRenderer.isEnabled() && -// mAttachInfo.mHardwareRenderer.validate() && -// lp != null && !PixelFormat.formatHasAlpha(lp.format)) { -// -// disposeResizeBuffer(); -// -// boolean completed = false; -// HardwareCanvas hwRendererCanvas = mAttachInfo.mHardwareRenderer.getCanvas(); -// HardwareCanvas layerCanvas = null; -// try { -// if (mResizeBuffer == null) { -// mResizeBuffer = mAttachInfo.mHardwareRenderer.createHardwareLayer( -// mWidth, mHeight, false); -// } else if (mResizeBuffer.getWidth() != mWidth || -// mResizeBuffer.getHeight() != mHeight) { -// mResizeBuffer.resize(mWidth, mHeight); -// } -// // TODO: should handle create/resize failure -// layerCanvas = mResizeBuffer.start(hwRendererCanvas); -// final int restoreCount = layerCanvas.save(); -// -// int yoff; -// final boolean scrolling = mScroller != null -// && mScroller.computeScrollOffset(); -// if (scrolling) { -// yoff = mScroller.getCurrY(); -// mScroller.abortAnimation(); -// } else { -// yoff = mScrollY; -// } -// -// layerCanvas.translate(0, -yoff); -// if (mTranslator != null) { -// mTranslator.translateCanvas(layerCanvas); -// } -// -// DisplayList displayList = mView.mDisplayList; -// if (displayList != null && displayList.isValid()) { -// layerCanvas.drawDisplayList(displayList, null, -// DisplayList.FLAG_CLIP_CHILDREN); -// } else { -// mView.draw(layerCanvas); -// } -// -// drawAccessibilityFocusedDrawableIfNeeded(layerCanvas); -// -// mResizeBufferStartTime = SystemClock.uptimeMillis(); -// mResizeBufferDuration = mView.getResources().getInteger( -// com.android.internal.R.integer.config_mediumAnimTime); -// completed = true; -// -// layerCanvas.restoreToCount(restoreCount); -// } catch (OutOfMemoryError e) { -// Log.w(TAG, "Not enough memory for content change anim buffer", e); -// } finally { -// if (mResizeBuffer != null) { -// mResizeBuffer.end(hwRendererCanvas); -// if (!completed) { -// disposeResizeBuffer(); -// } -// } -// } -// } + if (mWidth > 0 && mHeight > 0 && lp != null && + ((lp.systemUiVisibility|lp.subtreeSystemUiVisibility) + & View.SYSTEM_UI_LAYOUT_FLAGS) == 0 && + mSurface != null && mSurface.isValid() && + !mAttachInfo.mTurnOffWindowResizeAnim && + mAttachInfo.mHardwareRenderer != null && + mAttachInfo.mHardwareRenderer.isEnabled() && + lp != null && !PixelFormat.formatHasAlpha(lp.format)) { + + disposeResizeBuffer(); + + if (mResizeBuffer == null) { + mResizeBuffer = mAttachInfo.mHardwareRenderer.createDisplayListLayer( + mWidth, mHeight); + } + mResizeBuffer.prepare(mWidth, mHeight, false); + DisplayList layerDisplayList = mResizeBuffer.startRecording(); + HardwareCanvas layerCanvas = layerDisplayList.start(mWidth, mHeight); + final int restoreCount = layerCanvas.save(); + + int yoff; + final boolean scrolling = mScroller != null + && mScroller.computeScrollOffset(); + if (scrolling) { + yoff = mScroller.getCurrY(); + mScroller.abortAnimation(); + } else { + yoff = mScrollY; + } + + layerCanvas.translate(0, -yoff); + if (mTranslator != null) { + mTranslator.translateCanvas(layerCanvas); + } + + DisplayList displayList = mView.mDisplayList; + if (displayList != null && displayList.isValid()) { + layerCanvas.drawDisplayList(displayList, null, + DisplayList.FLAG_CLIP_CHILDREN); + } else { + mView.draw(layerCanvas); + } + + drawAccessibilityFocusedDrawableIfNeeded(layerCanvas); + + mResizeBufferStartTime = SystemClock.uptimeMillis(); + mResizeBufferDuration = mView.getResources().getInteger( + com.android.internal.R.integer.config_mediumAnimTime); + + layerCanvas.restoreToCount(restoreCount); + layerDisplayList.end(); + layerDisplayList.setCaching(true); + layerDisplayList.setLeftTopRightBottom(0, 0, mWidth, mHeight); + mTempRect.set(0, 0, mWidth, mHeight); + mResizeBuffer.endRecording(mTempRect); + mAttachInfo.mHardwareRenderer.flushLayerUpdates(); + } mAttachInfo.mContentInsets.set(mPendingContentInsets); if (DEBUG_LAYOUT) Log.v(TAG, "Content insets changing to: " + mAttachInfo.mContentInsets); @@ -1581,7 +1563,7 @@ public final class ViewRootImpl implements ViewParent, if (mScroller != null) { mScroller.abortAnimation(); } -// disposeResizeBuffer(); + disposeResizeBuffer(); // Our surface is gone if (mAttachInfo.mHardwareRenderer != null && mAttachInfo.mHardwareRenderer.isEnabled()) { @@ -2180,10 +2162,10 @@ public final class ViewRootImpl implements ViewParent, @Override public void onHardwarePostDraw(HardwareCanvas canvas) { -// if (mResizeBuffer != null) { -// mResizePaint.setAlpha(mResizeAlpha); -// canvas.drawHardwareLayer(mResizeBuffer, 0.0f, mHardwareYOffset, mResizePaint); -// } + if (mResizeBuffer != null) { + mResizePaint.setAlpha(mResizeAlpha); + canvas.drawHardwareLayer(mResizeBuffer, 0.0f, mHardwareYOffset, mResizePaint); + } // TODO: this if (!HardwareRenderer.sUseRenderThread) { drawAccessibilityFocusedDrawableIfNeeded(canvas); @@ -2342,17 +2324,17 @@ public final class ViewRootImpl implements ViewParent, final boolean scalingRequired = attachInfo.mScalingRequired; int resizeAlpha = 0; -// if (mResizeBuffer != null) { -// long deltaTime = SystemClock.uptimeMillis() - mResizeBufferStartTime; -// if (deltaTime < mResizeBufferDuration) { -// float amt = deltaTime/(float) mResizeBufferDuration; -// amt = mResizeInterpolator.getInterpolation(amt); -// animating = true; -// resizeAlpha = 255 - (int)(amt*255); -// } else { -// disposeResizeBuffer(); -// } -// } + if (mResizeBuffer != null) { + long deltaTime = SystemClock.uptimeMillis() - mResizeBufferStartTime; + if (deltaTime < mResizeBufferDuration) { + float amt = deltaTime/(float) mResizeBufferDuration; + amt = mResizeInterpolator.getInterpolation(amt); + animating = true; + resizeAlpha = 255 - (int)(amt*255); + } else { + disposeResizeBuffer(); + } + } final Rect dirty = mDirty; if (mSurfaceHolder != null) { @@ -2362,7 +2344,7 @@ public final class ViewRootImpl implements ViewParent, if (mScroller != null) { mScroller.abortAnimation(); } -// disposeResizeBuffer(); + disposeResizeBuffer(); } return; } @@ -2725,7 +2707,7 @@ public final class ViewRootImpl implements ViewParent, if (scrollY != mScrollY) { if (DEBUG_INPUT_RESIZE) Log.v(TAG, "Pan scroll changed: old=" + mScrollY + " , new=" + scrollY); - if (!immediate /*&& mResizeBuffer == null*/) { + if (!immediate && mResizeBuffer == null) { if (mScroller == null) { mScroller = new Scroller(mView.getContext()); } |