sl@0
|
1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
|
sl@0
|
17 |
#ifndef CLIPPINGREGIONMANAGER_H_
|
sl@0
|
18 |
#define CLIPPINGREGIONMANAGER_H_
|
sl@0
|
19 |
|
sl@0
|
20 |
#include <VG/openvg.h>
|
sl@0
|
21 |
#include <e32std.h>
|
sl@0
|
22 |
|
sl@0
|
23 |
/**
|
sl@0
|
24 |
Defines a rectangle of VGint coordinates for use when passing clipping rectangles to OpenVG.
|
sl@0
|
25 |
*/
|
sl@0
|
26 |
struct TVgClippingRect
|
sl@0
|
27 |
{
|
sl@0
|
28 |
VGint iX;
|
sl@0
|
29 |
VGint iY;
|
sl@0
|
30 |
VGint iWidth;
|
sl@0
|
31 |
VGint iHeight;
|
sl@0
|
32 |
};
|
sl@0
|
33 |
|
sl@0
|
34 |
/**
|
sl@0
|
35 |
Helper for managing clipping (OpenVG: scissoring) regions within CVGEngine.
|
sl@0
|
36 |
|
sl@0
|
37 |
OpenVG supports only a fixed number of clipping rects (actual number is defined by
|
sl@0
|
38 |
the OpenVG implementation, though guaranteed to be at least 32), whereas
|
sl@0
|
39 |
Symbian OS stipulates no upper bound on the number of clipping rects in the
|
sl@0
|
40 |
clipping region.
|
sl@0
|
41 |
|
sl@0
|
42 |
This class keeps the entire clipping region in OpenVG coordinates, and may
|
sl@0
|
43 |
be used to iterate over the clipping region, passing a set number of
|
sl@0
|
44 |
clipping rectangles to OpenVG on each iteration.
|
sl@0
|
45 |
|
sl@0
|
46 |
A typical use case would be as follows:
|
sl@0
|
47 |
@code
|
sl@0
|
48 |
for (iRegionManager.Begin(); iRegionManager.ApplyClipRegion(); iRegionManager.Next())
|
sl@0
|
49 |
vgDrawImage(openVgImage);
|
sl@0
|
50 |
@endcode
|
sl@0
|
51 |
|
sl@0
|
52 |
@internalComponent
|
sl@0
|
53 |
*/
|
sl@0
|
54 |
NONSHARABLE_CLASS(RClippingRegionManager)
|
sl@0
|
55 |
{
|
sl@0
|
56 |
public:
|
sl@0
|
57 |
RClippingRegionManager ();
|
sl@0
|
58 |
void Close ();
|
sl@0
|
59 |
void Reset ();
|
sl@0
|
60 |
void Initialize (TUint aItemsPerStep, TSize aVgEngineTargetSize);
|
sl@0
|
61 |
TInt SetClippingRegion(const TRegion& aRegion);
|
sl@0
|
62 |
const RRegion& ClippingRegion () const;
|
sl@0
|
63 |
void ClipTo(const TRect& aClipRect);
|
sl@0
|
64 |
void Begin();
|
sl@0
|
65 |
TBool Next();
|
sl@0
|
66 |
TBool ApplyClipRegion();
|
sl@0
|
67 |
TBool Intersects(const TRect& aClipRect) const;
|
sl@0
|
68 |
|
sl@0
|
69 |
private:
|
sl@0
|
70 |
void ResetIterator ();
|
sl@0
|
71 |
TUint RemainingItems() const;
|
sl@0
|
72 |
TUint ItemsInThisIteration() const;
|
sl@0
|
73 |
TInt Append(const TPoint& aVgPosition, VGint width, VGint height);
|
sl@0
|
74 |
const TPoint ConvertToVgCoords(const TRect& aRect) const;
|
sl@0
|
75 |
TInt ConvertClippingRegion(const TRegion& aRegion);
|
sl@0
|
76 |
|
sl@0
|
77 |
private:
|
sl@0
|
78 |
RArray<TVgClippingRect> iClippingRects; /**< Array of clipping rectangles stored in OpenVG coordinates.*/
|
sl@0
|
79 |
RRegion iClippingRegion; /**< The full clipping region.*/
|
sl@0
|
80 |
TSize iVgEngineTargetSize;
|
sl@0
|
81 |
TUint iItemsPerStep;
|
sl@0
|
82 |
TUint iCurrentRect;
|
sl@0
|
83 |
TUint iBegun;
|
sl@0
|
84 |
};
|
sl@0
|
85 |
|
sl@0
|
86 |
#endif
|