svgtopt/gfx2d/src/GfxGeom/GfxGeneralPathIteratorP.cpp
changeset 46 88edb906c587
equal deleted inserted replaced
-1:000000000000 46:88edb906c587
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Graphics Extension Library source file
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "GfxGeneralPathIteratorP.h"
       
    20 #include "GfxGeneralPath.h"
       
    21 
       
    22 
       
    23 
       
    24 // --------------------------------------------------------------------------
       
    25 //  CGfxGeneralPathIteratorP::CGfxGeneralPathIteratorP( CGfxGeneralPath* aPath,
       
    26 // ---------------------------------------------------------------------------
       
    27  CGfxGeneralPathIteratorP::CGfxGeneralPathIteratorP( CGfxGeneralPath* aPath,
       
    28                                                              TGfxAffineTransform* aTransform )
       
    29     {
       
    30     iPath = aPath;
       
    31     iTransform = aTransform;
       
    32     }
       
    33 
       
    34 //
       
    35 // ---------------------------------------------------------------------------
       
    36 // Destructor.
       
    37 // ---------------------------------------------------------------------------
       
    38 // --------------------------------------------------------------------------
       
    39 //  CGfxGeneralPathIteratorP::~CGfxGeneralPathIteratorP()
       
    40 // ---------------------------------------------------------------------------
       
    41  CGfxGeneralPathIteratorP::~CGfxGeneralPathIteratorP()
       
    42     {
       
    43     }
       
    44 
       
    45 
       
    46 
       
    47 // --------------------------------------------------------------------------
       
    48 //  TGfxSegType CGfxGeneralPathIteratorP::CurrentSegment( TFloatFixPt* aCoords )
       
    49 // ---------------------------------------------------------------------------
       
    50  TGfxSegType CGfxGeneralPathIteratorP::CurrentSegment( TFloatFixPt* aCoords )
       
    51     {
       
    52     TGfxSegType segtype = EGfxSegClose;
       
    53     TInt32 pts = 1;
       
    54 
       
    55     TFloatFixPt* pd = aCoords;
       
    56     if(iPath->iPointCoords->Count() <= 0)
       
    57 		{
       
    58 		return segtype;
       
    59 		}
       
    60     TFloatFixPt* ps = &( iPath->iPointCoords->operator[]( 0 ) );
       
    61     switch ( ( TGfxSegType ) ( *( iPath->iPointTypes ) )[iTypeIdx] )
       
    62         {
       
    63         case EGfxSegMoveTo:
       
    64             pd[0] = ps[iPointIdx];
       
    65             pd[1] = ps[iPointIdx + 1];
       
    66             iStartPoint.iX = pd[0];
       
    67             iStartPoint.iY = pd[1];
       
    68             segtype = EGfxSegMoveTo;
       
    69             break;
       
    70         case EGfxSegLineTo:
       
    71             pd[0] = ps[iPointIdx];
       
    72             pd[1] = ps[iPointIdx + 1];
       
    73             segtype = EGfxSegLineTo;
       
    74             break;
       
    75         case EGfxSegQuadTo:
       
    76             pd[0] = ps[iPointIdx];
       
    77             pd[1] = ps[iPointIdx + 1];
       
    78             pd[2] = ps[iPointIdx + 2];
       
    79             pd[3] = ps[iPointIdx + 3];
       
    80             segtype = EGfxSegQuadTo;
       
    81             pts = 2;
       
    82             break;
       
    83         case EGfxSegCubicTo:
       
    84             pd[0] = ps[iPointIdx];
       
    85             pd[1] = ps[iPointIdx + 1];
       
    86             pd[2] = ps[iPointIdx + 2];
       
    87             pd[3] = ps[iPointIdx + 3];
       
    88             pd[4] = ps[iPointIdx + 4];
       
    89             pd[5] = ps[iPointIdx + 5];
       
    90             segtype = EGfxSegCubicTo;
       
    91             pts = 3;
       
    92             break;
       
    93         case EGfxSegClose:
       
    94             pd[0] = iStartPoint.iX;
       
    95             pd[1] = iStartPoint.iY;
       
    96             segtype = EGfxSegClose;
       
    97             break;
       
    98         default:
       
    99             segtype = EGfxSegClose;
       
   100             pts = 0;
       
   101             break;
       
   102         }
       
   103 
       
   104     if ( !iTransform->IsIdentity() && pts > 0 )
       
   105         {
       
   106         iTransform->Transform( aCoords, aCoords, pts );
       
   107         }
       
   108 
       
   109     return segtype;
       
   110     }
       
   111 
       
   112 // --------------------------------------------------------------------------
       
   113 //  TBool CGfxGeneralPathIteratorP::IsDone()
       
   114 // ---------------------------------------------------------------------------
       
   115  TBool CGfxGeneralPathIteratorP::IsDone()
       
   116     {
       
   117     return ( iPath->iPointTypes->Count() <= iTypeIdx );
       
   118     }
       
   119 
       
   120 // --------------------------------------------------------------------------
       
   121 //  void CGfxGeneralPathIteratorP::Next()
       
   122 // ---------------------------------------------------------------------------
       
   123  void CGfxGeneralPathIteratorP::NextL()
       
   124     {
       
   125     if ( iPath->iPointTypes->Count() <= iTypeIdx - 1 )
       
   126         {
       
   127         return;
       
   128         }
       
   129     switch ( ( TGfxSegType ) ( *( iPath->iPointTypes ) )[iTypeIdx] )
       
   130         {
       
   131         case EGfxSegMoveTo:
       
   132             iPointIdx += 2;
       
   133             break;
       
   134         case EGfxSegLineTo:
       
   135             iPointIdx += 2;
       
   136             break;
       
   137         case EGfxSegQuadTo:
       
   138             iPointIdx += 4;
       
   139             break;
       
   140         case EGfxSegCubicTo:
       
   141             iPointIdx += 6;
       
   142             break;
       
   143         default:
       
   144             break;
       
   145         }
       
   146 
       
   147     iTypeIdx++;
       
   148     }
       
   149