From eb01f8fe59d0cc0c8cd455efe35aa13d73ad2923 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Tue, 15 Aug 2017 17:03:07 -0700 Subject: [PATCH] =?UTF-8?q?Revert=20D4449255:=20[react-native][PR]=20Fixed?= =?UTF-8?q?=20ART=20Surface=20initialization:=20do=20not=20cancel=20update?= =?UTF-8?q?s=20to=20the=20surfce,=20make=20them=20pen=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Differential Revision: D4449255 fbshipit-source-id: e210cebfde25c6cd68a1fb7e1dceeefad890cf93 --- .../views/art/ARTSurfaceViewShadowNode.java | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTSurfaceViewShadowNode.java b/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTSurfaceViewShadowNode.java index 7ababfafc..e3c78600b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTSurfaceViewShadowNode.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTSurfaceViewShadowNode.java @@ -34,7 +34,6 @@ public class ARTSurfaceViewShadowNode extends LayoutShadowNode implements TextureView.SurfaceTextureListener { private @Nullable Surface mSurface; - private @Nullable boolean mHasPendingUpdates; private @Nullable Integer mBackgroundColor; @@ -63,7 +62,7 @@ public class ARTSurfaceViewShadowNode extends LayoutShadowNode private void drawOutput() { if (mSurface == null || !mSurface.isValid()) { - mHasPendingUpdates = true; + markChildrenUpdatesSeen(this); return; } @@ -78,6 +77,7 @@ public class ARTSurfaceViewShadowNode extends LayoutShadowNode for (int i = 0; i < getChildCount(); i++) { ARTVirtualNode child = (ARTVirtualNode) getChildAt(i); child.draw(canvas, paint, 1f); + child.markUpdateSeen(); } if (mSurface == null) { @@ -85,20 +85,23 @@ public class ARTSurfaceViewShadowNode extends LayoutShadowNode } mSurface.unlockCanvasAndPost(canvas); - mHasPendingUpdates = false; } catch (IllegalArgumentException | IllegalStateException e) { - FLog.e(ReactConstants.TAG, e.getClass().getSimpleName() + " in SurfaceView.drawOutput"); - } catch (RuntimeException e) { - FLog.e(ReactConstants.TAG, e.getClass().getSimpleName() + " in SurfaceView.drawOutput"); + FLog.e(ReactConstants.TAG, e.getClass().getSimpleName() + " in Surface.unlockCanvasAndPost"); + } + } + + private void markChildrenUpdatesSeen(ReactShadowNode shadowNode) { + for (int i = 0; i < shadowNode.getChildCount(); i++) { + ReactShadowNode child = shadowNode.getChildAt(i); + child.markUpdateSeen(); + markChildrenUpdatesSeen(child); } } @Override public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) { mSurface = new Surface(surface); - if (mHasPendingUpdates) { - drawOutput(); - } + drawOutput(); } @Override @@ -109,9 +112,7 @@ public class ARTSurfaceViewShadowNode extends LayoutShadowNode } @Override - public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) { - drawOutput(); - } + public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {} @Override public void onSurfaceTextureUpdated(SurfaceTexture surface) {}