Bug 664996 Fix missing redraw when resuming application r=dougt
authorDoug Turner <dougt@dougt.org>
Sat, 25 Jun 2011 21:35:52 -0700
changeset 71777 38f69296b20c922c919d8d932e7c4e82ecc24a18
parent 71776 ba3e6e9e393310d8659aaf5cd2e8436d9fa73464
child 71778 755257708fa3d5a6b9a038d6bf2d5140fee55d5a
push id20608
push userdougt@mozilla.com
push dateSun, 26 Jun 2011 15:00:29 +0000
treeherdermozilla-central@38f69296b20c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdougt
bugs664996
milestone7.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 664996 Fix missing redraw when resuming application r=dougt Because I'd altered the way surface creation works, it was possible to have a null buffer in surfaceChanged while having a valid surface size. Instead of looking at the buffer pointers, I've replaced it with a boolean that tracks whether the surface size is valid or not. In addition, there was a typo that meant that synchronised redraws were being skipped, as the object from mSyncDraws was taken and immediately discarded.
embedding/android/GeckoSurfaceView.java
--- a/embedding/android/GeckoSurfaceView.java
+++ b/embedding/android/GeckoSurfaceView.java
@@ -171,25 +171,30 @@ class GeckoSurfaceView
             drawSplashScreen(holder, width, height);
         mSurfaceLock.lock();
 
         try {
             if (mInDrawing) {
                 Log.w("GeckoAppJava", "surfaceChanged while mInDrawing is true!");
             }
 
+            boolean invalidSize;
+
             if (width == 0 || height == 0) {
                 mSoftwareBitmap = null;
                 mSoftwareBuffer = null;
                 mSoftwareBufferCopy = null;
+                invalidSize = true;
+            } else {
+                invalidSize = false;
             }
 
             boolean doSyncDraw =
                 mDrawMode == DRAW_2D &&
-                (mSoftwareBitmap != null || mSoftwareBuffer != null) &&
+                !invalidSize &&
                 GeckoApp.checkLaunchState(GeckoApp.LaunchState.GeckoRunning);
             mSyncDraw = doSyncDraw;
 
             mFormat = format;
             mWidth = width;
             mHeight = height;
             mSurfaceValid = true;
 
@@ -197,42 +202,43 @@ class GeckoSurfaceView
 
             DisplayMetrics metrics = new DisplayMetrics();
             GeckoApp.mAppContext.getWindowManager().getDefaultDisplay().getMetrics(metrics);
 
             GeckoEvent e = new GeckoEvent(GeckoEvent.SIZE_CHANGED, width, height,
                                           metrics.widthPixels, metrics.heightPixels);
             GeckoAppShell.sendEventToGecko(e);
 
-            if (mSoftwareBitmap != null || mSoftwareBuffer != null)
-                GeckoAppShell.scheduleRedraw();
-
             if (!doSyncDraw) {
                 if (mDrawMode == DRAW_GLES_2 || mShowingSplashScreen)
                     return;
                 Canvas c = holder.lockCanvas();
                 c.drawARGB(255, 255, 255, 255);
                 holder.unlockCanvasAndPost(c);
                 return;
+            } else {
+                GeckoAppShell.scheduleRedraw();
             }
         } finally {
             mSurfaceLock.unlock();
         }
 
         Object syncDrawObject = null;
         try {
-            Object syncObject = mSyncDraws.take();
+            syncDrawObject = mSyncDraws.take();
         } catch (InterruptedException ie) {
             Log.e("GeckoAppJava", "Threw exception while getting sync draw bitmap/buffer: ", ie);
         }
         if (syncDrawObject != null) {
             if (syncDrawObject instanceof Bitmap)
                 draw(holder, (Bitmap)syncDrawObject);
             else
                 draw(holder, (ByteBuffer)syncDrawObject);
+        } else {
+            Log.e("GeckoSurfaceViewJava", "Synchronised draw object is null");
         }
     }
 
     public void surfaceCreated(SurfaceHolder holder) {
         Log.i("GeckoAppJava", "surface created");
         GeckoEvent e = new GeckoEvent(GeckoEvent.SURFACE_CREATED);
         GeckoAppShell.sendEventToGecko(e);
         if (mShowingSplashScreen)