2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef __NS_SVGFILTERINSTANCE_H__
|
|
|
|
#define __NS_SVGFILTERINSTANCE_H__
|
|
|
|
|
2012-03-20 05:15:55 -07:00
|
|
|
#include "gfxMatrix.h"
|
|
|
|
#include "gfxPoint.h"
|
|
|
|
#include "gfxRect.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsHashKeys.h"
|
|
|
|
#include "nsPoint.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsRect.h"
|
2012-03-20 05:15:55 -07:00
|
|
|
#include "nsSize.h"
|
2008-07-13 18:21:25 -07:00
|
|
|
#include "nsSVGFilters.h"
|
2011-07-23 01:44:52 -07:00
|
|
|
#include "nsSVGNumber2.h"
|
|
|
|
#include "nsSVGNumberPair.h"
|
2012-03-20 05:15:55 -07:00
|
|
|
#include "nsTArray.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-20 05:15:55 -07:00
|
|
|
class gfxASurface;
|
|
|
|
class gfxImageSurface;
|
|
|
|
class nsIFrame;
|
2008-09-10 17:24:16 -07:00
|
|
|
class nsSVGFilterPaintCallback;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-17 15:28:47 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class SVGFilterElement;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-13 18:21:25 -07:00
|
|
|
/**
|
|
|
|
* This class performs all filter processing.
|
|
|
|
*
|
|
|
|
* We build a graph of the filter image data flow, essentially
|
|
|
|
* converting the filter graph to SSA. This lets us easily propagate
|
|
|
|
* analysis data (such as bounding-boxes) over the filter primitive graph.
|
2012-04-13 06:22:06 -07:00
|
|
|
*
|
|
|
|
* Definition of "filter space": filter space is a coordinate system that is
|
|
|
|
* aligned with the user space of the filtered element, with its origin located
|
2012-06-16 13:23:48 -07:00
|
|
|
* at the top left of the filter region (as specified by our ctor's
|
|
|
|
* aFilterRegion, and returned by our GetFilterRegion, specifically), and with
|
|
|
|
* one unit equal in size to one pixel of the offscreen surface into which the
|
|
|
|
* filter output would/will be painted.
|
|
|
|
*
|
|
|
|
* The definition of "filter region" can be found here:
|
|
|
|
* http://www.w3.org/TR/SVG11/filters.html#FilterEffectsRegion
|
2008-07-13 18:21:25 -07:00
|
|
|
*/
|
2013-04-11 20:20:45 -07:00
|
|
|
class nsSVGFilterInstance
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2012-04-13 06:22:06 -07:00
|
|
|
/**
|
|
|
|
* @param aTargetFrame The frame of the filtered element under consideration.
|
|
|
|
* @param aPaintCallback [optional] The callback that Render() should use to
|
|
|
|
* paint. Only required if you will call Render().
|
|
|
|
* @param aFilterElement The filter element referenced by aTargetFrame's
|
|
|
|
* element.
|
|
|
|
* @param aTargetBBox The filtered element's bbox, in the filtered element's
|
|
|
|
* user space.
|
2012-06-16 13:23:48 -07:00
|
|
|
* @param aFilterRegion The "filter region", in the filtered element's user
|
2012-04-13 06:22:06 -07:00
|
|
|
* space. The caller must have already expanded the region out so that its
|
|
|
|
* edges coincide with pixel boundaries in the offscreen surface that
|
|
|
|
* would/will be created to paint the filter output.
|
|
|
|
* @param aFilterSpaceSize The size of the user specified "filter region",
|
|
|
|
* in filter space units.
|
|
|
|
* @param aFilterSpaceToDeviceSpaceTransform The transform from filter
|
|
|
|
* space to outer-<svg> device space.
|
|
|
|
* @param aTargetBounds The pre-filter paint bounds of the filtered element,
|
|
|
|
* in filter space.
|
2012-06-16 13:23:48 -07:00
|
|
|
* @param aPostFilterDirtyRect [optional] The bounds of the post-filter area
|
|
|
|
* that has to be repainted, in filter space. Only required if you will
|
|
|
|
* call ComputeSourceNeededRect() or Render().
|
|
|
|
* @param aPreFilterDirtyRect [optional] The bounds of the pre-filter area of
|
|
|
|
* the filtered element that changed, in filter space. Only required if you
|
|
|
|
* will call ComputePostFilterDirtyRect().
|
2012-04-13 06:22:06 -07:00
|
|
|
* @param aPrimitiveUnits The value from the 'primitiveUnits' attribute.
|
|
|
|
*/
|
2008-09-10 17:24:16 -07:00
|
|
|
nsSVGFilterInstance(nsIFrame *aTargetFrame,
|
|
|
|
nsSVGFilterPaintCallback *aPaintCallback,
|
2013-02-17 15:28:47 -08:00
|
|
|
const mozilla::dom::SVGFilterElement *aFilterElement,
|
2009-06-11 08:21:03 -07:00
|
|
|
const gfxRect &aTargetBBox,
|
2012-06-16 13:23:48 -07:00
|
|
|
const gfxRect& aFilterRegion,
|
2008-07-13 18:21:25 -07:00
|
|
|
const nsIntSize& aFilterSpaceSize,
|
2009-07-23 01:35:59 -07:00
|
|
|
const gfxMatrix &aFilterSpaceToDeviceSpaceTransform,
|
2012-06-26 03:49:23 -07:00
|
|
|
const gfxMatrix &aFilterSpaceToFrameSpaceInCSSPxTransform,
|
2011-09-17 01:29:51 -07:00
|
|
|
const nsIntRect& aTargetBounds,
|
2012-06-16 13:23:48 -07:00
|
|
|
const nsIntRect& aPostFilterDirtyRect,
|
|
|
|
const nsIntRect& aPreFilterDirtyRect,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint16_t aPrimitiveUnits) :
|
2008-07-13 18:21:25 -07:00
|
|
|
mTargetFrame(aTargetFrame),
|
2008-09-10 17:24:16 -07:00
|
|
|
mPaintCallback(aPaintCallback),
|
2008-07-13 18:21:25 -07:00
|
|
|
mFilterElement(aFilterElement),
|
2007-03-22 10:30:00 -07:00
|
|
|
mTargetBBox(aTargetBBox),
|
2008-07-22 19:15:27 -07:00
|
|
|
mFilterSpaceToDeviceSpaceTransform(aFilterSpaceToDeviceSpaceTransform),
|
2012-06-26 03:49:23 -07:00
|
|
|
mFilterSpaceToFrameSpaceInCSSPxTransform(aFilterSpaceToFrameSpaceInCSSPxTransform),
|
2012-06-16 13:23:48 -07:00
|
|
|
mFilterRegion(aFilterRegion),
|
2008-07-13 18:21:25 -07:00
|
|
|
mFilterSpaceSize(aFilterSpaceSize),
|
2012-04-13 06:22:06 -07:00
|
|
|
mSurfaceRect(nsIntPoint(0, 0), aFilterSpaceSize),
|
2011-09-17 01:29:51 -07:00
|
|
|
mTargetBounds(aTargetBounds),
|
2012-06-16 13:23:48 -07:00
|
|
|
mPostFilterDirtyRect(aPostFilterDirtyRect),
|
|
|
|
mPreFilterDirtyRect(aPreFilterDirtyRect),
|
2007-03-22 10:30:00 -07:00
|
|
|
mPrimitiveUnits(aPrimitiveUnits) {
|
|
|
|
}
|
2008-07-13 18:21:25 -07:00
|
|
|
|
2012-04-13 06:22:06 -07:00
|
|
|
/**
|
|
|
|
* Returns the user specified "filter region", in the filtered element's user
|
|
|
|
* space, after it has been adjusted out (if necessary) so that its edges
|
|
|
|
* coincide with pixel boundaries of the offscreen surface into which the
|
|
|
|
* filtered output would/will be painted.
|
|
|
|
*/
|
2012-06-16 13:23:48 -07:00
|
|
|
gfxRect GetFilterRegion() const { return mFilterRegion; }
|
2008-07-13 18:21:25 -07:00
|
|
|
|
2012-04-13 06:22:06 -07:00
|
|
|
/**
|
|
|
|
* Returns the size of the user specified "filter region", in filter space.
|
|
|
|
* The size will be {filterRes.x by filterRes.y}, whether the user specified
|
|
|
|
* the filter's filterRes attribute explicitly, or the implementation chose
|
|
|
|
* the filterRes values. (The top-left of the filter region is the origin of
|
|
|
|
* filter space, which is why this method returns an nsIntSize and not an
|
|
|
|
* nsIntRect.)
|
|
|
|
*/
|
2008-07-13 18:21:25 -07:00
|
|
|
const nsIntSize& GetFilterSpaceSize() { return mFilterSpaceSize; }
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t GetFilterResX() const { return mFilterSpaceSize.width; }
|
|
|
|
uint32_t GetFilterResY() const { return mFilterSpaceSize.height; }
|
2012-04-13 06:22:06 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the dimensions of the offscreen surface that is required for the
|
|
|
|
* output from the current filter operation, in filter space. This rect is
|
|
|
|
* clipped to, and therefore guaranteed to be fully contained by, the filter
|
|
|
|
* region.
|
|
|
|
*/
|
2008-07-13 18:21:25 -07:00
|
|
|
const nsIntRect& GetSurfaceRect() const { return mSurfaceRect; }
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t GetSurfaceWidth() const { return mSurfaceRect.width; }
|
|
|
|
int32_t GetSurfaceHeight() const { return mSurfaceRect.height; }
|
2012-04-13 06:22:06 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocates a gfxASurface, renders the filtered element into the surface,
|
|
|
|
* and then returns the surface via the aOutput outparam. The area that
|
|
|
|
* needs to be painted must have been specified before calling this method
|
2012-06-16 13:23:48 -07:00
|
|
|
* by passing it as the aPostFilterDirtyRect argument to the
|
2012-04-13 06:22:06 -07:00
|
|
|
* nsSVGFilterInstance constructor.
|
|
|
|
*/
|
2008-07-13 18:21:25 -07:00
|
|
|
nsresult Render(gfxASurface** aOutput);
|
2012-04-13 06:22:06 -07:00
|
|
|
|
|
|
|
/**
|
2012-06-16 13:23:48 -07:00
|
|
|
* Sets the aPostFilterDirtyRect outparam to the post-filter bounds in filter
|
|
|
|
* space of the area that would be dirtied by mTargetFrame when a given
|
|
|
|
* pre-filter area of mTargetFrame is dirtied. The pre-filter area must have
|
|
|
|
* been specified before calling this method by passing it as the
|
|
|
|
* aPreFilterDirtyRect argument to the nsSVGFilterInstance constructor.
|
2012-04-13 06:22:06 -07:00
|
|
|
*/
|
2012-06-16 13:23:48 -07:00
|
|
|
nsresult ComputePostFilterDirtyRect(nsIntRect* aPostFilterDirtyRect);
|
2012-04-13 06:22:06 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the aDirty outparam to the pre-filter bounds in filter space of the
|
|
|
|
* area of mTargetFrame that is needed in order to paint the filtered output
|
|
|
|
* for a given post-filter dirtied area. The post-filter area must have been
|
2012-06-16 13:23:48 -07:00
|
|
|
* specified before calling this method by passing it as the aPostFilterDirtyRect
|
2012-04-13 06:22:06 -07:00
|
|
|
* argument to the nsSVGFilterInstance constructor.
|
|
|
|
*/
|
2008-09-10 17:24:16 -07:00
|
|
|
nsresult ComputeSourceNeededRect(nsIntRect* aDirty);
|
2012-04-13 06:22:06 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the aDirty outparam to the post-filter bounds in filter space of the
|
|
|
|
* area that would be dirtied by mTargetFrame if its entire pre-filter area
|
|
|
|
* is dirtied.
|
|
|
|
*/
|
2008-09-10 17:24:16 -07:00
|
|
|
nsresult ComputeOutputBBox(nsIntRect* aBBox);
|
2008-07-22 19:15:27 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
float GetPrimitiveNumber(uint8_t aCtxType, const nsSVGNumber2 *aNumber) const
|
2011-07-23 01:44:52 -07:00
|
|
|
{
|
|
|
|
return GetPrimitiveNumber(aCtxType, aNumber->GetAnimValue());
|
|
|
|
}
|
2012-08-22 08:56:38 -07:00
|
|
|
float GetPrimitiveNumber(uint8_t aCtxType, const nsSVGNumberPair *aNumberPair,
|
2011-07-23 01:44:52 -07:00
|
|
|
nsSVGNumberPair::PairIndex aIndex) const
|
|
|
|
{
|
|
|
|
return GetPrimitiveNumber(aCtxType, aNumberPair->GetAnimValue(aIndex));
|
|
|
|
}
|
2012-04-13 06:22:06 -07:00
|
|
|
|
2011-09-14 07:48:32 -07:00
|
|
|
/**
|
2012-04-13 06:22:06 -07:00
|
|
|
* Converts a userSpaceOnUse/objectBoundingBoxUnits unitless point and length
|
|
|
|
* into filter space, depending on the value of mPrimitiveUnits. (For
|
|
|
|
* objectBoundingBoxUnits, the bounding box offset is applied to the point.)
|
2011-09-14 07:48:32 -07:00
|
|
|
*/
|
|
|
|
void ConvertLocation(float aValues[3]) const;
|
|
|
|
|
2012-04-13 06:22:06 -07:00
|
|
|
/**
|
|
|
|
* Returns the transform from the filtered element's user space to filter
|
|
|
|
* space. This will be a simple translation and/or scale.
|
|
|
|
*/
|
2009-07-23 01:35:59 -07:00
|
|
|
gfxMatrix GetUserSpaceToFilterSpaceTransform() const;
|
2012-04-13 06:22:06 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the transform from filter space to outer-<svg> device space.
|
|
|
|
*/
|
2009-07-23 01:35:59 -07:00
|
|
|
gfxMatrix GetFilterSpaceToDeviceSpaceTransform() const {
|
|
|
|
return mFilterSpaceToDeviceSpaceTransform;
|
2008-07-22 19:15:27 -07:00
|
|
|
}
|
2012-04-13 06:22:06 -07:00
|
|
|
|
2011-09-14 07:48:32 -07:00
|
|
|
gfxPoint FilterSpaceToUserSpace(const gfxPoint& aPt) const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-06-26 03:49:23 -07:00
|
|
|
/**
|
|
|
|
* Returns the transform from filter space to frame space, in CSS px. This
|
|
|
|
* transform does not transform to frame space in its normal app units, since
|
|
|
|
* app units are ints, requiring appropriate rounding which can't be done by
|
|
|
|
* a transform matrix. Callers have to do that themselves as appropriate for
|
|
|
|
* their needs.
|
|
|
|
*/
|
|
|
|
gfxMatrix GetFilterSpaceToFrameSpaceInCSSPxTransform() const {
|
|
|
|
return mFilterSpaceToFrameSpaceInCSSPxTransform;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t AppUnitsPerCSSPixel() const {
|
2012-06-26 03:49:23 -07:00
|
|
|
return mTargetFrame->PresContext()->AppUnitsPerCSSPixel();
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
private:
|
2008-07-13 18:21:25 -07:00
|
|
|
typedef nsSVGFE::Image Image;
|
|
|
|
typedef nsSVGFE::ColorModel ColorModel;
|
|
|
|
|
|
|
|
struct PrimitiveInfo {
|
2012-04-13 06:22:06 -07:00
|
|
|
/// Pointer to the filter primitive element.
|
2008-07-13 18:21:25 -07:00
|
|
|
nsSVGFE* mFE;
|
2012-04-13 06:22:06 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The filter space bounds of this filter primitive's output, were a full
|
|
|
|
* repaint of mTargetFrame to occur. Note that a filter primitive's output
|
|
|
|
* (and hence this rect) is always clipped to both the filter region and
|
|
|
|
* to the filter primitive subregion.
|
|
|
|
* XXX maybe rename this to mMaxBounds?
|
|
|
|
*/
|
2008-07-13 18:21:25 -07:00
|
|
|
nsIntRect mResultBoundingBox;
|
2012-04-13 06:22:06 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The filter space bounds of this filter primitive's output, were we to
|
|
|
|
* repaint a given post-filter dirty area, and were we to minimize
|
|
|
|
* repainting for that dirty area. In other words this is the part of the
|
|
|
|
* primitive's output that is needed by other primitives or the final
|
|
|
|
* filtered output in order to repaint that area. This rect is guaranteed
|
|
|
|
* to be contained within mResultBoundingBox and, if we're only painting
|
|
|
|
* part of the filtered output, may be smaller. This rect is used when
|
|
|
|
* calling Render() or ComputeSourceNeededRect().
|
|
|
|
* XXX maybe rename this to just mNeededBounds?
|
|
|
|
*/
|
2008-07-13 18:21:25 -07:00
|
|
|
nsIntRect mResultNeededBox;
|
2012-04-13 06:22:06 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The filter space bounds of this filter primitive's output, were only
|
|
|
|
* part of mTargetFrame's pre-filter output to be dirtied, and were we to
|
|
|
|
* minimize repainting for that dirty area. This is used when calculating
|
|
|
|
* the area that needs to be invalidated when only part of a filtered
|
|
|
|
* element is dirtied. This rect is guaranteed to be contained within
|
|
|
|
* mResultBoundingBox.
|
|
|
|
*/
|
2008-07-22 19:15:27 -07:00
|
|
|
nsIntRect mResultChangeBox;
|
2012-04-13 06:22:06 -07:00
|
|
|
|
2008-07-13 18:21:25 -07:00
|
|
|
Image mImage;
|
2012-04-13 06:22:06 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The number of times that this filter primitive's output is used as an
|
|
|
|
* input by other filter primitives in the filter graph.
|
|
|
|
* XXX seems like we could better use this to avoid creating images for
|
|
|
|
* primitives that are not used, or whose ouput in not used during the
|
|
|
|
* current operation.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mImageUsers;
|
2008-07-13 18:21:25 -07:00
|
|
|
|
|
|
|
// Can't use nsAutoTArray here, because these Info objects
|
|
|
|
// live in nsTArrays themselves and nsTArray moves the elements
|
|
|
|
// around in memory, which breaks nsAutoTArray.
|
|
|
|
nsTArray<PrimitiveInfo*> mInputs;
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
PrimitiveInfo() : mFE(nullptr), mImageUsers(0) {}
|
2008-07-13 18:21:25 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class ImageAnalysisEntry : public nsStringHashKey {
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
2008-07-13 18:21:25 -07:00
|
|
|
ImageAnalysisEntry(KeyTypePointer aStr) : nsStringHashKey(aStr) { }
|
|
|
|
ImageAnalysisEntry(const ImageAnalysisEntry& toCopy) : nsStringHashKey(toCopy),
|
|
|
|
mInfo(toCopy.mInfo) { }
|
|
|
|
|
|
|
|
PrimitiveInfo* mInfo;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2012-04-13 06:22:06 -07:00
|
|
|
/**
|
2012-08-05 12:10:21 -07:00
|
|
|
* Initializes the keyword nodes e.g. SourceGraphic (i.e. sets
|
2012-04-13 06:22:06 -07:00
|
|
|
* .mImage.mFilterPrimitiveSubregion and .mResultBoundingBox on
|
|
|
|
* mSourceColorAlpha and mSourceAlpha).
|
|
|
|
*/
|
2008-07-13 18:21:25 -07:00
|
|
|
nsresult BuildSources();
|
2012-04-13 06:22:06 -07:00
|
|
|
|
2012-08-05 12:10:21 -07:00
|
|
|
/**
|
|
|
|
* Creates a gfxImageSurface for either the FillPaint or StrokePaint graph
|
|
|
|
* nodes
|
|
|
|
*/
|
|
|
|
nsresult BuildSourcePaint(PrimitiveInfo *aPrimitive);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a gfxImageSurface for either the FillPaint and StrokePaint graph
|
|
|
|
* nodes, fills its contents and assigns it to mFillPaint.mImage.mImage and
|
|
|
|
* mStrokePaint.mImage.mImage respectively.
|
|
|
|
*/
|
|
|
|
nsresult BuildSourcePaints();
|
|
|
|
|
2012-04-13 06:22:06 -07:00
|
|
|
/**
|
|
|
|
* Creates the gfxImageSurfaces for the SourceGraphic and SourceAlpha graph
|
|
|
|
* nodes, paints their contents, and assigns them to
|
|
|
|
* mSourceColorAlpha.mImage.mImage and mSourceAlpha.mImage.mImage
|
|
|
|
* respectively.
|
|
|
|
*/
|
|
|
|
nsresult BuildSourceImages();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Build the graph of PrimitiveInfo nodes that describes the filter's filter
|
|
|
|
* primitives and their connections. This populates mPrimitives, and sets
|
|
|
|
* each PrimitiveInfo's mFE, mInputs, mImageUsers, mFilterPrimitiveSubregion,
|
|
|
|
* etc.
|
|
|
|
*/
|
2008-07-13 18:21:25 -07:00
|
|
|
nsresult BuildPrimitives();
|
2012-04-13 06:22:06 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Compute the filter space bounds of the output from each primitive, were we
|
|
|
|
* to do a full repaint of mTargetFrame. This sets mResultBoundingBox on the
|
|
|
|
* items in the filter graph, based on the mResultBoundingBox of each item's
|
|
|
|
* inputs, and clipped to the filter region and each primitive's filter
|
|
|
|
* primitive subregion.
|
|
|
|
*/
|
2008-07-13 18:21:25 -07:00
|
|
|
void ComputeResultBoundingBoxes();
|
2012-04-13 06:22:06 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Computes the filter space bounds of the areas that we actually *need* from
|
2012-06-16 13:23:48 -07:00
|
|
|
* each filter primitive's output, based on the value of mPostFilterDirtyRect.
|
2012-04-13 06:22:06 -07:00
|
|
|
* This sets mResultNeededBox on the items in the filter graph.
|
|
|
|
*/
|
|
|
|
void ComputeNeededBoxes();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Computes the filter space bounds of the area of each filter primitive
|
2012-06-16 13:23:48 -07:00
|
|
|
* that will change, based on the value of mPreFilterDirtyRect.
|
2012-04-13 06:22:06 -07:00
|
|
|
* This sets mResultChangeBox on the items in the filter graph.
|
|
|
|
*/
|
2008-07-22 19:15:27 -07:00
|
|
|
void ComputeResultChangeBoxes();
|
2012-04-13 06:22:06 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Computes and returns the union of all mResultNeededBox rects in the filter
|
|
|
|
* graph. This is useful for deciding the size of the offscreen surface that
|
|
|
|
* needs to be created for the filter operation.
|
|
|
|
*/
|
2008-07-13 18:21:25 -07:00
|
|
|
nsIntRect ComputeUnionOfAllNeededBoxes();
|
|
|
|
|
2012-04-13 06:22:06 -07:00
|
|
|
/**
|
|
|
|
* Allocates and returns a surface of mSurfaceRect.Size(), and with a device
|
|
|
|
* offset of -mSurfaceRect.TopLeft(). The surface is cleared to transparent
|
|
|
|
* black.
|
|
|
|
*/
|
2008-07-13 18:21:25 -07:00
|
|
|
already_AddRefed<gfxImageSurface> CreateImage();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-04-13 06:22:06 -07:00
|
|
|
/**
|
|
|
|
* Computes and sets mFilterPrimitiveSubregion for the given primitive.
|
|
|
|
*/
|
2008-07-13 18:21:25 -07:00
|
|
|
void ComputeFilterPrimitiveSubregion(PrimitiveInfo* aInfo);
|
2012-04-13 06:22:06 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If the color model of the pixel data in the aPrimitive's image isn't
|
|
|
|
* already aColorModel, then this method converts its pixel data to that
|
|
|
|
* color model.
|
|
|
|
*/
|
2008-07-13 18:21:25 -07:00
|
|
|
void EnsureColorModel(PrimitiveInfo* aPrimitive,
|
|
|
|
ColorModel aColorModel);
|
|
|
|
|
2011-07-23 01:44:52 -07:00
|
|
|
/**
|
|
|
|
* Scales a numeric filter primitive length in the X, Y or "XY" directions
|
|
|
|
* into a length in filter space (no offset is applied).
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
float GetPrimitiveNumber(uint8_t aCtxType, float aValue) const;
|
2011-07-23 01:44:52 -07:00
|
|
|
|
2008-07-13 18:21:25 -07:00
|
|
|
gfxRect UserSpaceToFilterSpace(const gfxRect& aUserSpace) const;
|
2012-04-13 06:22:06 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Clip the filter space rect aRect to the filter region.
|
|
|
|
*/
|
2008-07-13 18:21:25 -07:00
|
|
|
void ClipToFilterSpace(nsIntRect* aRect) const
|
|
|
|
{
|
|
|
|
nsIntRect filterSpace(nsIntPoint(0, 0), mFilterSpaceSize);
|
|
|
|
aRect->IntersectRect(*aRect, filterSpace);
|
|
|
|
}
|
|
|
|
|
2012-04-13 06:22:06 -07:00
|
|
|
/**
|
|
|
|
* The frame for the element that is currently being filtered.
|
|
|
|
*/
|
2008-09-10 17:24:16 -07:00
|
|
|
nsIFrame* mTargetFrame;
|
2012-04-13 06:22:06 -07:00
|
|
|
|
2008-09-10 17:24:16 -07:00
|
|
|
nsSVGFilterPaintCallback* mPaintCallback;
|
2013-02-17 15:28:47 -08:00
|
|
|
const mozilla::dom::SVGFilterElement* mFilterElement;
|
2012-04-13 06:22:06 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The SVG bbox of the element that is being filtered, in user space.
|
|
|
|
*/
|
2009-06-11 08:21:03 -07:00
|
|
|
gfxRect mTargetBBox;
|
2012-04-13 06:22:06 -07:00
|
|
|
|
2009-07-23 01:35:59 -07:00
|
|
|
gfxMatrix mFilterSpaceToDeviceSpaceTransform;
|
2012-06-26 03:49:23 -07:00
|
|
|
gfxMatrix mFilterSpaceToFrameSpaceInCSSPxTransform;
|
2012-06-16 13:23:48 -07:00
|
|
|
gfxRect mFilterRegion;
|
2008-07-13 18:21:25 -07:00
|
|
|
nsIntSize mFilterSpaceSize;
|
2012-04-13 06:22:06 -07:00
|
|
|
nsIntRect mSurfaceRect;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pre-filter paint bounds of the element that is being filtered, in filter
|
|
|
|
* space.
|
|
|
|
*/
|
2011-09-17 01:29:51 -07:00
|
|
|
nsIntRect mTargetBounds;
|
2012-04-13 06:22:06 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If set, this is the filter space bounds of the outer-<svg> device space
|
|
|
|
* bounds of the dirty area that needs to be repainted. (As bounds-of-bounds,
|
|
|
|
* this may be a fair bit bigger than we actually need, unfortunately.)
|
|
|
|
*/
|
2012-06-16 13:23:48 -07:00
|
|
|
nsIntRect mPostFilterDirtyRect;
|
2012-04-13 06:22:06 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If set, this is the filter space bounds of the outer-<svg> device bounds
|
|
|
|
* of the pre-filter area of the filtered element that changed. (As
|
|
|
|
* bounds-of-bounds, this may be a fair bit bigger than we actually need,
|
|
|
|
* unfortunately.)
|
|
|
|
*/
|
2012-06-16 13:23:48 -07:00
|
|
|
nsIntRect mPreFilterDirtyRect;
|
2012-04-13 06:22:06 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The 'primitiveUnits' attribute value (objectBoundingBox or userSpaceOnUse).
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
uint16_t mPrimitiveUnits;
|
2008-07-13 18:21:25 -07:00
|
|
|
|
|
|
|
PrimitiveInfo mSourceColorAlpha;
|
|
|
|
PrimitiveInfo mSourceAlpha;
|
2012-08-05 12:10:21 -07:00
|
|
|
PrimitiveInfo mFillPaint;
|
|
|
|
PrimitiveInfo mStrokePaint;
|
2008-07-13 18:21:25 -07:00
|
|
|
nsTArray<PrimitiveInfo> mPrimitives;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|