Loading packages/SystemUI/src/com/android/systemui/ImageWallpaper.java +56 −3 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.app.ActivityManager; import android.content.Context; import android.graphics.Rect; import android.os.HandlerThread; import android.os.Trace; import android.service.wallpaper.WallpaperService; import android.util.Log; import android.util.Size; Loading Loading @@ -48,6 +49,7 @@ public class ImageWallpaper extends WallpaperService { private static final int DELAY_FINISH_RENDERING = 1000; private static final int INTERVAL_WAIT_FOR_RENDERING = 100; private static final int PATIENCE_WAIT_FOR_RENDERING = 10; private static final boolean DEBUG = true; private HandlerThread mWorker; @Override Loading Loading @@ -125,6 +127,10 @@ public class ImageWallpaper extends WallpaperService { @Override public void onAmbientModeChanged(boolean inAmbientMode, long animationDuration) { if (!mNeedTransition) return; if (DEBUG) { Log.d(TAG, "onAmbientModeChanged: inAmbient=" + inAmbientMode + ", duration=" + animationDuration); } mWorker.getThreadHandler().post( () -> mRenderer.updateAmbientMode(inAmbientMode, animationDuration)); if (inAmbientMode && animationDuration == 0) { Loading Loading @@ -177,6 +183,10 @@ public class ImageWallpaper extends WallpaperService { @Override public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) { mWorker.getThreadHandler().post(() -> { if (DEBUG) { Log.d(TAG, "onSurfaceChanged: w=" + width + ", h=" + height); } mRenderer.onSurfaceChanged(width, height); mNeedRedraw = true; }); Loading @@ -185,15 +195,30 @@ public class ImageWallpaper extends WallpaperService { @Override public void onSurfaceRedrawNeeded(SurfaceHolder holder) { mWorker.getThreadHandler().post(() -> { if (DEBUG) { Log.d(TAG, "onSurfaceRedrawNeeded: mNeedRedraw=" + mNeedRedraw); } if (mNeedRedraw) { preRender(); requestRender(); postRender(); drawFrame(); mNeedRedraw = false; } }); } @Override public void onVisibilityChanged(boolean visible) { if (DEBUG) { Log.d(TAG, "wallpaper visibility changes to: " + visible); } } private void drawFrame() { preRender(); requestRender(); postRender(); } @Override public void onStatePostChange() { // When back to home, we try to release EGL, which is preserved in lock screen or aod. Loading @@ -204,8 +229,18 @@ public class ImageWallpaper extends WallpaperService { @Override public void preRender() { if (DEBUG) { Log.d(TAG, "preRender start"); } // This method should only be invoked from worker thread. Trace.beginSection("ImageWallpaper#preRender"); preRenderInternal(); Trace.endSection(); if (DEBUG) { Log.d(TAG, "preRender end"); } } private void preRenderInternal() { Loading Loading @@ -240,7 +275,9 @@ public class ImageWallpaper extends WallpaperService { @Override public void requestRender() { // This method should only be invoked from worker thread. Trace.beginSection("ImageWallpaper#requestRender"); requestRenderInternal(); Trace.endSection(); } private void requestRenderInternal() { Loading @@ -262,9 +299,19 @@ public class ImageWallpaper extends WallpaperService { @Override public void postRender() { if (DEBUG) { Log.d(TAG, "postRender start"); } // This method should only be invoked from worker thread. Trace.beginSection("ImageWallpaper#postRender"); notifyWaitingThread(); scheduleFinishRendering(); Trace.endSection(); if (DEBUG) { Log.d(TAG, "postRender end"); } } private void notifyWaitingThread() { Loading @@ -289,12 +336,18 @@ public class ImageWallpaper extends WallpaperService { } private void finishRendering() { if (DEBUG) { Log.d(TAG, "finishRendering, preserve=" + needPreserveEglContext()); } Trace.beginSection("ImageWallpaper#finishRendering"); if (mEglHelper != null) { mEglHelper.destroyEglSurface(); if (!needPreserveEglContext()) { mEglHelper.destroyEglContext(); } } Trace.endSection(); } private boolean needPreserveEglContext() { Loading packages/SystemUI/src/com/android/systemui/glwallpaper/ImageRevealHelper.java +15 −2 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.systemui.glwallpaper; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ValueAnimator; import android.util.Log; import com.android.systemui.Interpolators; Loading @@ -30,6 +31,7 @@ class ImageRevealHelper { private static final String TAG = ImageRevealHelper.class.getSimpleName(); private static final float MAX_REVEAL = 0f; private static final float MIN_REVEAL = 1f; private static final boolean DEBUG = true; private final ValueAnimator mAnimator; private final RevealStateListener mRevealListener; Loading @@ -56,15 +58,23 @@ class ImageRevealHelper { @Override public void onAnimationEnd(Animator animation) { if (!mIsCanceled && mRevealListener != null) { if (mRevealListener != null) { if (DEBUG) { Log.d(TAG, "transition end, cancel=" + mIsCanceled + ", reveal=" + mReveal); } if (!mIsCanceled) { mRevealListener.onRevealEnd(); } } mIsCanceled = false; } @Override public void onAnimationStart(Animator animation) { if (mRevealListener != null) { if (DEBUG) { Log.d(TAG, "transition start"); } mRevealListener.onRevealStart(true /* animate */); } } Loading @@ -82,6 +92,9 @@ class ImageRevealHelper { } void updateAwake(boolean awake, long duration) { if (DEBUG) { Log.d(TAG, "updateAwake: awake=" + awake + ", duration=" + duration); } mAwake = awake; mAnimator.setDuration(duration); if (duration == 0) { Loading packages/SystemUI/src/com/android/systemui/glwallpaper/ImageWallpaperRenderer.java +24 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ public class ImageWallpaperRenderer implements GLWallpaperRenderer, private static final String TAG = ImageWallpaperRenderer.class.getSimpleName(); private static final float SCALE_VIEWPORT_MIN = 1f; private static final float SCALE_VIEWPORT_MAX = 1.1f; private static final boolean DEBUG = true; private final WallpaperManager mWallpaperManager; private final ImageGLProgram mProgram; Loading Loading @@ -107,6 +108,9 @@ public class ImageWallpaperRenderer implements GLWallpaperRenderer, } private boolean loadBitmap() { if (DEBUG) { Log.d(TAG, "loadBitmap: mBitmap=" + mBitmap); } if (mWallpaperManager != null && mBitmap == null) { mBitmap = mWallpaperManager.getBitmap(); mWallpaperManager.forgetLoadedWallpaper(); Loading @@ -119,6 +123,9 @@ public class ImageWallpaperRenderer implements GLWallpaperRenderer, mSurfaceSize.set(0, 0, surfaceWidth, surfaceHeight); } } if (DEBUG) { Log.d(TAG, "loadBitmap done, surface size=" + mSurfaceSize); } return mBitmap != null; } Loading Loading @@ -193,16 +200,28 @@ public class ImageWallpaperRenderer implements GLWallpaperRenderer, @Override public void onRevealStart(boolean animate) { if (DEBUG) { Log.v(TAG, "onRevealStart: start, anim=" + animate); } if (animate) { mScissorMode = true; // Use current display area of texture. mWallpaper.adjustTextureCoordinates(mSurfaceSize, mScissor, mXOffset, mYOffset); } mProxy.preRender(); if (DEBUG) { Log.v(TAG, "onRevealStart: done"); } } @Override public void onRevealEnd() { if (DEBUG) { Log.v(TAG, "onRevealEnd: start, mScissorMode=" + mScissorMode); } if (mScissorMode) { mScissorMode = false; // reset texture coordinates to use full texture. Loading @@ -211,6 +230,10 @@ public class ImageWallpaperRenderer implements GLWallpaperRenderer, mProxy.requestRender(); } mProxy.postRender(); if (DEBUG) { Log.v(TAG, "onRevealEnd: done"); } } @Override Loading @@ -223,6 +246,7 @@ public class ImageWallpaperRenderer implements GLWallpaperRenderer, out.print(prefix); out.print("mXOffset="); out.print(mXOffset); out.print(prefix); out.print("mYOffset="); out.print(mYOffset); out.print(prefix); out.print("threshold="); out.print(mImageProcessHelper.getThreshold()); out.print(prefix); out.print("mReveal="); out.print(mImageRevealHelper.getReveal()); mWallpaper.dump(prefix, fd, out, args); } } Loading
packages/SystemUI/src/com/android/systemui/ImageWallpaper.java +56 −3 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.app.ActivityManager; import android.content.Context; import android.graphics.Rect; import android.os.HandlerThread; import android.os.Trace; import android.service.wallpaper.WallpaperService; import android.util.Log; import android.util.Size; Loading Loading @@ -48,6 +49,7 @@ public class ImageWallpaper extends WallpaperService { private static final int DELAY_FINISH_RENDERING = 1000; private static final int INTERVAL_WAIT_FOR_RENDERING = 100; private static final int PATIENCE_WAIT_FOR_RENDERING = 10; private static final boolean DEBUG = true; private HandlerThread mWorker; @Override Loading Loading @@ -125,6 +127,10 @@ public class ImageWallpaper extends WallpaperService { @Override public void onAmbientModeChanged(boolean inAmbientMode, long animationDuration) { if (!mNeedTransition) return; if (DEBUG) { Log.d(TAG, "onAmbientModeChanged: inAmbient=" + inAmbientMode + ", duration=" + animationDuration); } mWorker.getThreadHandler().post( () -> mRenderer.updateAmbientMode(inAmbientMode, animationDuration)); if (inAmbientMode && animationDuration == 0) { Loading Loading @@ -177,6 +183,10 @@ public class ImageWallpaper extends WallpaperService { @Override public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) { mWorker.getThreadHandler().post(() -> { if (DEBUG) { Log.d(TAG, "onSurfaceChanged: w=" + width + ", h=" + height); } mRenderer.onSurfaceChanged(width, height); mNeedRedraw = true; }); Loading @@ -185,15 +195,30 @@ public class ImageWallpaper extends WallpaperService { @Override public void onSurfaceRedrawNeeded(SurfaceHolder holder) { mWorker.getThreadHandler().post(() -> { if (DEBUG) { Log.d(TAG, "onSurfaceRedrawNeeded: mNeedRedraw=" + mNeedRedraw); } if (mNeedRedraw) { preRender(); requestRender(); postRender(); drawFrame(); mNeedRedraw = false; } }); } @Override public void onVisibilityChanged(boolean visible) { if (DEBUG) { Log.d(TAG, "wallpaper visibility changes to: " + visible); } } private void drawFrame() { preRender(); requestRender(); postRender(); } @Override public void onStatePostChange() { // When back to home, we try to release EGL, which is preserved in lock screen or aod. Loading @@ -204,8 +229,18 @@ public class ImageWallpaper extends WallpaperService { @Override public void preRender() { if (DEBUG) { Log.d(TAG, "preRender start"); } // This method should only be invoked from worker thread. Trace.beginSection("ImageWallpaper#preRender"); preRenderInternal(); Trace.endSection(); if (DEBUG) { Log.d(TAG, "preRender end"); } } private void preRenderInternal() { Loading Loading @@ -240,7 +275,9 @@ public class ImageWallpaper extends WallpaperService { @Override public void requestRender() { // This method should only be invoked from worker thread. Trace.beginSection("ImageWallpaper#requestRender"); requestRenderInternal(); Trace.endSection(); } private void requestRenderInternal() { Loading @@ -262,9 +299,19 @@ public class ImageWallpaper extends WallpaperService { @Override public void postRender() { if (DEBUG) { Log.d(TAG, "postRender start"); } // This method should only be invoked from worker thread. Trace.beginSection("ImageWallpaper#postRender"); notifyWaitingThread(); scheduleFinishRendering(); Trace.endSection(); if (DEBUG) { Log.d(TAG, "postRender end"); } } private void notifyWaitingThread() { Loading @@ -289,12 +336,18 @@ public class ImageWallpaper extends WallpaperService { } private void finishRendering() { if (DEBUG) { Log.d(TAG, "finishRendering, preserve=" + needPreserveEglContext()); } Trace.beginSection("ImageWallpaper#finishRendering"); if (mEglHelper != null) { mEglHelper.destroyEglSurface(); if (!needPreserveEglContext()) { mEglHelper.destroyEglContext(); } } Trace.endSection(); } private boolean needPreserveEglContext() { Loading
packages/SystemUI/src/com/android/systemui/glwallpaper/ImageRevealHelper.java +15 −2 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.systemui.glwallpaper; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ValueAnimator; import android.util.Log; import com.android.systemui.Interpolators; Loading @@ -30,6 +31,7 @@ class ImageRevealHelper { private static final String TAG = ImageRevealHelper.class.getSimpleName(); private static final float MAX_REVEAL = 0f; private static final float MIN_REVEAL = 1f; private static final boolean DEBUG = true; private final ValueAnimator mAnimator; private final RevealStateListener mRevealListener; Loading @@ -56,15 +58,23 @@ class ImageRevealHelper { @Override public void onAnimationEnd(Animator animation) { if (!mIsCanceled && mRevealListener != null) { if (mRevealListener != null) { if (DEBUG) { Log.d(TAG, "transition end, cancel=" + mIsCanceled + ", reveal=" + mReveal); } if (!mIsCanceled) { mRevealListener.onRevealEnd(); } } mIsCanceled = false; } @Override public void onAnimationStart(Animator animation) { if (mRevealListener != null) { if (DEBUG) { Log.d(TAG, "transition start"); } mRevealListener.onRevealStart(true /* animate */); } } Loading @@ -82,6 +92,9 @@ class ImageRevealHelper { } void updateAwake(boolean awake, long duration) { if (DEBUG) { Log.d(TAG, "updateAwake: awake=" + awake + ", duration=" + duration); } mAwake = awake; mAnimator.setDuration(duration); if (duration == 0) { Loading
packages/SystemUI/src/com/android/systemui/glwallpaper/ImageWallpaperRenderer.java +24 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ public class ImageWallpaperRenderer implements GLWallpaperRenderer, private static final String TAG = ImageWallpaperRenderer.class.getSimpleName(); private static final float SCALE_VIEWPORT_MIN = 1f; private static final float SCALE_VIEWPORT_MAX = 1.1f; private static final boolean DEBUG = true; private final WallpaperManager mWallpaperManager; private final ImageGLProgram mProgram; Loading Loading @@ -107,6 +108,9 @@ public class ImageWallpaperRenderer implements GLWallpaperRenderer, } private boolean loadBitmap() { if (DEBUG) { Log.d(TAG, "loadBitmap: mBitmap=" + mBitmap); } if (mWallpaperManager != null && mBitmap == null) { mBitmap = mWallpaperManager.getBitmap(); mWallpaperManager.forgetLoadedWallpaper(); Loading @@ -119,6 +123,9 @@ public class ImageWallpaperRenderer implements GLWallpaperRenderer, mSurfaceSize.set(0, 0, surfaceWidth, surfaceHeight); } } if (DEBUG) { Log.d(TAG, "loadBitmap done, surface size=" + mSurfaceSize); } return mBitmap != null; } Loading Loading @@ -193,16 +200,28 @@ public class ImageWallpaperRenderer implements GLWallpaperRenderer, @Override public void onRevealStart(boolean animate) { if (DEBUG) { Log.v(TAG, "onRevealStart: start, anim=" + animate); } if (animate) { mScissorMode = true; // Use current display area of texture. mWallpaper.adjustTextureCoordinates(mSurfaceSize, mScissor, mXOffset, mYOffset); } mProxy.preRender(); if (DEBUG) { Log.v(TAG, "onRevealStart: done"); } } @Override public void onRevealEnd() { if (DEBUG) { Log.v(TAG, "onRevealEnd: start, mScissorMode=" + mScissorMode); } if (mScissorMode) { mScissorMode = false; // reset texture coordinates to use full texture. Loading @@ -211,6 +230,10 @@ public class ImageWallpaperRenderer implements GLWallpaperRenderer, mProxy.requestRender(); } mProxy.postRender(); if (DEBUG) { Log.v(TAG, "onRevealEnd: done"); } } @Override Loading @@ -223,6 +246,7 @@ public class ImageWallpaperRenderer implements GLWallpaperRenderer, out.print(prefix); out.print("mXOffset="); out.print(mXOffset); out.print(prefix); out.print("mYOffset="); out.print(mYOffset); out.print(prefix); out.print("threshold="); out.print(mImageProcessHelper.getThreshold()); out.print(prefix); out.print("mReveal="); out.print(mImageRevealHelper.getReveal()); mWallpaper.dump(prefix, fd, out, args); } }