svgtopt/gfx2d/inc/GfxEdgeListP.h
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 header file
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef GFXEDGELISTP_H
       
    20 #define GFXEDGELISTP_H
       
    21 
       
    22 #include <e32std.h>
       
    23 #include <e32base.h>
       
    24 
       
    25 #include "GfxFloatFixPt.h"
       
    26 
       
    27 class TSegSet;
       
    28 class TGfxRendererInfoP;
       
    29 
       
    30 
       
    31 //****************************************************
       
    32 
       
    33 enum TAddSegStatus
       
    34     {
       
    35     ESegAdd,
       
    36     ESegMerge,
       
    37     ESegStartNew,
       
    38     ESegIgnore
       
    39     };
       
    40 
       
    41 /**
       
    42  *  Helping class to store a point using 16 bits for each value.
       
    43  *
       
    44  *  @lib Gfx2D.lib
       
    45  *  @since 1.0
       
    46  */
       
    47 class TPoint16
       
    48     {
       
    49     public:
       
    50         TInt16  iX;
       
    51         TInt16  iY;
       
    52     };
       
    53 
       
    54 /**
       
    55  *  Helping class to store a size using 16 bits for each value.
       
    56  *
       
    57  *  @lib Gfx2D.lib
       
    58  *  @since 1.0
       
    59  */
       
    60 class TSize16
       
    61     {
       
    62     public:
       
    63         TInt16  iWidth;
       
    64         TInt16  iHeight;
       
    65     };
       
    66 
       
    67 /**
       
    68  *  Helping class to store a segment edge info.
       
    69  *
       
    70  *  @lib Gfx2D.lib
       
    71  *  @since 1.0
       
    72  */
       
    73 class TGfxSegEdge
       
    74     {
       
    75     public:
       
    76         TInt16          iStart;
       
    77         TInt16          iEnd;
       
    78         TInt16          iOnlyForFill;
       
    79         TInt16          iSign;
       
    80         TGfxSegEdge*    iNext;
       
    81     };
       
    82 
       
    83 /**
       
    84  *  Helping class to store a segment set info.
       
    85  *
       
    86  *  @lib Gfx2D.lib
       
    87  *  @since 1.0
       
    88  */
       
    89 class TSegSet
       
    90     {
       
    91     public:
       
    92         /**
       
    93          * Constructor
       
    94          *
       
    95          * @since 1.0
       
    96          * @param aP1 : initial segment point 1
       
    97          * @param aP2 : initial segment point 2
       
    98          * @return
       
    99          */
       
   100         void            Construct( TPoint16* aP1, TPoint16* aP2 );
       
   101 
       
   102         /**
       
   103          * Add a new segment to this set.
       
   104          *
       
   105          * @since 1.0
       
   106          * @param aX : x coordinate of new segment end point
       
   107          * @param aY : y coordinate of new segment end point
       
   108          * @param aLastSegLenSq : storage for new segment length squared value
       
   109          * @param aClosePath : flag to indicate closing of path.
       
   110          * @return
       
   111          */
       
   112         TAddSegStatus   AddSegment( TInt aX,
       
   113                                     TInt aY,
       
   114                                     TUint& aLastSegLenSq,
       
   115                                     TBool aClosePath );
       
   116 
       
   117         /**
       
   118          *
       
   119          *
       
   120          * @since 1.0
       
   121          * @param aX1 :
       
   122          * @param aX2 :
       
   123          * @return
       
   124          */
       
   125         TBool           GetEdge( TInt& aX1, TInt& aX2 );
       
   126 
       
   127 
       
   128         /**
       
   129          * Initialize the Digital Differential Analyzer (DDA)
       
   130          *
       
   131          * @since 1.0
       
   132          * @return
       
   133          */
       
   134         void            InitDDA();
       
   135 
       
   136     public:
       
   137         TPoint16*       iTopPoint;
       
   138         TPoint16*       iBottomPoint;
       
   139         TPoint16*       iFillOnlySeg;
       
   140         TSegSet*        iNext;
       
   141         TSegSet*        iConnect;
       
   142 
       
   143         TInt16          iPointAryInc;     // -1 or 1
       
   144         TInt16          iSign;        // -1, 0, or 1
       
   145         TInt16          iValid;
       
   146         TInt16          iActualBottomY;
       
   147         TInt16          iConnectFlag;
       
   148 
       
   149     protected:
       
   150         // DDA info
       
   151         TPoint16*       iStart;
       
   152         TPoint16*       iFinish;
       
   153 
       
   154         TPoint16        iInc;
       
   155         TPoint16        iPos;
       
   156         TSize16         iDifference;
       
   157         TInt16          iGradient;
       
   158         TInt16          iCount;
       
   159         TInt16          iStatus;
       
   160 
       
   161     protected:
       
   162 
       
   163         /**
       
   164          * Construct the Digital Differential Analyzer (DDA)
       
   165          *
       
   166          * @since 1.0
       
   167          * @param aStart : start point
       
   168          * @param aFinish : end point
       
   169          * @return
       
   170          */
       
   171         void            ConstructDDA( TPoint16* aStart, TPoint16* aFinish );
       
   172 
       
   173         /**
       
   174          *
       
   175          *
       
   176          * @since 1.0
       
   177          * @param aPosition :
       
   178          * @return
       
   179          */
       
   180         TBool           SingleStep( TPoint16& aPosition );
       
   181 
       
   182         /**
       
   183          *
       
   184          *
       
   185          * @since 1.0
       
   186          * @param aStartPosition :
       
   187          * @param aEndPosition :
       
   188          * @return
       
   189          */
       
   190         TBool           SingleScanline( TPoint16& aStartPosition,
       
   191                                         TPoint16& aEndPosition );
       
   192 
       
   193         /**
       
   194          *
       
   195          *
       
   196          * @since 1.0
       
   197          * @return
       
   198          */
       
   199         void            UpdatePosition();
       
   200     };
       
   201 
       
   202 
       
   203 
       
   204 
       
   205 /**
       
   206  * This class maintains a list of segment edges, used for scanning a line
       
   207  * inside two edges.
       
   208  *
       
   209  *  @lib SVGEngine.lib
       
   210  *  @since 1.0
       
   211  */
       
   212 class CGfxEdgeListP : public CBase
       
   213     {
       
   214     public:
       
   215 
       
   216         /**
       
   217          * Two-phase constructor.
       
   218          *
       
   219          * @since 1.0
       
   220          * @param aRenderInfo : rendering info
       
   221          * @return
       
   222          */
       
   223         static CGfxEdgeListP*   NewLC( TGfxRendererInfoP* aRenderInfo );
       
   224 
       
   225         /**
       
   226          * Two-phase constructor.
       
   227          *
       
   228          * @since 1.0
       
   229          * @param aRenderInfo : rendering info
       
   230          * @return
       
   231          */
       
   232         static CGfxEdgeListP*   NewL( TGfxRendererInfoP* aRenderInfo );
       
   233 
       
   234         /**
       
   235          * Destructor.
       
   236          *
       
   237          * @since 1.0
       
   238          * @return
       
   239          */
       
   240                                 ~CGfxEdgeListP();
       
   241 
       
   242     public:
       
   243 
       
   244         /**
       
   245          * Get the start point in the edge list.
       
   246          *
       
   247          * @since 1.0
       
   248          * @param aX : storage for starting point x coordinate.
       
   249          * @param aY : storage for starting point y coordinate.
       
   250          * @return
       
   251          */
       
   252         void                    StartPoint( TFloatFixPt& aX, TFloatFixPt& aY );
       
   253 
       
   254         /**
       
   255          * Add a new point to this list.
       
   256          *
       
   257          * @since 1.0
       
   258          * @param aX : x coordinate of point
       
   259          * @param aY : y coordinate of point
       
   260          * @param aFillOnly : fill-onyl flag
       
   261          * @param aClosePath : close-path flag
       
   262          * @return
       
   263          */
       
   264          void                   AddPoint( TFloatFixPt & aX,
       
   265                                           TFloatFixPt & aY,
       
   266                                           TBool aFillOnly,
       
   267                                           TBool aClosePath );
       
   268         /**
       
   269          * Clear all points in this list.
       
   270          *
       
   271          * @since 1.0
       
   272          * @return
       
   273          */
       
   274         void                    Reset();
       
   275 
       
   276         /**
       
   277          * Intialize this edge list.
       
   278          *
       
   279          * @since 1.0
       
   280          * @return
       
   281          */
       
   282         void                    SetupEdgeList();
       
   283 
       
   284         /**
       
   285          * Update the active edge.
       
   286          *
       
   287          * @since 1.0
       
   288          * @param aY : line y coordinate
       
   289          * @return
       
   290          */
       
   291         void                    UpdateActiveEdge( TInt aY );
       
   292 
       
   293         /**
       
   294          * Get the active segment edge.
       
   295          *
       
   296          * @since 1.0
       
   297          * @return segment edge.
       
   298          */
       
   299         TGfxSegEdge*            EdgeList();
       
   300 
       
   301         /**
       
   302          * Adjust the level of detail to the given vertex size.
       
   303          *
       
   304          * @since 1.0
       
   305          * @param aVertexSize : vertex size
       
   306          * @return
       
   307          */
       
   308         void                AdjustShapeComplexityL( TInt32 aVertexSize );
       
   309 
       
   310     protected:
       
   311 
       
   312         /**
       
   313          * Constructor
       
   314          *
       
   315          * @since 1.0
       
   316          * @return
       
   317          */
       
   318                             CGfxEdgeListP();
       
   319 
       
   320         /**
       
   321          * Constructor
       
   322          *
       
   323          * @since 1.0
       
   324          * @param iRenderInfo : rendering info
       
   325          * @return
       
   326          */
       
   327                             CGfxEdgeListP( TGfxRendererInfoP* iRenderInfo );
       
   328 
       
   329         /**
       
   330          * Second-phase of construction
       
   331          *
       
   332          * @since 1.0
       
   333          * @return
       
   334          */
       
   335         void                ConstructL();
       
   336 
       
   337     private:
       
   338 
       
   339         /**
       
   340          * Add a new edge.
       
   341          *
       
   342          * @since 1.0
       
   343          * @param aSt : start point
       
   344          * @param aEd : end point
       
   345          * @return
       
   346          */
       
   347         TGfxSegEdge*        AddEdge( TInt32 aSt, TInt32 aEd );//, TInt aSegSign);
       
   348 
       
   349         /**
       
   350          * Add the given set of segments to this list.
       
   351          *
       
   352          * @since 1.0
       
   353          * @param aWaitingList : flag to wait
       
   354          * @param aSegSet : set of segments
       
   355          * @return
       
   356          */
       
   357         void                InsertToList( TBool aWaitingList, TSegSet& aSegSet );
       
   358 
       
   359         /**
       
   360          * Check and Connect
       
   361          *
       
   362          * @since 1.0
       
   363          * @return
       
   364          */
       
   365         void                CheckAndConnect();
       
   366 
       
   367         /**
       
   368          * Simple update of active edge.
       
   369          *
       
   370          * @since 1.0
       
   371          * @param aY : line y coordinate
       
   372          * @return
       
   373          */
       
   374         void                UpdateActiveEdgeSimple( TInt aY );
       
   375 
       
   376     protected:
       
   377         TInt32              iMinX, iMinY;
       
   378         TInt32              iMaxX, iMaxY;
       
   379 
       
   380         TGfxSegEdge*        iEdges;
       
   381         TInt                iEdgesCount;
       
   382 
       
   383         TUint               iPolygonAreaSize;
       
   384         TUint               iLastSegLenSq;
       
   385 
       
   386         TPoint16*           iPoints;
       
   387         TSegSet*            iSegset;
       
   388         TSegSet*            iWaitingSegList;
       
   389         TSegSet*            iActiveSegList;
       
   390         TGfxSegEdge*        iSortedEdges;
       
   391 
       
   392         TInt                iPointsCount;
       
   393        TInt                iSegsetCount;
       
   394         TInt                iPointsCountMax;
       
   395         TInt                iSegsetCountMax;
       
   396         TInt                iEdgesCountMax;
       
   397 
       
   398         TGfxRendererInfoP*  iRenderInfo;
       
   399 
       
   400     private:
       
   401         TSegSet*            iSegListForSimple[2];
       
   402         TSegSet*            iStartSeg;
       
   403         TBool               iIsNewOutlineStarted;
       
   404         TInt                iSubPathSegmentCount;
       
   405 
       
   406     private:
       
   407         friend class        TGfxPolygonRendererP;
       
   408         friend class        TGfxStrokeRendererP;
       
   409         friend class        CGfx2dGc;
       
   410         friend class        TSegSet;
       
   411     };
       
   412 
       
   413 #endif      // GFXEDGELISTP_H
       
   414