Skip to content

Commit

Permalink
Revert D8194925: Fix ART surface sleep issue
Browse files Browse the repository at this point in the history
Differential Revision:
D8194925

Original commit changeset: 5448d49d9590

fbshipit-source-id: c01e11d44424e1f6fb79866bb845ed60764c5f13
  • Loading branch information
himabindugadupudi authored and facebook-github-bot committed May 31, 2018
1 parent 536c937 commit fecfa2a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@

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;
import com.facebook.yoga.YogaMeasureFunction;
import com.facebook.yoga.YogaMeasureMode;
import com.facebook.yoga.YogaNode;


public class FlatARTSurfaceViewManager extends
BaseViewManager<ARTSurfaceView, FlatARTSurfaceViewShadowNode> {

Expand Down Expand Up @@ -57,6 +55,6 @@ protected ARTSurfaceView createViewInstance(ThemedReactContext reactContext) {

@Override
public void updateExtraData(ARTSurfaceView root, Object extraData) {
root.getHolder().addCallback((FlatARTSurfaceViewShadowNode) extraData);
root.setSurfaceTextureListener((FlatARTSurfaceViewShadowNode) extraData);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
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;
Expand All @@ -25,9 +25,8 @@
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;

Expand Down Expand Up @@ -124,16 +123,21 @@ public void setPaddingPercent(int spacingType, float percent) {
}

@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) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -61,7 +60,7 @@ protected ARTSurfaceView createViewInstance(ThemedReactContext reactContext) {

@Override
public void updateExtraData(ARTSurfaceView root, Object extraData) {
root.getHolder().addCallback((ARTSurfaceViewShadowNode) extraData);
root.setSurfaceTextureListener((ARTSurfaceViewShadowNode) extraData);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
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;
Expand All @@ -31,7 +29,7 @@
* Shadow node for ART virtual tree root - ARTSurfaceView
*/
public class ARTSurfaceViewShadowNode extends LayoutShadowNode
implements SurfaceHolder.Callback {
implements TextureView.SurfaceTextureListener {

private @Nullable Surface mSurface;

Expand Down Expand Up @@ -99,17 +97,21 @@ private void markChildrenUpdatesSeen(ReactShadowNode shadowNode) {
}

@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) {}
}

0 comments on commit fecfa2a

Please sign in to comment.