Bug 612392 - Avoid 2D draws when doing 3D, r=vlad a=blocking-fennec
authorMichael Wu <mwu@mozilla.com>
Thu, 02 Dec 2010 17:23:41 -0800
changeset 58525 318d60678767e973b872f2cb0aa518ca456993f6
parent 58524 d748232921a59df4a5fb7d8f4ddb209360d41c82
child 58526 a7692d5dd29b6ebdc4d68caa2a768072ede4c306
push id17335
push usermwu@mozilla.com
push dateFri, 03 Dec 2010 01:30:35 +0000
treeherdermozilla-central@15cdaa1d538b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvlad, blocking-fennec
bugs612392
milestone2.0b8pre
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 612392 - Avoid 2D draws when doing 3D, r=vlad a=blocking-fennec
embedding/android/GeckoSurfaceView.java
--- a/embedding/android/GeckoSurfaceView.java
+++ b/embedding/android/GeckoSurfaceView.java
@@ -108,17 +108,18 @@ class GeckoSurfaceView
             }
 
             if (width == 0 || height == 0)
                 mSoftwareBuffer = null;
             else if (mSoftwareBuffer == null ||
                      mSoftwareBuffer.capacity() < (width * height * 2) ||
                      mWidth != width || mHeight != height)
                 mSoftwareBuffer = ByteBuffer.allocateDirect(width * height * 2);
-            boolean doSyncDraw = m2DMode && mSoftwareBuffer != null &&
+            boolean doSyncDraw = mDrawMode == DRAW_2D &&
+                mSoftwareBuffer != null &&
                 GeckoApp.checkLaunchState(GeckoApp.LaunchState.GeckoRunning);
             mSyncDraw = doSyncDraw;
 
             mFormat = format;
             mWidth = width;
             mHeight = height;
             mSurfaceValid = true;
 
@@ -126,16 +127,18 @@ class GeckoSurfaceView
 
             GeckoEvent e = new GeckoEvent(GeckoEvent.SIZE_CHANGED, width, height, -1, -1);
             GeckoAppShell.sendEventToGecko(e);
 
             if (mSoftwareBuffer != null)
                 GeckoAppShell.scheduleRedraw();
 
             if (!doSyncDraw) {
+                if (mDrawMode == DRAW_GLES_2)
+                    return;
                 Canvas c = holder.lockCanvas();
                 c.drawARGB(255, 255, 255, 255);
                 holder.unlockCanvasAndPost(c);
                 return;
             }
         } finally {
             mSurfaceLock.unlock();
         }
@@ -160,26 +163,27 @@ class GeckoSurfaceView
 
     public void surfaceDestroyed(SurfaceHolder holder) {
         Log.i("GeckoAppJava", "surface destroyed");
         mSurfaceValid = false;
         mSoftwareBuffer = null;
     }
 
     public ByteBuffer getSoftwareDrawBuffer() {
-        m2DMode = true;
+        mDrawMode = DRAW_2D;
         return mSoftwareBuffer;
     }
 
     /*
      * Called on Gecko thread
      */
 
     public static final int DRAW_ERROR = 0;
     public static final int DRAW_GLES_2 = 1;
+    public static final int DRAW_2D = 2;
 
     public int beginDrawing() {
         if (mInDrawing) {
             Log.e("GeckoAppJava", "Recursive beginDrawing call!");
             return DRAW_ERROR;
         }
 
         /* Grab the lock, which we'll hold while we're drawing.
@@ -197,16 +201,17 @@ class GeckoSurfaceView
 
         if (!mSurfaceValid) {
             Log.e("GeckoAppJava", "Surface not valid");
             mSurfaceLock.unlock();
             return DRAW_ERROR;
         }
 
         mInDrawing = true;
+        mDrawMode = DRAW_GLES_2;
         return DRAW_GLES_2;
     }
 
     public void endDrawing() {
         if (!mInDrawing) {
             Log.e("GeckoAppJava", "endDrawing without beginDrawing!");
             return;
         }
@@ -381,17 +386,17 @@ class GeckoSurfaceView
 
     // Are we actively between beginDrawing/endDrawing?
     boolean mInDrawing;
 
     // Are we waiting for a buffer to draw in surfaceChanged?
     boolean mSyncDraw;
 
     // True if gecko requests a buffer
-    boolean m2DMode;
+    int mDrawMode;
 
     // let's not change stuff around while we're in the middle of
     // starting drawing, ending drawing, or changing surface
     // characteristics
     ReentrantLock mSurfaceLock;
 
     // Surface format, from surfaceChanged.  Largely
     // useless.