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

Commit 064f6ad3 authored by Romain Guy's avatar Romain Guy Committed by Android (Google) Code Review
Browse files

Merge "Recreate the EGL surface when ViewRoot's surface changes. Bug #3306150" into honeycomb

parents e70b445d 2a83f001
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -85,6 +85,13 @@ public abstract class HardwareRenderer {
     */
    abstract boolean initialize(SurfaceHolder holder);
    
    /**
     * Updates the hardware renderer for the specified surface.
     * 
     * @param holder The holder for the surface to hardware accelerate.
     */
    abstract void updateSurface(SurfaceHolder holder);

    /**
     * Setup the hardware renderer for drawing. This is called for every
     * frame to draw.
@@ -331,6 +338,13 @@ public abstract class HardwareRenderer {
            return false;
        }
        
        @Override
        void updateSurface(SurfaceHolder holder) {
            if (isRequested() && isEnabled()) {
                createEglSurface(holder);
            }
        }

        abstract GLES20Canvas createCanvas();

        void initializeEgl() {
+9 −0
Original line number Diff line number Diff line
@@ -159,6 +159,8 @@ public class Surface implements Parcelable {
    private Canvas mCanvas;
    @SuppressWarnings("unused")
    private int mNativeSurface;
    @SuppressWarnings("unused")
    private int mSurfaceGenerationId;
    private String mName;

    // The display metrics used to provide the pseudo canvas size for applications
@@ -309,6 +311,13 @@ public class Surface implements Parcelable {
     */
    public native   boolean isValid();

    /**
     * @hide
     */
    public int getGenerationId() {
        return mSurfaceGenerationId;
    }
    
    /** Free all server-side state associated with this surface and
     * release this object's reference. {@hide} */
    public native void destroy();
+5 −0
Original line number Diff line number Diff line
@@ -983,6 +983,8 @@ public final class ViewRoot extends Handler implements ViewParent,
                    Log.i(TAG, "host=w:" + host.getMeasuredWidth() + ", h:" +
                            host.getMeasuredHeight() + ", params=" + params);
                }

                final int surfaceGenerationId = mSurface.getGenerationId();
                relayoutResult = relayoutWindow(params, viewVisibility, insetsPending);

                if (params != null) {
@@ -1043,6 +1045,9 @@ public final class ViewRoot extends Handler implements ViewParent,
                        mScroller.abortAnimation();
                    }
                    disposeResizeBitmap();
                } else if (surfaceGenerationId != mSurface.getGenerationId() &&
                        mSurfaceHolder == null && mAttachInfo.mHardwareRenderer != null) {
                    mAttachInfo.mHardwareRenderer.updateSurface(mHolder);
                }
            } catch (RemoteException e) {
            }
+8 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ static sso_t sso;

struct so_t {
    jfieldID surfaceControl;
    jfieldID surfaceGenerationId;
    jfieldID surface;
    jfieldID saveCount;
    jfieldID canvas;
@@ -189,6 +190,12 @@ static void setSurface(JNIEnv* env, jobject clazz, const sp<Surface>& surface)
        p->decStrong(clazz);
    }
    env->SetIntField(clazz, so.surface, (int)surface.get());
    // This test is conservative and it would be better to compare the ISurfaces
    if (p && p != surface.get()) {
        jint generationId = env->GetIntField(clazz, so.surfaceGenerationId);
        generationId++;
        env->SetIntField(clazz, so.surfaceGenerationId, generationId);
    }
}

// ----------------------------------------------------------------------------
@@ -785,6 +792,7 @@ static JNINativeMethod gSurfaceMethods[] = {
void nativeClassInit(JNIEnv* env, jclass clazz)
{
    so.surface = env->GetFieldID(clazz, ANDROID_VIEW_SURFACE_JNI_ID, "I");
    so.surfaceGenerationId = env->GetFieldID(clazz, "mSurfaceGenerationId", "I");
    so.surfaceControl = env->GetFieldID(clazz, "mSurfaceControl", "I");
    so.saveCount = env->GetFieldID(clazz, "mSaveCount", "I");
    so.canvas    = env->GetFieldID(clazz, "mCanvas", "Landroid/graphics/Canvas;");