LCOV - code coverage report
Current view: directory - objdir/dist/include - nsTransform2D.h (source / functions) Found Hit Coverage
Test: app.info Lines: 4 0 0.0 %
Date: 2012-06-02 Functions: 4 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is mozilla.org code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Netscape Communications Corporation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 1998
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *      michaelp   09-25-97 1:56pm
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      27                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : #ifndef nsTransform2D_h___
      40                 : #define nsTransform2D_h___
      41                 : 
      42                 : #include "gfxCore.h"
      43                 : #include "nsCoord.h"
      44                 : 
      45                 : class NS_GFX nsTransform2D
      46                 : {
      47                 : private:
      48                 :  /**
      49                 :   * This represents the following matrix (note that the order of row/column
      50                 :   * indices is opposite to usual notation)
      51                 :   *
      52                 :   *      / m00   0   m20  \
      53                 :   * M =  |  0   m11  m21  |
      54                 :   *      \  0    0    1   /
      55                 :   *
      56                 :   * Transformation of a coordinate (x, y) is obtained by setting
      57                 :   * v = (x, y, 1)^T and evaluating  M . v
      58                 :   **/
      59                 : 
      60                 :   float     m00, m11, m20, m21;
      61                 : 
      62                 : public:
      63               0 :   nsTransform2D(void)                         { m20 = m21 = 0.0f; m00 = m11 = 1.0f; }
      64                 :   nsTransform2D(nsTransform2D *aTransform2D)  {
      65                 :     m00 = aTransform2D->m00;
      66                 :     m11 = aTransform2D->m11;
      67                 :     m20 = aTransform2D->m20;
      68                 :     m21 = aTransform2D->m21;
      69                 :   }
      70                 : 
      71               0 :   ~nsTransform2D(void)                        { }
      72                 : 
      73                 :  /**
      74                 :   * set this transform to a translation
      75                 :   *
      76                 :   * @param      tx, x translation
      77                 :   * @param      ty, y translation
      78                 :   **/
      79                 : 
      80               0 :   void SetToTranslate(float tx, float ty)    { m00 = m11 = 1.0f; m20 = tx; m21 = ty; }
      81                 :   
      82                 :  /**
      83                 :   * get the translation portion of this transform
      84                 :   *
      85                 :   * @param      pt, Point to return translation values in
      86                 :   **/
      87                 : 
      88                 :   void GetTranslationCoord(nscoord *ptX, nscoord *ptY) const { *ptX = NSToCoordRound(m20); *ptY = NSToCoordRound(m21); }
      89                 : 
      90                 :  /**
      91                 :   * apply matrix to vector
      92                 :   *
      93                 :   * @param    pt Point to transform
      94                 :   **/
      95                 : 
      96                 :   void TransformCoord(nscoord *ptX, nscoord *ptY) const;
      97                 : 
      98                 :  /**
      99                 :   * apply matrix to rect
     100                 :   *
     101                 :   * @param    rect Rect to transform
     102                 :   **/
     103                 : 
     104                 :   void TransformCoord(nscoord *aX, nscoord *aY, nscoord *aWidth, nscoord *aHeight) const;
     105                 : 
     106                 :  /**
     107                 :   * add a scale to a Transform via x, y pair
     108                 :   *
     109                 :   * @param    ptX x value to add as x scale
     110                 :   * @param    ptY y value to add as y scale
     111                 :   **/
     112                 : 
     113                 :   void AddScale(float ptX, float ptY) { m00 *= ptX; m11 *= ptY; }
     114                 : 
     115                 :  /**
     116                 :   * Set the scale (overriding any previous calls to AddScale, but leaving
     117                 :   * any existing translation).
     118                 :   *
     119                 :   * @param    ptX x value to add as x scale
     120                 :   * @param    ptY y value to add as y scale
     121                 :   **/
     122                 : 
     123               0 :   void SetScale(float ptX, float ptY) { m00 = ptX; m11 = ptY; }
     124                 : };
     125                 : 
     126                 : #endif

Generated by: LCOV version 1.7