author | Jon Medhurst |
Fri, 22 Oct 2010 13:37:16 +0100 | |
branch | bug235_bringup_0 |
changeset 64 | 5023b77b78d4 |
parent 59 | d9b81aebba7b |
permissions | -rwxr-xr-x |
24 | 1 |
// Copyright (c) 2010 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 |
// Header file defining Open VG client-side state classes. |
|
15 |
||
16 |
#ifndef VGSTATE_H |
|
17 |
#define VGSTATE_H |
|
18 |
||
19 |
#include <EGL/egl.h> |
|
20 |
#include <VG/openvg.h> |
|
21 |
#include <e32hashtab.h> |
|
22 |
#include "vghwutils.h" |
|
23 |
||
59
d9b81aebba7b
Add mapping fix to guestegl and debugging (temporary)
Faisal Memon <faisal.memon@nokia.com>
parents:
24
diff
changeset
|
24 |
#define _DEBUG // FAISALMEMON temporary |
24 | 25 |
|
26 |
// tracing |
|
59
d9b81aebba7b
Add mapping fix to guestegl and debugging (temporary)
Faisal Memon <faisal.memon@nokia.com>
parents:
24
diff
changeset
|
27 |
|
24 | 28 |
#include <e32debug.h> |
29 |
#ifdef _DEBUG |
|
30 |
#define OPENVG_TRACE(fmt, args...) RDebug::Printf(fmt, ##args) |
|
31 |
#define VGPANIC_ASSERT(condition, panic) if (!(condition)) { VgPanic(panic, #panic, #condition, __FILE__, __LINE__); } |
|
32 |
#define VGPANIC_ASSERT_DEBUG(condition, panic) if (!(condition)) { VgPanic(panic, #panic, #condition, __FILE__, __LINE__); } |
|
33 |
#define VGPANIC_ALWAYS(panic) { VgPanic(panic, #panic, NULL, __FILE__, __LINE__); } |
|
34 |
#else |
|
35 |
#define OPENVG_TRACE(fmt, args...) |
|
36 |
#define VGPANIC_ASSERT(condition, panic) if (!(condition)) { VgPanic(panic, NULL, NULL, NULL, __LINE__); } |
|
37 |
#define VGPANIC_ASSERT_DEBUG(condition, panic) |
|
38 |
#define VGPANIC_ALWAYS(panic) { VgPanic(panic, NULL, NULL, NULL, __LINE__); } |
|
39 |
#endif |
|
40 |
||
41 |
||
42 |
// Guest Open VG panic codes |
|
43 |
typedef enum |
|
44 |
{ |
|
45 |
EVgPanicTemp = 1, // note: for development, references should be replaced with a more specific panic |
|
46 |
EVgPanicNullPixmapPointer, |
|
47 |
EVgPanicPixmapSizeError, |
|
48 |
EVgPanicSingletonAlreadyInitialised, |
|
49 |
EVgPanicSingletonNotInitialised, |
|
50 |
EVgPanicNullPointer, |
|
51 |
EVgPanicBadLastBitsParam, |
|
52 |
EVgPanicBadRowLengthParam, |
|
53 |
EVgPanicBadRowCountParam, |
|
54 |
EVgPanicStrideSmallerThanRowLength, // 10 |
|
55 |
EVgPanicNotReplyOpcode, |
|
56 |
EVgPanicDeleteInUseVgImageInfo, |
|
57 |
EVgPanicUidGeneratorZeroSeed, |
|
58 |
EVgPanicMissingEglInterface, |
|
59 |
EVgPanicNullCVgHandlePointer, |
|
60 |
EVgPanicWrongVgHandleType, |
|
61 |
EVgPanicHandleAlreadyMarkedDestroyed, |
|
62 |
EVgPanicUnknownVgHandleType, |
|
63 |
EVgPanicHostHandleIsInvalid, |
|
64 |
EVgPanicImageParentIsInvalid, // 20 |
|
65 |
EVgPanicFunctionParameterIsNull, |
|
66 |
EVgPanicValueFromHostVgIsInvalid, |
|
67 |
EVgPanicHostHandleAlreadySet, |
|
68 |
EVgPanicParentImageAlreadyDestroyed, |
|
69 |
EVgPanicStateLockMutexNotHeld, |
|
70 |
} TVgPanic; |
|
71 |
||
72 |
void VgPanic(TVgPanic aPanicCode, char* aPanicName, char* aCondition, char* aFile, TInt aLine); |
|
73 |
||
74 |
||
75 |
// state singleton, in Writeable Static Data memory |
|
76 |
class XOpenVgState; |
|
77 |
extern XOpenVgState OpenVgState; |
|
78 |
||
79 |
// classes declared in this header |
|
80 |
class CVgHandleBase; |
|
81 |
class CVgImageBase; |
|
82 |
class CVgMaskLayerInfo; |
|
83 |
class CVgFontInfo; |
|
84 |
class CVgImageInfo; |
|
85 |
class CVgPaintInfo; |
|
86 |
class CVgPathInfo; |
|
87 |
class THandleGen; |
|
88 |
class TVgLockHolder; |
|
89 |
||
90 |
extern const float KFloatMinusOne; |
|
91 |
||
92 |
||
93 |
class THandleGen |
|
94 |
{ |
|
95 |
public: |
|
96 |
inline void Init(TUint aInit); |
|
97 |
TUint NextUid(); |
|
98 |
private: |
|
99 |
TUint iValue; |
|
100 |
}; |
|
101 |
||
102 |
typedef enum |
|
103 |
{ |
|
104 |
EVgHandleAny = -1, // match any valid handle type, e.g. for vgSetParameteri |
|
105 |
EVgHandleForFont = 0, // specific types ... |
|
106 |
EVgHandleForImage, |
|
107 |
EVgHandleForPaint, |
|
108 |
EVgHandleForPath, |
|
109 |
EVgHandleForMaskLayer, |
|
110 |
} TVgHandleType; |
|
111 |
||
112 |
||
113 |
// state structures for VG objects (i.e. anything that is a VGHandle): VGImage, VGPath, VGMaskLayer, VGPaint, VGFont |
|
114 |
// ToDo review how to handle thread locking these objects whilst they are in use |
|
115 |
NONSHARABLE_CLASS(CVgHandleBase) : public CBase // Base Class |
|
116 |
{ |
|
117 |
public: |
|
118 |
static void InitStatics(); |
|
119 |
||
120 |
// public inline methods |
|
121 |
inline VGHandle HostHandle() const; |
|
122 |
inline TVgHandleType HandleType() const; |
|
123 |
inline TBool IsDestroyed() const; |
|
124 |
inline void SetHostHandle(VGHandle aHostHandle); |
|
125 |
inline TUint ClientHandle() const; |
|
126 |
||
127 |
// general & specific portions of derived object destruction |
|
128 |
void Destroy(MVgContext& aVgContext); |
|
129 |
virtual TBool DestroyObject(MVgContext& aVgContext) = 0; |
|
130 |
||
131 |
// Each VGHandle object type must implement GetParameterVectorSize |
|
132 |
virtual VGint GetParameterVectorSize(MVgContext& aVgContext, VGint aParamType) = 0; |
|
133 |
// Base version of GetParameter* uses GetParameterVectorSize to validate aParamType then calls Host VG |
|
134 |
virtual VGfloat GetParameterf(MVgContext& aVgContext, VGint aParamType); |
|
135 |
virtual VGint GetParameteri(MVgContext& aVgContext, VGint aParamType); |
|
136 |
// For details of Base versions of GetParameter*v see vghandle.cpp |
|
137 |
virtual void GetParameterfv(MVgContext& aVgContext, VGint aParamType, VGint aCount, VGfloat * aValues); |
|
138 |
virtual void GetParameteriv(MVgContext& aVgContext, VGint aParamType, VGint aCount, VGint * aValues); |
|
139 |
// Base versions of SetParameter* assume parameters are read-only, and give an error return |
|
140 |
virtual void SetParameterf(MVgContext& aVgContext, VGint aParamType, VGfloat aValue); |
|
141 |
virtual void SetParameteri(MVgContext& aVgContext, VGint aParamType, VGint aValue); |
|
142 |
virtual void SetParameterfv(MVgContext& aVgContext, VGint aParamType, VGint aCount, const VGfloat * aValues); |
|
143 |
virtual void SetParameteriv(MVgContext& aVgContext, VGint aParamType, VGint aCount, const VGint * aValues); |
|
144 |
||
145 |
protected: |
|
146 |
inline CVgHandleBase(TVgHandleType aHandleType); |
|
147 |
inline ~CVgHandleBase(); |
|
148 |
||
149 |
VGint HostVgGetParameterVectorSize(MVgContext& aVgContext, VGint aParamType); |
|
150 |
VGint HostVgGetParameteri(MVgContext& aVgContext, VGint aParamType); |
|
151 |
VGfloat HostVgGetParameterf(MVgContext& aVgContext, VGint aParamType); |
|
152 |
void HostVgGetParameterfv(MVgContext& aVgContext, VGint aParamType, VGint aCount, const VGfloat * aValues); |
|
153 |
void HostVgGetParameteriv(MVgContext& aVgContext, VGint aParamType, VGint aCount, const VGint * aValues); |
|
154 |
void HostVgSetParameterf(MVgContext& aVgContext, VGint aParamType, VGfloat aValue); |
|
155 |
void HostVgSetParameteri(MVgContext& aVgContext, VGint aParamType, VGint aValue); |
|
156 |
void HostVgSetParameterfv(MVgContext& aVgContext, VGint aParamType, VGint aCount, const VGfloat * aValues); |
|
157 |
void HostVgSetParameteriv(MVgContext& aVgContext, VGint aParamType, VGint aCount, const VGint * aValues); |
|
158 |
||
159 |
protected: |
|
160 |
TUint iClientHandle; |
|
161 |
TVgHandleType iHandleType; |
|
162 |
VGHandle iHostHandle; |
|
163 |
TBool iIsDestroyed; |
|
164 |
||
165 |
private: |
|
166 |
static THandleGen iHandleGen; // generator for unique client side handles |
|
167 |
}; |
|
168 |
||
169 |
||
170 |
NONSHARABLE_CLASS(CVgImageBase) : public CVgHandleBase |
|
171 |
{ |
|
172 |
public: |
|
173 |
inline VGint Width() const; |
|
174 |
inline VGint Height() const; |
|
175 |
||
176 |
TBool DestroyObject(MVgContext& aVgContext) = 0; |
|
177 |
||
178 |
virtual VGint GetParameterVectorSize(MVgContext& aVgContext, VGint aParamType) = 0; |
|
179 |
||
180 |
protected: |
|
181 |
inline CVgImageBase(TVgHandleType aHandleType, VGint aWidth, VGint aHeight); |
|
182 |
||
183 |
protected: |
|
184 |
VGint const iWidth; |
|
185 |
VGint const iHeight; |
|
186 |
}; |
|
187 |
||
188 |
||
189 |
NONSHARABLE_CLASS(CVgMaskLayerInfo) : public CVgImageBase |
|
190 |
{ |
|
191 |
public: |
|
192 |
static CVgMaskLayerInfo* New(VGint aWidth, VGint aHeight); |
|
193 |
virtual TBool DestroyObject(MVgContext& aVgContext); |
|
194 |
||
195 |
virtual VGint GetParameterVectorSize(MVgContext& aVgContext, VGint aParamType); |
|
196 |
||
197 |
// Mask specific operations |
|
198 |
void FillMaskLayer(MVgContext& aVgContext, VGint aX, VGint aY, VGint aWidth, VGint aHeight, VGfloat aValue); |
|
199 |
void CopyMask(MVgContext& aVgContext, VGint aSx, VGint aSy, VGint aDx, VGint aDy, VGint aWidth, VGint aHeight); |
|
200 |
||
201 |
private: |
|
202 |
inline CVgMaskLayerInfo(VGint aWidth, VGint aHeight); |
|
203 |
inline ~CVgMaskLayerInfo(); |
|
204 |
}; |
|
205 |
||
206 |
||
207 |
NONSHARABLE_CLASS(CVgImageInfo) : public CVgImageBase |
|
208 |
{ |
|
209 |
public: |
|
210 |
static CVgImageInfo* New(VGImageFormat aFormat, VGint aWidth, VGint aHeight, VGbitfield aAllowedQuality); |
|
211 |
static CVgImageInfo* New(VGImageFormat aFormat, VGint aWidth, VGint aHeight, EGLImageKHR aEglImage, TUint64& aSgImageId); |
|
212 |
static CVgImageInfo* New(VGint aWidth, VGint aHeight, CVgImageInfo* aParent); |
|
213 |
virtual TBool DestroyObject(MVgContext& aVgContext); |
|
214 |
||
215 |
TInt ChildCount() const; |
|
216 |
CVgImageInfo* Parent() const; |
|
217 |
VGbitfield AllowedQuality() const; |
|
218 |
TBool IsEglSibling() const; |
|
219 |
TUint64 SgImageId() const; |
|
220 |
EGLImageKHR EglImage() const; |
|
221 |
||
222 |
static TInt BitsPerPixelForVgImageFormat(VGImageFormat aFormat); |
|
223 |
static void PixmapBlit(TUint8* aDest, const TUint8* aSource, TInt aDestStride, TInt aSourceStride, TInt aRowCount, |
|
224 |
size_t aRowLength, TInt aLastBits=0); |
|
225 |
||
226 |
virtual VGint GetParameterVectorSize(MVgContext& aVgContext, VGint aParamType); |
|
227 |
virtual VGfloat GetParameterf(MVgContext& aVgContext, VGint aParamType); |
|
228 |
virtual VGint GetParameteri(MVgContext& aVgContext, VGint aParamType); |
|
229 |
||
230 |
void ClearImage(MVgContext& aVgContext, VGint aX, VGint aY, VGint aWidth, VGint aHeight); |
|
231 |
void ImageSubData(MVgContext& aVgContext, const void * aData, VGint aDataStride, VGImageFormat aDataFormat, VGint aX, VGint aY, |
|
232 |
VGint aWidth, VGint aHeight); |
|
233 |
void GetImageSubData(MVgContext& aVgContext, void * aData, VGint aDataStride, VGImageFormat aDataFormat, VGint aX, VGint aY, |
|
234 |
VGint aWidth, VGint aHeight); |
|
235 |
void CopyImage(MVgContext& aVgContext, VGint aDx, VGint aDy, CVgImageInfo& aSrcImageInfo, VGint aSx, VGint aSy, VGint aWidth, |
|
236 |
VGint aHeight, VGboolean aDither); |
|
237 |
void DrawImage(MVgContext& aVgContext); |
|
238 |
void SetPixels(MVgContext& aVgContext, VGint aDx, VGint aDy, VGint aSx, VGint aSy, VGint aWidth, VGint aHeight); |
|
239 |
void GetPixels(MVgContext& aVgContext, VGint aDx, VGint aDy, VGint aSx, VGint aSy, VGint aWidth, VGint aHeight); |
|
240 |
void ColorMatrix(MVgContext& aVgContext, CVgImageInfo& aSrcImageInfo, const VGfloat * aMatrix); |
|
241 |
void Convolve(MVgContext& aVgContext, CVgImageInfo& aSrcImageInfo, VGint aKernelWidth, VGint aKernelHeight, |
|
242 |
VGint aShiftX, VGint aShiftY, const VGshort * aKernel, VGfloat aScale, VGfloat aBias, VGTilingMode aTilingMode); |
|
243 |
void SeparableConvolve(MVgContext& aVgContext, CVgImageInfo& aSrcImageInfo, VGint aKernelWidth, VGint aKernelHeight, |
|
244 |
VGint aShiftX, VGint aShiftY, const VGshort * aKernelX, const VGshort * aKernelY, |
|
245 |
VGfloat aScale, VGfloat aBias, VGTilingMode aTilingMode); |
|
246 |
void GaussianBlur(MVgContext& aVgContext, CVgImageInfo& aSrcImageInfo, VGfloat aStdDeviationX, VGfloat aStdDeviationY, VGTilingMode aTilingMode); |
|
247 |
void Lookup(MVgContext& aVgContext, CVgImageInfo& aSrcImageInfo, const VGubyte * aRedLUT, const VGubyte * aGreenLUT, const VGubyte * aBlueLUT, |
|
248 |
const VGubyte * aAlphaLUT, VGboolean aOutputLinear, VGboolean aOutputPremultiplied); |
|
249 |
void LookupSingle(MVgContext& aVgContext, CVgImageInfo& aSrcImageInfo, const VGuint * aLookupTable, VGImageChannel aSourceChannel, |
|
250 |
VGboolean aOutputLinear, VGboolean aOutputPremultiplied); |
|
251 |
||
252 |
private: |
|
253 |
inline CVgImageInfo(VGImageFormat aFormat, VGint aWidth, VGint aHeight, CVgImageInfo* aParent, VGbitfield aAllowedQuality, |
|
254 |
EGLImageKHR aEglImage, TUint64 aSgImageId); |
|
255 |
inline ~CVgImageInfo(); |
|
256 |
inline void IncChildCount(); |
|
257 |
inline void DecChildCount(); |
|
258 |
void HostVgGetImageSubData(MVgContext& aVgContext, void* aPixmap, size_t aPixmapSize, VGint aHostDataStride, |
|
259 |
VGImageFormat aDataFormat, VGint aX, VGint aY, VGint aWidth, VGint aHeight); |
|
260 |
void HostVgImageSubData(MVgContext& aVgContext, const void* aPixmap, size_t aPixmapSize, VGint aHostDataStride, |
|
261 |
VGImageFormat aDataFormat, VGint aX, VGint aY, VGint aWidth, VGint aHeight); |
|
262 |
||
263 |
||
264 |
/* **** desireable: expand CVgImageInfo to include and use for validating for various appropriate: |
|
265 |
(TBool iIsRenderTarget; - VgImage is a surface currently being rendered, blocks some operations) |
|
266 |
(TUint iUsedAsPaintPattern; - non-zero stops use as a render target) |
|
267 |
(TUint iUsedAsGlyph; - count of how many places the VgImage is being used as a font glyph) |
|
268 |
*/ |
|
269 |
private: |
|
270 |
VGImageFormat iFormat; // not const because this is not currently initialised at creation for EglImages |
|
271 |
CVgImageInfo* const iParent; // immediate parent VgImage, NULL if not a child |
|
272 |
VGbitfield const iAllowedQuality; |
|
273 |
// EglImage / SgImage info ... |
|
274 |
TBool const iIsEglSibling; |
|
275 |
EGLImageKHR const iEglImage; |
|
276 |
TUint64 const iSgImageId; // Set or copied from parent for Egl Sibling - used to prompt Cmd Scheduler to sync pbuffer & vgimage |
|
277 |
// non-const state |
|
278 |
TInt iChildCount; // count of direct child images |
|
279 |
}; |
|
280 |
||
281 |
||
282 |
NONSHARABLE_CLASS(CVgFontInfo) : public CVgHandleBase |
|
283 |
{ |
|
284 |
public: |
|
285 |
static CVgFontInfo* New(); |
|
286 |
virtual TBool DestroyObject(MVgContext& aVgContext); |
|
287 |
||
288 |
virtual VGint GetParameterVectorSize(MVgContext& aVgContext, VGint aParamType); |
|
289 |
||
290 |
void SetGlyphToPath(MVgContext& aVgContext, VGuint aGlyphIndex, CVgPathInfo* aPathInfo, VGboolean aIsHinted, |
|
291 |
const VGfloat aGlyphOrigin [2], const VGfloat aEscapement[2]); |
|
292 |
void SetGlyphToImage(MVgContext& aVgContext, VGuint aGlyphIndex, CVgImageInfo* aImageInfo, const VGfloat aGlyphOrigin [2], |
|
293 |
const VGfloat aEscapement[2]); |
|
294 |
void ClearGlyph(MVgContext& aVgContext, VGuint aGlyphIndex); |
|
295 |
void DrawGlyph(MVgContext& aVgContext, VGuint aGlyphIndex, VGbitfield aPaintModes, VGboolean aAllowAutoHinting); |
|
296 |
void DrawGlyphs(MVgContext& aVgContext, VGint aGlyphCount, const VGuint * aGlyphIndices, const VGfloat * aAdjustmentsX, |
|
297 |
const VGfloat * aAdjustmentsY, VGbitfield aPaintModes, VGboolean aAllowAutoHinting); |
|
298 |
||
299 |
private: |
|
300 |
inline CVgFontInfo(); |
|
301 |
inline ~CVgFontInfo(); |
|
302 |
}; |
|
303 |
||
304 |
||
305 |
NONSHARABLE_CLASS(CVgPaintInfo) : public CVgHandleBase |
|
306 |
{ |
|
307 |
public: |
|
308 |
static CVgPaintInfo* New(); |
|
309 |
virtual TBool DestroyObject(MVgContext& aVgContext); |
|
310 |
||
311 |
virtual VGint GetParameterVectorSize(MVgContext& aVgContext, VGint aParamType); |
|
312 |
virtual VGfloat GetParameterf(MVgContext& aVgContext, VGint aParamType); |
|
313 |
virtual VGint GetParameteri(MVgContext& aVgContext, VGint aParamType); |
|
314 |
virtual void GetParameterfv(MVgContext& aVgContext, VGint aParamType, VGint aCount, VGfloat * aValues); |
|
315 |
virtual void GetParameteriv(MVgContext& aVgContext, VGint aParamType, VGint aCount, VGint * aValues); |
|
316 |
||
317 |
virtual void SetParameterf(MVgContext& aVgContext, VGint aParamType, VGfloat aValue); |
|
318 |
virtual void SetParameteri(MVgContext& aVgContext, VGint aParamType, VGint aValue); |
|
319 |
virtual void SetParameterfv(MVgContext& aVgContext, VGint aParamType, VGint aCount, const VGfloat * aValues); |
|
320 |
virtual void SetParameteriv(MVgContext& aVgContext, VGint aParamType, VGint aCount, const VGint * aValues); |
|
321 |
||
322 |
static void ResetPaint(MVgContext& aVgContext); |
|
323 |
void SetPaint(MVgContext& aVgContext, VGbitfield aPaintModes); |
|
324 |
void SetColor(MVgContext& aVgContext, VGuint aRgba); |
|
325 |
VGuint GetColor(MVgContext& aVgContext); |
|
326 |
void PaintPattern(MVgContext& aVgContext, CVgImageInfo* aPatternInfo); |
|
327 |
||
328 |
private: |
|
329 |
inline CVgPaintInfo(); |
|
330 |
inline ~CVgPaintInfo(); |
|
331 |
||
332 |
private: |
|
333 |
// cached parameters |
|
334 |
VGPaintType iPaintType; |
|
335 |
VGColorRampSpreadMode iColorRampSpreadMode; |
|
336 |
VGboolean iColorRampPremultiplied; |
|
337 |
VGTilingMode iPatternTilingMode; |
|
338 |
// VGfloat vector parameters are not currently cached in client |
|
339 |
}; |
|
340 |
||
341 |
||
342 |
NONSHARABLE_CLASS(CVgPathInfo) : public CVgHandleBase |
|
343 |
{ |
|
344 |
public: |
|
345 |
static CVgPathInfo* CVgPathInfo::New(VGPathDatatype aDatatype, VGfloat aScale, VGfloat aBias, VGbitfield aCapabilities); |
|
346 |
virtual TBool DestroyObject(MVgContext& aVgContext); |
|
347 |
||
348 |
void ClearPath(MVgContext& aVgContext, VGbitfield aCapabilities); |
|
349 |
void RemovePathCapabilities(MVgContext& aVgContext, VGbitfield aCapabilities); |
|
350 |
VGbitfield GetPathCapabilities(MVgContext& aVgContext); |
|
351 |
||
352 |
void AppendPath(MVgContext& aVgContext, CVgPathInfo& aSrcPathInfo); |
|
353 |
void AppendPathData(MVgContext& aVgContext, VGint aNumSegments, const VGubyte * aPathSegments, const void* aPathData); |
|
354 |
void ModifyPathCoords(MVgContext& aVgContext, VGint aStartIndex, VGint aNumSegments, const void* aPathData); |
|
355 |
void TransformPath(MVgContext& aVgContext, CVgPathInfo& aSrcPathInfo); |
|
356 |
VGboolean InterpolatePath(MVgContext& aVgContext, CVgPathInfo& aStartPathInfo, CVgPathInfo& aEndPathInfo, VGfloat aAmount); |
|
357 |
VGfloat PathLength(MVgContext& aVgContext, VGint aStartSegment, VGint aNumSegments); |
|
358 |
void PointAlongPath(MVgContext& aVgContext, VGint aStartSegment, VGint aNumSegments, VGfloat aDistance, |
|
359 |
VGfloat* aX, VGfloat* aY, VGfloat* aTangentX, VGfloat* aTangentY); |
|
360 |
void PathBounds(MVgContext& aVgContext, VGfloat* aMinX, VGfloat* aMinY, VGfloat* aWidth, VGfloat* aHeight); |
|
361 |
void PathTransformedBounds(MVgContext& aVgContext, VGfloat* aMinX, VGfloat* aMinY, VGfloat* aWidth, VGfloat* aHeight); |
|
362 |
void DrawPath(MVgContext& aVgContext, VGbitfield aPaintModes); |
|
363 |
void RenderToMask(MVgContext& aVgContext, VGbitfield aPaintModes, VGMaskOperation aOperation); |
|
364 |
||
365 |
inline VGPathDatatype PathDatatype() const; |
|
366 |
||
367 |
TBool CheckHasPathCapabilities(MVgContext& aVgContext, VGbitfield aCapabilities); |
|
368 |
||
369 |
virtual VGint GetParameterVectorSize(MVgContext& aVgContext, VGint aParamType); |
|
370 |
virtual VGfloat GetParameterf(MVgContext& aVgContext, VGint aParamType); |
|
371 |
virtual VGint GetParameteri(MVgContext& aVgContext, VGint aParamType); |
|
372 |
||
373 |
private: |
|
374 |
inline CVgPathInfo(VGPathDatatype aPathDatatype, VGfloat aScale, VGfloat aBias, VGbitfield aCapabilities); |
|
375 |
inline ~CVgPathInfo(); |
|
376 |
TBool CheckAppendPathData(MVgContext& aVgContext, VGint aNumSegments, const VGubyte* aPathSegments, const void* aPathData, |
|
377 |
VGint* aPathDataSize); |
|
378 |
TBool CheckPathDataAlignment(MVgContext& aVgContext, const void* aPathData); |
|
379 |
TBool CheckPathDataSize(MVgContext& aVgContext, const VGubyte* aPathSegments, VGint aNumSegments, VGint* aPathDataSize); |
|
380 |
VGint HostVgeGetPathCoordsSizeInBytes(MVgContext& aVgContext, VGint aStartIndex, VGint aNumSegments); |
|
381 |
||
382 |
private: |
|
383 |
VGPathDatatype const iDatatype; |
|
384 |
VGfloat const iScale; |
|
385 |
VGfloat const iBias; |
|
386 |
VGbitfield iCapabilities; |
|
387 |
}; |
|
388 |
||
389 |
||
390 |
// Collection of static parameter checking functions - all "Chk" functions set the appropriate last VG Error on failure |
|
391 |
class TCheck |
|
392 |
{ |
|
393 |
public: |
|
394 |
inline static TBool Chk16bitPtr(MVgContext& aVgContext, const void* aDataPtr); |
|
395 |
inline static TBool Chk2x16bitPtr(MVgContext& aVgContext, const void* aDataPtr1, const void* aDataPtr2); |
|
396 |
inline static TBool Chk32bitPtr(MVgContext& aVgContext, const void* aDataPtr); |
|
397 |
inline static TBool Chk2x32bitPtr(MVgContext& aVgContext, const void* aDataPtr1, const void* aDataPtr2); |
|
398 |
inline static TBool Chk4x32bitPtr(MVgContext& aVgContext, const void* aDataPtr1, const void* aDataPtr2, const void* aDataPtr3, const void* aDataPtr4); |
|
399 |
inline static TBool Chk2xOptional32bitPtr(MVgContext& aVgContext, const void* aDataPtr1, const void* aDataPtr2); |
|
400 |
inline static TBool ChkVGMaskOperation(MVgContext& aVgContext, VGMaskOperation aOperation); |
|
401 |
inline static TBool ChkVGPaintMode(MVgContext& aVgContext, VGPaintMode aPaintMode); |
|
402 |
inline static TBool ChkVGPathDataType(MVgContext& aVgContext, VGPathDatatype aDatatype); |
|
403 |
inline static TBool ChkVGTilingMode(MVgContext& aVgContext, VGTilingMode aTilingMode); |
|
404 |
inline static TBool ChkVgImageFormat(MVgContext& aVgContext, VGImageFormat aFormat); |
|
405 |
inline static TBool ChkImageAlignment(MVgContext& aVgContext, VGImageFormat aImageFormat, const void* aData); |
|
406 |
inline static TBool ChkPositiveImageSize(MVgContext& aVgContext, VGint aWidth, VGint aHeight); |
|
407 |
inline static TBool ChkNewImageSize(MVgContext& aVgContext, VGint aWidth, VGint aHeight); |
|
408 |
inline static TBool ChkVGPaintModesCombination(MVgContext& aVgContext, VGbitfield aPaintModes); |
|
409 |
inline static TBool ChkVGPathFormat(MVgContext& aVgContext, VGint aPathFormat); |
|
410 |
static TBool ChkAreaIsWithinImage(MVgContext& aVgContext, CVgImageBase* aImageInfo, VGint aX, VGint aY, VGint aWidth, VGint aHeight); |
|
411 |
static TBool ChkParamCountAndValuesPtr(MVgContext& aVgContext, VGint aCount, const void* aValues); |
|
412 |
static VGint ImageFormatByteDepth(VGImageFormat aImageFormat); |
|
413 |
}; |
|
414 |
||
415 |
||
416 |
/* |
|
417 |
Class holds mutex for Open VG client side state on construction, & releases it on destruction. |
|
418 |
||
419 |
Placing methods here ensures the procedural requirement that the Mutex is held before these methods are called. |
|
420 |
*/ |
|
421 |
class TCleanupVgLocks |
|
422 |
{ |
|
423 |
public: |
|
424 |
// having functions here forces the caller to hold the Open VG Mutex before they are called (when the lock object is constructed) |
|
425 |
TCleanupVgLocks(MVgContext& aVgContext); |
|
426 |
~TCleanupVgLocks(); |
|
427 |
void WaitForMutex(RMutex& aMutex); |
|
428 |
void SignalMutex(); |
|
429 |
||
430 |
inline TBool CheckVGFont(VGFont aFont, CVgFontInfo** aFontInfo); |
|
431 |
inline TBool CheckVGImage(VGImage aImage, CVgImageInfo** aImageInfo); |
|
432 |
inline TBool CheckOptionalVGImage(VGImage aImage, CVgImageInfo** aImageInfo); |
|
433 |
inline TBool Check2VGImages(VGImage aImage1, CVgImageInfo** aImageInfo1, VGImage aImage2, CVgImageInfo** aImageInfo2); |
|
434 |
inline TBool CheckVGMaskLayer(VGMaskLayer aMaskLayer, CVgMaskLayerInfo** aHandleInfo); |
|
435 |
inline TBool CheckVGPaint(VGPaint aPaint, CVgPaintInfo** aPaintInfo); |
|
436 |
inline TBool CheckOptionalVGPaint(VGPaint aPaint, CVgPaintInfo** aPaintInfo); |
|
437 |
// ToDo maybe add a version that checks Start Segment & Segment Count |
|
438 |
inline TBool CheckVGPath(VGPath aPath, CVgPathInfo** aPathInfo, VGbitfield aReqdCapabilities=0); |
|
439 |
inline TBool CheckOptionalVGPath(VGPath aPath, CVgPathInfo** aPathInfo); |
|
440 |
inline TBool CheckVGAnyHandle(VGHandle aHandle, CVgHandleBase** aHandleInfo); |
|
441 |
TBool CheckVGMaskOperationAndHandle(VGMaskOperation aOperation, VGHandle aMask, CVgImageBase** aImageInfo); |
|
442 |
inline TBool CheckKernelWidthAndHeight(VGint aKernelWidth, VGint aKernelHeight, VGParamType aLimitType); |
|
443 |
||
444 |
VGFont CreateFont(VGint aGlyphCapacityHint); |
|
445 |
VGImage ChildImage(CVgImageInfo& aParentInfo, VGint aX, VGint aY, VGint aWidth, VGint aHeight); |
|
446 |
VGImage CreateImage(VGImageFormat aFormat, VGint aWidth, VGint aHeight, VGbitfield aAllowedQuality); |
|
447 |
VGMaskLayer CreateMaskLayer(VGint aWidth, VGint aHeight); |
|
448 |
VGPaint CreatePaint(); |
|
449 |
VGPaint GetPaint(VGPaintMode aPaintMode); |
|
450 |
VGPath CreatePath(VGint aPathFormat, VGPathDatatype aDatatype, VGfloat aScale, VGfloat aBias, |
|
451 |
VGint aSegmentCapacityHint, VGint aCoordCapacityHint, VGbitfield aCapabilities); |
|
452 |
VGImage CreateEGLImageTargetKHR(VGeglImageKHR aImage); |
|
453 |
||
454 |
private: |
|
455 |
MVgContext& const iVgContext; |
|
456 |
RMutex& iMutex; |
|
457 |
TBool iIsHeld; |
|
458 |
}; |
|
459 |
||
460 |
||
461 |
||
462 |
// per VG client state |
|
463 |
NONSHARABLE_CLASS(XOpenVgState) : public MEglManagementApi, public MVgApiForEgl |
|
464 |
{ |
|
465 |
friend class TCleanupVgLocks; |
|
466 |
public: |
|
467 |
XOpenVgState(); |
|
468 |
~XOpenVgState(); |
|
469 |
||
470 |
// functions using/maintaining Open Vg Handle Map |
|
471 |
TBool AddToHashMap(MVgContext& aVgContext, CVgHandleBase* aHandleInfo, VGHandle aHostHandle); |
|
472 |
void UnMapHandle(TUint32 aClientHandle); |
|
473 |
||
474 |
// MEglManagementApi - redirects via CVghwUtils to the EGL implementation |
|
475 |
virtual TBool EglImageOpenForVgImage(EGLImageKHR aImage, TSize& aSize, VGHandle& aVgHandle, TUint64& aSgImageId); |
|
476 |
virtual void EglImageClose(EGLImageKHR aImage); |
|
477 |
||
478 |
// MVgApiForEgl - exported via CvghwUtils to the Guest EGL implementation |
|
479 |
virtual ExtensionProcPointer guestGetVgProcAddress (const char *aProcName); |
|
480 |
||
481 |
protected: // fns only visible to TVgLockHolder class |
|
482 |
inline RMutex& MutexWait(); |
|
483 |
TBool CheckVGHandle(MVgContext& aVgContext, VGHandle aHandle, CVgHandleBase** aHandleInfo, TVgHandleType aMatchType); |
|
484 |
// functions using cached values from Host Open VG implementation |
|
485 |
TBool CheckKernelWidthAndHeight(MVgContext& aVgContext, VGint aKernelWidth, VGint aKernelHeight, VGParamType aLimitType); |
|
486 |
||
487 |
private: |
|
488 |
RMutex iStateLock; |
|
489 |
||
490 |
// Map holds info about VG Handle based objects |
|
491 |
RMutex iMapLock; |
|
492 |
RHashMap<TUint, CVgHandleBase*> iHandleHashMap; |
|
493 |
MEglManagementApi* iEglManagementApi; |
|
494 |
||
495 |
// 'constants' initialised from x86 VG implementation the first time they are required |
|
496 |
VGint iKVgMaxKernelSize; |
|
497 |
VGint iKVgMaxSeparableKernelSize; |
|
498 |
// ToDo: more values to cache: VG_MAX_IMAGE_WIDTH, VG_MAX_IMAGE_HEIGHT, VG_MAX_IMAGE_PIXELS |
|
499 |
||
500 |
// ToDo Record when VG fonts use glyphs based on SgImages, required for Ref counting |
|
501 |
}; |
|
502 |
||
503 |
||
504 |
||
505 |
||
506 |
// class of static methods to implement Open VG APIs |
|
507 |
class TGuestOpenVg |
|
508 |
{ |
|
509 |
public: |
|
510 |
// VG APIs |
|
511 |
static VGPaint vgGetPaint(VGPaintMode aPaintMode); |
|
512 |
static VGPaint vgCreatePaint(); |
|
513 |
static VGboolean vgInterpolatePath(VGPath aDstPath, VGPath aStartPath, VGPath aEndPath, VGfloat aAmount); |
|
514 |
static VGfloat vgPathLength(VGPath aPath, VGint aStartSegment, VGint aNumSegments); |
|
515 |
static VGbitfield vgGetPathCapabilities(VGPath aPath); |
|
516 |
static VGPath vgCreatePath(VGint aPathFormat, VGPathDatatype aDatatype, VGfloat aScale, VGfloat aBias, |
|
517 |
VGint aSegmentCapacityHint, VGint aCoordCapacityHint, VGbitfield aCapabilities); |
|
518 |
static VGfloat vgGetf(VGParamType aType); |
|
519 |
static VGint vgGeti(VGParamType aType); |
|
520 |
static VGfloat vgGetParameterf(VGHandle aObject, VGint aParamType); |
|
521 |
static VGint vgGetParameteri(VGHandle aObject, VGint aParamType); |
|
522 |
static VGint vgGetParameterVectorSize(VGHandle aObject, VGint aParamType); |
|
523 |
static VGMaskLayer vgCreateMaskLayer(VGint aWidth, VGint aHeight); |
|
524 |
static VGuint vgGetColor(VGPaint aPaint); |
|
525 |
static VGImage vgCreateImage(VGImageFormat aFormat, VGint aWidth, VGint aHeight, VGbitfield aAllowedQuality); |
|
526 |
static VGImage vgChildImage(VGImage aParent, VGint aX, VGint aY, VGint aWidth, VGint aHeight); |
|
527 |
static VGImage vgGetParent(VGImage aImage); |
|
528 |
static VGImage vgCreateEGLImageTargetKHR(VGeglImageKHR aImage); |
|
529 |
static VGFont vgCreateFont(VGint aGlyphCapacityHint); |
|
530 |
static VGHardwareQueryResult vgHardwareQuery(VGHardwareQueryType key, VGint setting); |
|
531 |
static void vgGetParameterfv(VGHandle aObject, VGint aParamType, VGint aCount, VGfloat * aValues); |
|
532 |
static void vgGetParameteriv(VGHandle aObject, VGint aParamType, VGint aCount, VGint * aValues); |
|
533 |
static VGint vgGetVectorSize(VGParamType type); |
|
534 |
static void vgGetfv(VGParamType aType, VGint aCount, const VGfloat * aValues); |
|
535 |
static void vgGetiv(VGParamType aType, VGint aCount, const VGint * aValues); |
|
536 |
static void vgGetMatrix(VGfloat* aM); |
|
537 |
static void vgGetImageSubData(VGImage aImage, void* aData, VGint aDataStride, VGImageFormat aDataFormat, |
|
538 |
VGint aX, VGint aY, VGint aWidth, VGint aHeight); |
|
539 |
static void vgReadPixels(void* aData, VGint aDataStride, VGImageFormat aDataFormat, VGint aSx, VGint aSy, |
|
540 |
VGint aWidth, VGint aHeight); |
|
541 |
static void vgPathBounds(VGPath aPath, VGfloat* aMinX, VGfloat* aMinY, VGfloat* aWidth, VGfloat* aHeight); |
|
542 |
static void vgPathTransformedBounds(VGPath aPath, VGfloat* aMinX, VGfloat* aMinY, VGfloat* aWidth, VGfloat* aHeight); |
|
543 |
static void vgSetf(VGParamType aType, VGfloat aValue); |
|
544 |
static void vgSeti(VGParamType aType, VGint aVvalue); |
|
545 |
static void vgSetfv(VGParamType aType, VGint aCount, const VGfloat * aValues); |
|
546 |
static void vgSetiv(VGParamType aType, VGint aCount, const VGint * aValues); |
|
547 |
static void vgSetParameterf(VGHandle aObject, VGint aParamType, VGfloat aValue); |
|
548 |
static void vgSetParameteri(VGHandle aObject, VGint aParamType, VGint aValue); |
|
549 |
static void vgSetParameterfv(VGHandle aObject, VGint aParamType, VGint aCount, const VGfloat * aValues); |
|
550 |
static void vgSetParameteriv(VGHandle aObject, VGint aParamType, VGint aCount, const VGint * aValues); |
|
551 |
static void vgLoadIdentity(); |
|
552 |
static void vgLoadMatrix(const VGfloat* aM); |
|
553 |
static void vgMultMatrix(const VGfloat* aM); |
|
554 |
static void vgTranslate(VGfloat aTx, VGfloat aTy); |
|
555 |
static void vgScale(VGfloat aSx, VGfloat aSy); |
|
556 |
static void vgShear(VGfloat aShx, VGfloat aShy); |
|
557 |
static void vgRotate(VGfloat aAngle); |
|
558 |
static void vgMask(VGHandle aMask, VGMaskOperation aOperation, VGint aX, VGint aY, VGint aWidth, VGint aHeight); |
|
559 |
static void vgRenderToMask(VGPath aPath, VGbitfield aPaintModes, VGMaskOperation aOperation); |
|
560 |
static void vgDestroyMaskLayer(VGMaskLayer maskLayer); |
|
561 |
static void vgFillMaskLayer(VGMaskLayer aMaskLayer, VGint aX, VGint aY, VGint aWidth, VGint aHeight, VGfloat aValue); |
|
562 |
static void vgCopyMask(VGMaskLayer aMaskLayer, VGint aSx, VGint aSy, VGint aDx, VGint aDy, VGint aWidth, VGint aHeight); |
|
563 |
static void vgClear(VGint aX, VGint aY, VGint aWidth, VGint aHeight); |
|
564 |
static void vgClearPath(VGPath aPath, VGbitfield aCapabilities); |
|
565 |
static void vgDestroyPath(VGPath aPath); |
|
566 |
static void vgRemovePathCapabilities(VGPath aPath, VGbitfield aCapabilities); |
|
567 |
static void vgAppendPath(VGPath aDstPath, VGPath aSrcPath); |
|
568 |
static void vgAppendPathData(VGPath aDstPath, VGint aNumSegments, const VGubyte* aPathSegments, const void* aPathData); |
|
569 |
static void vgModifyPathCoords(VGPath aDstPath, VGint aStartIndex, VGint aNumSegments, const void* aPathData); |
|
570 |
static void vgTransformPath(VGPath aDstPath, VGPath aSrcPath); |
|
571 |
static void vgPointAlongPath(VGPath aPath, VGint aStartSegment, VGint aNumSegments, VGfloat aDistance, |
|
572 |
VGfloat* aX, VGfloat* aY, VGfloat* aTangentX, VGfloat* aTangentY); |
|
573 |
static void vgDrawPath(VGPath aPath, VGbitfield aPaintModes); |
|
574 |
static void vgDestroyPaint(VGPaint aPaint); |
|
575 |
static void vgSetPaint(VGPaint aPaint, VGbitfield aPaintModes); |
|
576 |
static void vgSetColor(VGPaint aPaint, VGuint aRgba); |
|
577 |
static void vgPaintPattern(VGPaint aPaint, VGImage aPattern); |
|
578 |
static void vgDestroyImage(VGImage aImage); |
|
579 |
static void vgClearImage(VGImage aImage, VGint aX, VGint aY, VGint aWidth, VGint aHeight); |
|
580 |
static void vgImageSubData(VGImage aImage, const void* aData, VGint aDataStride, VGImageFormat aDataFormat, |
|
581 |
VGint aX, VGint aY, VGint aWidth, VGint aHeight); |
|
582 |
static void vgCopyImage(VGImage aDst, VGint aDx, VGint aDy, VGImage aSrc, VGint aSx, VGint aSy, VGint aWidth, VGint aHeight, |
|
583 |
VGboolean aDither); |
|
584 |
static void vgDrawImage(VGImage aImage); |
|
585 |
static void vgSetPixels(VGint aDx, VGint aDy, VGImage aSrc, VGint aSx, VGint aSy, VGint aWidth, VGint aHeight); |
|
586 |
static void vgWritePixels(const void* data, VGint aDataStride, VGImageFormat aDataFormat, VGint aDx, VGint aDy, |
|
587 |
VGint aWidth, VGint aHeight); |
|
588 |
static void vgGetPixels(VGImage aDst, VGint aDx, VGint aDy, VGint aSx, VGint aSy, VGint aWidth, VGint aHeight); |
|
589 |
static void vgCopyPixels(VGint aDx, VGint aDy, VGint aSx, VGint aSy, VGint aWidth, VGint aHeight); |
|
590 |
static void vgDestroyFont(VGFont aFont); |
|
591 |
static void vgSetGlyphToPath(VGFont aFont, VGuint aGlyphIndex, VGPath aPath, VGboolean aIsHinted, const VGfloat aGlyphOrigin [2], |
|
592 |
const VGfloat aEscapement[2]); |
|
593 |
static void vgSetGlyphToImage(VGFont aFont, VGuint aGlyphIndex, VGImage aImage, const VGfloat aGlyphOrigin [2], |
|
594 |
const VGfloat aEscapement[2]); |
|
595 |
static void vgClearGlyph(VGFont aFont, VGuint aGlyphIndex); |
|
596 |
static void vgDrawGlyph(VGFont aFont, VGuint aGlyphIndex, VGbitfield aPaintModes, VGboolean aAllowAutoHinting); |
|
597 |
static void vgDrawGlyphs(VGFont aFont, VGint aGlyphCount, const VGuint* aGlyphIndices, const VGfloat* aAdjustmentsX, |
|
598 |
const VGfloat* aAdjustmentsY, VGbitfield aPaintModes, VGboolean aAllowAutoHinting); |
|
599 |
static void vgColorMatrix(VGImage aDst, VGImage aSrc, const VGfloat* aMatrix); |
|
600 |
static void vgConvolve(VGImage aDst, VGImage aSrc, VGint aKernelWidth, VGint aKernelHeight, VGint aShiftX, VGint aShiftY, |
|
601 |
const VGshort* aKernel, VGfloat aScale, VGfloat aBias, VGTilingMode aTilingMode); |
|
602 |
static void vgSeparableConvolve(VGImage aDst, VGImage aSrc, VGint aKernelWidth, VGint aKernelHeight, VGint aShiftX, VGint aShiftY, |
|
603 |
const VGshort* aKernelX, const VGshort* aKernelY, VGfloat aScale, VGfloat aBias, VGTilingMode aTilingMode); |
|
604 |
static void vgGaussianBlur(VGImage aDst, VGImage aSrc, VGfloat aStdDeviationX, VGfloat aStdDeviationY, VGTilingMode aTilingMode); |
|
605 |
static void vgLookup(VGImage aDst, VGImage aSrc, const VGubyte* aRedLUT, const VGubyte* aGreenLUT, const VGubyte* aBlueLUT, |
|
606 |
const VGubyte* aAlphaLUT, VGboolean aOutputLinear, VGboolean aOutputPremultiplied); |
|
607 |
static void vgLookupSingle(VGImage aDst, VGImage aSrc, const VGuint* aLookupTable, VGImageChannel aSourceChannel, |
|
608 |
VGboolean aOutputLinear, VGboolean aOutputPremultiplied); |
|
609 |
||
610 |
private: |
|
611 |
// fns that directly talk to Host Open VG (no parameter checking) |
|
612 |
static void HostVgReadPixels(MVgContext& aVgContext, void* aPixmap, size_t aPixmapSize, VGint aHostDataStride, |
|
613 |
VGImageFormat aDataFormat, VGint aSx, VGint aSy, VGint aWidth, VGint aHeight); |
|
614 |
static void HostVgWritePixels(MVgContext& aVgContext, const void* aPixmap, size_t aPixmapSize, VGint aHostDataStride, |
|
615 |
VGImageFormat aDataFormat, VGint aDx, VGint aDy, VGint aWidth, VGint aHeight); |
|
616 |
||
617 |
static VGint HostGetVectorSize(MVgContext& aVgContext, VGParamType aType); |
|
618 |
||
619 |
public: // ToDo find a more elegant way of calling this from XOpenVgState |
|
620 |
static VGint HostGeti(MVgContext& aVgContext, VGParamType type); |
|
621 |
private: |
|
622 |
static inline VGfloat HostGetf(MVgContext& aVgContext, VGParamType type); |
|
623 |
}; |
|
624 |
||
625 |
||
626 |
// C api extensions |
|
627 |
#ifdef __cplusplus |
|
628 |
extern "C" { |
|
629 |
#endif |
|
630 |
||
631 |
VGImage vgCreateEGLImageTargetKHR(VGeglImageKHR image); |
|
632 |
||
633 |
#ifdef __cplusplus |
|
634 |
} |
|
635 |
#endif |
|
636 |
||
637 |
||
638 |
#include "openvg.inl" |
|
639 |
||
640 |
#endif // VGSTATE_H |