Merge "Fix NPE in TextureView" into nyc-mr1-dev
This commit is contained in:
@@ -229,7 +229,6 @@ public class TextureView extends View {
|
|||||||
@Override
|
@Override
|
||||||
protected void destroyHardwareResources() {
|
protected void destroyHardwareResources() {
|
||||||
destroyHardwareLayer();
|
destroyHardwareLayer();
|
||||||
mUpdateSurface = mSurface != null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void destroyHardwareLayer() {
|
private void destroyHardwareLayer() {
|
||||||
@@ -376,17 +375,17 @@ public class TextureView extends View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mLayer = mAttachInfo.mHardwareRenderer.createTextureLayer();
|
mLayer = mAttachInfo.mHardwareRenderer.createTextureLayer();
|
||||||
if (!mUpdateSurface) {
|
boolean createNewSurface = (mSurface == null);
|
||||||
|
if (createNewSurface) {
|
||||||
// Create a new SurfaceTexture for the layer.
|
// Create a new SurfaceTexture for the layer.
|
||||||
mSurface = new SurfaceTexture(false);
|
mSurface = new SurfaceTexture(false);
|
||||||
mLayer.setSurfaceTexture(mSurface);
|
mLayer.setSurfaceTexture(mSurface);
|
||||||
nCreateNativeWindow(mSurface);
|
nCreateNativeWindow(mSurface);
|
||||||
}
|
}
|
||||||
mSurface.setDefaultBufferSize(getWidth(), getHeight());
|
mSurface.setDefaultBufferSize(getWidth(), getHeight());
|
||||||
|
|
||||||
mSurface.setOnFrameAvailableListener(mUpdateListener, mAttachInfo.mHandler);
|
mSurface.setOnFrameAvailableListener(mUpdateListener, mAttachInfo.mHandler);
|
||||||
|
|
||||||
if (mListener != null && !mUpdateSurface) {
|
if (mListener != null && createNewSurface) {
|
||||||
mListener.onSurfaceTextureAvailable(mSurface, getWidth(), getHeight());
|
mListener.onSurfaceTextureAvailable(mSurface, getWidth(), getHeight());
|
||||||
}
|
}
|
||||||
mLayer.setLayerPaint(mLayerPaint);
|
mLayer.setLayerPaint(mLayerPaint);
|
||||||
@@ -745,9 +744,11 @@ public class TextureView extends View {
|
|||||||
"released SurfaceTexture");
|
"released SurfaceTexture");
|
||||||
}
|
}
|
||||||
if (mSurface != null) {
|
if (mSurface != null) {
|
||||||
|
nDestroyNativeWindow();
|
||||||
mSurface.release();
|
mSurface.release();
|
||||||
}
|
}
|
||||||
mSurface = surfaceTexture;
|
mSurface = surfaceTexture;
|
||||||
|
nCreateNativeWindow(mSurface);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the view is visible and we already made a layer, update the
|
* If the view is visible and we already made a layer, update the
|
||||||
|
|||||||
Reference in New Issue
Block a user