Backed out changeset a5d4d7450d02 (bug 948265)
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Thu, 17 Jul 2014 14:25:48 +0200
changeset 216593 3cb1ab1938373ee8228f0a88076a53351d67d006
parent 216592 557bc4f3fd268b1eae8ea4a047349886f197dede
child 216594 1b27093811d9aeda69d2ada954b4ba349b6ef01e
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs948265
milestone33.0a1
backs outa5d4d7450d020b323ebe69689b8df7efa286b0ce
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 a5d4d7450d02 (bug 948265)
gfx/src/FilterSupport.cpp
gfx/src/FilterSupport.h
layout/svg/nsSVGFilterInstance.cpp
--- a/gfx/src/FilterSupport.cpp
+++ b/gfx/src/FilterSupport.cpp
@@ -981,16 +981,17 @@ static const T&
 ElementForIndex(int32_t aIndex,
                 const nsTArray<T>& aPrimitiveElements,
                 const T& aSourceGraphicElement,
                 const T& aFillPaintElement,
                 const T& aStrokePaintElement)
 {
   switch (aIndex) {
     case FilterPrimitiveDescription::kPrimitiveIndexSourceGraphic:
+    case FilterPrimitiveDescription::kPrimitiveIndexSourceAlpha:
       return aSourceGraphicElement;
     case FilterPrimitiveDescription::kPrimitiveIndexFillPaint:
       return aFillPaintElement;
     case FilterPrimitiveDescription::kPrimitiveIndexStrokePaint:
       return aStrokePaintElement;
     default:
       MOZ_ASSERT(aIndex >= 0, "bad index");
       return aPrimitiveElements[aIndex];
@@ -1097,16 +1098,20 @@ FilterNodeGraphFromDescription(DrawTarge
             ElementForIndex(inputIndex, primitiveSurfaces,
                             aSourceGraphic, aFillPaint, aStrokePaint);
           IntRect surfaceRect =
             ElementForIndex(inputIndex, primitiveSurfaceRects,
                             aSourceGraphicRect, aFillPaintRect, aStrokePaintRect);
           if (surf) {
             IntPoint offset = surfaceRect.TopLeft();
             sourceFilterNode = FilterWrappers::ForSurface(aDT, surf, offset);
+
+            if (inputIndex == FilterPrimitiveDescription::kPrimitiveIndexSourceAlpha) {
+              sourceFilterNode = FilterWrappers::ToAlpha(aDT, sourceFilterNode);
+            }
           }
 
           inputFilter = new FilterCachedColorModels(aDT, sourceFilterNode,
                                                     ColorModel::PremulSRGB());
           sourceFilters[sourceIndex] = inputFilter;
         }
       }
       MOZ_ASSERT(inputFilter);
--- a/gfx/src/FilterSupport.h
+++ b/gfx/src/FilterSupport.h
@@ -279,18 +279,19 @@ MOZ_END_ENUM_CLASS(PrimitiveType)
  * filter. Will be serializable via IPDL, so it must not contain complex
  * functionality.
  * Used as part of a FilterDescription.
  */
 class FilterPrimitiveDescription MOZ_FINAL {
 public:
   enum {
     kPrimitiveIndexSourceGraphic = -1,
-    kPrimitiveIndexFillPaint = -2,
-    kPrimitiveIndexStrokePaint = -3
+    kPrimitiveIndexSourceAlpha = -2,
+    kPrimitiveIndexFillPaint = -3,
+    kPrimitiveIndexStrokePaint = -4
   };
 
   FilterPrimitiveDescription();
   FilterPrimitiveDescription(PrimitiveType aType);
   FilterPrimitiveDescription(const FilterPrimitiveDescription& aOther);
   FilterPrimitiveDescription& operator=(const FilterPrimitiveDescription& aOther);
 
   PrimitiveType Type() const { return mType; }
--- a/layout/svg/nsSVGFilterInstance.cpp
+++ b/layout/svg/nsSVGFilterInstance.cpp
@@ -287,41 +287,43 @@ GetLastResultIndex(const nsTArray<Filter
   return !numPrimitiveDescrs ?
     FilterPrimitiveDescription::kPrimitiveIndexSourceGraphic :
     numPrimitiveDescrs - 1;
 }
 
 int32_t
 nsSVGFilterInstance::GetOrCreateSourceAlphaIndex(nsTArray<FilterPrimitiveDescription>& aPrimitiveDescrs)
 {
-  // If the SourceAlpha index has already been created for this SVG filter,
-  // return it.
+  // If the SourceAlpha index has already been determined or created for this
+  // SVG filter, just return it.
   if (mSourceAlphaAvailable)
     return mSourceAlphaIndex;
 
+  // If this is the first filter in the chain, we can just use the
+  // kPrimitiveIndexSourceAlpha keyword to refer to the SourceAlpha of the
+  // original image.
+  if (mSourceGraphicIndex < 0) {
+    mSourceAlphaIndex = FilterPrimitiveDescription::kPrimitiveIndexSourceAlpha;
+    mSourceAlphaAvailable = true;
+    return mSourceAlphaIndex;
+  }
+
   // Otherwise, create a primitive description to turn the previous filter's
   // output into a SourceAlpha input.
   FilterPrimitiveDescription descr(PrimitiveType::ToAlpha);
   descr.SetInputPrimitive(0, mSourceGraphicIndex);
 
-  if (mSourceGraphicIndex >= 0) {
-    const FilterPrimitiveDescription& sourcePrimitiveDescr =
-      aPrimitiveDescrs[mSourceGraphicIndex];
-    descr.SetPrimitiveSubregion(sourcePrimitiveDescr.PrimitiveSubregion());
-    descr.SetIsTainted(sourcePrimitiveDescr.IsTainted());
+  const FilterPrimitiveDescription& sourcePrimitiveDescr =
+    aPrimitiveDescrs[mSourceGraphicIndex];
+  descr.SetPrimitiveSubregion(sourcePrimitiveDescr.PrimitiveSubregion());
+  descr.SetIsTainted(sourcePrimitiveDescr.IsTainted());
 
-    ColorSpace colorSpace = sourcePrimitiveDescr.OutputColorSpace();
-    descr.SetInputColorSpace(0, colorSpace);
-    descr.SetOutputColorSpace(colorSpace);
-  } else {
-    descr.SetPrimitiveSubregion(ToIntRect(mFilterSpaceBounds));
-    descr.SetIsTainted(true);
-    descr.SetInputColorSpace(0, ColorSpace::SRGB);
-    descr.SetOutputColorSpace(ColorSpace::SRGB);
-  }
+  ColorSpace colorSpace = sourcePrimitiveDescr.OutputColorSpace();
+  descr.SetInputColorSpace(0, colorSpace);
+  descr.SetOutputColorSpace(colorSpace);
 
   aPrimitiveDescrs.AppendElement(descr);
   mSourceAlphaIndex = aPrimitiveDescrs.Length() - 1;
   mSourceAlphaAvailable = true;
   return mSourceAlphaIndex;
 }
 
 nsresult