Backed out changeset a5c71a784e33 (bug 950647) for Linux Build Bustage on a CLOSED TREE
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Thu, 23 Jan 2014 13:34:56 +0100
changeset 181844 d56e36c1837e15719ba9ae1374ce65ac4fe02e0b
parent 181843 73d1c5429eaa504f1b03a83d362b3a3552f06291
child 181845 5297eafc36e23c002ef64504d7ceb69c10f737e9
push id462
push userraliiev@mozilla.com
push dateTue, 22 Apr 2014 00:22:30 +0000
treeherdermozilla-release@ac5db8c74ac0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs950647
milestone29.0a1
backs outa5c71a784e331bd210f9b029fcee207189d31cb8
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
Backed out changeset a5c71a784e33 (bug 950647) for Linux Build Bustage on a CLOSED TREE
widget/gtk/nsImageToPixbuf.cpp
widget/gtk/nsImageToPixbuf.h
--- a/widget/gtk/nsImageToPixbuf.cpp
+++ b/widget/gtk/nsImageToPixbuf.cpp
@@ -3,28 +3,23 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
 #include "gfxASurface.h"
 #include "gfxImageSurface.h"
 #include "gfxContext.h"
-#include "gfxPlatform.h"
-#include "mozilla/gfx/2D.h"
 
 #include "imgIContainer.h"
 
 #include "nsAutoPtr.h"
 
 #include "nsImageToPixbuf.h"
 
-using mozilla::gfx::DataSourceSurface;
-using mozilla::gfx::SurfaceFormat;
-
 NS_IMPL_ISUPPORTS1(nsImageToPixbuf, nsIImageToPixbuf)
 
 inline unsigned char
 unpremultiply (unsigned char color,
                unsigned char alpha)
 {
     if (alpha == 0)
         return 0;
@@ -36,99 +31,84 @@ NS_IMETHODIMP_(GdkPixbuf*)
 nsImageToPixbuf::ConvertImageToPixbuf(imgIContainer* aImage)
 {
     return ImageToPixbuf(aImage);
 }
 
 GdkPixbuf*
 nsImageToPixbuf::ImageToPixbuf(imgIContainer* aImage)
 {
-    nsRefPtr<gfxASurface> thebesSurface =
+    nsRefPtr<gfxASurface> surface =
       aImage->GetFrame(imgIContainer::FRAME_CURRENT,
                        imgIContainer::FLAG_SYNC_DECODE);
 
     // If the last call failed, it was probably because our call stack originates
     // in an imgINotificationObserver event, meaning that we're not allowed request
     // a sync decode. Presumably the originating event is something sensible like
     // OnStopFrame(), so we can just retry the call without a sync decode.
-    if (!thebesSurface)
-      thebesSurface = aImage->GetFrame(imgIContainer::FRAME_CURRENT,
-                                       imgIContainer::FLAG_NONE);
+    if (!surface)
+        surface = aImage->GetFrame(imgIContainer::FRAME_CURRENT,
+                                   imgIContainer::FLAG_NONE);
 
-    NS_ENSURE_TRUE(thebesSurface, nullptr);
-
-    RefPtr<SourceSurface> surface =
-      gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(nullptr,
-                                                             thebesSurface);
     NS_ENSURE_TRUE(surface, nullptr);
 
-    return SourceSurfaceToPixbuf(surface,
-                                 surface->GetSize().width,
-                                 surface->GetSize().height);
+    nsRefPtr<gfxImageSurface> frame(surface->GetAsReadableARGB32ImageSurface());
+    NS_ENSURE_TRUE(frame, nullptr);
+
+    return ImgSurfaceToPixbuf(frame, frame->Width(), frame->Height());
 }
 
 GdkPixbuf*
-nsImageToPixbuf::SourceSurfaceToPixbuf(SourceSurface* aSurface,
-                                       int32_t aWidth,
-                                       int32_t aHeight)
+nsImageToPixbuf::ImgSurfaceToPixbuf(gfxImageSurface* aImgSurface, int32_t aWidth, int32_t aHeight)
 {
-    MOZ_ASSERT(aWidth <= aSurface->GetSize().width &&
-               aHeight <= aSurface->GetSize().height,
-               "Requested rect is bigger than the supplied surface");
-
     GdkPixbuf* pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8,
                                        aWidth, aHeight);
     if (!pixbuf)
         return nullptr;
 
-    uint32_t destStride = gdk_pixbuf_get_rowstride (pixbuf);
-    guchar* destPixels = gdk_pixbuf_get_pixels (pixbuf);
+    uint32_t rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+    guchar* pixels = gdk_pixbuf_get_pixels (pixbuf);
 
-    RefPtr<DataSourceSurface> dataSurface = aSurface->GetDataSurface();
-    DataSourceSurface::MappedSurface map;
-    dataSurface->Map(DataSourceSurface::MapType::READ, &map);
-    uint8_t* srcData = map.mData;
-    int32_t srcStride = map.mStride;
+    long cairoStride = aImgSurface->Stride();
+    unsigned char* cairoData = aImgSurface->Data();
 
-    SurfaceFormat format = dataSurface->GetFormat();
+    gfxImageFormat format = aImgSurface->Format();
 
     for (int32_t row = 0; row < aHeight; ++row) {
         for (int32_t col = 0; col < aWidth; ++col) {
-            guchar* destPixel = destPixels + row * destStride + 4 * col;
+            guchar* pixel = pixels + row * rowstride + 4 * col;
 
-            uint32_t* srcPixel =
-                reinterpret_cast<uint32_t*>((srcData + row * srcStride + 4 * col));
+            uint32_t* cairoPixel = reinterpret_cast<uint32_t*>
+                                                   ((cairoData + row * cairoStride + 4 * col));
 
-            if (format == SurfaceFormat::B8G8R8A8) {
-                const uint8_t a = (*srcPixel >> 24) & 0xFF;
-                const uint8_t r = unpremultiply((*srcPixel >> 16) & 0xFF, a);
-                const uint8_t g = unpremultiply((*srcPixel >>  8) & 0xFF, a);
-                const uint8_t b = unpremultiply((*srcPixel >>  0) & 0xFF, a);
+            if (format == gfxImageFormatARGB32) {
+                const uint8_t a = (*cairoPixel >> 24) & 0xFF;
+                const uint8_t r = unpremultiply((*cairoPixel >> 16) & 0xFF, a);
+                const uint8_t g = unpremultiply((*cairoPixel >>  8) & 0xFF, a);
+                const uint8_t b = unpremultiply((*cairoPixel >>  0) & 0xFF, a);
 
-                *destPixel++ = r;
-                *destPixel++ = g;
-                *destPixel++ = b;
-                *destPixel++ = a;
+                *pixel++ = r;
+                *pixel++ = g;
+                *pixel++ = b;
+                *pixel++ = a;
             } else {
-                MOZ_ASSERT(format == SurfaceFormat::B8G8R8X8);
+                NS_ASSERTION(format == gfxImageFormatRGB24,
+                             "unexpected format");
+                const uint8_t r = (*cairoPixel >> 16) & 0xFF;
+                const uint8_t g = (*cairoPixel >>  8) & 0xFF;
+                const uint8_t b = (*cairoPixel >>  0) & 0xFF;
 
-                const uint8_t r = (*srcPixel >> 16) & 0xFF;
-                const uint8_t g = (*srcPixel >>  8) & 0xFF;
-                const uint8_t b = (*srcPixel >>  0) & 0xFF;
-
-                *destPixel++ = r;
-                *destPixel++ = g;
-                *destPixel++ = b;
-                *destPixel++ = 0xFF; // A
+                *pixel++ = r;
+                *pixel++ = g;
+                *pixel++ = b;
+                *pixel++ = 0xFF; // A
             }
         }
     }
 
-    dataSurface->Unmap();
-
     return pixbuf;
 }
 
 GdkPixbuf*
 nsImageToPixbuf::SurfaceToPixbuf(gfxASurface* aSurface, int32_t aWidth, int32_t aHeight)
 {
     if (aSurface->CairoStatus()) {
         NS_ERROR("invalid surface");
@@ -150,14 +130,10 @@ nsImageToPixbuf::SurfaceToPixbuf(gfxASur
         if (!context)
             return nullptr;
 
         context->SetOperator(gfxContext::OPERATOR_SOURCE);
         context->SetSource(aSurface);
         context->Paint();
     }
 
-    RefPtr<SourceSurface> surface =
-        gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(nullptr,
-                                                               imgSurface);
-
-    return SourceSurfaceToPixbuf(surface, aWidth, aHeight);
+    return ImgSurfaceToPixbuf(imgSurface, aWidth, aHeight);
 }
--- a/widget/gtk/nsImageToPixbuf.h
+++ b/widget/gtk/nsImageToPixbuf.h
@@ -8,43 +8,33 @@
 
 #include "nsIImageToPixbuf.h"
 #include "mozilla/Attributes.h"
 
 class gfxASurface;
 class gfxPattern;
 class gfxImageSurface;
 
-namespace mozilla {
-namespace gfx {
-class SourceSurface;
-}
-}
-
 class nsImageToPixbuf MOZ_FINAL : public nsIImageToPixbuf {
-    typedef mozilla::gfx::SourceSurface SourceSurface;
-
     public:
         NS_DECL_ISUPPORTS
         NS_IMETHOD_(GdkPixbuf*) ConvertImageToPixbuf(imgIContainer* aImage);
 
         // Friendlier version of ConvertImageToPixbuf for callers inside of
         // widget
         /**
          * The return value of all these, if not null, should be
          * released as needed by the caller using g_object_unref.
          */
         static GdkPixbuf* ImageToPixbuf(imgIContainer * aImage);
         static GdkPixbuf* SurfaceToPixbuf(gfxASurface* aSurface,
                                           int32_t aWidth, int32_t aHeight);
-        static GdkPixbuf* SourceSurfaceToPixbuf(SourceSurface* aSurface,
-                                                int32_t aWidth,
-                                                int32_t aHeight);
-
     private:
+        static GdkPixbuf* ImgSurfaceToPixbuf(gfxImageSurface* aImgSurface,
+                                             int32_t aWidth, int32_t aHeight);
         ~nsImageToPixbuf() {}
 };
 
 
 // fc2389b8-c650-4093-9e42-b05e5f0685b7
 #define NS_IMAGE_TO_PIXBUF_CID \
 { 0xfc2389b8, 0xc650, 0x4093, \
   { 0x9e, 0x42, 0xb0, 0x5e, 0x5f, 0x06, 0x85, 0xb7 } }