Bug 952977: Switch nsSVGImageFrame to gfx::Matrix r=nical
authorDavid Zbarsky <dzbarsky@gmail.com>
Mon, 30 Dec 2013 16:42:26 -0500
changeset 161864 3cf7d0ef7869221cc221c69aba0a0a5d0337f0fa
parent 161863 fbaaeeb5ab4f2aaad121b579b3b0c5ee3b6b3c09
child 161865 f8e39fa87ba3b5ba82f9ace05b9d43e4db97f060
push id4144
push userphilringnalda@gmail.com
push dateTue, 31 Dec 2013 03:17:33 +0000
treeherderfx-team@d3dee5e99c1e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs952977
milestone29.0a1
Bug 952977: Switch nsSVGImageFrame to gfx::Matrix r=nical
layout/svg/nsSVGForeignObjectFrame.cpp
layout/svg/nsSVGImageFrame.cpp
layout/svg/nsSVGInnerSVGFrame.cpp
layout/svg/nsSVGInnerSVGFrame.h
layout/svg/nsSVGSwitchFrame.cpp
layout/svg/nsSVGUtils.cpp
layout/svg/nsSVGUtils.h
--- a/layout/svg/nsSVGForeignObjectFrame.cpp
+++ b/layout/svg/nsSVGForeignObjectFrame.cpp
@@ -3,17 +3,16 @@
  * 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/. */
 
 // Main header first:
 #include "nsSVGForeignObjectFrame.h"
 
 // Keep others in (case-insensitive) order:
 #include "gfxContext.h"
-#include "gfxMatrix.h"
 #include "nsGkAtoms.h"
 #include "nsINameSpaceManager.h"
 #include "nsLayoutUtils.h"
 #include "nsRegion.h"
 #include "nsRenderingContext.h"
 #include "nsSVGContainerFrame.h"
 #include "nsSVGEffects.h"
 #include "mozilla/dom/SVGForeignObjectElement.h"
--- a/layout/svg/nsSVGImageFrame.cpp
+++ b/layout/svg/nsSVGImageFrame.cpp
@@ -89,22 +89,22 @@ public:
   }
 #endif
 
   // nsIReflowCallback
   virtual bool ReflowFinished() MOZ_OVERRIDE;
   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);
 
   nsCOMPtr<imgINotificationObserver> mListener;
 
   nsCOMPtr<imgIContainer> mImageContainer;
 
   bool mReflowCallbackPosted;
@@ -218,57 +218,57 @@ nsSVGImageFrame::AttributeChanged(int32_
       element->CancelImageRequests(true);
     }
   }
 
   return nsSVGImageFrameBase::AttributeChanged(aNameSpaceID,
                                                aAttribute, aModType);
 }
 
-gfxMatrix
+gfx::Matrix
 nsSVGImageFrame::GetRasterImageTransform(int32_t aNativeWidth,
                                          int32_t aNativeHeight,
                                          uint32_t aFor,
                                          nsIFrame* aTransformRoot)
 {
   float x, y, width, height;
   SVGImageElement *element = static_cast<SVGImageElement*>(mContent);
   element->GetAnimatedLengthValues(&x, &y, &width, &height, nullptr);
 
   Matrix viewBoxTM =
     SVGContentUtils::GetViewBoxTransform(width, height,
                                          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)
 {
   float x, y, width, height;
   SVGImageElement *element = static_cast<SVGImageElement*>(mContent);
   element->GetAnimatedLengthValues(&x, &y, &width, &height, nullptr);
 
   // No viewBoxTM needed here -- our height/width overrides any concept of
   // "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 {
     int32_t nativeWidth, nativeHeight;
     if (NS_FAILED(mImageContainer->GetWidth(&nativeWidth)) ||
         NS_FAILED(mImageContainer->GetHeight(&nativeHeight)) ||
         nativeWidth == 0 || nativeHeight == 0) {
       return false;
@@ -284,17 +284,17 @@ nsSVGImageFrame::TransformContextForPain
       nsPresContext::AppUnitsToFloatCSSPixels(appUnitsPerDevPx);
     imageTransform.Scale(pageZoomFactor, pageZoomFactor);
   }
 
   if (imageTransform.IsSingular()) {
     return false;
   }
 
-  aGfxContext->Multiply(imageTransform);
+  aGfxContext->Multiply(ThebesMatrix(imageTransform));
   return true;
 }
 
 //----------------------------------------------------------------------
 // nsISVGChildFrame methods:
 NS_IMETHODIMP
 nsSVGImageFrame::PaintSVG(nsRenderingContext *aContext,
                           const nsIntRect *aDirtyRect,
--- a/layout/svg/nsSVGInnerSVGFrame.cpp
+++ b/layout/svg/nsSVGInnerSVGFrame.cpp
@@ -235,17 +235,17 @@ nsSVGInnerSVGFrame::GetFrameForPoint(con
 
   if (StyleDisplay()->IsScrollableOverflow()) {
     nsSVGElement *content = static_cast<nsSVGElement*>(mContent);
     nsSVGContainerFrame *parent = static_cast<nsSVGContainerFrame*>(mParent);
 
     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))) {
       return nullptr;
     }
   }
 
   return nsSVGInnerSVGFrameBase::GetFrameForPoint(aPoint);
--- a/layout/svg/nsSVGInnerSVGFrame.h
+++ b/layout/svg/nsSVGInnerSVGFrame.h
@@ -4,17 +4,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef __NS_SVGINNERSVGFRAME_H__
 #define __NS_SVGINNERSVGFRAME_H__
 
 #include "mozilla/Attributes.h"
 #include "nsSVGContainerFrame.h"
 #include "nsISVGSVGFrame.h"
-#include "gfxMatrix.h"
 
 class nsRenderingContext;
 
 typedef nsSVGDisplayContainerFrame nsSVGInnerSVGFrameBase;
 
 class nsSVGInnerSVGFrame : public nsSVGInnerSVGFrameBase,
                            public nsISVGSVGFrame
 {
--- a/layout/svg/nsSVGSwitchFrame.cpp
+++ b/layout/svg/nsSVGSwitchFrame.cpp
@@ -1,15 +1,14 @@
 /* -*- Mode: C++; tab-width: 2; 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/. */
 
 // Keep in (case-insensitive) order:
-#include "gfxMatrix.h"
 #include "gfxRect.h"
 #include "nsSVGEffects.h"
 #include "nsSVGGFrame.h"
 #include "mozilla/dom/SVGSwitchElement.h"
 #include "nsSVGUtils.h"
 
 class nsRenderingContext;
 
--- a/layout/svg/nsSVGUtils.cpp
+++ b/layout/svg/nsSVGUtils.cpp
@@ -1028,27 +1028,27 @@ nsSVGUtils::ConvertToSurfaceSize(const g
                                 surfaceSize.height);
     *aResultOverflows = true;
   }
 
   return surfaceSize;
 }
 
 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();
 }
 
 gfxRect
 nsSVGUtils::GetClipRectForFrame(nsIFrame *aFrame,
                                 float aX, float aY, float aWidth, float aHeight)
 {
--- a/layout/svg/nsSVGUtils.h
+++ b/layout/svg/nsSVGUtils.h
@@ -457,17 +457,17 @@ public:
    */
   static gfxIntSize ConvertToSurfaceSize(const gfxSize& aSize,
                                          bool *aResultOverflows);
 
   /*
    * 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);
 
 
   /**
    * Get the clip rect for the given frame, taking into account the CSS 'clip'
    * property. See:
    * http://www.w3.org/TR/SVG11/masking.html#OverflowAndClipProperties