Bug 1305234 - Back out changeset f7aeb4b3ccb1 (bug 1279398) for causing top crashes. r=edwin, a=ritu
authorEdwin Flores <eflores@mozilla.com>
Tue, 27 Sep 2016 19:52:17 +0100
changeset 422388 149e6651b5c8d9cfdca8379357784b30e062890d
parent 422387 90a578222d6c254a19c4adc48737cb2d611be197
child 422389 9b8bac3cd9eb1454b92462a41607136732716861
push id31738
push userbmo:giles@thaumas.net
push dateFri, 07 Oct 2016 20:30:41 +0000
reviewersedwin, ritu
bugs1305234, 1279398
milestone50.0
Bug 1305234 - Back out changeset f7aeb4b3ccb1 (bug 1279398) for causing top crashes. r=edwin, a=ritu
gfx/thebes/gfxASurface.cpp
gfx/thebes/gfxASurface.h
--- a/gfx/thebes/gfxASurface.cpp
+++ b/gfx/thebes/gfxASurface.cpp
@@ -166,17 +166,17 @@ gfxASurface::Wrap (cairo_surface_t *csur
     }
 #endif
 #ifdef CAIRO_HAS_QUARTZ_SURFACE
     else if (stype == CAIRO_SURFACE_TYPE_QUARTZ) {
         result = new gfxQuartzSurface(csurf, aSize);
     }
 #endif
     else {
-        MOZ_CRASH("Unknown cairo surface type");
+        result = new gfxUnknownSurface(csurf, aSize);
     }
 
     // fprintf(stderr, "New wrapper for %p -> %p\n", csurf, result);
 
     return result.forget();
 }
 
 void
--- a/gfx/thebes/gfxASurface.h
+++ b/gfx/thebes/gfxASurface.h
@@ -178,9 +178,27 @@ private:
 
     int32_t mFloatingRefs;
     int32_t mBytesRecorded;
 
 protected:
     bool mSurfaceValid;
 };
 
+/**
+ * An Unknown surface; used to wrap unknown cairo_surface_t returns from cairo
+ */
+class gfxUnknownSurface : public gfxASurface {
+public:
+    gfxUnknownSurface(cairo_surface_t *surf, const mozilla::gfx::IntSize& aSize)
+        : mSize(aSize)
+    {
+        Init(surf, true);
+    }
+
+    virtual ~gfxUnknownSurface() { }
+    virtual const mozilla::gfx::IntSize GetSize() const override { return mSize; }
+
+private:
+    mozilla::gfx::IntSize mSize;
+};
+
 #endif /* GFX_ASURFACE_H */