Bug 767980 - Create SurfaceView/TextureView after view tree is created (r=kats)
authorLucas Rocha <lucasr@mozilla.com>
Fri, 12 Oct 2012 12:57:07 +0100
changeset 110063 2e416d28e933ab2b7991046d6d7f20025a0fca44
parent 110062 d2dabf55ea419d9c48d10920654d1cdad9e36728
child 110064 913e25c339f80428031686c4d33000182c8e6104
push id16340
push userlrocha@mozilla.com
push dateFri, 12 Oct 2012 11:57:35 +0000
treeherdermozilla-inbound@9990a1074771 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs767980
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 767980 - Create SurfaceView/TextureView after view tree is created (r=kats)
mobile/android/base/GeckoApp.java
mobile/android/base/gfx/LayerView.java
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -1666,17 +1666,17 @@ abstract public class GeckoApp
 
         if (cameraView == null) {
             cameraView = new SurfaceView(this);
             cameraView.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
         }
 
         if (mLayerView == null) {
             LayerView layerView = (LayerView) findViewById(R.id.layer_view);
-            layerView.createLayerClient(GeckoAppShell.getEventDispatcher());
+            layerView.initializeView(GeckoAppShell.getEventDispatcher());
             mLayerView = layerView;
         }
 
         mPluginContainer = (AbsoluteLayout) findViewById(R.id.plugin_container);
         mFormAssistPopup = (FormAssistPopup) findViewById(R.id.form_assist_popup);
 
         Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - UI almost up");
 
--- a/mobile/android/base/gfx/LayerView.java
+++ b/mobile/android/base/gfx/LayerView.java
@@ -78,38 +78,42 @@ public class LayerView extends FrameLayo
             Log.i(LOGTAG, "Not using TextureView: caught exception checking for hw accel: " + e.toString());
             return false;
         }
     }
 
     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);
 
             SurfaceHolder holder = mSurfaceView.getHolder();
             holder.addCallback(new SurfaceListener());
             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);
         mRenderer = new LayerRenderer(this);
         mInputConnectionHandler = null;
 
         setFocusable(true);
         setFocusableInTouchMode(true);