diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatARTSurfaceViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatARTSurfaceViewManager.java index d1172d82a..f6382b80b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatARTSurfaceViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatARTSurfaceViewManager.java @@ -7,7 +7,6 @@ package com.facebook.react.flat; -import android.view.SurfaceHolder; import com.facebook.react.uimanager.BaseViewManager; import com.facebook.react.uimanager.ThemedReactContext; import com.facebook.react.views.art.ARTSurfaceView; @@ -15,7 +14,6 @@ import com.facebook.yoga.YogaMeasureFunction; import com.facebook.yoga.YogaMeasureMode; import com.facebook.yoga.YogaNode; - public class FlatARTSurfaceViewManager extends BaseViewManager { @@ -57,6 +55,6 @@ public class FlatARTSurfaceViewManager extends @Override public void updateExtraData(ARTSurfaceView root, Object extraData) { - root.getHolder().addCallback((FlatARTSurfaceViewShadowNode) extraData); + root.setSurfaceTextureListener((FlatARTSurfaceViewShadowNode) extraData); } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatARTSurfaceViewShadowNode.java b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatARTSurfaceViewShadowNode.java index aefe34104..09fa6a42a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatARTSurfaceViewShadowNode.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatARTSurfaceViewShadowNode.java @@ -16,7 +16,7 @@ import android.graphics.PorterDuff; import android.graphics.SurfaceTexture; import android.util.Log; import android.view.Surface; -import android.view.SurfaceHolder; +import android.view.TextureView; import com.facebook.react.common.ReactConstants; import com.facebook.react.uimanager.ReactShadowNode; @@ -25,9 +25,8 @@ import com.facebook.react.views.art.ARTVirtualNode; import com.facebook.yoga.YogaValue; import com.facebook.yoga.YogaUnit; - /* package */ class FlatARTSurfaceViewShadowNode extends FlatShadowNode - implements AndroidView, SurfaceHolder.Callback { + implements AndroidView, TextureView.SurfaceTextureListener { private boolean mPaddingChanged = false; private @Nullable Surface mSurface; @@ -124,16 +123,21 @@ import com.facebook.yoga.YogaUnit; } @Override - public void surfaceCreated(SurfaceHolder holder) { - mSurface = holder.getSurface(); + public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) { + mSurface = new Surface(surface); drawOutput(); } @Override - public void surfaceDestroyed(SurfaceHolder holder) { + public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) { + surface.release(); mSurface = null; + return true; } @Override - public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {} + public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {} + + @Override + public void onSurfaceTextureUpdated(SurfaceTexture surface) {} } diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTSurfaceView.java b/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTSurfaceView.java index ac68a9b2e..93f2c21eb 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTSurfaceView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTSurfaceView.java @@ -8,13 +8,14 @@ package com.facebook.react.views.art; import android.content.Context; -import android.view.SurfaceView; +import android.view.TextureView; /** * Custom {@link View} implementation that draws an ARTSurface React view and its children. */ -public class ARTSurfaceView extends SurfaceView { +public class ARTSurfaceView extends TextureView { public ARTSurfaceView(Context context) { super(context); + setOpaque(false); } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTSurfaceViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTSurfaceViewManager.java index d1ee910d0..24787ef84 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTSurfaceViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/art/ARTSurfaceViewManager.java @@ -7,7 +7,6 @@ package com.facebook.react.views.art; -import android.view.SurfaceHolder; import com.facebook.yoga.YogaMeasureMode; import com.facebook.yoga.YogaMeasureFunction; import com.facebook.yoga.YogaNode; @@ -61,7 +60,7 @@ public class ARTSurfaceViewManager extends @Override public void updateExtraData(ARTSurfaceView root, Object extraData) { - root.getHolder().addCallback((ARTSurfaceViewShadowNode) extraData); + root.setSurfaceTextureListener((ARTSurfaceViewShadowNode) extraData); } @Override 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 c0a893481..429812e19 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 @@ -15,10 +15,8 @@ import android.graphics.Color; import android.view.Surface; import android.graphics.PorterDuff; import android.graphics.SurfaceTexture; -import android.view.SurfaceHolder; import android.view.TextureView; - import com.facebook.common.logging.FLog; import com.facebook.react.common.ReactConstants; import com.facebook.react.uimanager.LayoutShadowNode; @@ -31,7 +29,7 @@ import com.facebook.react.uimanager.annotations.ReactProp; * Shadow node for ART virtual tree root - ARTSurfaceView */ public class ARTSurfaceViewShadowNode extends LayoutShadowNode - implements SurfaceHolder.Callback { + implements TextureView.SurfaceTextureListener { private @Nullable Surface mSurface; @@ -99,17 +97,21 @@ public class ARTSurfaceViewShadowNode extends LayoutShadowNode } @Override - public void surfaceCreated(SurfaceHolder holder) { - mSurface = holder.getSurface(); + public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) { + mSurface = new Surface(surface); drawOutput(); } @Override - public void surfaceDestroyed(SurfaceHolder holder) { + public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) { + surface.release(); mSurface = null; + return true; } @Override - public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {} + public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {} + @Override + public void onSurfaceTextureUpdated(SurfaceTexture surface) {} }