Bug 767980 - Create SurfaceView/TextureView after view tree is created (r=kats)
This commit is contained in:
@@ -1671,7 +1671,7 @@ abstract public class GeckoApp
|
|||||||
|
|
||||||
if (mLayerView == null) {
|
if (mLayerView == null) {
|
||||||
LayerView layerView = (LayerView) findViewById(R.id.layer_view);
|
LayerView layerView = (LayerView) findViewById(R.id.layer_view);
|
||||||
layerView.createLayerClient(GeckoAppShell.getEventDispatcher());
|
layerView.initializeView(GeckoAppShell.getEventDispatcher());
|
||||||
mLayerView = layerView;
|
mLayerView = layerView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -83,13 +83,24 @@ public class LayerView extends FrameLayout {
|
|||||||
public LayerView(Context context, AttributeSet attrs) {
|
public LayerView(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
|
|
||||||
|
mGLController = new GLController(this);
|
||||||
|
mPaintState = PAINT_BEFORE_FIRST;
|
||||||
|
mCheckerboardColor = Color.WHITE;
|
||||||
|
mCheckerboardShouldShowChecks = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initializeView(EventDispatcher eventDispatcher) {
|
||||||
|
// This check should not be done while the view tree is still being
|
||||||
|
// created as hardware acceleration will not be enabled at this point.
|
||||||
|
// initializeView() is called on the initialization phase of GeckoApp,
|
||||||
|
// which is late enough to detect hardware acceleration properly.
|
||||||
if (shouldUseTextureView()) {
|
if (shouldUseTextureView()) {
|
||||||
mTextureView = new TextureView(context);
|
mTextureView = new TextureView(getContext());
|
||||||
mTextureView.setSurfaceTextureListener(new SurfaceTextureListener());
|
mTextureView.setSurfaceTextureListener(new SurfaceTextureListener());
|
||||||
mTextureView.setBackgroundColor(Color.WHITE);
|
mTextureView.setBackgroundColor(Color.WHITE);
|
||||||
addView(mTextureView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
addView(mTextureView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||||
} else {
|
} else {
|
||||||
mSurfaceView = new SurfaceView(context);
|
mSurfaceView = new SurfaceView(getContext());
|
||||||
mSurfaceView.setBackgroundColor(Color.WHITE);
|
mSurfaceView.setBackgroundColor(Color.WHITE);
|
||||||
addView(mSurfaceView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
addView(mSurfaceView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||||
|
|
||||||
@@ -98,13 +109,6 @@ public class LayerView extends FrameLayout {
|
|||||||
holder.setFormat(PixelFormat.RGB_565);
|
holder.setFormat(PixelFormat.RGB_565);
|
||||||
}
|
}
|
||||||
|
|
||||||
mGLController = new GLController(this);
|
|
||||||
mPaintState = PAINT_BEFORE_FIRST;
|
|
||||||
mCheckerboardColor = Color.WHITE;
|
|
||||||
mCheckerboardShouldShowChecks = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void createLayerClient(EventDispatcher eventDispatcher) {
|
|
||||||
mLayerClient = new GeckoLayerClient(getContext(), this, eventDispatcher);
|
mLayerClient = new GeckoLayerClient(getContext(), this, eventDispatcher);
|
||||||
|
|
||||||
mTouchEventHandler = new TouchEventHandler(getContext(), this, mLayerClient);
|
mTouchEventHandler = new TouchEventHandler(getContext(), this, mLayerClient);
|
||||||
|
|||||||
Reference in New Issue
Block a user