Bug 709492 - Part 3: Implement expose events. r=kats
authorPatrick Walton <pwalton@mozilla.com>
Thu, 29 Dec 2011 15:10:28 -0800
changeset 83551 37961e70dc8f730bea98750eed3038c3f15054b7
parent 83550 22e0c14b7fc85ff2d91c754cacebe195d667b705
child 83552 995f29e5de472782424937f1f87d52bd6bfe9e5d
push id412
push usertim.taubert@gmx.de
push dateSun, 01 Jan 2012 15:52:25 +0000
treeherderfx-team@d702c3cf4e4a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs709492
milestone12.0a1
Bug 709492 - Part 3: Implement expose events. r=kats
mobile/android/base/GeckoEvent.java
widget/src/android/AndroidJavaWrappers.h
widget/src/android/nsWindow.cpp
--- a/mobile/android/base/GeckoEvent.java
+++ b/mobile/android/base/GeckoEvent.java
@@ -73,16 +73,17 @@ public class GeckoEvent {
     public static final int ACTIVITY_SHUTDOWN = 11;
     public static final int LOAD_URI = 12;
     public static final int SURFACE_CREATED = 13;
     public static final int SURFACE_DESTROYED = 14;
     public static final int GECKO_EVENT_SYNC = 15;
     public static final int ACTIVITY_START = 17;
     public static final int BROADCAST = 19;
     public static final int VIEWPORT = 20;
+    public static final int EXPOSE = 21;
 
     public static final int IME_COMPOSITION_END = 0;
     public static final int IME_COMPOSITION_BEGIN = 1;
     public static final int IME_SET_TEXT = 2;
     public static final int IME_GET_TEXT = 3;
     public static final int IME_DELETE_TEXT = 4;
     public static final int IME_SET_SELECTION = 5;
     public static final int IME_GET_SELECTION = 6;
--- a/widget/src/android/AndroidJavaWrappers.h
+++ b/widget/src/android/AndroidJavaWrappers.h
@@ -527,16 +527,17 @@ public:
         LOAD_URI = 12,
         SURFACE_CREATED = 13,
         SURFACE_DESTROYED = 14,
         GECKO_EVENT_SYNC = 15,
         FORCED_RESIZE = 16,
         ACTIVITY_START = 17,
         BROADCAST = 19,
         VIEWPORT = 20,
+        EXPOSE = 21,
         dummy_java_enum_list_end
     };
 
     enum {
         IME_COMPOSITION_END = 0,
         IME_COMPOSITION_BEGIN = 1,
         IME_SET_TEXT = 2,
         IME_GET_TEXT = 3,
--- a/widget/src/android/nsWindow.cpp
+++ b/widget/src/android/nsWindow.cpp
@@ -973,16 +973,17 @@ nsWindow::OnGlobalAndroidEvent(AndroidGe
 
         case AndroidGeckoEvent::KEY_EVENT:
             win->UserActivity();
             if (win->mFocus)
                 win->mFocus->OnKeyEvent(ae);
             break;
 
         case AndroidGeckoEvent::DRAW:
+        case AndroidGeckoEvent::EXPOSE:
             win->OnDraw(ae);
             break;
 
         case AndroidGeckoEvent::IME_EVENT:
             win->UserActivity();
             if (win->mFocus) {
                 win->mFocus->OnIMEEvent(ae);
             } else {
@@ -1163,35 +1164,42 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
     }
 
     AndroidBridge::AutoLocalJNIFrame jniFrame;
 #ifdef MOZ_JAVA_COMPOSITOR
     // We haven't been given a window-size yet, so do nothing
     if (gAndroidBounds.width <= 0 || gAndroidBounds.height <= 0)
         return;
 
-    /*
-     * Check to see whether browser.js wants us to draw. This will be false during page
-     * transitions, in which case we immediately bail out.
-     */
     nsCOMPtr<nsIAndroidDrawMetadataProvider> metadataProvider =
         AndroidBridge::Bridge()->GetDrawMetadataProvider();
 
+    /*
+     * If this is a DRAW event (not an EXPOSE event), check to see whether browser.js wants us to
+     * draw. This will be false during page transitions, in which case we immediately bail out.
+     */
+
     bool shouldDraw = true;
-    if (metadataProvider) {
+    if (metadataProvider && ae->Type() == AndroidGeckoEvent::DRAW) {
         metadataProvider->DrawingAllowed(&shouldDraw);
     }
     if (!shouldDraw) {
         return;
     }
 
     AndroidGeckoSoftwareLayerClient &client =
         AndroidBridge::Bridge()->GetSoftwareLayerClient();
     client.BeginDrawing(gAndroidBounds.width, gAndroidBounds.height);
 
+    // Redraw the entire tile on an EXPOSE event. Otherwise (on a DRAW event), redraw only the
+    // portion specified by the event.
+    nsIntRect rect(0, 0, gAndroidBounds.width, gAndroidBounds.height);
+    if (ae->Type() == AndroidGeckoEvent::DRAW)
+        rect = ae->Rect();
+
     nsAutoString metadata;
     unsigned char *bits = NULL;
     if (sHasDirectTexture) {
       if ((sDirectTexture->Width() != gAndroidBounds.width ||
            sDirectTexture->Height() != gAndroidBounds.height) &&
           gAndroidBounds.width != 0 && gAndroidBounds.height != 0) {
         sDirectTexture->Reallocate(gAndroidBounds.width, gAndroidBounds.height);
       }
@@ -1214,30 +1222,30 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
                                 gfxASurface::ImageFormatRGB16_565);
         if (targetSurface->CairoStatus()) {
             ALOG("### Failed to create a valid surface from the bitmap");
         } else {
             if (sHasDirectTexture) {
               // XXX: lock only the dirty rect above and pass it in here
               DrawTo(targetSurface);
             } else {
-              DrawTo(targetSurface, ae->Rect());
+              DrawTo(targetSurface, rect);
             }
 
             if (metadataProvider) {
                 metadataProvider->GetDrawMetadata(metadata);
             }
         }
         if (sHasDirectTexture) {
           sDirectTexture->Unlock();
         } else {
           client.UnlockBuffer();
         }
     }
-    client.EndDrawing(ae->Rect(), metadata);
+    client.EndDrawing(rect, metadata);
     return;
 #endif
 
     if (!sSurfaceExists) {
         return;
     }
 
     AndroidGeckoSurfaceView& sview(AndroidBridge::Bridge()->SurfaceView());