Bug 718014 - Restrict dirty rect to subrect of tile texture
authorJames Willcox <jwillcox@mozilla.com>
Wed, 18 Jan 2012 10:41:30 -0500
changeset 86064 c8b028065b13386841418783f7369046f623abfa
parent 86063 96a9dffede078c3baca6e9a68866cb9e355c6a4d
child 86065 cfd3838b4dc2420462e09d8bbf187e43b2a3af0e
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs718014
milestone12.0a1
Bug 718014 - Restrict dirty rect to subrect of tile texture
widget/android/nsWindow.cpp
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -1183,25 +1183,27 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
     if (paintingSuppressed) {
         return;
     }
 
     AndroidGeckoSoftwareLayerClient &client =
         AndroidBridge::Bridge()->GetSoftwareLayerClient();
     client.BeginDrawing(gAndroidBounds.width, gAndroidBounds.height);
 
+    nsIntRect dirtyRect = ae->Rect().Intersect(nsIntRect(0, 0, gAndroidBounds.width, gAndroidBounds.height));
+
     nsAutoString metadata;
     unsigned char *bits = NULL;
     if (sHasDirectTexture) {
       if (sDirectTexture->Width() != gAndroidBounds.width ||
           sDirectTexture->Height() != gAndroidBounds.height) {
         sDirectTexture->Reallocate(gAndroidBounds.width, gAndroidBounds.height);
       }
 
-      sDirectTexture->Lock(AndroidGraphicBuffer::UsageSoftwareWrite, ae->Rect(), &bits);
+      sDirectTexture->Lock(AndroidGraphicBuffer::UsageSoftwareWrite, dirtyRect, &bits);
     } else {
       bits = client.LockBufferBits();
     }
     if (!bits) {
         ALOG("### Failed to lock buffer");
     } else {
         // If tile size is 0,0, we assume we only have a single tile
         int tileWidth = (gAndroidTileSize.width > 0) ? gAndroidTileSize.width : gAndroidBounds.width;
@@ -1224,34 +1226,34 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
                 offset += width * height * 2;
 
                 if (targetSurface->CairoStatus()) {
                     ALOG("### Failed to create a valid surface from the bitmap");
                     drawSuccess = false;
                     break;
                 } else {
                     targetSurface->SetDeviceOffset(gfxPoint(-x, -y));
-                    DrawTo(targetSurface, ae->Rect());
+                    DrawTo(targetSurface, dirtyRect);
                 }
             }
         }
 
         // Don't fill in the draw metadata on an unsuccessful draw
         if (drawSuccess && metadataProvider) {
             metadataProvider->GetDrawMetadata(metadata);
         }
     }
 
     if (sHasDirectTexture) {
         sDirectTexture->Unlock();
     } else {
         client.UnlockBuffer();
     }
 
-    client.EndDrawing(ae->Rect(), metadata);
+    client.EndDrawing(dirtyRect, metadata);
     return;
 #endif
 
     if (!sSurfaceExists) {
         return;
     }
 
     AndroidGeckoSurfaceView& sview(AndroidBridge::Bridge()->SurfaceView());