LCOV - app.info - content/svg/content/src/DOMSVGMatrix.h

LCOV - code coverage report
| Current view: | directory - content/svg/content/src - DOMSVGMatrix.h (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 18 | 1 | 5.6 %
| Date: | 2012-06-02 | Functions: | 12 | 1 | 8.3 %

           1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
           2                 :  * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
           3                 :  * ***** BEGIN LICENSE BLOCK *****
           4                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
           5                 :  *
           6                 :  * The contents of this file are subject to the Mozilla Public License Version
           7                 :  * 1.1 (the "License"); you may not use this file except in compliance with
           8                 :  * the License. You may obtain a copy of the License at
           9                 :  * http://www.mozilla.org/MPL/
          10                 :  *
          11                 :  * Software distributed under the License is distributed on an "AS IS" basis,
          12                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
          13                 :  * for the specific language governing rights and limitations under the
          14                 :  * License.
          15                 :  *
          16                 :  * The Original Code is the Mozilla SVG project.
          17                 :  *
          18                 :  * The Initial Developer of the Original Code is
          19                 :  * Crocodile Clips Ltd..
          20                 :  * Portions created by the Initial Developer are Copyright (C) 2001
          21                 :  * the Initial Developer. All Rights Reserved.
          22                 :  *
          23                 :  * Contributor(s):
          24                 :  *   Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
          25                 :  *   Brian Birtles <birtles@gmail.com>
          26                 :  *
          27                 :  * Alternatively, the contents of this file may be used under the terms of
          28                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
          29                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
          30                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
          31                 :  * of those above. If you wish to allow use of your version of this file only
          32                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
          33                 :  * use your version of this file under the terms of the MPL, indicate your
          34                 :  * decision by deleting the provisions above and replace them with the notice
          35                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
          36                 :  * the provisions above, a recipient may use your version of this file under
          37                 :  * the terms of any one of the MPL, the GPL or the LGPL.
          38                 :  *
          39                 :  * ***** END LICENSE BLOCK ***** */
          40                 :
          41                 : /**
          42                 :  * Notes on transforms in Mozilla and the SVG code.
          43                 :  *
          44                 :  * It's important to note that the matrix convention used in the SVG standard
          45                 :  * is the opposite convention to the one used in the Mozilla code or, more
          46                 :  * specifically, the convention used in Thebes code (code using gfxMatrix).
          47                 :  * Whereas the SVG standard uses the column vector convention, Thebes code uses
          48                 :  * the row vector convention. Thus, whereas in the SVG standard you have
          49                 :  * [M1][M2][M3]|p|, in Thebes you have |p|'[M3]'[M2]'[M1]'. In other words, the
          50                 :  * following are equivalent:
          51                 :  *
          52                 :  *                       / a1 c1 tx1 \   / a2 c2 tx2 \   / a3 c3 tx3 \   / x \
          53                 :  * SVG:                  | b1 d1 ty1 |   | b2 d2 ty2 |   | b3 d3 ty3 |   | y |
          54                 :  *                       \  0  0   1 /   \  0  0   1 /   \  0  0   1 /   \ 1 /
          55                 :  *
          56                 :  *                       /  a3  b3 0 \   /  a2  b2 0 \   /  a1  b1 0 \
          57                 :  * Thebes:   [ x y 1 ]   |  c3  d3 0 |   |  c2  d2 0 |   |  c1  d1 0 |
          58                 :  *                       \ tx3 ty3 1 /   \ tx2 ty2 1 /   \ tx1 ty1 1 /
          59                 :  *
          60                 :  * Because the Thebes representation of a transform is the transpose of the SVG
          61                 :  * representation, our transform order must be reversed when representing SVG
          62                 :  * transforms using gfxMatrix in the SVG code. Since the SVG implementation
          63                 :  * stores and obtains matrices in SVG order, to do this we must pre-multiply
          64                 :  * gfxMatrix objects that represent SVG transforms instead of post-multiplying
          65                 :  * them as we would for matrices using SVG's column vector convention.
          66                 :  * Pre-multiplying may look wrong if you're only familiar with the SVG
          67                 :  * convention, but in that case hopefully the above explanation clears things
          68                 :  * up.
          69                 :  */
          70                 :
          71                 : #ifndef MOZILLA_DOMSVGMATRIX_H__
          72                 : #define MOZILLA_DOMSVGMATRIX_H__
          73                 :
          74                 : #include "DOMSVGTransform.h"
          75                 : #include "gfxMatrix.h"
          76                 : #include "nsAutoPtr.h"
          77                 : #include "nsCycleCollectionParticipant.h"
          78                 : #include "nsIDOMSVGMatrix.h"
          79                 :
          80                 : // We make DOMSVGMatrix a pseudo-interface to allow us to QI to it in order
          81                 : // to check that the objects that scripts pass in are our *native* matrix
          82                 : // objects.
          83                 : //
          84                 : // {633419E5-7E88-4C3E-8A9A-856F635E90A3}
          85                 : #define MOZILLA_DOMSVGMATRIX_IID \
          86                 :   { 0x633419E5, 0x7E88, 0x4C3E, \
          87                 :     { 0x8A, 0x9A, 0x85, 0x6F, 0x63, 0x5E, 0x90, 0xA3 } }
          88                 :
          89                 : namespace mozilla {
          90                 :
          91                 : /**
          92                 :  * DOM wrapper for an SVG matrix.
          93                 :  */
          94                 : class DOMSVGMatrix : public nsIDOMSVGMatrix
          95                 : {
          96                 : public:
          97                 :   NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_DOMSVGMATRIX_IID)
          98               0 :   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
          99            1464 :   NS_DECL_CYCLE_COLLECTION_CLASS(DOMSVGMatrix)
         100                 :   NS_DECL_NSIDOMSVGMATRIX
         101                 :
         102                 :   /**
         103                 :    * Ctor for DOMSVGMatrix objects that belong to a DOMSVGTransform.
         104                 :    */
         105               0 :   DOMSVGMatrix(DOMSVGTransform& aTransform) : mTransform(&aTransform) { }
         106                 :
         107                 :   /**
         108                 :    * Ctors for DOMSVGMatrix objects created independently of a DOMSVGTransform.
         109                 :    */
         110               0 :   DOMSVGMatrix() { } // Default ctor for gfxMatrix will produce identity mx
         111               0 :   DOMSVGMatrix(const gfxMatrix &aMatrix) : mMatrix(aMatrix) { }
         112               0 :   ~DOMSVGMatrix() {
         113               0 :     if (mTransform) {
         114               0 :       mTransform->ClearMatrixTearoff(this);
         115                 :     }
         116               0 :   }
         117                 :
         118               0 :   const gfxMatrix& Matrix() const {
         119               0 :     return mTransform ? mTransform->Matrix() : mMatrix;
         120                 :   }
         121                 :
         122                 : private:
         123               0 :   void SetMatrix(const gfxMatrix& aMatrix) {
         124               0 :     if (mTransform) {
         125               0 :       mTransform->SetMatrix(aMatrix);
         126                 :     } else {
         127               0 :       mMatrix = aMatrix;
         128                 :     }
         129               0 :   }
         130                 :
         131               0 :   bool IsAnimVal() const {
         132               0 :     return mTransform ? mTransform->IsAnimVal() : false;
         133                 :   }
         134                 :
         135                 :   nsRefPtr<DOMSVGTransform> mTransform;
         136                 :
         137                 :   // Typically we operate on the matrix data accessed via mTransform but for
         138                 :   // matrices that exist independently of an SVGTransform we use mMatrix below.
         139                 :   gfxMatrix mMatrix;
         140                 : };
         141                 :
         142                 : NS_DEFINE_STATIC_IID_ACCESSOR(DOMSVGMatrix, MOZILLA_DOMSVGMATRIX_IID)
         143                 :
         144                 : } // namespace mozilla
         145                 :
         146                 : #endif // MOZILLA_DOMSVGMATRIX_H__

Generated by: LCOV version 1.7