Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef __FilterSupport_h |
michael@0 | 7 | #define __FilterSupport_h |
michael@0 | 8 | |
michael@0 | 9 | #include "mozilla/Attributes.h" |
michael@0 | 10 | #include "mozilla/RefPtr.h" |
michael@0 | 11 | #include "mozilla/TypedEnum.h" |
michael@0 | 12 | #include "mozilla/gfx/Rect.h" |
michael@0 | 13 | #include "mozilla/gfx/Matrix.h" |
michael@0 | 14 | #include "nsClassHashtable.h" |
michael@0 | 15 | #include "nsTArray.h" |
michael@0 | 16 | #include "nsRegion.h" |
michael@0 | 17 | |
michael@0 | 18 | namespace mozilla { |
michael@0 | 19 | namespace gfx { |
michael@0 | 20 | |
michael@0 | 21 | // Morphology Operators |
michael@0 | 22 | const unsigned short SVG_OPERATOR_UNKNOWN = 0; |
michael@0 | 23 | const unsigned short SVG_OPERATOR_ERODE = 1; |
michael@0 | 24 | const unsigned short SVG_OPERATOR_DILATE = 2; |
michael@0 | 25 | |
michael@0 | 26 | // ColorMatrix types |
michael@0 | 27 | const unsigned short SVG_FECOLORMATRIX_TYPE_UNKNOWN = 0; |
michael@0 | 28 | const unsigned short SVG_FECOLORMATRIX_TYPE_MATRIX = 1; |
michael@0 | 29 | const unsigned short SVG_FECOLORMATRIX_TYPE_SATURATE = 2; |
michael@0 | 30 | const unsigned short SVG_FECOLORMATRIX_TYPE_HUE_ROTATE = 3; |
michael@0 | 31 | const unsigned short SVG_FECOLORMATRIX_TYPE_LUMINANCE_TO_ALPHA = 4; |
michael@0 | 32 | |
michael@0 | 33 | // ComponentTransfer types |
michael@0 | 34 | const unsigned short SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN = 0; |
michael@0 | 35 | const unsigned short SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY = 1; |
michael@0 | 36 | const unsigned short SVG_FECOMPONENTTRANSFER_TYPE_TABLE = 2; |
michael@0 | 37 | const unsigned short SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE = 3; |
michael@0 | 38 | const unsigned short SVG_FECOMPONENTTRANSFER_TYPE_LINEAR = 4; |
michael@0 | 39 | const unsigned short SVG_FECOMPONENTTRANSFER_TYPE_GAMMA = 5; |
michael@0 | 40 | |
michael@0 | 41 | // Blend Mode Values |
michael@0 | 42 | const unsigned short SVG_FEBLEND_MODE_UNKNOWN = 0; |
michael@0 | 43 | const unsigned short SVG_FEBLEND_MODE_NORMAL = 1; |
michael@0 | 44 | const unsigned short SVG_FEBLEND_MODE_MULTIPLY = 2; |
michael@0 | 45 | const unsigned short SVG_FEBLEND_MODE_SCREEN = 3; |
michael@0 | 46 | const unsigned short SVG_FEBLEND_MODE_DARKEN = 4; |
michael@0 | 47 | const unsigned short SVG_FEBLEND_MODE_LIGHTEN = 5; |
michael@0 | 48 | |
michael@0 | 49 | // Edge Mode Values |
michael@0 | 50 | const unsigned short SVG_EDGEMODE_UNKNOWN = 0; |
michael@0 | 51 | const unsigned short SVG_EDGEMODE_DUPLICATE = 1; |
michael@0 | 52 | const unsigned short SVG_EDGEMODE_WRAP = 2; |
michael@0 | 53 | const unsigned short SVG_EDGEMODE_NONE = 3; |
michael@0 | 54 | |
michael@0 | 55 | // Channel Selectors |
michael@0 | 56 | const unsigned short SVG_CHANNEL_UNKNOWN = 0; |
michael@0 | 57 | const unsigned short SVG_CHANNEL_R = 1; |
michael@0 | 58 | const unsigned short SVG_CHANNEL_G = 2; |
michael@0 | 59 | const unsigned short SVG_CHANNEL_B = 3; |
michael@0 | 60 | const unsigned short SVG_CHANNEL_A = 4; |
michael@0 | 61 | |
michael@0 | 62 | // Turbulence Types |
michael@0 | 63 | const unsigned short SVG_TURBULENCE_TYPE_UNKNOWN = 0; |
michael@0 | 64 | const unsigned short SVG_TURBULENCE_TYPE_FRACTALNOISE = 1; |
michael@0 | 65 | const unsigned short SVG_TURBULENCE_TYPE_TURBULENCE = 2; |
michael@0 | 66 | |
michael@0 | 67 | // Composite Operators |
michael@0 | 68 | const unsigned short SVG_FECOMPOSITE_OPERATOR_UNKNOWN = 0; |
michael@0 | 69 | const unsigned short SVG_FECOMPOSITE_OPERATOR_OVER = 1; |
michael@0 | 70 | const unsigned short SVG_FECOMPOSITE_OPERATOR_IN = 2; |
michael@0 | 71 | const unsigned short SVG_FECOMPOSITE_OPERATOR_OUT = 3; |
michael@0 | 72 | const unsigned short SVG_FECOMPOSITE_OPERATOR_ATOP = 4; |
michael@0 | 73 | const unsigned short SVG_FECOMPOSITE_OPERATOR_XOR = 5; |
michael@0 | 74 | const unsigned short SVG_FECOMPOSITE_OPERATOR_ARITHMETIC = 6; |
michael@0 | 75 | |
michael@0 | 76 | enum AttributeName { |
michael@0 | 77 | eBlendBlendmode = 0, |
michael@0 | 78 | eMorphologyRadii, |
michael@0 | 79 | eMorphologyOperator, |
michael@0 | 80 | eColorMatrixType, |
michael@0 | 81 | eColorMatrixValues, |
michael@0 | 82 | eFloodColor, |
michael@0 | 83 | eTileSourceRect, |
michael@0 | 84 | eComponentTransferFunctionR, |
michael@0 | 85 | eComponentTransferFunctionG, |
michael@0 | 86 | eComponentTransferFunctionB, |
michael@0 | 87 | eComponentTransferFunctionA, |
michael@0 | 88 | eComponentTransferFunctionType, |
michael@0 | 89 | eComponentTransferFunctionTableValues, |
michael@0 | 90 | eComponentTransferFunctionSlope, |
michael@0 | 91 | eComponentTransferFunctionIntercept, |
michael@0 | 92 | eComponentTransferFunctionAmplitude, |
michael@0 | 93 | eComponentTransferFunctionExponent, |
michael@0 | 94 | eComponentTransferFunctionOffset, |
michael@0 | 95 | eConvolveMatrixKernelSize, |
michael@0 | 96 | eConvolveMatrixKernelMatrix, |
michael@0 | 97 | eConvolveMatrixDivisor, |
michael@0 | 98 | eConvolveMatrixBias, |
michael@0 | 99 | eConvolveMatrixTarget, |
michael@0 | 100 | eConvolveMatrixEdgeMode, |
michael@0 | 101 | eConvolveMatrixKernelUnitLength, |
michael@0 | 102 | eConvolveMatrixPreserveAlpha, |
michael@0 | 103 | eOffsetOffset, |
michael@0 | 104 | eDropShadowStdDeviation, |
michael@0 | 105 | eDropShadowOffset, |
michael@0 | 106 | eDropShadowColor, |
michael@0 | 107 | eDisplacementMapScale, |
michael@0 | 108 | eDisplacementMapXChannel, |
michael@0 | 109 | eDisplacementMapYChannel, |
michael@0 | 110 | eTurbulenceOffset, |
michael@0 | 111 | eTurbulenceBaseFrequency, |
michael@0 | 112 | eTurbulenceNumOctaves, |
michael@0 | 113 | eTurbulenceSeed, |
michael@0 | 114 | eTurbulenceStitchable, |
michael@0 | 115 | eTurbulenceType, |
michael@0 | 116 | eCompositeOperator, |
michael@0 | 117 | eCompositeCoefficients, |
michael@0 | 118 | eGaussianBlurStdDeviation, |
michael@0 | 119 | eLightingLight, |
michael@0 | 120 | eLightingSurfaceScale, |
michael@0 | 121 | eLightingKernelUnitLength, |
michael@0 | 122 | eLightingColor, |
michael@0 | 123 | eDiffuseLightingDiffuseConstant, |
michael@0 | 124 | eSpecularLightingSpecularConstant, |
michael@0 | 125 | eSpecularLightingSpecularExponent, |
michael@0 | 126 | eLightType, |
michael@0 | 127 | eLightTypeNone, |
michael@0 | 128 | eLightTypePoint, |
michael@0 | 129 | eLightTypeSpot, |
michael@0 | 130 | eLightTypeDistant, |
michael@0 | 131 | ePointLightPosition, |
michael@0 | 132 | eSpotLightPosition, |
michael@0 | 133 | eSpotLightPointsAt, |
michael@0 | 134 | eSpotLightFocus, |
michael@0 | 135 | eSpotLightLimitingConeAngle, |
michael@0 | 136 | eDistantLightAzimuth, |
michael@0 | 137 | eDistantLightElevation, |
michael@0 | 138 | eImageInputIndex, |
michael@0 | 139 | eImageFilter, |
michael@0 | 140 | eImageNativeSize, |
michael@0 | 141 | eImageSubregion, |
michael@0 | 142 | eImageTransform, |
michael@0 | 143 | eLastAttributeName |
michael@0 | 144 | }; |
michael@0 | 145 | |
michael@0 | 146 | class DrawTarget; |
michael@0 | 147 | class SourceSurface; |
michael@0 | 148 | class FilterNode; |
michael@0 | 149 | struct FilterAttribute; |
michael@0 | 150 | |
michael@0 | 151 | MOZ_BEGIN_ENUM_CLASS(AttributeType) |
michael@0 | 152 | eBool, |
michael@0 | 153 | eUint, |
michael@0 | 154 | eFloat, |
michael@0 | 155 | eSize, |
michael@0 | 156 | eIntSize, |
michael@0 | 157 | eIntPoint, |
michael@0 | 158 | eMatrix, |
michael@0 | 159 | eMatrix5x4, |
michael@0 | 160 | ePoint3D, |
michael@0 | 161 | eColor, |
michael@0 | 162 | eAttributeMap, |
michael@0 | 163 | eFloats, |
michael@0 | 164 | Max |
michael@0 | 165 | MOZ_END_ENUM_CLASS(AttributeType) |
michael@0 | 166 | |
michael@0 | 167 | // A class that stores values of different types, keyed by an attribute name. |
michael@0 | 168 | // The Get*() methods assert that they're called for the same type that the |
michael@0 | 169 | // attribute was Set() with. |
michael@0 | 170 | // AttributeMaps can be nested because AttributeMap is a valid attribute type. |
michael@0 | 171 | class AttributeMap MOZ_FINAL { |
michael@0 | 172 | public: |
michael@0 | 173 | AttributeMap(); |
michael@0 | 174 | AttributeMap(const AttributeMap& aOther); |
michael@0 | 175 | AttributeMap& operator=(const AttributeMap& aOther); |
michael@0 | 176 | bool operator==(const AttributeMap& aOther) const; |
michael@0 | 177 | bool operator!=(const AttributeMap& aOther) const |
michael@0 | 178 | { |
michael@0 | 179 | return !(*this == aOther); |
michael@0 | 180 | } |
michael@0 | 181 | ~AttributeMap(); |
michael@0 | 182 | |
michael@0 | 183 | void Set(AttributeName aName, bool aValue); |
michael@0 | 184 | void Set(AttributeName aName, uint32_t aValue); |
michael@0 | 185 | void Set(AttributeName aName, float aValue); |
michael@0 | 186 | void Set(AttributeName aName, const Size& aValue); |
michael@0 | 187 | void Set(AttributeName aName, const IntSize& aValue); |
michael@0 | 188 | void Set(AttributeName aName, const IntPoint& aValue); |
michael@0 | 189 | void Set(AttributeName aName, const Matrix& aValue); |
michael@0 | 190 | void Set(AttributeName aName, const Matrix5x4& aValue); |
michael@0 | 191 | void Set(AttributeName aName, const Point3D& aValue); |
michael@0 | 192 | void Set(AttributeName aName, const Color& aValue); |
michael@0 | 193 | void Set(AttributeName aName, const AttributeMap& aValue); |
michael@0 | 194 | void Set(AttributeName aName, const float* aValues, int32_t aLength); |
michael@0 | 195 | |
michael@0 | 196 | bool GetBool(AttributeName aName) const; |
michael@0 | 197 | uint32_t GetUint(AttributeName aName) const; |
michael@0 | 198 | float GetFloat(AttributeName aName) const; |
michael@0 | 199 | Size GetSize(AttributeName aName) const; |
michael@0 | 200 | IntSize GetIntSize(AttributeName aName) const; |
michael@0 | 201 | IntPoint GetIntPoint(AttributeName aName) const; |
michael@0 | 202 | Matrix GetMatrix(AttributeName aName) const; |
michael@0 | 203 | Matrix5x4 GetMatrix5x4(AttributeName aName) const; |
michael@0 | 204 | Point3D GetPoint3D(AttributeName aName) const; |
michael@0 | 205 | Color GetColor(AttributeName aName) const; |
michael@0 | 206 | AttributeMap GetAttributeMap(AttributeName aName) const; |
michael@0 | 207 | const nsTArray<float>& GetFloats(AttributeName aName) const; |
michael@0 | 208 | |
michael@0 | 209 | typedef bool (*AttributeHandleCallback)(AttributeName aName, AttributeType aType, void* aUserData); |
michael@0 | 210 | void EnumerateRead(AttributeHandleCallback aCallback, void* aUserData) const; |
michael@0 | 211 | uint32_t Count() const; |
michael@0 | 212 | |
michael@0 | 213 | private: |
michael@0 | 214 | mutable nsClassHashtable<nsUint32HashKey, FilterAttribute> mMap; |
michael@0 | 215 | }; |
michael@0 | 216 | |
michael@0 | 217 | MOZ_BEGIN_ENUM_CLASS(ColorSpace) |
michael@0 | 218 | SRGB, |
michael@0 | 219 | LinearRGB, |
michael@0 | 220 | Max |
michael@0 | 221 | MOZ_END_ENUM_CLASS(ColorSpace) |
michael@0 | 222 | |
michael@0 | 223 | MOZ_BEGIN_ENUM_CLASS(AlphaModel) |
michael@0 | 224 | Unpremultiplied, |
michael@0 | 225 | Premultiplied |
michael@0 | 226 | MOZ_END_ENUM_CLASS(AlphaModel) |
michael@0 | 227 | |
michael@0 | 228 | class ColorModel { |
michael@0 | 229 | public: |
michael@0 | 230 | static ColorModel PremulSRGB() |
michael@0 | 231 | { |
michael@0 | 232 | return ColorModel(ColorSpace::SRGB, AlphaModel::Premultiplied); |
michael@0 | 233 | } |
michael@0 | 234 | |
michael@0 | 235 | ColorModel(ColorSpace aColorSpace, AlphaModel aAlphaModel) : |
michael@0 | 236 | mColorSpace(aColorSpace), mAlphaModel(aAlphaModel) {} |
michael@0 | 237 | ColorModel() : |
michael@0 | 238 | mColorSpace(ColorSpace::SRGB), mAlphaModel(AlphaModel::Premultiplied) {} |
michael@0 | 239 | bool operator==(const ColorModel& aOther) const { |
michael@0 | 240 | return mColorSpace == aOther.mColorSpace && |
michael@0 | 241 | mAlphaModel == aOther.mAlphaModel; |
michael@0 | 242 | } |
michael@0 | 243 | |
michael@0 | 244 | // Used to index FilterCachedColorModels::mFilterForColorModel. |
michael@0 | 245 | uint8_t ToIndex() const |
michael@0 | 246 | { |
michael@0 | 247 | return (uint8_t(mColorSpace) << 1) + uint8_t(mAlphaModel); |
michael@0 | 248 | } |
michael@0 | 249 | |
michael@0 | 250 | ColorSpace mColorSpace; |
michael@0 | 251 | AlphaModel mAlphaModel; |
michael@0 | 252 | }; |
michael@0 | 253 | |
michael@0 | 254 | MOZ_BEGIN_ENUM_CLASS(PrimitiveType) |
michael@0 | 255 | Empty = 0, |
michael@0 | 256 | Blend, |
michael@0 | 257 | Morphology, |
michael@0 | 258 | ColorMatrix, |
michael@0 | 259 | Flood, |
michael@0 | 260 | Tile, |
michael@0 | 261 | ComponentTransfer, |
michael@0 | 262 | ConvolveMatrix, |
michael@0 | 263 | Offset, |
michael@0 | 264 | DisplacementMap, |
michael@0 | 265 | Turbulence, |
michael@0 | 266 | Composite, |
michael@0 | 267 | Merge, |
michael@0 | 268 | Image, |
michael@0 | 269 | GaussianBlur, |
michael@0 | 270 | DropShadow, |
michael@0 | 271 | DiffuseLighting, |
michael@0 | 272 | SpecularLighting, |
michael@0 | 273 | Max |
michael@0 | 274 | MOZ_END_ENUM_CLASS(PrimitiveType) |
michael@0 | 275 | |
michael@0 | 276 | /** |
michael@0 | 277 | * A data structure to carry attributes for a given primitive that's part of a |
michael@0 | 278 | * filter. Will be serializable via IPDL, so it must not contain complex |
michael@0 | 279 | * functionality. |
michael@0 | 280 | * Used as part of a FilterDescription. |
michael@0 | 281 | */ |
michael@0 | 282 | class FilterPrimitiveDescription MOZ_FINAL { |
michael@0 | 283 | public: |
michael@0 | 284 | enum { |
michael@0 | 285 | kPrimitiveIndexSourceGraphic = -1, |
michael@0 | 286 | kPrimitiveIndexSourceAlpha = -2, |
michael@0 | 287 | kPrimitiveIndexFillPaint = -3, |
michael@0 | 288 | kPrimitiveIndexStrokePaint = -4 |
michael@0 | 289 | }; |
michael@0 | 290 | |
michael@0 | 291 | FilterPrimitiveDescription(); |
michael@0 | 292 | FilterPrimitiveDescription(PrimitiveType aType); |
michael@0 | 293 | FilterPrimitiveDescription(const FilterPrimitiveDescription& aOther); |
michael@0 | 294 | FilterPrimitiveDescription& operator=(const FilterPrimitiveDescription& aOther); |
michael@0 | 295 | |
michael@0 | 296 | PrimitiveType Type() const { return mType; } |
michael@0 | 297 | void SetType(PrimitiveType aType) { mType = aType; } |
michael@0 | 298 | const AttributeMap& Attributes() const { return mAttributes; } |
michael@0 | 299 | AttributeMap& Attributes() { return mAttributes; } |
michael@0 | 300 | |
michael@0 | 301 | IntRect PrimitiveSubregion() const { return mFilterPrimitiveSubregion; } |
michael@0 | 302 | bool IsTainted() const { return mIsTainted; } |
michael@0 | 303 | |
michael@0 | 304 | size_t NumberOfInputs() const { return mInputPrimitives.Length(); } |
michael@0 | 305 | int32_t InputPrimitiveIndex(size_t aInputIndex) const |
michael@0 | 306 | { |
michael@0 | 307 | return aInputIndex < mInputPrimitives.Length() ? |
michael@0 | 308 | mInputPrimitives[aInputIndex] : 0; |
michael@0 | 309 | } |
michael@0 | 310 | |
michael@0 | 311 | ColorSpace InputColorSpace(size_t aInputIndex) const |
michael@0 | 312 | { |
michael@0 | 313 | return aInputIndex < mInputColorSpaces.Length() ? |
michael@0 | 314 | mInputColorSpaces[aInputIndex] : ColorSpace(); |
michael@0 | 315 | } |
michael@0 | 316 | |
michael@0 | 317 | ColorSpace OutputColorSpace() const { return mOutputColorSpace; } |
michael@0 | 318 | |
michael@0 | 319 | void SetPrimitiveSubregion(const IntRect& aRect) |
michael@0 | 320 | { |
michael@0 | 321 | mFilterPrimitiveSubregion = aRect; |
michael@0 | 322 | } |
michael@0 | 323 | |
michael@0 | 324 | void SetIsTainted(bool aIsTainted) |
michael@0 | 325 | { |
michael@0 | 326 | mIsTainted = aIsTainted; |
michael@0 | 327 | } |
michael@0 | 328 | |
michael@0 | 329 | void SetInputPrimitive(size_t aInputIndex, int32_t aInputPrimitiveIndex) |
michael@0 | 330 | { |
michael@0 | 331 | mInputPrimitives.EnsureLengthAtLeast(aInputIndex + 1); |
michael@0 | 332 | mInputPrimitives[aInputIndex] = aInputPrimitiveIndex; |
michael@0 | 333 | } |
michael@0 | 334 | |
michael@0 | 335 | void SetInputColorSpace(size_t aInputIndex, ColorSpace aColorSpace) |
michael@0 | 336 | { |
michael@0 | 337 | mInputColorSpaces.EnsureLengthAtLeast(aInputIndex + 1); |
michael@0 | 338 | mInputColorSpaces[aInputIndex] = aColorSpace; |
michael@0 | 339 | } |
michael@0 | 340 | |
michael@0 | 341 | void SetOutputColorSpace(const ColorSpace& aColorSpace) |
michael@0 | 342 | { |
michael@0 | 343 | mOutputColorSpace = aColorSpace; |
michael@0 | 344 | } |
michael@0 | 345 | |
michael@0 | 346 | bool operator==(const FilterPrimitiveDescription& aOther) const; |
michael@0 | 347 | bool operator!=(const FilterPrimitiveDescription& aOther) const |
michael@0 | 348 | { |
michael@0 | 349 | return !(*this == aOther); |
michael@0 | 350 | } |
michael@0 | 351 | |
michael@0 | 352 | private: |
michael@0 | 353 | PrimitiveType mType; |
michael@0 | 354 | AttributeMap mAttributes; |
michael@0 | 355 | nsTArray<int32_t> mInputPrimitives; |
michael@0 | 356 | IntRect mFilterPrimitiveSubregion; |
michael@0 | 357 | nsTArray<ColorSpace> mInputColorSpaces; |
michael@0 | 358 | ColorSpace mOutputColorSpace; |
michael@0 | 359 | bool mIsTainted; |
michael@0 | 360 | }; |
michael@0 | 361 | |
michael@0 | 362 | /** |
michael@0 | 363 | * A data structure that contains one or more FilterPrimitiveDescriptions. |
michael@0 | 364 | * Designed to be serializable via IPDL, so it must not contain complex |
michael@0 | 365 | * functionality. |
michael@0 | 366 | */ |
michael@0 | 367 | struct FilterDescription MOZ_FINAL { |
michael@0 | 368 | FilterDescription() {} |
michael@0 | 369 | FilterDescription(const nsTArray<FilterPrimitiveDescription>& aPrimitives, |
michael@0 | 370 | const IntRect& aFilterSpaceBounds) |
michael@0 | 371 | : mPrimitives(aPrimitives) |
michael@0 | 372 | , mFilterSpaceBounds(aFilterSpaceBounds) |
michael@0 | 373 | {} |
michael@0 | 374 | |
michael@0 | 375 | bool operator==(const FilterDescription& aOther) const; |
michael@0 | 376 | bool operator!=(const FilterDescription& aOther) const |
michael@0 | 377 | { |
michael@0 | 378 | return !(*this == aOther); |
michael@0 | 379 | } |
michael@0 | 380 | |
michael@0 | 381 | nsTArray<FilterPrimitiveDescription> mPrimitives; |
michael@0 | 382 | IntRect mFilterSpaceBounds; |
michael@0 | 383 | }; |
michael@0 | 384 | |
michael@0 | 385 | /** |
michael@0 | 386 | * The methods of this class are not on FilterDescription because |
michael@0 | 387 | * FilterDescription is designed as a simple value holder that can be used |
michael@0 | 388 | * on any thread. |
michael@0 | 389 | */ |
michael@0 | 390 | class FilterSupport { |
michael@0 | 391 | public: |
michael@0 | 392 | |
michael@0 | 393 | /** |
michael@0 | 394 | * Draw the filter described by aFilter. All rect parameters are in filter |
michael@0 | 395 | * space coordinates. aRenderRect specifies the part of the filter output |
michael@0 | 396 | * that will be drawn at (0, 0) into the draw target aDT, subject to the |
michael@0 | 397 | * current transform on aDT but with no additional scaling. |
michael@0 | 398 | * The source surfaces must match their corresponding rect in size. |
michael@0 | 399 | * aAdditionalImages carries the images that are referenced by the |
michael@0 | 400 | * eImageInputIndex attribute on any image primitives in the filter. |
michael@0 | 401 | */ |
michael@0 | 402 | static void |
michael@0 | 403 | RenderFilterDescription(DrawTarget* aDT, |
michael@0 | 404 | const FilterDescription& aFilter, |
michael@0 | 405 | const Rect& aRenderRect, |
michael@0 | 406 | SourceSurface* aSourceGraphic, |
michael@0 | 407 | const IntRect& aSourceGraphicRect, |
michael@0 | 408 | SourceSurface* aFillPaint, |
michael@0 | 409 | const IntRect& aFillPaintRect, |
michael@0 | 410 | SourceSurface* aStrokePaint, |
michael@0 | 411 | const IntRect& aStrokePaintRect, |
michael@0 | 412 | nsTArray<RefPtr<SourceSurface>>& aAdditionalImages); |
michael@0 | 413 | |
michael@0 | 414 | /** |
michael@0 | 415 | * Computes the region that changes in the filter output due to a change in |
michael@0 | 416 | * input. |
michael@0 | 417 | */ |
michael@0 | 418 | static nsIntRegion |
michael@0 | 419 | ComputeResultChangeRegion(const FilterDescription& aFilter, |
michael@0 | 420 | const nsIntRegion& aSourceGraphicChange, |
michael@0 | 421 | const nsIntRegion& aFillPaintChange, |
michael@0 | 422 | const nsIntRegion& aStrokePaintChange); |
michael@0 | 423 | |
michael@0 | 424 | /** |
michael@0 | 425 | * Computes the regions that need to be supplied in the filter inputs when |
michael@0 | 426 | * painting aResultNeededRegion of the filter output. |
michael@0 | 427 | */ |
michael@0 | 428 | static void |
michael@0 | 429 | ComputeSourceNeededRegions(const FilterDescription& aFilter, |
michael@0 | 430 | const nsIntRegion& aResultNeededRegion, |
michael@0 | 431 | nsIntRegion& aSourceGraphicNeededRegion, |
michael@0 | 432 | nsIntRegion& aFillPaintNeededRegion, |
michael@0 | 433 | nsIntRegion& aStrokePaintNeededRegion); |
michael@0 | 434 | |
michael@0 | 435 | /** |
michael@0 | 436 | * Computes the size of the filter output. |
michael@0 | 437 | */ |
michael@0 | 438 | static nsIntRegion |
michael@0 | 439 | ComputePostFilterExtents(const FilterDescription& aFilter, |
michael@0 | 440 | const nsIntRegion& aSourceGraphicExtents); |
michael@0 | 441 | |
michael@0 | 442 | }; |
michael@0 | 443 | |
michael@0 | 444 | } |
michael@0 | 445 | } |
michael@0 | 446 | |
michael@0 | 447 | #endif // __FilterSupport_h |