b=792305 delay shape mask update from resize to expose r=roc
authorKarl Tomlinson <karlt+@karlt.net>
Mon, 24 Sep 2012 11:15:48 +1200
changeset 107879 f92968ac30fae4c58a6147e4a95c5f492c44f723
parent 107878 9fb29b2cc63181dde1f2cf218b0b23972b1ddae5
child 107880 5a9ee59a8c3b888916b389c358bc4ad594234e5a
push id15256
push userktomlinson@mozilla.com
push dateMon, 24 Sep 2012 03:08:43 +0000
treeherdermozilla-inbound@5a9ee59a8c3b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs792305
milestone18.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
b=792305 delay shape mask update from resize to expose r=roc
widget/gtk2/nsWindow.cpp
widget/gtk2/nsWindow.h
--- a/widget/gtk2/nsWindow.cpp
+++ b/widget/gtk2/nsWindow.cpp
@@ -2362,28 +2362,22 @@ nsWindow::OnSizeAllocate(GtkWidget *aWid
 {
     LOG(("size_allocate [%p] %d %d %d %d\n",
          (void *)this, aAllocation->x, aAllocation->y,
          aAllocation->width, aAllocation->height));
 
     nsIntRect rect(aAllocation->x, aAllocation->y,
                    aAllocation->width, aAllocation->height);
 
-    ResizeTransparencyBitmap(rect.width, rect.height);
-
     mBounds.width = rect.width;
     mBounds.height = rect.height;
 
     if (!mGdkWindow)
         return;
 
-    if (mTransparencyBitmap) {
-      ApplyTransparencyBitmap();
-    }
-
     if (mWidgetListener)
         mWidgetListener->WindowResized(this, rect.width, rect.height);
 }
 
 void
 nsWindow::OnDeleteEvent(GtkWidget *aWidget, GdkEventAny *aEvent)
 {
     if (mWidgetListener)
@@ -3804,18 +3798,16 @@ nsWindow::SetWindowClass(const nsAString
 }
 
 void
 nsWindow::NativeResize(int32_t aWidth, int32_t aHeight, bool    aRepaint)
 {
     LOG(("nsWindow::NativeResize [%p] %d %d\n", (void *)this,
          aWidth, aHeight));
 
-    ResizeTransparencyBitmap(aWidth, aHeight);
-
     // clear our resize flag
     mNeedsResize = false;
 
     if (mIsTopLevel) {
         gtk_window_resize(GTK_WINDOW(mShell), aWidth, aHeight);
     }
     else if (mContainer) {
         GtkWidget *widget = GTK_WIDGET(mContainer);
@@ -3838,18 +3830,16 @@ nsWindow::NativeResize(int32_t aX, int32
                        bool    aRepaint)
 {
     mNeedsResize = false;
     mNeedsMove = false;
 
     LOG(("nsWindow::NativeResize [%p] %d %d %d %d\n", (void *)this,
          aX, aY, aWidth, aHeight));
 
-    ResizeTransparencyBitmap(aWidth, aHeight);
-
     if (mIsTopLevel) {
         // aX and aY give the position of the window manager frame top-left.
         gtk_window_move(GTK_WINDOW(mShell), aX, aY);
         // This sets the client window size.
         gtk_window_resize(GTK_WINDOW(mShell), aWidth, aHeight);
     }
     else if (mContainer) {
         GtkAllocation allocation;
@@ -4192,57 +4182,50 @@ nsWindow::SetWindowClipRegion(const nsTA
     gdk_window_shape_combine_region(mGdkWindow, region, 0, 0);
     cairo_region_destroy(region);
 #endif
   
     return;
 }
 
 void
-nsWindow::ResizeTransparencyBitmap(int32_t aNewWidth, int32_t aNewHeight)
+nsWindow::ResizeTransparencyBitmap()
 {
     if (!mTransparencyBitmap)
         return;
 
-    if (aNewWidth == mTransparencyBitmapWidth &&
-        aNewHeight == mTransparencyBitmapHeight)
+    if (mBounds.width == mTransparencyBitmapWidth &&
+        mBounds.height == mTransparencyBitmapHeight)
         return;
 
-    int32_t newSize = GetBitmapStride(aNewWidth)*aNewHeight;
+    int32_t newRowBytes = GetBitmapStride(mBounds.width);
+    int32_t newSize = newRowBytes * mBounds.height;
     gchar* newBits = new gchar[newSize];
-    if (!newBits) {
-        delete[] mTransparencyBitmap;
-        mTransparencyBitmap = nullptr;
-        mTransparencyBitmapWidth = 0;
-        mTransparencyBitmapHeight = 0;
-        return;
-    }
-    // fill new mask with "opaque", first
-    memset(newBits, 255, newSize);
+    // fill new mask with "transparent", first
+    memset(newBits, 0, newSize);
 
     // Now copy the intersection of the old and new areas into the new mask
-    int32_t copyWidth = NS_MIN(aNewWidth, mTransparencyBitmapWidth);
-    int32_t copyHeight = NS_MIN(aNewHeight, mTransparencyBitmapHeight);
+    int32_t copyWidth = NS_MIN(mBounds.width, mTransparencyBitmapWidth);
+    int32_t copyHeight = NS_MIN(mBounds.height, mTransparencyBitmapHeight);
     int32_t oldRowBytes = GetBitmapStride(mTransparencyBitmapWidth);
-    int32_t newRowBytes = GetBitmapStride(aNewWidth);
     int32_t copyBytes = GetBitmapStride(copyWidth);
 
     int32_t i;
     gchar* fromPtr = mTransparencyBitmap;
     gchar* toPtr = newBits;
     for (i = 0; i < copyHeight; i++) {
         memcpy(toPtr, fromPtr, copyBytes);
         fromPtr += oldRowBytes;
         toPtr += newRowBytes;
     }
 
     delete[] mTransparencyBitmap;
     mTransparencyBitmap = newBits;
-    mTransparencyBitmapWidth = aNewWidth;
-    mTransparencyBitmapHeight = aNewHeight;
+    mTransparencyBitmapWidth = mBounds.width;
+    mTransparencyBitmapHeight = mBounds.height;
 }
 
 static bool
 ChangedMaskBits(gchar* aMaskBits, int32_t aMaskWidth, int32_t aMaskHeight,
         const nsIntRect& aRect, uint8_t* aAlphas, int32_t aStride)
 {
     int32_t x, y, xMax = aRect.XMost(), yMax = aRect.YMost();
     int32_t maskBytesPerRow = GetBitmapStride(aMaskWidth);
@@ -4354,21 +4337,21 @@ nsWindow::UpdateTranslucentWindowAlphaIn
         return topWindow->UpdateTranslucentWindowAlphaInternal(aRect, aAlphas, aStride);
     }
 
     NS_ASSERTION(mIsTransparent, "Window is not transparent");
 
     if (mTransparencyBitmap == nullptr) {
         int32_t size = GetBitmapStride(mBounds.width)*mBounds.height;
         mTransparencyBitmap = new gchar[size];
-        if (mTransparencyBitmap == nullptr)
-            return NS_ERROR_FAILURE;
         memset(mTransparencyBitmap, 255, size);
         mTransparencyBitmapWidth = mBounds.width;
         mTransparencyBitmapHeight = mBounds.height;
+    } else {
+        ResizeTransparencyBitmap();
     }
 
     NS_ASSERTION(aRect.x >= 0 && aRect.y >= 0
             && aRect.XMost() <= mBounds.width && aRect.YMost() <= mBounds.height,
             "Rect is out of window bounds");
 
     if (!ChangedMaskBits(mTransparencyBitmap, mBounds.width, mBounds.height,
                          aRect, aAlphas, aStride))
--- a/widget/gtk2/nsWindow.h
+++ b/widget/gtk2/nsWindow.h
@@ -276,17 +276,17 @@ public:
     NS_IMETHOD ResetInputState();
     NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
                                       const InputContextAction& aAction);
     NS_IMETHOD_(InputContext) GetInputContext();
     NS_IMETHOD CancelIMEComposition();
     NS_IMETHOD OnIMEFocusChange(bool aFocus);
     NS_IMETHOD GetToggledKeyState(uint32_t aKeyCode, bool* aLEDState);
 
-   void                ResizeTransparencyBitmap(int32_t aNewWidth, int32_t aNewHeight);
+   void                ResizeTransparencyBitmap();
    void                ApplyTransparencyBitmap();
    virtual void        SetTransparencyMode(nsTransparencyMode aMode);
    virtual nsTransparencyMode GetTransparencyMode();
    virtual nsresult    ConfigureChildren(const nsTArray<Configuration>& aConfigurations);
    nsresult            UpdateTranslucentWindowAlphaInternal(const nsIntRect& aRect,
                                                             uint8_t* aAlphas, int32_t aStride);
 
 #if defined(MOZ_WIDGET_GTK2)