Bug 948265 - Remove kPrimitiveIndexSourceAlpha since nsSVGFilterInstance creates ToAlpha filter nodes now. r=mstange
☠☠ backed out by 3cb1ab193837 ☠ ☠
authorMax Vujovic <mvujovic@adobe.com>
Tue, 15 Jul 2014 11:50:00 +0200
changeset 194668 a5d4d7450d020b323ebe69689b8df7efa286b0ce
parent 194667 8ab80015952558cf798afaa22a99c18ceb13f216
child 194669 9747c285620e4f7f3a8ed7e78ff126a220cb2783
push id27152
push userryanvm@gmail.com
push dateThu, 17 Jul 2014 21:33:47 +0000
treeherdermozilla-central@f77a9f825427 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs948265
milestone33.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 948265 - Remove kPrimitiveIndexSourceAlpha since nsSVGFilterInstance creates ToAlpha filter nodes now. r=mstange
gfx/src/FilterSupport.cpp
gfx/src/FilterSupport.h
layout/svg/nsSVGFilterInstance.cpp
--- a/gfx/src/FilterSupport.cpp
+++ b/gfx/src/FilterSupport.cpp
@@ -981,17 +981,16 @@ 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];
@@ -1098,20 +1097,16 @@ 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,19 +279,18 @@ 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,
-    kPrimitiveIndexSourceAlpha = -2,
-    kPrimitiveIndexFillPaint = -3,
-    kPrimitiveIndexStrokePaint = -4
+    kPrimitiveIndexFillPaint = -2,
+    kPrimitiveIndexStrokePaint = -3
   };
 
   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,43 +287,41 @@ GetLastResultIndex(const nsTArray<Filter
   return !numPrimitiveDescrs ?
     FilterPrimitiveDescription::kPrimitiveIndexSourceGraphic :
     numPrimitiveDescrs - 1;
 }
 
 int32_t
 nsSVGFilterInstance::GetOrCreateSourceAlphaIndex(nsTArray<FilterPrimitiveDescription>& aPrimitiveDescrs)
 {
-  // If the SourceAlpha index has already been determined or created for this
-  // SVG filter, just return it.
+  // If the SourceAlpha index has already been created for this SVG filter,
+  // 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);
 
-  const FilterPrimitiveDescription& sourcePrimitiveDescr =
-    aPrimitiveDescrs[mSourceGraphicIndex];
-  descr.SetPrimitiveSubregion(sourcePrimitiveDescr.PrimitiveSubregion());
-  descr.SetIsTainted(sourcePrimitiveDescr.IsTainted());
+  if (mSourceGraphicIndex >= 0) {
+    const FilterPrimitiveDescription& sourcePrimitiveDescr =
+      aPrimitiveDescrs[mSourceGraphicIndex];
+    descr.SetPrimitiveSubregion(sourcePrimitiveDescr.PrimitiveSubregion());
+    descr.SetIsTainted(sourcePrimitiveDescr.IsTainted());
 
-  ColorSpace colorSpace = sourcePrimitiveDescr.OutputColorSpace();
-  descr.SetInputColorSpace(0, colorSpace);
-  descr.SetOutputColorSpace(colorSpace);
+    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);
+  }
 
   aPrimitiveDescrs.AppendElement(descr);
   mSourceAlphaIndex = aPrimitiveDescrs.Length() - 1;
   mSourceAlphaAvailable = true;
   return mSourceAlphaIndex;
 }
 
 nsresult