os/graphics/graphicsdeviceinterface/directgdiadaptation/hwsrc/clippingregionmanager.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 
    17 #ifndef CLIPPINGREGIONMANAGER_H_
    18 #define CLIPPINGREGIONMANAGER_H_
    19 
    20 #include <VG/openvg.h>
    21 #include <e32std.h>
    22 
    23 /** 
    24 Defines a rectangle of VGint coordinates for use when passing clipping rectangles to OpenVG.
    25 */
    26 struct TVgClippingRect
    27 	{
    28 	VGint iX;
    29 	VGint iY;
    30 	VGint iWidth;
    31 	VGint iHeight;
    32 	};
    33 
    34 /**
    35 Helper for managing clipping (OpenVG: scissoring) regions within CVGEngine.
    36 
    37 OpenVG supports only a fixed number of clipping rects (actual number is defined by 
    38 the OpenVG implementation, though guaranteed to be at least 32), whereas 
    39 Symbian OS stipulates no upper bound on the number of clipping rects in the
    40 clipping region.   
    41 
    42 This class keeps the entire clipping region in OpenVG coordinates, and may
    43 be used to iterate over the clipping region, passing a set number of
    44 clipping rectangles to OpenVG on each iteration.
    45 
    46 A typical use case would be as follows:
    47 @code
    48 	for (iRegionManager.Begin(); iRegionManager.ApplyClipRegion(); iRegionManager.Next())
    49 		vgDrawImage(openVgImage);
    50 @endcode
    51 
    52 @internalComponent
    53 */
    54 NONSHARABLE_CLASS(RClippingRegionManager)
    55 	{
    56 	public:
    57 		RClippingRegionManager ();
    58 		void  Close ();
    59 		void  Reset ();
    60 		void  Initialize (TUint aItemsPerStep, TSize aVgEngineTargetSize);
    61 		TInt  SetClippingRegion(const TRegion& aRegion);
    62 		const RRegion& ClippingRegion () const;
    63 		void  ClipTo(const TRect& aClipRect);
    64 		void  Begin();
    65 		TBool Next();
    66 		TBool ApplyClipRegion();
    67 		TBool Intersects(const TRect& aClipRect) const;
    68 		
    69 	private:
    70 		void ResetIterator ();
    71 		TUint RemainingItems() const;
    72 		TUint ItemsInThisIteration() const;
    73 		TInt  Append(const TPoint& aVgPosition, VGint width, VGint height);
    74 		const TPoint ConvertToVgCoords(const TRect& aRect) const;
    75 		TInt ConvertClippingRegion(const TRegion& aRegion);
    76 		
    77 	private:
    78 		RArray<TVgClippingRect> iClippingRects; 	/**< Array of clipping rectangles stored in OpenVG coordinates.*/
    79 		RRegion iClippingRegion;					/**< The full clipping region.*/
    80 		TSize iVgEngineTargetSize;
    81 		TUint iItemsPerStep;
    82 		TUint iCurrentRect;
    83 		TUint iBegun;
    84 	};
    85 
    86 #endif