Loading core/java/android/view/HardwareRenderer.java +14 −0 Original line number Diff line number Diff line Loading @@ -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. Loading Loading @@ -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() { Loading core/java/android/view/Surface.java +9 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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(); Loading core/java/android/view/ViewRoot.java +5 −0 Original line number Diff line number Diff line Loading @@ -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) { Loading Loading @@ -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) { } Loading core/jni/android_view_Surface.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -61,6 +61,7 @@ static sso_t sso; struct so_t { jfieldID surfaceControl; jfieldID surfaceGenerationId; jfieldID surface; jfieldID saveCount; jfieldID canvas; Loading Loading @@ -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); } } // ---------------------------------------------------------------------------- Loading Loading @@ -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;"); Loading Loading
core/java/android/view/HardwareRenderer.java +14 −0 Original line number Diff line number Diff line Loading @@ -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. Loading Loading @@ -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() { Loading
core/java/android/view/Surface.java +9 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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(); Loading
core/java/android/view/ViewRoot.java +5 −0 Original line number Diff line number Diff line Loading @@ -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) { Loading Loading @@ -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) { } Loading
core/jni/android_view_Surface.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -61,6 +61,7 @@ static sso_t sso; struct so_t { jfieldID surfaceControl; jfieldID surfaceGenerationId; jfieldID surface; jfieldID saveCount; jfieldID canvas; Loading Loading @@ -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); } } // ---------------------------------------------------------------------------- Loading Loading @@ -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;"); Loading