Loading core/java/android/widget/Magnifier.java +27 −44 Original line number Diff line number Diff line Loading @@ -277,7 +277,7 @@ public final class Magnifier { mWindowElevation, mWindowCornerRadius, mOverlay != null ? mOverlay : new ColorDrawable(Color.TRANSPARENT), Handler.getMain() /* draw the magnifier on the UI thread */, mLock, mDestroyLock, mCallback); mCallback); } } performPixelCopy(startX, startY, true /* update window position */); Loading Loading @@ -306,12 +306,10 @@ public final class Magnifier { */ public void dismiss() { if (mWindow != null) { synchronized (mDestroyLock) { synchronized (mLock) { mWindow.destroy(); mWindow = null; } } mPrevShowSourceCoords.x = NONEXISTENT_PREVIOUS_CONFIG_VALUE; mPrevShowSourceCoords.y = NONEXISTENT_PREVIOUS_CONFIG_VALUE; mPrevShowWindowCoords.x = NONEXISTENT_PREVIOUS_CONFIG_VALUE; Loading Loading @@ -835,24 +833,16 @@ public final class Magnifier { private int mWindowPositionY; private boolean mPendingWindowPositionUpdate; // The lock used to synchronize the UI and render threads when a #destroy // is performed on the UI thread and a frame callback on the render thread. // When both mLock and mDestroyLock need to be held at the same time, // mDestroyLock should be acquired before mLock in order to avoid deadlocks. private final Object mDestroyLock; // The current content of the magnifier. It is mBitmap + mOverlay, only used for testing. private Bitmap mCurrentContent; InternalPopupWindow(final Context context, final Display display, final SurfaceControl parentSurfaceControl, final int width, final int height, final float elevation, final float cornerRadius, final Drawable overlay, final Handler handler, final Object lock, final Object destroyLock, final Callback callback) { final Handler handler, final Object lock, final Callback callback) { mDisplay = display; mOverlay = overlay; mLock = lock; mDestroyLock = destroyLock; mCallback = callback; mContentWidth = width; Loading Loading @@ -1039,14 +1029,12 @@ public final class Magnifier { } /** * Destroys this instance. * Destroys this instance. The method has to be called in a context holding {@link #mLock}. */ public void destroy() { synchronized (mDestroyLock) { mSurface.destroy(); } synchronized (mLock) { // Destroy the renderer. This will not proceed until pending frame callbacks complete. mRenderer.destroy(); mSurface.destroy(); mSurfaceControl.remove(); mSurfaceSession.kill(); mHandler.removeCallbacks(mMagnifierUpdater); Loading @@ -1054,7 +1042,6 @@ public final class Magnifier { mBitmap.recycle(); } } } private void doDraw() { final ThreadedRenderer.FrameDrawingCallback callback; Loading Loading @@ -1090,11 +1077,9 @@ public final class Magnifier { final int pendingY = mWindowPositionY; callback = frame -> { synchronized (mDestroyLock) { if (!mSurface.isValid()) { return; } synchronized (mLock) { // Show or move the window at the content draw frame. SurfaceControl.openTransaction(); mSurfaceControl.deferTransactionUntil(mSurface, frame); Loading @@ -1106,8 +1091,6 @@ public final class Magnifier { mSurfaceControl.show(); } SurfaceControl.closeTransaction(); } } }; mRenderer.setLightCenter(mDisplay, pendingX, pendingY); } else { Loading Loading
core/java/android/widget/Magnifier.java +27 −44 Original line number Diff line number Diff line Loading @@ -277,7 +277,7 @@ public final class Magnifier { mWindowElevation, mWindowCornerRadius, mOverlay != null ? mOverlay : new ColorDrawable(Color.TRANSPARENT), Handler.getMain() /* draw the magnifier on the UI thread */, mLock, mDestroyLock, mCallback); mCallback); } } performPixelCopy(startX, startY, true /* update window position */); Loading Loading @@ -306,12 +306,10 @@ public final class Magnifier { */ public void dismiss() { if (mWindow != null) { synchronized (mDestroyLock) { synchronized (mLock) { mWindow.destroy(); mWindow = null; } } mPrevShowSourceCoords.x = NONEXISTENT_PREVIOUS_CONFIG_VALUE; mPrevShowSourceCoords.y = NONEXISTENT_PREVIOUS_CONFIG_VALUE; mPrevShowWindowCoords.x = NONEXISTENT_PREVIOUS_CONFIG_VALUE; Loading Loading @@ -835,24 +833,16 @@ public final class Magnifier { private int mWindowPositionY; private boolean mPendingWindowPositionUpdate; // The lock used to synchronize the UI and render threads when a #destroy // is performed on the UI thread and a frame callback on the render thread. // When both mLock and mDestroyLock need to be held at the same time, // mDestroyLock should be acquired before mLock in order to avoid deadlocks. private final Object mDestroyLock; // The current content of the magnifier. It is mBitmap + mOverlay, only used for testing. private Bitmap mCurrentContent; InternalPopupWindow(final Context context, final Display display, final SurfaceControl parentSurfaceControl, final int width, final int height, final float elevation, final float cornerRadius, final Drawable overlay, final Handler handler, final Object lock, final Object destroyLock, final Callback callback) { final Handler handler, final Object lock, final Callback callback) { mDisplay = display; mOverlay = overlay; mLock = lock; mDestroyLock = destroyLock; mCallback = callback; mContentWidth = width; Loading Loading @@ -1039,14 +1029,12 @@ public final class Magnifier { } /** * Destroys this instance. * Destroys this instance. The method has to be called in a context holding {@link #mLock}. */ public void destroy() { synchronized (mDestroyLock) { mSurface.destroy(); } synchronized (mLock) { // Destroy the renderer. This will not proceed until pending frame callbacks complete. mRenderer.destroy(); mSurface.destroy(); mSurfaceControl.remove(); mSurfaceSession.kill(); mHandler.removeCallbacks(mMagnifierUpdater); Loading @@ -1054,7 +1042,6 @@ public final class Magnifier { mBitmap.recycle(); } } } private void doDraw() { final ThreadedRenderer.FrameDrawingCallback callback; Loading Loading @@ -1090,11 +1077,9 @@ public final class Magnifier { final int pendingY = mWindowPositionY; callback = frame -> { synchronized (mDestroyLock) { if (!mSurface.isValid()) { return; } synchronized (mLock) { // Show or move the window at the content draw frame. SurfaceControl.openTransaction(); mSurfaceControl.deferTransactionUntil(mSurface, frame); Loading @@ -1106,8 +1091,6 @@ public final class Magnifier { mSurfaceControl.show(); } SurfaceControl.closeTransaction(); } } }; mRenderer.setLightCenter(mDisplay, pendingX, pendingY); } else { Loading