sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #ifndef SWDIRECTGDIPOLYGON_H sl@0: #define SWDIRECTGDIPOLYGON_H sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: */ sl@0: sl@0: #include "directgdiadapter.h" sl@0: #include sl@0: #include sl@0: sl@0: /** sl@0: A utility class to efficiently fill polygons. sl@0: @see CSwDirectGdiEngine::PolyFill sl@0: @see CSwDirectGdiEngine::PolyFillLarge sl@0: */ sl@0: NONSHARABLE_CLASS(CSwDirectGdiPolygonFiller) : public CBase sl@0: { sl@0: public: sl@0: sl@0: /** sl@0: Describes how pixels are to be displayed in the polygon. aUsage should be set to sl@0: one of these values before CSwDirectGdiPolygonFiller::Construct is used. sl@0: */ sl@0: enum TUsage sl@0: { sl@0: /** sl@0: A request for all pixel runs in sequential order. sl@0: */ sl@0: EGetAllPixelRunsSequentially, sl@0: /** sl@0: A request for all pixel runs in sequential order but only for specified lines. sl@0: */ sl@0: EGetPixelRunsSequentiallyForSpecifiedScanLines sl@0: }; sl@0: public: sl@0: CSwDirectGdiPolygonFiller(); sl@0: ~CSwDirectGdiPolygonFiller(); sl@0: void Construct(const TArray* aPointArray, DirectGdi::TFillRule aFillRule,TUsage aUsage=EGetAllPixelRunsSequentially); // N.B. this cannot fail sl@0: void Construct(const TPoint* aPointList,TInt aNumPoints, DirectGdi::TFillRule aFillRule, TUsage aUsage=EGetAllPixelRunsSequentially); // N.B. this cannot fail sl@0: void Reset(); sl@0: void GetNextPixelRun(TBool& aExists, TInt& aScanLine, TInt& aStart, TInt& aEnd); sl@0: void GetNextPixelRunOnSpecifiedScanLine(TBool& aExists, TInt aScanLine, TInt& aStart, TInt& aEnd); sl@0: private: // data-types for the fast algorithm sl@0: struct SFastEdge sl@0: { sl@0: TInt upperVertex; sl@0: TInt lowerVertex; sl@0: TInt firstVertex; sl@0: }; sl@0: struct SFastScanLineIntersection; sl@0: struct SFastActiveEdge sl@0: { sl@0: SFastEdge* edgePtr; sl@0: TLinearDDA lineGenerator; sl@0: SFastScanLineIntersection* scanLineIntersectionPtr; sl@0: }; sl@0: struct SFastScanLineIntersection sl@0: { sl@0: TInt firstPixel; sl@0: TInt lastPixel; sl@0: SFastActiveEdge* activeEdgePtr; sl@0: }; sl@0: private: // data-types for the slow algorithm sl@0: struct SSlowScanLineIntersection sl@0: { sl@0: TInt firstPixel; sl@0: TInt lastPixel; sl@0: TInt firstVertexOfEdge; sl@0: }; sl@0: private: // data-types for both algorithms sl@0: struct SFastData sl@0: { sl@0: TPoint* vertexList; sl@0: SFastEdge* edgeList; sl@0: SFastActiveEdge* activeEdgeList; sl@0: SFastScanLineIntersection* scanLineIntersectionList; sl@0: TInt numActiveEdges; sl@0: TInt numScanLineIntersections; sl@0: TInt nextEdgeToActivate; sl@0: }; sl@0: struct SSlowData sl@0: { sl@0: enum {EStoreSize=8}; sl@0: TLinearDDA lineGenerator; sl@0: SSlowScanLineIntersection scanLineIntersectionList[EStoreSize]; sl@0: TInt numIntersectionsWithSameFirstPixelPreviouslyMet; sl@0: TInt numIntersectionsWithSameFirstPixelMetThisTime; sl@0: TInt numScanLineIntersections; sl@0: TBool scanLineComplete; sl@0: TInt firstPixelOfLastIntersectionInPrevBuffer; sl@0: }; sl@0: private: sl@0: void Construct(DirectGdi::TFillRule aFillRule, TUsage aUsage); sl@0: void FastHandleVertexIntersection(TInt& aCurrentActiveEdge, TBool aIsLowerVertex); sl@0: void SetFastIntersection(SFastActiveEdge& aActiveEdge, SFastScanLineIntersection& aScanLineIntersection); sl@0: void SlowHandleVertexIntersection(SSlowScanLineIntersection& aScanLineIntersection, TInt& aVertexStartingCurrentEdge,TBool aIsLowerVertex); sl@0: void JumpToCurrentScanLine(TLinearDDA& aLineGenerator, const TPoint& aUpper, const TPoint& aLower,TPoint& aStartPos, TPoint& aEndPos) const; sl@0: const TPoint& Point(TInt aIndex); sl@0: private: sl@0: const TArray* iPointArray; // not owned by the class sl@0: DirectGdi::TFillRule iFillRule; sl@0: TBool iUseFastAlgorithm; sl@0: TInt iNumVertexes; sl@0: TBool iToggler; // used by EAlternate fill-rule sl@0: TInt iNestingLevel; // used by EWinding fill-rule sl@0: TInt iScanLineIntersection; sl@0: TInt iRightMostPixelOnScanLine; sl@0: TInt iFirstVertex; sl@0: TBool iPolygonIsAllHorizontal; sl@0: TInt iFirstScanLine; sl@0: TInt iLastScanLine; sl@0: TInt iCurrentScanLine; sl@0: SFastData iFastData; sl@0: SSlowData iSlowData; sl@0: private: sl@0: friend class TCompareEdgesUpperY; sl@0: friend class TCompareActiveEdgesFirstVertex; sl@0: friend class TCompareScanLineIntersectionsFirstPixel; sl@0: friend class TSwapEdges; sl@0: friend class TSwapActiveEdges; sl@0: friend class TSwapScanLineIntersections; sl@0: }; sl@0: sl@0: #endif /*SWDIRECTGDIPOLYGON_H*/ sl@0: