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

Commit cf15efba authored by Romain Guy's avatar Romain Guy
Browse files

Properly cancel pending buffers on window size change

Change-Id: Id6108ce61a971673f3ebc8270e9dd00849c91ae5
parent b1216dd9
Loading
Loading
Loading
Loading
+20 −7
Original line number Diff line number Diff line
@@ -135,7 +135,7 @@ public abstract class HardwareRenderer {
    /**
     * Updates the hardware renderer for the specified surface.
     * 
     * @param holder The holder for the surface to hardware accelerate.
     * @param holder The holder for the surface to hardware accelerate
     */
    abstract void updateSurface(SurfaceHolder holder) throws Surface.OutOfResourcesException;

@@ -149,8 +149,10 @@ public abstract class HardwareRenderer {
    /**
     * This method should be invoked whenever the current hardware renderer
     * context should be reset.
     * 
     * @param holder The holder for the surface to hardware accelerate
     */
    abstract void invalidate();
    abstract void invalidate(SurfaceHolder holder);

    /**
     * This method should be invoked to ensure the hardware renderer is in
@@ -707,11 +709,22 @@ public abstract class HardwareRenderer {
        }

        @Override
        void invalidate() {
        void invalidate(SurfaceHolder holder) {
            // Cancels any existing buffer to ensure we'll get a buffer
            // of the right size before we call eglSwapBuffers
            sEgl.eglMakeCurrent(sEglDisplay, EGL_NO_SURFACE,
                    EGL_NO_SURFACE, EGL_NO_CONTEXT);
            sEgl.eglMakeCurrent(sEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
            sEgl.eglDestroySurface(sEglDisplay, mEglSurface);
            mEglSurface = sEgl.eglCreateWindowSurface(sEglDisplay, sEglConfig, holder, null);

            if (mEglSurface == null || mEglSurface == EGL_NO_SURFACE) {
                int error = sEgl.eglGetError();
                if (error == EGL_BAD_NATIVE_WINDOW) {
                    Log.e(LOG_TAG, "createWindowSurface returned EGL_BAD_NATIVE_WINDOW.");
                    return;
                }
                throw new RuntimeException("createWindowSurface failed "
                        + getEGLErrorString(error));
            }
        }

        @Override
+1 −1
Original line number Diff line number Diff line
@@ -1344,7 +1344,7 @@ public final class ViewRootImpl extends Handler implements ViewParent,
                    mAttachInfo.mHardwareRenderer.isEnabled())) {
                mAttachInfo.mHardwareRenderer.setup(mWidth, mHeight);
                if (!hwInitialized) {
                    mAttachInfo.mHardwareRenderer.invalidate();
                    mAttachInfo.mHardwareRenderer.invalidate(mHolder);
                }
            }