os/graphics/graphicsdeviceinterface/directgdiadaptation/swsrc/swdirectgdipolygon.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicsdeviceinterface/directgdiadaptation/swsrc/swdirectgdipolygon.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,142 @@
     1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#ifndef SWDIRECTGDIPOLYGON_H
    1.20 +#define SWDIRECTGDIPOLYGON_H
    1.21 +
    1.22 +/**
    1.23 +@file
    1.24 +@internalComponent
    1.25 +*/
    1.26 +
    1.27 +#include "directgdiadapter.h"
    1.28 +#include <gdi.h>
    1.29 +#include <e32base.h>
    1.30 +
    1.31 +/**
    1.32 +A utility class to efficiently fill polygons.
    1.33 +@see CSwDirectGdiEngine::PolyFill
    1.34 +@see CSwDirectGdiEngine::PolyFillLarge
    1.35 +*/
    1.36 +NONSHARABLE_CLASS(CSwDirectGdiPolygonFiller) : public CBase
    1.37 +	{
    1.38 +public:
    1.39 +
    1.40 +	/**
    1.41 +	Describes how pixels are to be displayed in the polygon. aUsage should be set to
    1.42 +	one of these values before CSwDirectGdiPolygonFiller::Construct is used.
    1.43 +	*/
    1.44 +	enum TUsage
    1.45 +		{
    1.46 +		/**
    1.47 +		A request for all pixel runs in sequential order.
    1.48 +		*/
    1.49 +		EGetAllPixelRunsSequentially,
    1.50 +		/**
    1.51 +		A request for all pixel runs in sequential order but only for specified lines.
    1.52 +		*/
    1.53 +		EGetPixelRunsSequentiallyForSpecifiedScanLines
    1.54 +		};
    1.55 +public:
    1.56 +	CSwDirectGdiPolygonFiller();
    1.57 +	~CSwDirectGdiPolygonFiller();
    1.58 +	void Construct(const TArray<TPoint>* aPointArray, DirectGdi::TFillRule aFillRule,TUsage aUsage=EGetAllPixelRunsSequentially); // N.B. this cannot fail
    1.59 +	void Construct(const TPoint* aPointList,TInt aNumPoints, DirectGdi::TFillRule aFillRule, TUsage aUsage=EGetAllPixelRunsSequentially); // N.B. this cannot fail
    1.60 +	void Reset();
    1.61 +	void GetNextPixelRun(TBool& aExists, TInt& aScanLine, TInt& aStart, TInt& aEnd);
    1.62 +	void GetNextPixelRunOnSpecifiedScanLine(TBool& aExists, TInt aScanLine, TInt& aStart, TInt& aEnd);
    1.63 +private: // data-types for the fast algorithm
    1.64 +	struct SFastEdge
    1.65 +		{
    1.66 +		TInt upperVertex;
    1.67 +		TInt lowerVertex;
    1.68 +		TInt firstVertex;
    1.69 +		};
    1.70 +	struct SFastScanLineIntersection;
    1.71 +	struct SFastActiveEdge
    1.72 +		{
    1.73 +		SFastEdge* edgePtr;
    1.74 +		TLinearDDA lineGenerator;
    1.75 +		SFastScanLineIntersection* scanLineIntersectionPtr;
    1.76 +		};
    1.77 +	struct SFastScanLineIntersection
    1.78 +		{
    1.79 +		TInt firstPixel;
    1.80 +		TInt lastPixel;
    1.81 +		SFastActiveEdge* activeEdgePtr;
    1.82 +		};
    1.83 +private: // data-types for the slow algorithm
    1.84 +	struct SSlowScanLineIntersection
    1.85 +		{
    1.86 +		TInt firstPixel;
    1.87 +		TInt lastPixel;
    1.88 +		TInt firstVertexOfEdge;
    1.89 +		};
    1.90 +private: // data-types for both algorithms
    1.91 +	struct SFastData
    1.92 +		{
    1.93 +		TPoint* vertexList;
    1.94 +		SFastEdge* edgeList;
    1.95 +		SFastActiveEdge* activeEdgeList;
    1.96 +		SFastScanLineIntersection* scanLineIntersectionList;
    1.97 +		TInt numActiveEdges;
    1.98 +		TInt numScanLineIntersections;
    1.99 +		TInt nextEdgeToActivate;
   1.100 +		};
   1.101 +	struct SSlowData
   1.102 +		{
   1.103 +		enum {EStoreSize=8};
   1.104 +		TLinearDDA lineGenerator;
   1.105 +		SSlowScanLineIntersection scanLineIntersectionList[EStoreSize];
   1.106 +		TInt numIntersectionsWithSameFirstPixelPreviouslyMet;
   1.107 +		TInt numIntersectionsWithSameFirstPixelMetThisTime;
   1.108 +		TInt numScanLineIntersections;
   1.109 +		TBool scanLineComplete;
   1.110 +		TInt firstPixelOfLastIntersectionInPrevBuffer;
   1.111 +		};
   1.112 +private:
   1.113 +	void Construct(DirectGdi::TFillRule aFillRule, TUsage aUsage);
   1.114 +	void FastHandleVertexIntersection(TInt& aCurrentActiveEdge, TBool aIsLowerVertex);
   1.115 +	void SetFastIntersection(SFastActiveEdge& aActiveEdge, SFastScanLineIntersection& aScanLineIntersection);
   1.116 +	void SlowHandleVertexIntersection(SSlowScanLineIntersection& aScanLineIntersection, TInt& aVertexStartingCurrentEdge,TBool aIsLowerVertex);
   1.117 +	void JumpToCurrentScanLine(TLinearDDA& aLineGenerator, const TPoint& aUpper, const TPoint& aLower,TPoint& aStartPos, TPoint& aEndPos) const;
   1.118 +	const TPoint& Point(TInt aIndex);
   1.119 +private:
   1.120 +	const TArray<TPoint>* iPointArray; // not owned by the class
   1.121 +	DirectGdi::TFillRule iFillRule;
   1.122 +	TBool iUseFastAlgorithm;
   1.123 +	TInt iNumVertexes;
   1.124 +	TBool iToggler; // used by EAlternate fill-rule
   1.125 +	TInt iNestingLevel; // used by EWinding fill-rule
   1.126 +	TInt iScanLineIntersection;
   1.127 +	TInt iRightMostPixelOnScanLine;
   1.128 +	TInt iFirstVertex;
   1.129 +	TBool iPolygonIsAllHorizontal;
   1.130 +	TInt iFirstScanLine;
   1.131 +	TInt iLastScanLine;
   1.132 +	TInt iCurrentScanLine;
   1.133 +	SFastData iFastData;
   1.134 +	SSlowData iSlowData;
   1.135 +private:
   1.136 +	friend class TCompareEdgesUpperY;
   1.137 +	friend class TCompareActiveEdgesFirstVertex;
   1.138 +	friend class TCompareScanLineIntersectionsFirstPixel;
   1.139 +	friend class TSwapEdges;
   1.140 +	friend class TSwapActiveEdges;
   1.141 +	friend class TSwapScanLineIntersections;
   1.142 +	};
   1.143 +
   1.144 +#endif /*SWDIRECTGDIPOLYGON_H*/
   1.145 +