Bug 924102 - Add filter API to Moz2D. r=Bas, r=mattwoodrow
authorMarkus Stange <mstange@themasta.com>
Wed, 27 Nov 2013 12:22:07 +0100
changeset 157798 6e9afaacf2422dd40e75223df47af7b379eee849
parent 157797 d5bc7ed8af530e711d2216f3e954729e3cd49ba6
child 157799 c57ffc30cd4374d8aca3462861f6eaf35b767d62
push id25726
push usercbook@mozilla.com
push dateThu, 28 Nov 2013 10:47:25 +0000
treeherdermozilla-central@cdca43b7657d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas, mattwoodrow
bugs924102
milestone28.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 924102 - Add filter API to Moz2D. r=Bas, r=mattwoodrow
gfx/2d/2D.h
gfx/2d/Filters.h
gfx/2d/Types.h
gfx/2d/moz.build
--- a/gfx/2d/2D.h
+++ b/gfx/2d/2D.h
@@ -48,16 +48,17 @@ typedef struct CGContext *CGContextRef;
 namespace mozilla {
 
 namespace gfx {
 
 class SourceSurface;
 class DataSourceSurface;
 class DrawTarget;
 class DrawEventRecorder;
+class FilterNode;
 
 struct NativeSurface {
   NativeSurfaceType mType;
   SurfaceFormat mFormat;
   void *mSurface;
 };
 
 struct NativeFont {
@@ -618,16 +619,29 @@ public:
    */
   virtual void DrawSurface(SourceSurface *aSurface,
                            const Rect &aDest,
                            const Rect &aSource,
                            const DrawSurfaceOptions &aSurfOptions = DrawSurfaceOptions(),
                            const DrawOptions &aOptions = DrawOptions()) = 0;
 
   /*
+   * Draw the output of a FilterNode to the DrawTarget.
+   *
+   * aNode FilterNode to draw
+   * aSourceRect Source rectangle in FilterNode space to draw
+   * aDestPoint Destination point on the DrawTarget to draw the
+   *            SourceRectangle of the filter output to
+   */
+  virtual void DrawFilter(FilterNode *aNode,
+                          const Rect &aSourceRect,
+                          const Point &aDestPoint,
+                          const DrawOptions &aOptions = DrawOptions()) = 0;
+
+  /*
    * Blend a surface to the draw target with a shadow. The shadow is drawn as a
    * gaussian blur using a specified sigma. The shadow is clipped to the size
    * of the input surface, so the input surface should contain a transparent
    * border the size of the approximate coverage of the blur (3 * aSigma).
    * NOTE: This function works in device space!
    *
    * aSurface Source surface to draw.
    * aDest Destination point that this drawing operation should draw to.
@@ -861,16 +875,24 @@ public:
    * aExtendNone This describes how to extend the stop color outside of the
    *             gradient area.
    */
   virtual TemporaryRef<GradientStops>
     CreateGradientStops(GradientStop *aStops,
                         uint32_t aNumStops,
                         ExtendMode aExtendMode = EXTEND_CLAMP) const = 0;
 
+  /*
+   * Create a FilterNode object that can be used to apply a filter to various
+   * inputs.
+   *
+   * aType Type of filter node to be created.
+   */
+  virtual TemporaryRef<FilterNode> CreateFilter(FilterType aType) = 0;
+
   const Matrix &GetTransform() const { return mTransform; }
 
   /*
    * Set a transform on the surface, this transform is applied at drawing time
    * to both the mask and source of the operation.
    */
   virtual void SetTransform(const Matrix &aTransform)
     { mTransform = aTransform; mTransformDirty = true; }
new file mode 100644
--- /dev/null
+++ b/gfx/2d/Filters.h
@@ -0,0 +1,497 @@
+/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * 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/. */
+
+#ifndef MOZILLA_GFX_FILTERS_H_
+#define MOZILLA_GFX_FILTERS_H_
+
+#include "Types.h"
+#include "mozilla/RefPtr.h"
+
+#include "Point.h"
+#include "Matrix.h"
+#include <vector>
+
+namespace mozilla {
+namespace gfx {
+
+class SourceSurface;
+
+enum FilterBackend {
+  FILTER_BACKEND_SOFTWARE = 0,
+  FILTER_BACKEND_DIRECT2D1_1
+};
+
+enum BlendFilterAtts
+{
+  ATT_BLEND_BLENDMODE = 0                   // uint32_t
+};
+
+enum BlendMode
+{
+  BLEND_MODE_MULTIPLY = 0,
+  BLEND_MODE_SCREEN,
+  BLEND_MODE_DARKEN,
+  BLEND_MODE_LIGHTEN
+};
+
+enum BlendFilterInputs
+{
+  IN_BLEND_IN = 0,
+  IN_BLEND_IN2
+};
+
+enum MorphologyFilterAtts
+{
+  ATT_MORPHOLOGY_RADII = 0,                 // IntSize
+  ATT_MORPHOLOGY_OPERATOR                   // MorphologyOperator
+};
+
+enum MorphologyOperator
+{
+  MORPHOLOGY_OPERATOR_ERODE = 0,
+  MORPHOLOGY_OPERATOR_DILATE
+};
+
+enum MorphologyFilterInputs
+{
+  IN_MORPHOLOGY_IN = 0
+};
+
+enum AlphaMode
+{
+  ALPHA_MODE_PREMULTIPLIED = 0,
+  ALPHA_MODE_STRAIGHT
+};
+
+enum ColorMatrixFilterAtts
+{
+  ATT_COLOR_MATRIX_MATRIX = 0,              // Matrix5x4
+  ATT_COLOR_MATRIX_ALPHA_MODE               // AlphaMode
+};
+
+enum ColorMatrixFilterInputs
+{
+  IN_COLOR_MATRIX_IN = 0
+};
+
+enum FloodFilterAtts
+{
+  ATT_FLOOD_COLOR = 0                       // Color
+};
+
+enum FloodFilterInputs
+{
+  IN_FLOOD_IN = 0
+};
+
+enum TileFilterAtts
+{
+  ATT_TILE_SOURCE_RECT = 0                  // IntRect
+};
+
+enum TileFilterInputs
+{
+  IN_TILE_IN = 0
+};
+
+enum TransferAtts
+{
+  ATT_TRANSFER_DISABLE_R = 0,               // bool
+  ATT_TRANSFER_DISABLE_G,                   // bool
+  ATT_TRANSFER_DISABLE_B,                   // bool
+  ATT_TRANSFER_DISABLE_A                    // bool
+};
+
+enum TransferInputs
+{
+  IN_TRANSFER_IN = 0
+};
+
+enum TableTransferAtts
+{
+  ATT_TABLE_TRANSFER_DISABLE_R = ATT_TRANSFER_DISABLE_R,
+  ATT_TABLE_TRANSFER_DISABLE_G = ATT_TRANSFER_DISABLE_G,
+  ATT_TABLE_TRANSFER_DISABLE_B = ATT_TRANSFER_DISABLE_B,
+  ATT_TABLE_TRANSFER_DISABLE_A = ATT_TRANSFER_DISABLE_A,
+  ATT_TABLE_TRANSFER_TABLE_R,               // Float[]
+  ATT_TABLE_TRANSFER_TABLE_G,               // Float[]
+  ATT_TABLE_TRANSFER_TABLE_B,               // Float[]
+  ATT_TABLE_TRANSFER_TABLE_A                // Float[]
+};
+
+enum TableTransferInputs
+{
+  IN_TABLE_TRANSFER_IN = IN_TRANSFER_IN
+};
+
+enum DiscreteTransferAtts
+{
+  ATT_DISCRETE_TRANSFER_DISABLE_R = ATT_TRANSFER_DISABLE_R,
+  ATT_DISCRETE_TRANSFER_DISABLE_G = ATT_TRANSFER_DISABLE_G,
+  ATT_DISCRETE_TRANSFER_DISABLE_B = ATT_TRANSFER_DISABLE_B,
+  ATT_DISCRETE_TRANSFER_DISABLE_A = ATT_TRANSFER_DISABLE_A,
+  ATT_DISCRETE_TRANSFER_TABLE_R,            // Float[]
+  ATT_DISCRETE_TRANSFER_TABLE_G,            // Float[]
+  ATT_DISCRETE_TRANSFER_TABLE_B,            // Float[]
+  ATT_DISCRETE_TRANSFER_TABLE_A             // Float[]
+};
+
+enum DiscreteTransferInputs
+{
+  IN_DISCRETE_TRANSFER_IN = IN_TRANSFER_IN
+};
+
+enum LinearTransferAtts
+{
+  ATT_LINEAR_TRANSFER_DISABLE_R = ATT_TRANSFER_DISABLE_R,
+  ATT_LINEAR_TRANSFER_DISABLE_G = ATT_TRANSFER_DISABLE_G,
+  ATT_LINEAR_TRANSFER_DISABLE_B = ATT_TRANSFER_DISABLE_B,
+  ATT_LINEAR_TRANSFER_DISABLE_A = ATT_TRANSFER_DISABLE_A,
+  ATT_LINEAR_TRANSFER_SLOPE_R,              // Float
+  ATT_LINEAR_TRANSFER_SLOPE_G,              // Float
+  ATT_LINEAR_TRANSFER_SLOPE_B,              // Float
+  ATT_LINEAR_TRANSFER_SLOPE_A,              // Float
+  ATT_LINEAR_TRANSFER_INTERCEPT_R,          // Float
+  ATT_LINEAR_TRANSFER_INTERCEPT_G,          // Float
+  ATT_LINEAR_TRANSFER_INTERCEPT_B,          // Float
+  ATT_LINEAR_TRANSFER_INTERCEPT_A           // Float
+};
+
+enum LinearTransferInputs
+{
+  IN_LINEAR_TRANSFER_IN = IN_TRANSFER_IN
+};
+
+enum GammaTransferAtts
+{
+  ATT_GAMMA_TRANSFER_DISABLE_R = ATT_TRANSFER_DISABLE_R,
+  ATT_GAMMA_TRANSFER_DISABLE_G = ATT_TRANSFER_DISABLE_G,
+  ATT_GAMMA_TRANSFER_DISABLE_B = ATT_TRANSFER_DISABLE_B,
+  ATT_GAMMA_TRANSFER_DISABLE_A = ATT_TRANSFER_DISABLE_A,
+  ATT_GAMMA_TRANSFER_AMPLITUDE_R,             // Float
+  ATT_GAMMA_TRANSFER_AMPLITUDE_G,             // Float
+  ATT_GAMMA_TRANSFER_AMPLITUDE_B,             // Float
+  ATT_GAMMA_TRANSFER_AMPLITUDE_A,             // Float
+  ATT_GAMMA_TRANSFER_EXPONENT_R,              // Float
+  ATT_GAMMA_TRANSFER_EXPONENT_G,              // Float
+  ATT_GAMMA_TRANSFER_EXPONENT_B,              // Float
+  ATT_GAMMA_TRANSFER_EXPONENT_A,              // Float
+  ATT_GAMMA_TRANSFER_OFFSET_R,                // Float
+  ATT_GAMMA_TRANSFER_OFFSET_G,                // Float
+  ATT_GAMMA_TRANSFER_OFFSET_B,                // Float
+  ATT_GAMMA_TRANSFER_OFFSET_A                 // Float
+};
+
+enum GammaTransferInputs
+{
+  IN_GAMMA_TRANSFER_IN = IN_TRANSFER_IN
+};
+
+enum ConvolveMatrixAtts
+{
+  ATT_CONVOLVE_MATRIX_KERNEL_SIZE = 0,      // IntSize
+  ATT_CONVOLVE_MATRIX_KERNEL_MATRIX,        // Float[]
+  ATT_CONVOLVE_MATRIX_DIVISOR,              // Float
+  ATT_CONVOLVE_MATRIX_BIAS,                 // Float
+  ATT_CONVOLVE_MATRIX_TARGET,               // IntPoint
+  ATT_CONVOLVE_MATRIX_SOURCE_RECT,          // IntRect
+  ATT_CONVOLVE_MATRIX_EDGE_MODE,            // ConvolveMatrixEdgeMode
+  ATT_CONVOLVE_MATRIX_KERNEL_UNIT_LENGTH,   // Size
+  ATT_CONVOLVE_MATRIX_PRESERVE_ALPHA,       // bool
+};
+
+enum ConvolveMatrixEdgeMode
+{
+  EDGE_MODE_DUPLICATE = 0,
+  EDGE_MODE_WRAP,
+  EDGE_MODE_NONE
+};
+
+enum ConvolveMatrixInputs
+{
+  IN_CONVOLVE_MATRIX_IN = 0
+};
+
+enum OffsetAtts
+{
+  ATT_OFFSET_OFFSET = 0                     // IntPoint
+};
+
+enum OffsetInputs
+{
+  IN_OFFSET_IN = 0
+};
+
+enum DisplacementMapAtts
+{
+  ATT_DISPLACEMENT_MAP_SCALE = 0,           // Float
+  ATT_DISPLACEMENT_MAP_X_CHANNEL,           // ColorChannel
+  ATT_DISPLACEMENT_MAP_Y_CHANNEL            // ColorChannel
+};
+
+enum ColorChannel
+{
+  COLOR_CHANNEL_R = 0,
+  COLOR_CHANNEL_G,
+  COLOR_CHANNEL_B,
+  COLOR_CHANNEL_A
+};
+
+enum DisplacementMapInputs
+{
+  IN_DISPLACEMENT_MAP_IN = 0,
+  IN_DISPLACEMENT_MAP_IN2
+};
+
+enum TurbulenceAtts
+{
+  ATT_TURBULENCE_BASE_FREQUENCY = 0,        // Size
+  ATT_TURBULENCE_NUM_OCTAVES,               // uint32_t
+  ATT_TURBULENCE_SEED,                      // uint32_t
+  ATT_TURBULENCE_STITCHABLE,                // bool
+  ATT_TURBULENCE_TYPE,                      // TurbulenceType
+  ATT_TURBULENCE_RECT                       // IntRect
+};
+
+enum TurbulenceType
+{
+  TURBULENCE_TYPE_TURBULENCE = 0,
+  TURBULENCE_TYPE_FRACTAL_NOISE
+};
+
+enum ArithmeticCombineAtts
+{
+  ATT_ARITHMETIC_COMBINE_COEFFICIENTS = 0   // Float[4]
+};
+
+enum ArithmeticCombineInputs
+{
+  IN_ARITHMETIC_COMBINE_IN = 0,
+  IN_ARITHMETIC_COMBINE_IN2
+};
+
+enum CompositeAtts
+{
+  ATT_COMPOSITE_OPERATOR = 0                // CompositeOperator
+};
+
+enum CompositeOperator
+{
+  COMPOSITE_OPERATOR_OVER = 0,
+  COMPOSITE_OPERATOR_IN,
+  COMPOSITE_OPERATOR_OUT,
+  COMPOSITE_OPERATOR_ATOP,
+  COMPOSITE_OPERATOR_XOR
+};
+
+enum CompositeInputs
+{
+  // arbitrary number of inputs
+  IN_COMPOSITE_IN_START = 0
+};
+
+enum GaussianBlurAtts
+{
+  ATT_GAUSSIAN_BLUR_STD_DEVIATION = 0       // Float
+};
+
+enum GaussianBlurInputs
+{
+  IN_GAUSSIAN_BLUR_IN = 0
+};
+
+enum DirectionalBlurAtts
+{
+  ATT_DIRECTIONAL_BLUR_STD_DEVIATION = 0,   // Float
+  ATT_DIRECTIONAL_BLUR_DIRECTION            // BlurDirection
+};
+
+enum BlurDirection
+{
+  BLUR_DIRECTION_X = 0,
+  BLUR_DIRECTION_Y
+};
+
+enum DirectionalBlurInputs
+{
+  IN_DIRECTIONAL_BLUR_IN = 0
+};
+
+enum LightingAtts
+{
+  ATT_POINT_LIGHT_POSITION = 0,             // Point3D
+
+  ATT_SPOT_LIGHT_POSITION,                  // Point3D
+  ATT_SPOT_LIGHT_POINTS_AT,                 // Point3D
+  ATT_SPOT_LIGHT_FOCUS,                     // Float
+  ATT_SPOT_LIGHT_LIMITING_CONE_ANGLE,       // Float
+
+  ATT_DISTANT_LIGHT_AZIMUTH,                // Float
+  ATT_DISTANT_LIGHT_ELEVATION,              // Float
+
+  ATT_LIGHTING_COLOR,                       // Color
+  ATT_LIGHTING_SURFACE_SCALE,               // Float
+  ATT_LIGHTING_KERNEL_UNIT_LENGTH,          // Size
+
+  ATT_DIFFUSE_LIGHTING_DIFFUSE_CONSTANT,    // Float
+
+  ATT_SPECULAR_LIGHTING_SPECULAR_CONSTANT,  // Float
+  ATT_SPECULAR_LIGHTING_SPECULAR_EXPONENT   // Float
+};
+
+enum LightingInputs
+{
+  IN_LIGHTING_IN = 0
+};
+
+enum PointDiffuseAtts
+{
+  ATT_POINT_DIFFUSE_POSITION              = ATT_POINT_LIGHT_POSITION,
+  ATT_POINT_DIFFUSE_COLOR                 = ATT_LIGHTING_COLOR,
+  ATT_POINT_DIFFUSE_SURFACE_SCALE         = ATT_LIGHTING_SURFACE_SCALE,
+  ATT_POINT_DIFFUSE_KERNEL_UNIT_LENGTH    = ATT_LIGHTING_KERNEL_UNIT_LENGTH,
+  ATT_POINT_DIFFUSE_DIFFUSE_CONSTANT      = ATT_DIFFUSE_LIGHTING_DIFFUSE_CONSTANT
+};
+
+enum PointDiffuseInputs
+{
+  IN_POINT_DIFFUSE_IN = IN_LIGHTING_IN
+};
+
+enum SpotDiffuseAtts
+{
+  ATT_SPOT_DIFFUSE_POSITION               = ATT_SPOT_LIGHT_POSITION,
+  ATT_SPOT_DIFFUSE_POINTS_AT              = ATT_SPOT_LIGHT_POINTS_AT,
+  ATT_SPOT_DIFFUSE_FOCUS                  = ATT_SPOT_LIGHT_FOCUS,
+  ATT_SPOT_DIFFUSE_LIMITING_CONE_ANGLE    = ATT_SPOT_LIGHT_LIMITING_CONE_ANGLE,
+  ATT_SPOT_DIFFUSE_COLOR                  = ATT_LIGHTING_COLOR,
+  ATT_SPOT_DIFFUSE_SURFACE_SCALE          = ATT_LIGHTING_SURFACE_SCALE,
+  ATT_SPOT_DIFFUSE_KERNEL_UNIT_LENGTH     = ATT_LIGHTING_KERNEL_UNIT_LENGTH,
+  ATT_SPOT_DIFFUSE_DIFFUSE_CONSTANT       = ATT_DIFFUSE_LIGHTING_DIFFUSE_CONSTANT
+};
+
+enum SpotDiffuseInputs
+{
+  IN_SPOT_DIFFUSE_IN = IN_LIGHTING_IN
+};
+
+enum DistantDiffuseAtts
+{
+  ATT_DISTANT_DIFFUSE_AZIMUTH             = ATT_DISTANT_LIGHT_AZIMUTH,
+  ATT_DISTANT_DIFFUSE_ELEVATION           = ATT_DISTANT_LIGHT_ELEVATION,
+  ATT_DISTANT_DIFFUSE_COLOR               = ATT_LIGHTING_COLOR,
+  ATT_DISTANT_DIFFUSE_SURFACE_SCALE       = ATT_LIGHTING_SURFACE_SCALE,
+  ATT_DISTANT_DIFFUSE_KERNEL_UNIT_LENGTH  = ATT_LIGHTING_KERNEL_UNIT_LENGTH,
+  ATT_DISTANT_DIFFUSE_DIFFUSE_CONSTANT    = ATT_DIFFUSE_LIGHTING_DIFFUSE_CONSTANT
+};
+
+enum DistantDiffuseInputs
+{
+  IN_DISTANT_DIFFUSE_IN = IN_LIGHTING_IN
+};
+
+enum PointSpecularAtts
+{
+  ATT_POINT_SPECULAR_POSITION             = ATT_POINT_LIGHT_POSITION,
+  ATT_POINT_SPECULAR_COLOR                = ATT_LIGHTING_COLOR,
+  ATT_POINT_SPECULAR_SURFACE_SCALE        = ATT_LIGHTING_SURFACE_SCALE,
+  ATT_POINT_SPECULAR_KERNEL_UNIT_LENGTH   = ATT_LIGHTING_KERNEL_UNIT_LENGTH,
+  ATT_POINT_SPECULAR_SPECULAR_CONSTANT    = ATT_SPECULAR_LIGHTING_SPECULAR_CONSTANT,
+  ATT_POINT_SPECULAR_SPECULAR_EXPONENT    = ATT_SPECULAR_LIGHTING_SPECULAR_EXPONENT
+};
+
+enum PointSpecularInputs
+{
+  IN_POINT_SPECULAR_IN = IN_LIGHTING_IN
+};
+
+enum SpotSpecularAtts
+{
+  ATT_SPOT_SPECULAR_POSITION              = ATT_SPOT_LIGHT_POSITION,
+  ATT_SPOT_SPECULAR_POINTS_AT             = ATT_SPOT_LIGHT_POINTS_AT,
+  ATT_SPOT_SPECULAR_FOCUS                 = ATT_SPOT_LIGHT_FOCUS,
+  ATT_SPOT_SPECULAR_LIMITING_CONE_ANGLE   = ATT_SPOT_LIGHT_LIMITING_CONE_ANGLE,
+  ATT_SPOT_SPECULAR_COLOR                 = ATT_LIGHTING_COLOR,
+  ATT_SPOT_SPECULAR_SURFACE_SCALE         = ATT_LIGHTING_SURFACE_SCALE,
+  ATT_SPOT_SPECULAR_KERNEL_UNIT_LENGTH    = ATT_LIGHTING_KERNEL_UNIT_LENGTH,
+  ATT_SPOT_SPECULAR_SPECULAR_CONSTANT     = ATT_SPECULAR_LIGHTING_SPECULAR_CONSTANT,
+  ATT_SPOT_SPECULAR_SPECULAR_EXPONENT     = ATT_SPECULAR_LIGHTING_SPECULAR_EXPONENT
+};
+
+enum SpotSpecularInputs
+{
+  IN_SPOT_SPECULAR_IN = IN_LIGHTING_IN
+};
+
+enum DistantSpecularAtts
+{
+  ATT_DISTANT_SPECULAR_AZIMUTH            = ATT_DISTANT_LIGHT_AZIMUTH,
+  ATT_DISTANT_SPECULAR_ELEVATION          = ATT_DISTANT_LIGHT_ELEVATION,
+  ATT_DISTANT_SPECULAR_COLOR              = ATT_LIGHTING_COLOR,
+  ATT_DISTANT_SPECULAR_SURFACE_SCALE      = ATT_LIGHTING_SURFACE_SCALE,
+  ATT_DISTANT_SPECULAR_KERNEL_UNIT_LENGTH = ATT_LIGHTING_KERNEL_UNIT_LENGTH,
+  ATT_DISTANT_SPECULAR_SPECULAR_CONSTANT  = ATT_SPECULAR_LIGHTING_SPECULAR_CONSTANT,
+  ATT_DISTANT_SPECULAR_SPECULAR_EXPONENT  = ATT_SPECULAR_LIGHTING_SPECULAR_EXPONENT
+};
+
+enum DistantSpecularInputs
+{
+  IN_DISTANT_SPECULAR_IN = IN_LIGHTING_IN
+};
+
+enum CropAtts
+{
+  ATT_CROP_RECT = 0                         // Rect
+};
+
+enum CropInputs
+{
+  IN_CROP_IN = 0
+};
+
+enum PremultiplyInputs
+{
+  IN_PREMULTIPLY_IN = 0
+};
+
+enum UnpremultiplyInputs
+{
+  IN_UNPREMULTIPLY_IN = 0
+};
+
+class FilterNode : public RefCounted<FilterNode>
+{
+public:
+  virtual ~FilterNode() {}
+
+  virtual FilterBackend GetBackendType() = 0;
+
+  virtual void SetInput(uint32_t aIndex, SourceSurface *aSurface) { MOZ_CRASH(); }
+  virtual void SetInput(uint32_t aIndex, FilterNode *aFilter) { MOZ_CRASH(); }
+
+  virtual void SetAttribute(uint32_t aIndex, bool) { MOZ_CRASH(); }
+  virtual void SetAttribute(uint32_t aIndex, uint32_t) { MOZ_CRASH(); }
+  virtual void SetAttribute(uint32_t aIndex, Float) { MOZ_CRASH(); }
+  virtual void SetAttribute(uint32_t aIndex, const Size &) { MOZ_CRASH(); }
+  virtual void SetAttribute(uint32_t aIndex, const IntSize &) { MOZ_CRASH(); }
+  virtual void SetAttribute(uint32_t aIndex, const IntPoint &) { MOZ_CRASH(); }
+  virtual void SetAttribute(uint32_t aIndex, const Rect &) { MOZ_CRASH(); }
+  virtual void SetAttribute(uint32_t aIndex, const IntRect &) { MOZ_CRASH(); }
+  virtual void SetAttribute(uint32_t aIndex, const Point &) { MOZ_CRASH(); }
+  virtual void SetAttribute(uint32_t aIndex, const Matrix5x4 &) { MOZ_CRASH(); }
+  virtual void SetAttribute(uint32_t aIndex, const Point3D &) { MOZ_CRASH(); }
+  virtual void SetAttribute(uint32_t aIndex, const Color &) { MOZ_CRASH(); }
+  virtual void SetAttribute(uint32_t aIndex, const Float* aFloat, uint32_t aSize) { MOZ_CRASH(); }
+
+protected:
+  friend class Factory;
+
+  FilterNode() {}
+};
+
+}
+}
+
+#endif
--- a/gfx/2d/Types.h
+++ b/gfx/2d/Types.h
@@ -38,16 +38,46 @@ enum SurfaceFormat
   FORMAT_R8G8B8A8,
   FORMAT_R8G8B8X8,
   FORMAT_R5G6B5,
   FORMAT_A8,
   FORMAT_YUV,
   FORMAT_UNKNOWN
 };
 
+enum FilterType
+{
+  FILTER_BLEND = 0,
+  FILTER_MORPHOLOGY,
+  FILTER_COLOR_MATRIX,
+  FILTER_FLOOD,
+  FILTER_TILE,
+  FILTER_TABLE_TRANSFER,
+  FILTER_DISCRETE_TRANSFER,
+  FILTER_LINEAR_TRANSFER,
+  FILTER_GAMMA_TRANSFER,
+  FILTER_CONVOLVE_MATRIX,
+  FILTER_OFFSET,
+  FILTER_DISPLACEMENT_MAP,
+  FILTER_TURBULENCE,
+  FILTER_ARITHMETIC_COMBINE,
+  FILTER_COMPOSITE,
+  FILTER_DIRECTIONAL_BLUR,
+  FILTER_GAUSSIAN_BLUR,
+  FILTER_POINT_DIFFUSE,
+  FILTER_POINT_SPECULAR,
+  FILTER_SPOT_DIFFUSE,
+  FILTER_SPOT_SPECULAR,
+  FILTER_DISTANT_DIFFUSE,
+  FILTER_DISTANT_SPECULAR,
+  FILTER_CROP,
+  FILTER_PREMULTIPLY,
+  FILTER_UNPREMULTIPLY
+};
+
 enum BackendType
 {
   BACKEND_NONE = 0,
   BACKEND_DIRECT2D,
   BACKEND_COREGRAPHICS,
   BACKEND_COREGRAPHICS_ACCELERATED,
   BACKEND_CAIRO,
   BACKEND_SKIA,
--- a/gfx/2d/moz.build
+++ b/gfx/2d/moz.build
@@ -14,16 +14,17 @@ EXPORTS.mozilla.gfx += [
     'BasePoint.h',
     'BasePoint3D.h',
     'BasePoint4D.h',
     'BaseRect.h',
     'BaseSize.h',
     'Blur.h',
     'BorrowedContext.h',
     'DataSurfaceHelpers.h',
+    'Filters.h',
     'Helpers.h',
     'Matrix.h',
     'PathHelpers.h',
     'Point.h',
     'Rect.h',
     'Scale.h',
     'ScaleFactor.h',
     'Tools.h',