Bug 952977: Switch GetViewBoxTransform to gfx::Matrix r=nical

This commit is contained in:
David Zbarsky 2013-12-30 01:50:17 -05:00
Родитель 1957b209f5
Коммит e357f0c9be
20 изменённых файлов: 62 добавлений и 59 удалений

Просмотреть файл

@ -272,7 +272,7 @@ SVGContentUtils::AngleBisect(float a1, float a2)
return r;
}
gfxMatrix
gfx::Matrix
SVGContentUtils::GetViewBoxTransform(float aViewportWidth, float aViewportHeight,
float aViewboxX, float aViewboxY,
float aViewboxWidth, float aViewboxHeight,
@ -284,7 +284,7 @@ SVGContentUtils::GetViewBoxTransform(float aViewportWidth, float aViewportHeight
aPreserveAspectRatio.GetAnimValue());
}
gfxMatrix
gfx::Matrix
SVGContentUtils::GetViewBoxTransform(float aViewportWidth, float aViewportHeight,
float aViewboxX, float aViewboxY,
float aViewboxWidth, float aViewboxHeight,
@ -361,11 +361,11 @@ SVGContentUtils::GetViewBoxTransform(float aViewportWidth, float aViewportHeight
}
else NS_NOTREACHED("Unknown value for meetOrSlice");
}
if (aViewboxX) e += -a * aViewboxX;
if (aViewboxY) f += -d * aViewboxY;
return gfxMatrix(a, 0.0f, 0.0f, d, e, f);
return gfx::Matrix(a, 0.0f, 0.0f, d, e, f);
}
static bool

Просмотреть файл

@ -28,6 +28,10 @@ namespace dom {
class Element;
class SVGSVGElement;
} // namespace dom
namespace gfx {
class Matrix;
} // namespace gfx
} // namespace mozilla
inline bool
@ -123,13 +127,13 @@ public:
/* Generate a viewbox to viewport tranformation matrix */
static gfxMatrix
static mozilla::gfx::Matrix
GetViewBoxTransform(float aViewportWidth, float aViewportHeight,
float aViewboxX, float aViewboxY,
float aViewboxWidth, float aViewboxHeight,
const SVGAnimatedPreserveAspectRatio &aPreserveAspectRatio);
static gfxMatrix
static mozilla::gfx::Matrix
GetViewBoxTransform(float aViewportWidth, float aViewportHeight,
float aViewboxX, float aViewboxY,
float aViewboxWidth, float aViewboxHeight,

Просмотреть файл

@ -229,12 +229,12 @@ SVGFEImageElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
imageContainer->GetWidth(&nativeSize.width);
imageContainer->GetHeight(&nativeSize.height);
gfxMatrix viewBoxTM =
Matrix viewBoxTM =
SVGContentUtils::GetViewBoxTransform(aFilterSubregion.width, aFilterSubregion.height,
0, 0, nativeSize.width, nativeSize.height,
mPreserveAspectRatio);
Matrix xyTM = Matrix().Translate(aFilterSubregion.x, aFilterSubregion.y);
Matrix TM = ToMatrix(viewBoxTM) * xyTM;
Matrix TM = viewBoxTM * xyTM;
Filter filter = ToFilter(nsLayoutUtils::GetGraphicsFilterForFrame(frame));

Просмотреть файл

@ -13,7 +13,7 @@
#include "mozilla/dom/SVGMarkerElement.h"
#include "mozilla/dom/SVGMarkerElementBinding.h"
#include "mozilla/Preferences.h"
#include "gfxMatrix.h"
#include "mozilla/gfx/Matrix.h"
#include "SVGContentUtils.h"
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Marker)
@ -334,7 +334,7 @@ SVGMarkerElement::GetViewBoxRect()
mLengthAttributes[MARKERHEIGHT].GetAnimValue(mCoordCtx));
}
gfxMatrix
gfx::Matrix
SVGMarkerElement::GetViewBoxTransform()
{
if (!mViewBoxToViewportTransform) {
@ -342,13 +342,13 @@ SVGMarkerElement::GetViewBoxTransform()
mLengthAttributes[MARKERWIDTH].GetAnimValue(mCoordCtx);
float viewportHeight =
mLengthAttributes[MARKERHEIGHT].GetAnimValue(mCoordCtx);
nsSVGViewBoxRect viewbox = GetViewBoxRect();
NS_ABORT_IF_FALSE(viewbox.width > 0.0f && viewbox.height > 0.0f,
"Rendering should be disabled");
gfxMatrix viewBoxTM =
gfx::Matrix viewBoxTM =
SVGContentUtils::GetViewBoxTransform(viewportWidth, viewportHeight,
viewbox.x, viewbox.y,
viewbox.width, viewbox.height,
@ -357,11 +357,11 @@ SVGMarkerElement::GetViewBoxTransform()
float refX = mLengthAttributes[REFX].GetAnimValue(mCoordCtx);
float refY = mLengthAttributes[REFY].GetAnimValue(mCoordCtx);
gfxPoint ref = viewBoxTM.Transform(gfxPoint(refX, refY));
gfx::Point ref = viewBoxTM * gfx::Point(refX, refY);
gfxMatrix TM = viewBoxTM * gfxMatrix().Translate(gfxPoint(-ref.x, -ref.y));
gfx::Matrix TM = viewBoxTM * gfx::Matrix().Translate(-ref.x, -ref.y);
mViewBoxToViewportTransform = new gfxMatrix(TM);
mViewBoxToViewportTransform = new gfx::Matrix(TM);
}
return *mViewBoxToViewportTransform;

Просмотреть файл

@ -6,7 +6,6 @@
#ifndef mozilla_dom_SVGMarkerElement_h
#define mozilla_dom_SVGMarkerElement_h
#include "gfxMatrix.h"
#include "nsSVGAngle.h"
#include "nsSVGEnum.h"
#include "nsSVGLength2.h"
@ -121,11 +120,11 @@ public:
virtual bool HasValidDimensions() const MOZ_OVERRIDE;
// public helpers
mozilla::gfx::Matrix GetMarkerTransform(float aStrokeWidth,
float aX, float aY, float aAutoAngle,
bool aIsStart);
gfx::Matrix GetMarkerTransform(float aStrokeWidth,
float aX, float aY, float aAutoAngle,
bool aIsStart);
nsSVGViewBoxRect GetViewBoxRect();
gfxMatrix GetViewBoxTransform();
gfx::Matrix GetViewBoxTransform();
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
@ -181,7 +180,7 @@ protected:
nsSVGOrientType mOrientType;
SVGSVGElement *mCoordCtx;
nsAutoPtr<gfxMatrix> mViewBoxToViewportTransform;
nsAutoPtr<gfx::Matrix> mViewBoxToViewportTransform;
};
} // namespace dom

Просмотреть файл

@ -42,6 +42,8 @@
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT_CHECK_PARSER(SVG)
using namespace mozilla::gfx;
namespace mozilla {
namespace dom {
@ -639,7 +641,7 @@ ComputeSynthesizedViewBoxDimension(const nsSVGLength2& aLength,
//----------------------------------------------------------------------
// public helpers:
gfxMatrix
gfx::Matrix
SVGSVGElement::GetViewBoxTransform() const
{
float viewportWidth, viewportHeight;
@ -653,14 +655,14 @@ SVGSVGElement::GetViewBoxTransform() const
}
if (viewportWidth <= 0.0f || viewportHeight <= 0.0f) {
return gfxMatrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular
return gfx::Matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular
}
nsSVGViewBoxRect viewBox =
GetViewBoxWithSynthesis(viewportWidth, viewportHeight);
if (viewBox.width <= 0.0f || viewBox.height <= 0.0f) {
return gfxMatrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular
return gfx::Matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular
}
return SVGContentUtils::GetViewBoxTransform(viewportWidth, viewportHeight,
@ -965,21 +967,21 @@ SVGSVGElement::PrependLocalTransformsTo(const gfxMatrix &aMatrix,
const_cast<SVGSVGElement*>(this)->GetAnimatedLengthValues(&x, &y, nullptr);
if (aWhich == eAllTransforms) {
// the common case
return GetViewBoxTransform() * gfxMatrix().Translate(gfxPoint(x, y)) * fromUserSpace;
return ThebesMatrix(GetViewBoxTransform()) * gfxMatrix().Translate(gfxPoint(x, y)) * fromUserSpace;
}
NS_ABORT_IF_FALSE(aWhich == eChildToUserSpace, "Unknown TransformTypes");
return GetViewBoxTransform() * gfxMatrix().Translate(gfxPoint(x, y));
return ThebesMatrix(GetViewBoxTransform()) * gfxMatrix().Translate(gfxPoint(x, y));
}
if (IsRoot()) {
gfxMatrix zoomPanTM;
zoomPanTM.Translate(gfxPoint(mCurrentTranslate.GetX(), mCurrentTranslate.GetY()));
zoomPanTM.Scale(mCurrentScale, mCurrentScale);
return GetViewBoxTransform() * zoomPanTM * fromUserSpace;
return ThebesMatrix(GetViewBoxTransform()) * zoomPanTM * fromUserSpace;
}
// outer-<svg>, but inline in some other content:
return GetViewBoxTransform() * fromUserSpace;
return ThebesMatrix(GetViewBoxTransform()) * fromUserSpace;
}
/* virtual */ bool

Просмотреть файл

@ -168,7 +168,7 @@ public:
return HasViewBoxRect() || ShouldSynthesizeViewBox();
}
gfxMatrix GetViewBoxTransform() const;
gfx::Matrix GetViewBoxTransform() const;
bool HasChildrenOnlyTransform() const {
return mHasChildrenOnlyTransform;

Просмотреть файл

@ -133,7 +133,7 @@ public:
* @param aFlags Flags indicating whether, stroke, for example, should be
* included in the bbox calculation.
*/
virtual SVGBBox GetBBoxContribution(const mozilla::gfx::Matrix &aToBBoxUserspace,
virtual SVGBBox GetBBoxContribution(const Matrix &aToBBoxUserspace,
uint32_t aFlags) = 0;
// Are we a container frame?

Просмотреть файл

@ -68,7 +68,7 @@ public:
* due to a root-<svg> having its currentScale/currentTransform properties
* set. If aTransform is non-null, then it will be set to the transform.
*/
virtual bool HasChildrenOnlyTransform(mozilla::gfx::Matrix *aTransform) const {
virtual bool HasChildrenOnlyTransform(Matrix *aTransform) const {
return false;
}
@ -141,8 +141,8 @@ public:
const nsRect& aDirtyRect,
const nsDisplayListSet& aLists) MOZ_OVERRIDE;
virtual bool IsSVGTransformed(mozilla::gfx::Matrix *aOwnTransform = nullptr,
mozilla::gfx::Matrix *aFromParentTransform = nullptr) const MOZ_OVERRIDE;
virtual bool IsSVGTransformed(Matrix *aOwnTransform = nullptr,
Matrix *aFromParentTransform = nullptr) const MOZ_OVERRIDE;
// nsISVGChildFrame interface:
NS_IMETHOD PaintSVG(nsRenderingContext* aContext,
@ -152,7 +152,7 @@ public:
NS_IMETHOD_(nsRect) GetCoveredRegion() MOZ_OVERRIDE;
virtual void ReflowSVG() MOZ_OVERRIDE;
virtual void NotifySVGChanged(uint32_t aFlags) MOZ_OVERRIDE;
virtual SVGBBox GetBBoxContribution(const mozilla::gfx::Matrix &aToBBoxUserspace,
virtual SVGBBox GetBBoxContribution(const Matrix &aToBBoxUserspace,
uint32_t aFlags) MOZ_OVERRIDE;
NS_IMETHOD_(bool) IsDisplayContainer() MOZ_OVERRIDE { return true; }
};

Просмотреть файл

@ -165,8 +165,8 @@ nsSVGForeignObjectFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
}
bool
nsSVGForeignObjectFrame::IsSVGTransformed(mozilla::gfx::Matrix *aOwnTransform,
mozilla::gfx::Matrix *aFromParentTransform) const
nsSVGForeignObjectFrame::IsSVGTransformed(Matrix *aOwnTransform,
Matrix *aFromParentTransform) const
{
bool foundTransform = false;

Просмотреть файл

@ -65,8 +65,8 @@ public:
~(nsIFrame::eSVG | nsIFrame::eSVGForeignObject));
}
virtual bool IsSVGTransformed(mozilla::gfx::Matrix *aOwnTransform,
mozilla::gfx::Matrix *aFromParentTransform) const MOZ_OVERRIDE;
virtual bool IsSVGTransformed(Matrix *aOwnTransform,
Matrix *aFromParentTransform) const MOZ_OVERRIDE;
#ifdef DEBUG
NS_IMETHOD GetFrameName(nsAString& aResult) const MOZ_OVERRIDE

Просмотреть файл

@ -233,12 +233,12 @@ nsSVGImageFrame::GetRasterImageTransform(int32_t aNativeWidth,
SVGImageElement *element = static_cast<SVGImageElement*>(mContent);
element->GetAnimatedLengthValues(&x, &y, &width, &height, nullptr);
gfxMatrix viewBoxTM =
Matrix viewBoxTM =
SVGContentUtils::GetViewBoxTransform(width, height,
0, 0, aNativeWidth, aNativeHeight,
element->mPreserveAspectRatio);
return viewBoxTM *
return ThebesMatrix(viewBoxTM) *
gfxMatrix().Translate(gfxPoint(x, y)) *
GetCanvasTM(aFor, aTransformRoot);
}

Просмотреть файл

@ -300,7 +300,7 @@ nsSVGInnerSVGFrame::HasChildrenOnlyTransform(gfx::Matrix *aTransform) const
if (content->HasViewBoxOrSyntheticViewBox()) {
// XXX Maybe return false if the transform is the identity transform?
if (aTransform) {
*aTransform = gfx::ToMatrix(content->GetViewBoxTransform());
*aTransform = content->GetViewBoxTransform();
}
return true;
}

Просмотреть файл

@ -65,7 +65,7 @@ public:
virtual gfxMatrix GetCanvasTM(uint32_t aFor,
nsIFrame* aTransformRoot = nullptr) MOZ_OVERRIDE;
virtual bool HasChildrenOnlyTransform(mozilla::gfx::Matrix *aTransform) const MOZ_OVERRIDE;
virtual bool HasChildrenOnlyTransform(Matrix *aTransform) const MOZ_OVERRIDE;
// nsISVGSVGFrame interface:
virtual void NotifyViewportOrTransformChanged(uint32_t aFlags) MOZ_OVERRIDE;

Просмотреть файл

@ -88,9 +88,9 @@ nsSVGMarkerFrame::GetCanvasTM(uint32_t aFor, nsIFrame* aTransformRoot)
Matrix markerTM = content->GetMarkerTransform(mStrokeWidth, mX, mY,
mAutoAngle, mIsStart);
gfxMatrix viewBoxTM = content->GetViewBoxTransform();
Matrix viewBoxTM = content->GetViewBoxTransform();
return viewBoxTM * ThebesMatrix(markerTM) * markedTM;
return ThebesMatrix(viewBoxTM * markerTM) * markedTM;
}
static nsIFrame*
@ -186,9 +186,9 @@ nsSVGMarkerFrame::GetMarkBBoxContribution(const Matrix &aToBBoxUserspace,
Matrix markerTM =
content->GetMarkerTransform(mStrokeWidth, mX, mY, mAutoAngle, mIsStart);
gfxMatrix viewBoxTM = content->GetViewBoxTransform();
Matrix viewBoxTM = content->GetViewBoxTransform();
Matrix tm = ToMatrix(viewBoxTM) * markerTM * aToBBoxUserspace;
Matrix tm = viewBoxTM * markerTM * aToBBoxUserspace;
nsISVGChildFrame* child = do_QueryFrame(GetAnonymousChildFrame(this));
// When we're being called to obtain the invalidation area, we need to

Просмотреть файл

@ -94,7 +94,7 @@ public:
nsSVGMark *aMark,
float aStrokeWidth);
SVGBBox GetMarkBBoxContribution(const mozilla::gfx::Matrix &aToBBoxUserspace,
SVGBBox GetMarkBBoxContribution(const Matrix &aToBBoxUserspace,
uint32_t aFlags,
nsSVGPathGeometryFrame *aMarkedFrame,
const nsSVGMark *aMark,

Просмотреть файл

@ -97,8 +97,8 @@ public:
return GetFirstPrincipalChild()->GetContentInsertionFrame();
}
virtual bool IsSVGTransformed(mozilla::gfx::Matrix *aOwnTransform,
mozilla::gfx::Matrix *aFromParentTransform) const MOZ_OVERRIDE {
virtual bool IsSVGTransformed(Matrix *aOwnTransform,
Matrix *aFromParentTransform) const MOZ_OVERRIDE {
// Our anonymous wrapper performs the transforms. We simply
// return whether we are transformed here but don't apply the transforms
// themselves.
@ -132,7 +132,7 @@ public:
void RegisterForeignObject(nsSVGForeignObjectFrame* aFrame);
void UnregisterForeignObject(nsSVGForeignObjectFrame* aFrame);
virtual bool HasChildrenOnlyTransform(mozilla::gfx::Matrix *aTransform) const MOZ_OVERRIDE {
virtual bool HasChildrenOnlyTransform(Matrix *aTransform) const MOZ_OVERRIDE {
// Our anonymous wrapper child must claim our children-only transforms as
// its own so that our real children (the frames it wraps) are transformed
// by them, and we must pretend we don't have any children-only transforms
@ -270,7 +270,7 @@ public:
return static_cast<nsSVGOuterSVGFrame*>(mParent)->GetCanvasTM(aFor, aTransformRoot);
}
virtual bool HasChildrenOnlyTransform(mozilla::gfx::Matrix *aTransform) const MOZ_OVERRIDE;
virtual bool HasChildrenOnlyTransform(Matrix *aTransform) const MOZ_OVERRIDE;
};
#endif

Просмотреть файл

@ -66,8 +66,8 @@ public:
*/
virtual nsIAtom* GetType() const MOZ_OVERRIDE;
virtual bool IsSVGTransformed(mozilla::gfx::Matrix *aOwnTransforms = nullptr,
mozilla::gfx::Matrix *aFromParentTransforms = nullptr) const MOZ_OVERRIDE;
virtual bool IsSVGTransformed(Matrix *aOwnTransforms = nullptr,
Matrix *aFromParentTransforms = nullptr) const MOZ_OVERRIDE;
#ifdef DEBUG
NS_IMETHOD GetFrameName(nsAString& aResult) const MOZ_OVERRIDE
@ -93,7 +93,7 @@ protected:
NS_IMETHOD_(nsRect) GetCoveredRegion() MOZ_OVERRIDE;
virtual void ReflowSVG() MOZ_OVERRIDE;
virtual void NotifySVGChanged(uint32_t aFlags) MOZ_OVERRIDE;
virtual SVGBBox GetBBoxContribution(const mozilla::gfx::Matrix &aToBBoxUserspace,
virtual SVGBBox GetBBoxContribution(const Matrix &aToBBoxUserspace,
uint32_t aFlags) MOZ_OVERRIDE;
NS_IMETHOD_(bool) IsDisplayContainer() MOZ_OVERRIDE { return false; }

Просмотреть файл

@ -679,13 +679,13 @@ nsSVGPatternFrame::ConstructCTM(const nsSVGViewBox& aViewBox,
return gfxMatrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular
}
gfxMatrix tm = SVGContentUtils::GetViewBoxTransform(
Matrix tm = SVGContentUtils::GetViewBoxTransform(
viewportWidth, viewportHeight,
viewBoxRect.x, viewBoxRect.y,
viewBoxRect.width, viewBoxRect.height,
GetPreserveAspectRatio());
return tm * tCTM;
return ThebesMatrix(tm) * tCTM;
}
//----------------------------------------------------------------------

Просмотреть файл

@ -31,8 +31,6 @@ typedef nsSVGPaintServerFrame nsSVGPatternFrameBase;
*/
class nsSVGPatternFrame : public nsSVGPatternFrameBase
{
typedef mozilla::gfx::Matrix Matrix;
public:
NS_DECL_FRAMEARENA_HELPERS