@@ -224,6 +224,8 @@ public void run() {
224224 private void destroySurface () {
225225 if (mLayer != null ) {
226226 mSurface .detachFromGLContext ();
227+ // SurfaceTexture owns the texture name and detachFromGLContext
228+ // should have deleted it
227229 mLayer .clearStorage ();
228230
229231 boolean shouldRelease = true ;
@@ -291,6 +293,9 @@ public void buildLayer() {
291293 */
292294 @ Override
293295 public final void draw (Canvas canvas ) {
296+ // NOTE: Maintain this carefully (see View.java)
297+ mPrivateFlags = (mPrivateFlags & ~PFLAG_DIRTY_MASK ) | PFLAG_DRAWN ;
298+
294299 applyUpdate ();
295300 applyTransformMatrix ();
296301 }
@@ -335,6 +340,10 @@ protected void destroyHardwareResources() {
335340
336341 @ Override
337342 HardwareLayer getHardwareLayer () {
343+ // NOTE: Maintain these two lines very carefully (see View.java)
344+ mPrivateFlags |= PFLAG_DRAWN | PFLAG_DRAWING_CACHE_VALID ;
345+ mPrivateFlags &= ~PFLAG_DIRTY_MASK ;
346+
338347 if (mLayer == null ) {
339348 if (mAttachInfo == null || mAttachInfo .mHardwareRenderer == null ) {
340349 return null ;
@@ -773,6 +782,7 @@ public static interface SurfaceTextureListener {
773782 * Invoked when the specified {@link SurfaceTexture} is about to be destroyed.
774783 * If returns true, no rendering should happen inside the surface texture after this method
775784 * is invoked. If returns false, the client needs to call {@link SurfaceTexture#release()}.
785+ * Most applications should return true.
776786 *
777787 * @param surface The surface about to be destroyed
778788 */
0 commit comments