os/graphics/graphicsdeviceinterface/directgdiadaptation/swsrc/swdirectgdipolygon.h
Update contrib.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef SWDIRECTGDIPOLYGON_H
17 #define SWDIRECTGDIPOLYGON_H
24 #include "directgdiadapter.h"
29 A utility class to efficiently fill polygons.
30 @see CSwDirectGdiEngine::PolyFill
31 @see CSwDirectGdiEngine::PolyFillLarge
33 NONSHARABLE_CLASS(CSwDirectGdiPolygonFiller) : public CBase
38 Describes how pixels are to be displayed in the polygon. aUsage should be set to
39 one of these values before CSwDirectGdiPolygonFiller::Construct is used.
44 A request for all pixel runs in sequential order.
46 EGetAllPixelRunsSequentially,
48 A request for all pixel runs in sequential order but only for specified lines.
50 EGetPixelRunsSequentiallyForSpecifiedScanLines
53 CSwDirectGdiPolygonFiller();
54 ~CSwDirectGdiPolygonFiller();
55 void Construct(const TArray<TPoint>* aPointArray, DirectGdi::TFillRule aFillRule,TUsage aUsage=EGetAllPixelRunsSequentially); // N.B. this cannot fail
56 void Construct(const TPoint* aPointList,TInt aNumPoints, DirectGdi::TFillRule aFillRule, TUsage aUsage=EGetAllPixelRunsSequentially); // N.B. this cannot fail
58 void GetNextPixelRun(TBool& aExists, TInt& aScanLine, TInt& aStart, TInt& aEnd);
59 void GetNextPixelRunOnSpecifiedScanLine(TBool& aExists, TInt aScanLine, TInt& aStart, TInt& aEnd);
60 private: // data-types for the fast algorithm
67 struct SFastScanLineIntersection;
68 struct SFastActiveEdge
71 TLinearDDA lineGenerator;
72 SFastScanLineIntersection* scanLineIntersectionPtr;
74 struct SFastScanLineIntersection
78 SFastActiveEdge* activeEdgePtr;
80 private: // data-types for the slow algorithm
81 struct SSlowScanLineIntersection
85 TInt firstVertexOfEdge;
87 private: // data-types for both algorithms
92 SFastActiveEdge* activeEdgeList;
93 SFastScanLineIntersection* scanLineIntersectionList;
95 TInt numScanLineIntersections;
96 TInt nextEdgeToActivate;
101 TLinearDDA lineGenerator;
102 SSlowScanLineIntersection scanLineIntersectionList[EStoreSize];
103 TInt numIntersectionsWithSameFirstPixelPreviouslyMet;
104 TInt numIntersectionsWithSameFirstPixelMetThisTime;
105 TInt numScanLineIntersections;
106 TBool scanLineComplete;
107 TInt firstPixelOfLastIntersectionInPrevBuffer;
110 void Construct(DirectGdi::TFillRule aFillRule, TUsage aUsage);
111 void FastHandleVertexIntersection(TInt& aCurrentActiveEdge, TBool aIsLowerVertex);
112 void SetFastIntersection(SFastActiveEdge& aActiveEdge, SFastScanLineIntersection& aScanLineIntersection);
113 void SlowHandleVertexIntersection(SSlowScanLineIntersection& aScanLineIntersection, TInt& aVertexStartingCurrentEdge,TBool aIsLowerVertex);
114 void JumpToCurrentScanLine(TLinearDDA& aLineGenerator, const TPoint& aUpper, const TPoint& aLower,TPoint& aStartPos, TPoint& aEndPos) const;
115 const TPoint& Point(TInt aIndex);
117 const TArray<TPoint>* iPointArray; // not owned by the class
118 DirectGdi::TFillRule iFillRule;
119 TBool iUseFastAlgorithm;
121 TBool iToggler; // used by EAlternate fill-rule
122 TInt iNestingLevel; // used by EWinding fill-rule
123 TInt iScanLineIntersection;
124 TInt iRightMostPixelOnScanLine;
126 TBool iPolygonIsAllHorizontal;
129 TInt iCurrentScanLine;
133 friend class TCompareEdgesUpperY;
134 friend class TCompareActiveEdgesFirstVertex;
135 friend class TCompareScanLineIntersectionsFirstPixel;
136 friend class TSwapEdges;
137 friend class TSwapActiveEdges;
138 friend class TSwapScanLineIntersections;
141 #endif /*SWDIRECTGDIPOLYGON_H*/