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

This commit is contained in:
David Zbarsky 2013-12-30 16:42:26 -05:00
Родитель ad99dd5cef
Коммит 3344050b5f
7 изменённых файлов: 21 добавлений и 24 удалений

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

@ -8,7 +8,6 @@
// Keep others in (case-insensitive) order:
#include "gfxContext.h"
#include "gfxMatrix.h"
#include "nsGkAtoms.h"
#include "nsINameSpaceManager.h"
#include "nsLayoutUtils.h"

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

@ -94,12 +94,12 @@ public:
virtual void ReflowCallbackCanceled() MOZ_OVERRIDE;
private:
gfxMatrix GetRasterImageTransform(int32_t aNativeWidth,
int32_t aNativeHeight,
uint32_t aFor,
nsIFrame* aTransformRoot = nullptr);
gfxMatrix GetVectorImageTransform(uint32_t aFor,
nsIFrame* aTransformRoot = nullptr);
gfx::Matrix GetRasterImageTransform(int32_t aNativeWidth,
int32_t aNativeHeight,
uint32_t aFor,
nsIFrame* aTransformRoot = nullptr);
gfx::Matrix GetVectorImageTransform(uint32_t aFor,
nsIFrame* aTransformRoot = nullptr);
bool TransformContextForPainting(gfxContext* aGfxContext,
nsIFrame* aTransformRoot);
@ -223,7 +223,7 @@ nsSVGImageFrame::AttributeChanged(int32_t aNameSpaceID,
aAttribute, aModType);
}
gfxMatrix
gfx::Matrix
nsSVGImageFrame::GetRasterImageTransform(int32_t aNativeWidth,
int32_t aNativeHeight,
uint32_t aFor,
@ -238,12 +238,12 @@ nsSVGImageFrame::GetRasterImageTransform(int32_t aNativeWidth,
0, 0, aNativeWidth, aNativeHeight,
element->mPreserveAspectRatio);
return ThebesMatrix(viewBoxTM) *
gfxMatrix().Translate(gfxPoint(x, y)) *
GetCanvasTM(aFor, aTransformRoot);
return viewBoxTM *
gfx::Matrix().Translate(x, y) *
gfx::ToMatrix(GetCanvasTM(aFor, aTransformRoot));
}
gfxMatrix
gfx::Matrix
nsSVGImageFrame::GetVectorImageTransform(uint32_t aFor,
nsIFrame* aTransformRoot)
{
@ -255,15 +255,15 @@ nsSVGImageFrame::GetVectorImageTransform(uint32_t aFor,
// "native size" that the SVG image has, and it will handle viewBox and
// preserveAspectRatio on its own once we give it a region to draw into.
return gfxMatrix().Translate(gfxPoint(x, y)) *
GetCanvasTM(aFor, aTransformRoot);
return gfx::Matrix().Translate(x, y) *
gfx::ToMatrix(GetCanvasTM(aFor, aTransformRoot));
}
bool
nsSVGImageFrame::TransformContextForPainting(gfxContext* aGfxContext,
nsIFrame* aTransformRoot)
{
gfxMatrix imageTransform;
gfx::Matrix imageTransform;
if (mImageContainer->GetType() == imgIContainer::TYPE_VECTOR) {
imageTransform = GetVectorImageTransform(FOR_PAINTING, aTransformRoot);
} else {
@ -289,7 +289,7 @@ nsSVGImageFrame::TransformContextForPainting(gfxContext* aGfxContext,
return false;
}
aGfxContext->Multiply(imageTransform);
aGfxContext->Multiply(ThebesMatrix(imageTransform));
return true;
}

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

@ -240,7 +240,7 @@ nsSVGInnerSVGFrame::GetFrameForPoint(const nsPoint &aPoint)
float clipX, clipY, clipWidth, clipHeight;
content->GetAnimatedLengthValues(&clipX, &clipY, &clipWidth, &clipHeight, nullptr);
if (!nsSVGUtils::HitTestRect(parent->GetCanvasTM(FOR_HIT_TESTING),
if (!nsSVGUtils::HitTestRect(gfx::ToMatrix(parent->GetCanvasTM(FOR_HIT_TESTING)),
clipX, clipY, clipWidth, clipHeight,
PresContext()->AppUnitsToDevPixels(aPoint.x),
PresContext()->AppUnitsToDevPixels(aPoint.y))) {

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

@ -9,7 +9,6 @@
#include "mozilla/Attributes.h"
#include "nsSVGContainerFrame.h"
#include "nsISVGSVGFrame.h"
#include "gfxMatrix.h"
class nsRenderingContext;

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

@ -4,7 +4,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Keep in (case-insensitive) order:
#include "gfxMatrix.h"
#include "gfxRect.h"
#include "nsSVGEffects.h"
#include "nsSVGGFrame.h"

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

@ -1033,17 +1033,17 @@ nsSVGUtils::ConvertToSurfaceSize(const gfxSize& aSize,
}
bool
nsSVGUtils::HitTestRect(const gfxMatrix &aMatrix,
nsSVGUtils::HitTestRect(const gfx::Matrix &aMatrix,
float aRX, float aRY, float aRWidth, float aRHeight,
float aX, float aY)
{
gfxRect rect(aRX, aRY, aRWidth, aRHeight);
gfx::Rect rect(aRX, aRY, aRWidth, aRHeight);
if (rect.IsEmpty() || aMatrix.IsSingular()) {
return false;
}
gfxMatrix toRectSpace = aMatrix;
gfx::Matrix toRectSpace = aMatrix;
toRectSpace.Invert();
gfxPoint p = toRectSpace.Transform(gfxPoint(aX, aY));
gfx::Point p = toRectSpace * gfx::Point(aX, aY);
return rect.x <= p.x && p.x <= rect.XMost() &&
rect.y <= p.y && p.y <= rect.YMost();
}

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

@ -462,7 +462,7 @@ public:
* Hit test a given rectangle/matrix.
*/
static bool
HitTestRect(const gfxMatrix &aMatrix,
HitTestRect(const mozilla::gfx::Matrix &aMatrix,
float aRX, float aRY, float aRWidth, float aRHeight,
float aX, float aY);