Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 01a5ea35 authored by John Reck's avatar John Reck
Browse files

Resume RT-animations after a pauseSurface

Bug: 18203577

The issue occurs as a result of performTraversals() both doing
a window relayout call *and* early-returning because it's not dirty.

To fix this pauseSurface() returns whether or not the RT-side is
"dirty" to force ViewRootImpl to do a draw even if mDirty is
otherwise empty.

Change-Id: I534f367e75d18d273ebf14df3927f5c464ef6bef
parent 8d72046b
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -235,7 +235,7 @@ public abstract class HardwareRenderer {
     * or not the surface used by the HardwareRenderer will be changing. It
     * or not the surface used by the HardwareRenderer will be changing. It
     * Suspends any rendering into the surface, but will not do any destruction
     * Suspends any rendering into the surface, but will not do any destruction
     */
     */
    abstract void pauseSurface(Surface surface);
    abstract boolean pauseSurface(Surface surface);


    /**
    /**
     * Destroys all hardware rendering resources associated with the specified
     * Destroys all hardware rendering resources associated with the specified
+3 −3
Original line number Original line Diff line number Diff line
@@ -155,8 +155,8 @@ public class ThreadedRenderer extends HardwareRenderer {
    }
    }


    @Override
    @Override
    void pauseSurface(Surface surface) {
    boolean pauseSurface(Surface surface) {
        nPauseSurface(mNativeProxy, surface);
        return nPauseSurface(mNativeProxy, surface);
    }
    }


    @Override
    @Override
@@ -494,7 +494,7 @@ public class ThreadedRenderer extends HardwareRenderer {


    private static native boolean nInitialize(long nativeProxy, Surface window);
    private static native boolean nInitialize(long nativeProxy, Surface window);
    private static native void nUpdateSurface(long nativeProxy, Surface window);
    private static native void nUpdateSurface(long nativeProxy, Surface window);
    private static native void nPauseSurface(long nativeProxy, Surface window);
    private static native boolean nPauseSurface(long nativeProxy, Surface window);
    private static native void nSetup(long nativeProxy, int width, int height,
    private static native void nSetup(long nativeProxy, int width, int height,
            float lightX, float lightY, float lightZ, float lightRadius,
            float lightX, float lightY, float lightZ, float lightRadius,
            int ambientShadowAlpha, int spotShadowAlpha);
            int ambientShadowAlpha, int spotShadowAlpha);
+5 −1
Original line number Original line Diff line number Diff line
@@ -1493,7 +1493,11 @@ public final class ViewRootImpl implements ViewParent,
                    // relayoutWindow may decide to destroy mSurface. As that decision
                    // relayoutWindow may decide to destroy mSurface. As that decision
                    // happens in WindowManager service, we need to be defensive here
                    // happens in WindowManager service, we need to be defensive here
                    // and stop using the surface in case it gets destroyed.
                    // and stop using the surface in case it gets destroyed.
                    mAttachInfo.mHardwareRenderer.pauseSurface(mSurface);
                    if (mAttachInfo.mHardwareRenderer.pauseSurface(mSurface)) {
                        // Animations were running so we need to push a frame
                        // to resume them
                        mDirty.set(0, 0, mWidth, mHeight);
                    }
                }
                }
                final int surfaceGenerationId = mSurface.getGenerationId();
                final int surfaceGenerationId = mSurface.getGenerationId();
                relayoutResult = relayoutWindow(params, viewVisibility, insetsPending);
                relayoutResult = relayoutWindow(params, viewVisibility, insetsPending);
+3 −3
Original line number Original line Diff line number Diff line
@@ -270,14 +270,14 @@ static void android_view_ThreadedRenderer_updateSurface(JNIEnv* env, jobject cla
    proxy->updateSurface(window);
    proxy->updateSurface(window);
}
}


static void android_view_ThreadedRenderer_pauseSurface(JNIEnv* env, jobject clazz,
static jboolean android_view_ThreadedRenderer_pauseSurface(JNIEnv* env, jobject clazz,
        jlong proxyPtr, jobject jsurface) {
        jlong proxyPtr, jobject jsurface) {
    RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
    RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
    sp<ANativeWindow> window;
    sp<ANativeWindow> window;
    if (jsurface) {
    if (jsurface) {
        window = android_view_Surface_getNativeWindow(env, jsurface);
        window = android_view_Surface_getNativeWindow(env, jsurface);
    }
    }
    proxy->pauseSurface(window);
    return proxy->pauseSurface(window);
}
}


static void android_view_ThreadedRenderer_setup(JNIEnv* env, jobject clazz, jlong proxyPtr,
static void android_view_ThreadedRenderer_setup(JNIEnv* env, jobject clazz, jlong proxyPtr,
@@ -429,7 +429,7 @@ static JNINativeMethod gMethods[] = {
    { "nLoadSystemProperties", "(J)Z", (void*) android_view_ThreadedRenderer_loadSystemProperties },
    { "nLoadSystemProperties", "(J)Z", (void*) android_view_ThreadedRenderer_loadSystemProperties },
    { "nInitialize", "(JLandroid/view/Surface;)Z", (void*) android_view_ThreadedRenderer_initialize },
    { "nInitialize", "(JLandroid/view/Surface;)Z", (void*) android_view_ThreadedRenderer_initialize },
    { "nUpdateSurface", "(JLandroid/view/Surface;)V", (void*) android_view_ThreadedRenderer_updateSurface },
    { "nUpdateSurface", "(JLandroid/view/Surface;)V", (void*) android_view_ThreadedRenderer_updateSurface },
    { "nPauseSurface", "(JLandroid/view/Surface;)V", (void*) android_view_ThreadedRenderer_pauseSurface },
    { "nPauseSurface", "(JLandroid/view/Surface;)Z", (void*) android_view_ThreadedRenderer_pauseSurface },
    { "nSetup", "(JIIFFFFII)V", (void*) android_view_ThreadedRenderer_setup },
    { "nSetup", "(JIIFFFFII)V", (void*) android_view_ThreadedRenderer_setup },
    { "nSetOpaque", "(JZ)V", (void*) android_view_ThreadedRenderer_setOpaque },
    { "nSetOpaque", "(JZ)V", (void*) android_view_ThreadedRenderer_setOpaque },
    { "nSyncAndDrawFrame", "(JJJF)I", (void*) android_view_ThreadedRenderer_syncAndDrawFrame },
    { "nSyncAndDrawFrame", "(JJJF)I", (void*) android_view_ThreadedRenderer_syncAndDrawFrame },
+2 −2
Original line number Original line Diff line number Diff line
@@ -123,8 +123,8 @@ void CanvasContext::updateSurface(ANativeWindow* window) {
    setSurface(window);
    setSurface(window);
}
}


void CanvasContext::pauseSurface(ANativeWindow* window) {
bool CanvasContext::pauseSurface(ANativeWindow* window) {
    stopDrawing();
    return mRenderThread.removeFrameCallback(this);
}
}


// TODO: don't pass viewport size, it's automatic via EGL
// TODO: don't pass viewport size, it's automatic via EGL
Loading