Home | History | Annotate | Download | only in openvg
      1 /*
      2  * Copyright (C) Research In Motion Limited 2009. All rights reserved.
      3  *
      4  * This library is free software; you can redistribute it and/or
      5  * modify it under the terms of the GNU Library General Public
      6  * License as published by the Free Software Foundation; either
      7  * version 2 of the License, or (at your option) any later version.
      8  *
      9  * This library is distributed in the hope that it will be useful,
     10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     12  * Library General Public License for more details.
     13  *
     14  * You should have received a copy of the GNU Library General Public License
     15  * along with this library; see the file COPYING.LIB.  If not, write to
     16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     17  * Boston, MA 02110-1301, USA.
     18  */
     19 
     20 #include "config.h"
     21 #include "VGUtils.h"
     22 
     23 #include "FloatRect.h"
     24 #include "TransformationMatrix.h"
     25 
     26 namespace WebCore {
     27 
     28 VGMatrix::VGMatrix(const VGfloat data[9])
     29 {
     30     m_data[0] = data[0];
     31     m_data[1] = data[1];
     32     m_data[2] = data[2];
     33     m_data[3] = data[3];
     34     m_data[4] = data[4];
     35     m_data[5] = data[5];
     36     m_data[6] = data[6];
     37     m_data[7] = data[7];
     38     m_data[8] = data[8];
     39 }
     40 
     41 VGMatrix::VGMatrix(const TransformationMatrix& matrix)
     42 {
     43     m_data[0] = matrix.m11();
     44     m_data[1] = matrix.m12();
     45     m_data[2] = matrix.m14();
     46     m_data[3] = matrix.m21();
     47     m_data[4] = matrix.m22();
     48     m_data[5] = matrix.m24();
     49     m_data[6] = matrix.m41();
     50     m_data[7] = matrix.m42();
     51     m_data[8] = matrix.m44();
     52 }
     53 
     54 VGMatrix::operator TransformationMatrix() const
     55 {
     56     TransformationMatrix matrix;
     57     matrix.setM11(m_data[0]);
     58     matrix.setM12(m_data[1]);
     59     matrix.setM14(m_data[2]);
     60     matrix.setM21(m_data[3]);
     61     matrix.setM22(m_data[4]);
     62     matrix.setM24(m_data[5]);
     63     matrix.setM41(m_data[6]);
     64     matrix.setM42(m_data[7]);
     65     matrix.setM44(m_data[8]);
     66     return matrix;
     67 }
     68 
     69 TransformationMatrix::operator VGMatrix() const
     70 {
     71     return VGMatrix(*this);
     72 }
     73 
     74 VGRect::VGRect(const VGfloat data[4])
     75 {
     76     m_data[0] = data[0];
     77     m_data[1] = data[1];
     78     m_data[2] = data[2];
     79     m_data[3] = data[3];
     80 }
     81 
     82 VGRect::VGRect(const FloatRect& rect)
     83 {
     84     m_data[0] = rect.x();
     85     m_data[1] = rect.y();
     86     m_data[2] = rect.width();
     87     m_data[3] = rect.height();
     88 }
     89 
     90 VGRect::operator FloatRect() const
     91 {
     92     return FloatRect(m_data[0], m_data[1], m_data[2], m_data[3]);
     93 }
     94 
     95 FloatRect::operator VGRect() const
     96 {
     97     return VGRect(*this);
     98 }
     99 
    100 }
    101