summaryrefslogtreecommitdiff
path: root/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
diff options
context:
space:
mode:
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/ImageWallpaper.java')
-rw-r--r--packages/SystemUI/src/com/android/systemui/ImageWallpaper.java59
1 files changed, 56 insertions, 3 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
index bd91333100bd..c0c14fb01222 100644
--- a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
+++ b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
@@ -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;
@@ -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
@@ -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) {
@@ -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;
});
@@ -185,16 +195,31 @@ 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.
if (mController.getState() == StatusBarState.SHADE) {
@@ -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() {
@@ -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() {
@@ -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() {
@@ -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() {