Bug 1054838, part 1 - Remove dead code supporting cairo_surface_t wrapping gfxPattern. r=Bas
authorMatt Woodrow <mwoodrow@mozilla.com>
Sun, 14 Sep 2014 10:58:55 +0100
changeset 205216 55948a19e455f8e5009c146360e7896cbdaf758c
parent 205215 df5e004949644858d92ff517f1da698f18509645
child 205217 771d12cf1f2118e3de68241a844aa65d6bd46182
push id49113
push userjwatt@jwatt.org
push dateSun, 14 Sep 2014 10:02:10 +0000
treeherdermozilla-inbound@826f233564b4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas
bugs1054838
milestone35.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
Bug 1054838, part 1 - Remove dead code supporting cairo_surface_t wrapping gfxPattern. r=Bas
gfx/thebes/gfxContext.cpp
gfx/thebes/gfxPattern.cpp
gfx/thebes/gfxPattern.h
--- a/gfx/thebes/gfxContext.cpp
+++ b/gfx/thebes/gfxContext.cpp
@@ -935,26 +935,19 @@ gfxContext::Mask(gfxPattern *pattern)
     Point offset;
     if (pattern->IsAzure()) {
       // This is an Azure pattern. i.e. this was the result of a PopGroup and
       // then the extend mode was changed to EXTEND_NONE.
       // XXX - We may need some additional magic here in theory to support
       // device offsets in these patterns, but no problems have been observed
       // yet because of this. And it would complicate things a little further.
       offset = Point(0.f, 0.f);
-    } else if (pattern->GetType() == gfxPattern::PATTERN_SURFACE) {
-      nsRefPtr<gfxASurface> asurf = pattern->GetSurface();
-      gfxPoint deviceOffset = asurf->GetDeviceOffset();
-      offset = Point(-deviceOffset.x, -deviceOffset.y);
-
-      // this lets GetAzureSurface work
-      pattern->GetPattern(mDT);
     }
 
-    if (pattern->IsAzure() || pattern->GetType() == gfxPattern::PATTERN_SURFACE) {
+    if (pattern->IsAzure()) {
       RefPtr<SourceSurface> mask = pattern->GetAzureSurface();
       Matrix mat = ToMatrix(pattern->GetInverseMatrix());
       Matrix old = mTransform;
       // add in the inverse of the pattern transform so that when we
       // MaskSurface we are transformed to the place matching the pattern transform
       mat = mat * mTransform;
 
       ChangeTransform(mat);
--- a/gfx/thebes/gfxPattern.cpp
+++ b/gfx/thebes/gfxPattern.cpp
@@ -11,35 +11,22 @@
 #include "gfxGradientCache.h"
 
 #include "cairo.h"
 
 #include <vector>
 
 using namespace mozilla::gfx;
 
-gfxPattern::gfxPattern(cairo_pattern_t *aPattern)
-  : mGfxPattern(nullptr)
-{
-    mPattern = cairo_pattern_reference(aPattern);
-}
-
 gfxPattern::gfxPattern(const gfxRGBA& aColor)
   : mGfxPattern(nullptr)
 {
     mPattern = cairo_pattern_create_rgba(aColor.r, aColor.g, aColor.b, aColor.a);
 }
 
-// from another surface
-gfxPattern::gfxPattern(gfxASurface *surface)
-  : mGfxPattern(nullptr)
-{
-    mPattern = cairo_pattern_create_for_surface(surface->CairoSurface());
-}
-
 // linear
 gfxPattern::gfxPattern(gfxFloat x0, gfxFloat y0, gfxFloat x1, gfxFloat y1)
   : mGfxPattern(nullptr)
 {
     mPattern = cairo_pattern_create_linear(x0, y0, x1, y1);
 }
 
 // radial
@@ -66,22 +53,16 @@ gfxPattern::~gfxPattern()
 {
     cairo_pattern_destroy(mPattern);
 
     if (mGfxPattern) {
       mGfxPattern->~Pattern();
     }
 }
 
-cairo_pattern_t *
-gfxPattern::CairoPattern()
-{
-    return mPattern;
-}
-
 void
 gfxPattern::AddColorStop(gfxFloat offset, const gfxRGBA& c)
 {
   if (mPattern) {
     mStops = nullptr;
     if (gfxPlatform::GetCMSMode() == eCMSMode_All) {
         gfxRGBA cms;
         qcms_transform *transform = gfxPlatform::GetCMSRGBTransform();
@@ -194,48 +175,16 @@ gfxPattern::GetPattern(DrawTarget *aTarg
   case CAIRO_PATTERN_TYPE_SOLID:
     {
       double r, g, b, a;
       cairo_pattern_get_rgba(mPattern, &r, &g, &b, &a);
 
       new (mColorPattern.addr()) ColorPattern(Color(r, g, b, a));
       return mColorPattern.addr();
     }
-  case CAIRO_PATTERN_TYPE_SURFACE:
-    {
-      GraphicsFilter filter = (GraphicsFilter)cairo_pattern_get_filter(mPattern);
-      cairo_matrix_t mat;
-      cairo_pattern_get_matrix(mPattern, &mat);
-      gfxMatrix matrix(*reinterpret_cast<gfxMatrix*>(&mat));
-
-      cairo_surface_t *surf = nullptr;
-      cairo_pattern_get_surface(mPattern, &surf);
-
-      if (!mSourceSurface) {
-        nsRefPtr<gfxASurface> gfxSurf = gfxASurface::Wrap(surf);
-        // The underlying surface here will be kept around by the gfxPattern.
-        // This function is intended to be used right away.
-        mSourceSurface =
-          gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(aTarget, gfxSurf);
-      }
-
-      if (mSourceSurface) {
-        Matrix newMat = ToMatrix(matrix);
-
-        AdjustTransformForPattern(newMat, aTarget->GetTransform(), aPatternTransform);
-
-        double x, y;
-        cairo_surface_get_device_offset(surf, &x, &y);
-        newMat.PreTranslate(-x, -y);
-        mGfxPattern = new (mSurfacePattern.addr())
-          SurfacePattern(mSourceSurface, ToExtendMode(extend), newMat, ToFilter(filter));
-        return mGfxPattern;
-      }
-      break;
-    }
   case CAIRO_PATTERN_TYPE_LINEAR:
     {
       double x1, y1, x2, y2;
       cairo_pattern_get_linear_points(mPattern, &x1, &y1, &x2, &y2);
       if (!mStops) {
         int count = 0;
         cairo_pattern_get_color_stop_count(mPattern, &count);
 
@@ -319,66 +268,32 @@ gfxPattern::GetPattern(DrawTarget *aTarg
 }
 
 void
 gfxPattern::SetExtend(GraphicsExtend extend)
 {
   if (mPattern) {
     mStops = nullptr;
     if (extend == EXTEND_PAD_EDGE) {
-        if (cairo_pattern_get_type(mPattern) == CAIRO_PATTERN_TYPE_SURFACE) {
-            cairo_surface_t *surf = nullptr;
-
-            cairo_pattern_get_surface (mPattern, &surf);
-            if (surf) {
-                switch (cairo_surface_get_type(surf)) {
-                    case CAIRO_SURFACE_TYPE_WIN32_PRINTING:
-                    case CAIRO_SURFACE_TYPE_QUARTZ:
-                        extend = EXTEND_NONE;
-                        break;
-
-                    case CAIRO_SURFACE_TYPE_WIN32:
-                    case CAIRO_SURFACE_TYPE_XLIB:
-                    default:
-                        extend = EXTEND_PAD;
-                        break;
-                }
-            }
-        }
-
-        // if something went wrong, or not a surface pattern, use PAD
-        if (extend == EXTEND_PAD_EDGE)
-            extend = EXTEND_PAD;
+      extend = EXTEND_PAD;
     }
 
     cairo_pattern_set_extend(mPattern, (cairo_extend_t)extend);
   } else {
     // This is always a surface pattern and will default to EXTEND_PAD
     // for EXTEND_PAD_EDGE.
     mExtend = extend;
   }
 }
 
 bool
 gfxPattern::IsOpaque()
 {
   if (mPattern) {
-    switch (cairo_pattern_get_type(mPattern)) {
-    case CAIRO_PATTERN_TYPE_SURFACE:
-      {
-        cairo_surface_t *surf = nullptr;
-        cairo_pattern_get_surface(mPattern, &surf);
-
-        if (cairo_surface_get_content(surf) == CAIRO_CONTENT_COLOR) {
-          return true;
-        }
-      }
-    default:
-      return false;
-    }
+    return false;
   }
 
   if (mSourceSurface->GetFormat() == SurfaceFormat::B8G8R8X8) {
     return true;
   }
   return false;
 }
 
@@ -417,33 +332,16 @@ gfxPattern::GetSolidColor(gfxRGBA& aColo
 {
     return cairo_pattern_get_rgba(mPattern,
                                   &aColor.r,
                                   &aColor.g,
                                   &aColor.b,
                                   &aColor.a) == CAIRO_STATUS_SUCCESS;
 }
 
-already_AddRefed<gfxASurface>
-gfxPattern::GetSurface()
-{
-  if (mPattern) {
-    cairo_surface_t *surf = nullptr;
-
-    if (cairo_pattern_get_surface (mPattern, &surf) != CAIRO_STATUS_SUCCESS)
-        return nullptr;
-
-    return gfxASurface::Wrap(surf);
-  } else {
-    // We should never be trying to get the surface off an Azure gfx Pattern.
-    NS_ERROR("Attempt to get surface off an Azure gfxPattern!");
-    return nullptr;
-  }
-}
-
 gfxPattern::GraphicsPatternType
 gfxPattern::GetType() const
 {
   if (mPattern) {
     return (GraphicsPatternType) cairo_pattern_get_type(mPattern);
   } else {
     // We should never be trying to get the type off an Azure gfx Pattern.
     MOZ_ASSERT(0);
--- a/gfx/thebes/gfxPattern.h
+++ b/gfx/thebes/gfxPattern.h
@@ -21,27 +21,24 @@ class gfxASurface;
 struct gfxRGBA;
 typedef struct _cairo_pattern cairo_pattern_t;
 
 
 class gfxPattern MOZ_FINAL{
     NS_INLINE_DECL_REFCOUNTING(gfxPattern)
 
 public:
-    explicit gfxPattern(cairo_pattern_t *aPattern);
     explicit gfxPattern(const gfxRGBA& aColor);
-    explicit gfxPattern(gfxASurface *surface); // from another surface
     // linear
     gfxPattern(gfxFloat x0, gfxFloat y0, gfxFloat x1, gfxFloat y1); // linear
     gfxPattern(gfxFloat cx0, gfxFloat cy0, gfxFloat radius0,
                gfxFloat cx1, gfxFloat cy1, gfxFloat radius1); // radial
     gfxPattern(mozilla::gfx::SourceSurface *aSurface,
                const mozilla::gfx::Matrix &aTransform); // Azure
 
-    cairo_pattern_t *CairoPattern();
     void AddColorStop(gfxFloat offset, const gfxRGBA& c);
     void SetColorStops(mozilla::gfx::GradientStops* aStops);
 
     // This should only be called on a cairo pattern that we want to use with
     // Azure. We will read back the color stops from cairo and try to look
     // them up in the cache.
     void CacheColorStops(mozilla::gfx::DrawTarget *aDT);
 
@@ -91,18 +88,16 @@ public:
     int CairoStatus();
 
     void SetFilter(GraphicsFilter filter);
     GraphicsFilter Filter() const;
 
     /* returns TRUE if it succeeded */
     bool GetSolidColor(gfxRGBA& aColor);
 
-    already_AddRefed<gfxASurface> GetSurface();
-
     bool IsAzure() { return !mPattern; }
 
     mozilla::TemporaryRef<mozilla::gfx::SourceSurface> GetAzureSurface() { return mSourceSurface; }
 
 private:
     // Private destructor, to discourage deletion outside of Release():
     ~gfxPattern();