Bug 767980 - Create SurfaceView/TextureView after view tree is created (r=kats)

This commit is contained in:
Lucas Rocha
2012-10-12 12:57:07 +01:00
parent ff156598f6
commit d7f00b57e3
2 changed files with 14 additions and 10 deletions

View File

@@ -1671,7 +1671,7 @@ abstract public class GeckoApp
if (mLayerView == null) {
LayerView layerView = (LayerView) findViewById(R.id.layer_view);
layerView.createLayerClient(GeckoAppShell.getEventDispatcher());
layerView.initializeView(GeckoAppShell.getEventDispatcher());
mLayerView = layerView;
}

View File

@@ -83,13 +83,24 @@ public class LayerView extends FrameLayout {
public LayerView(Context context, AttributeSet 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()) {
mTextureView = new TextureView(context);
mTextureView = new TextureView(getContext());
mTextureView.setSurfaceTextureListener(new SurfaceTextureListener());
mTextureView.setBackgroundColor(Color.WHITE);
addView(mTextureView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
} else {
mSurfaceView = new SurfaceView(context);
mSurfaceView = new SurfaceView(getContext());
mSurfaceView.setBackgroundColor(Color.WHITE);
addView(mSurfaceView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
@@ -98,13 +109,6 @@ public class LayerView extends FrameLayout {
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);
mTouchEventHandler = new TouchEventHandler(getContext(), this, mLayerClient);