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 |
// Inline functions for Open VG client-side state classes.
|
|
15 |
|
|
16 |
#ifndef OPENVG_INL
|
|
17 |
#define OPENVG_INL
|
|
18 |
|
|
19 |
#include "vgstate.h"
|
|
20 |
|
|
21 |
|
|
22 |
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
23 |
// XOpenVgState
|
|
24 |
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
25 |
|
|
26 |
RMutex& XOpenVgState::MutexWait()
|
|
27 |
{
|
|
28 |
iStateLock.Wait();
|
|
29 |
return iStateLock;
|
|
30 |
}
|
|
31 |
|
|
32 |
|
|
33 |
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
34 |
// CVgHandleBase
|
|
35 |
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
36 |
|
|
37 |
CVgHandleBase::CVgHandleBase(TVgHandleType aHandleType) :
|
|
38 |
iClientHandle(iHandleGen.NextUid()), iHandleType(aHandleType), iHostHandle(VG_INVALID_HANDLE), iIsDestroyed(EFalse)
|
|
39 |
{
|
|
40 |
}
|
|
41 |
|
|
42 |
|
|
43 |
CVgHandleBase::~CVgHandleBase()
|
|
44 |
{
|
|
45 |
VGPANIC_ASSERT_DEBUG( iIsDestroyed || (iHostHandle == VG_INVALID_HANDLE), EVgPanicTemp);
|
|
46 |
}
|
|
47 |
|
|
48 |
|
|
49 |
TUint CVgHandleBase::ClientHandle() const
|
|
50 |
{
|
|
51 |
return iClientHandle;
|
|
52 |
}
|
|
53 |
|
|
54 |
|
|
55 |
VGHandle CVgHandleBase::HostHandle() const
|
|
56 |
{
|
|
57 |
VGPANIC_ASSERT(iHostHandle, EVgPanicHostHandleIsInvalid);
|
|
58 |
return iHostHandle;
|
|
59 |
}
|
|
60 |
|
|
61 |
|
|
62 |
TVgHandleType CVgHandleBase::HandleType() const
|
|
63 |
{
|
|
64 |
return iHandleType;
|
|
65 |
}
|
|
66 |
|
|
67 |
|
|
68 |
TBool CVgHandleBase::IsDestroyed() const
|
|
69 |
{
|
|
70 |
return iIsDestroyed;
|
|
71 |
}
|
|
72 |
|
|
73 |
|
|
74 |
void CVgHandleBase::SetHostHandle(VGHandle aHostHandle)
|
|
75 |
{ // should be set exactly once (For EglImages it should be the underlying VG Image)
|
|
76 |
VGPANIC_ASSERT(iHostHandle == 0, EVgPanicHostHandleAlreadySet);
|
|
77 |
VGPANIC_ASSERT(aHostHandle, EVgPanicHostHandleIsInvalid);
|
|
78 |
iHostHandle = aHostHandle;
|
|
79 |
}
|
|
80 |
|
|
81 |
|
|
82 |
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
83 |
// CVgImageBase
|
|
84 |
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
85 |
|
|
86 |
CVgImageBase::CVgImageBase(TVgHandleType aHandleType, VGint aWidth, VGint aHeight) :
|
|
87 |
CVgHandleBase(aHandleType), iWidth(aWidth), iHeight(aHeight)
|
|
88 |
{
|
|
89 |
}
|
|
90 |
|
|
91 |
|
|
92 |
VGint CVgImageBase::Width() const
|
|
93 |
{
|
|
94 |
return iWidth;
|
|
95 |
}
|
|
96 |
|
|
97 |
|
|
98 |
VGint CVgImageBase::Height() const
|
|
99 |
{
|
|
100 |
return iHeight;
|
|
101 |
}
|
|
102 |
|
|
103 |
|
|
104 |
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
105 |
// TCleanupVgLocks
|
|
106 |
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
107 |
|
|
108 |
/*
|
|
109 |
Returns false & sets VG error to VG_BAD_HANDLE_ERROR if aPath is not a valid VGPath handle
|
|
110 |
*/
|
|
111 |
TBool TCleanupVgLocks::CheckVGPath(VGPath aPath, CVgPathInfo** aPathInfo, VGbitfield aReqdCapabilities)
|
|
112 |
{ // VGPath is an opaque data handle
|
|
113 |
TBool valid = OpenVgState.CheckVGHandle(iVgContext, aPath, (CVgHandleBase**)aPathInfo, EVgHandleForPath);
|
|
114 |
if (valid && aReqdCapabilities)
|
|
115 |
{ // Check for VG_PATH_CAPABILITY_ERROR
|
|
116 |
return (*aPathInfo)->CheckHasPathCapabilities(iVgContext, aReqdCapabilities);
|
|
117 |
}
|
|
118 |
return valid;
|
|
119 |
}
|
|
120 |
|
|
121 |
|
|
122 |
/*
|
|
123 |
Returns false & sets VG error to VG_BAD_HANDLE_ERROR if aPath is neither VG_INVALID_HANDLE or a valid VGPath handle
|
|
124 |
*/
|
|
125 |
TBool TCleanupVgLocks::CheckOptionalVGPath(VGPath aPath, CVgPathInfo** aPathInfo)
|
|
126 |
{ // VGPath is an opaque data handle
|
|
127 |
if (aPath == VG_INVALID_HANDLE)
|
|
128 |
{
|
|
129 |
return ETrue;
|
|
130 |
}
|
|
131 |
return OpenVgState.CheckVGHandle(iVgContext, aPath, (CVgHandleBase**)aPathInfo, EVgHandleForPath);
|
|
132 |
}
|
|
133 |
|
|
134 |
|
|
135 |
/*
|
|
136 |
Returns false & sets VG error to VG_BAD_HANDLE_ERROR if aPaint is not a valid VGPaint handle
|
|
137 |
*/
|
|
138 |
TBool TCleanupVgLocks::CheckVGPaint(VGPaint aPaint, CVgPaintInfo** aPaintInfo)
|
|
139 |
{ // VGPaint is an opaque data handle
|
|
140 |
return OpenVgState.CheckVGHandle(iVgContext, aPaint, (CVgHandleBase**)aPaintInfo, EVgHandleForPaint);
|
|
141 |
}
|
|
142 |
|
|
143 |
|
|
144 |
/*
|
|
145 |
Returns false & sets VG error to VG_BAD_HANDLE_ERROR if aPaint is neither VG_INVALID_HANDLE or a valid VGPaint handle
|
|
146 |
*/
|
|
147 |
TBool TCleanupVgLocks::CheckOptionalVGPaint(VGPaint aPaint, CVgPaintInfo** aPaintInfo)
|
|
148 |
{ // VGPaint is an opaque data handle
|
|
149 |
if (aPaint == VG_INVALID_HANDLE)
|
|
150 |
{
|
|
151 |
return ETrue;
|
|
152 |
}
|
|
153 |
return OpenVgState.CheckVGHandle(iVgContext, aPaint, (CVgHandleBase**)aPaintInfo, EVgHandleForPaint);
|
|
154 |
}
|
|
155 |
|
|
156 |
|
|
157 |
/*
|
|
158 |
Returns false & sets VG error to VG_BAD_HANDLE_ERROR if aImage is not a valid VGImage handle
|
|
159 |
*/
|
|
160 |
TBool TCleanupVgLocks::CheckVGImage(VGImage aImage, CVgImageInfo** aImageInfo)
|
|
161 |
{ // VGImage is an opaque data handle
|
|
162 |
return OpenVgState.CheckVGHandle(iVgContext, aImage, (CVgHandleBase**)aImageInfo, EVgHandleForImage);
|
|
163 |
}
|
|
164 |
|
|
165 |
|
|
166 |
/*
|
|
167 |
Returns false & sets VG error to VG_BAD_HANDLE_ERROR if aImage is neither VG_INVALID_HANDLE or a valid VGImage handle
|
|
168 |
*/
|
|
169 |
TBool TCleanupVgLocks::CheckOptionalVGImage(VGImage aImage, CVgImageInfo** aImageInfo)
|
|
170 |
{ // VGImage is an opaque data handle
|
|
171 |
if (aImage == VG_INVALID_HANDLE)
|
|
172 |
{
|
|
173 |
return ETrue;
|
|
174 |
}
|
|
175 |
return OpenVgState.CheckVGHandle(iVgContext, aImage, (CVgHandleBase**)aImageInfo, EVgHandleForImage);
|
|
176 |
}
|
|
177 |
|
|
178 |
|
|
179 |
/*
|
|
180 |
Returns false & sets VG error to VG_BAD_HANDLE_ERROR if aImage is not a valid VGImage handle,
|
|
181 |
or if the 2 Images are the same.
|
|
182 |
*/
|
|
183 |
TBool TCleanupVgLocks::Check2VGImages(VGImage aImage1, CVgImageInfo** aImageInfo1, VGImage aImage2, CVgImageInfo** aImageInfo2)
|
|
184 |
{ // VGImage is an opaque data handle
|
|
185 |
// ToDo some (all?) callers need the 2 images to not be overlapping
|
|
186 |
if (aImage1 != aImage2)
|
|
187 |
{
|
|
188 |
return OpenVgState.CheckVGHandle(iVgContext, aImage1, (CVgHandleBase**)aImageInfo1, EVgHandleForImage) &&
|
|
189 |
OpenVgState.CheckVGHandle(iVgContext, aImage2, (CVgHandleBase**)aImageInfo2, EVgHandleForImage);
|
|
190 |
}
|
|
191 |
iVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR);
|
|
192 |
return EFalse;
|
|
193 |
}
|
|
194 |
|
|
195 |
/*
|
|
196 |
Returns false & sets VG error to VG_BAD_HANDLE_ERROR if aFont is not a valid VGFont handle
|
|
197 |
*/
|
|
198 |
TBool TCleanupVgLocks::CheckVGFont(VGFont aFont, CVgFontInfo** aFontInfo)
|
|
199 |
{ // VGFont is an opaque data handle
|
|
200 |
return OpenVgState.CheckVGHandle(iVgContext, aFont, (CVgHandleBase**)aFontInfo, EVgHandleForFont);
|
|
201 |
}
|
|
202 |
|
|
203 |
|
|
204 |
/*
|
|
205 |
Returns false & sets VG error to VG_BAD_HANDLE_ERROR if aMaskLayer is not a valid VGMaskLayer handle
|
|
206 |
*/
|
|
207 |
TBool TCleanupVgLocks::CheckVGMaskLayer(VGMaskLayer aMaskLayer, CVgMaskLayerInfo** aMaskLayerInfo)
|
|
208 |
{ // VGMaskLayer is an opaque data handle
|
|
209 |
return OpenVgState.CheckVGHandle(iVgContext, aMaskLayer, (CVgHandleBase**)aMaskLayerInfo, EVgHandleForMaskLayer);
|
|
210 |
}
|
|
211 |
|
|
212 |
|
|
213 |
/*
|
|
214 |
Returns false & sets VG error to VG_BAD_HANDLE_ERROR if aHandle is not a valid Open VG handle
|
|
215 |
*/
|
|
216 |
TBool TCleanupVgLocks::CheckVGAnyHandle(VGHandle aHandle, CVgHandleBase** aHandleInfo)
|
|
217 |
{
|
|
218 |
return OpenVgState.CheckVGHandle(iVgContext, aHandle, aHandleInfo, EVgHandleAny);
|
|
219 |
}
|
|
220 |
|
|
221 |
|
|
222 |
TBool TCleanupVgLocks::CheckKernelWidthAndHeight(VGint aKernelWidth, VGint aKernelHeight, VGParamType aLimitType)
|
|
223 |
{
|
|
224 |
return OpenVgState.CheckKernelWidthAndHeight(iVgContext, aKernelWidth, aKernelHeight, aLimitType);
|
|
225 |
}
|
|
226 |
|
|
227 |
|
|
228 |
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
229 |
// TCheck - parameter checking utility functions
|
|
230 |
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
231 |
|
|
232 |
/*
|
|
233 |
Returns false & sets VG error to VG_ILLEGAL_ARGUMENT_ERROR if aDataPtr is NULL or not 32-bit aligned
|
|
234 |
*/
|
|
235 |
TBool TCheck::Chk32bitPtr(MVgContext& aVgContext, const void* aDataPtr)
|
|
236 |
{
|
|
237 |
TBool result = (aDataPtr != NULL) && !(3ul & (unsigned)aDataPtr);
|
|
238 |
if (!result)
|
|
239 |
{
|
|
240 |
OPENVG_TRACE("TCheck::Chk32bitPtr setting VG_ILLEGAL_ARGUMENT_ERROR");
|
|
241 |
aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR);
|
|
242 |
}
|
|
243 |
return result;
|
|
244 |
}
|
|
245 |
|
|
246 |
|
|
247 |
/*
|
|
248 |
Returns false & sets VG error to VG_ILLEGAL_ARGUMENT_ERROR if aDataPtrN is NULL or not 32-bit aligned
|
|
249 |
*/
|
|
250 |
TBool TCheck::Chk2x32bitPtr(MVgContext& aVgContext, const void* aDataPtr1, const void* aDataPtr2)
|
|
251 |
{
|
|
252 |
TBool result = (aDataPtr1 != NULL) && !(3ul & (unsigned)aDataPtr1) && (aDataPtr2 != NULL) && !(3ul & (unsigned)aDataPtr2);
|
|
253 |
if (!result)
|
|
254 |
{
|
|
255 |
OPENVG_TRACE("TCheck::Chk2x32bitPtr setting VG_ILLEGAL_ARGUMENT_ERROR");
|
|
256 |
aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR);
|
|
257 |
}
|
|
258 |
return result;
|
|
259 |
}
|
|
260 |
|
|
261 |
|
|
262 |
/*
|
|
263 |
Returns false & sets VG error to VG_ILLEGAL_ARGUMENT_ERROR if aDataPtrN is NULL or not 32-bit aligned
|
|
264 |
*/
|
|
265 |
TBool TCheck::Chk4x32bitPtr(MVgContext& aVgContext, const void* aDataPtr1, const void* aDataPtr2, const void* aDataPtr3, const void* aDataPtr4)
|
|
266 |
{
|
|
267 |
TBool result = (aDataPtr1 != NULL) && !(3ul & (unsigned)aDataPtr1) && (aDataPtr2 != NULL) && !(3ul & (unsigned)aDataPtr2) &&
|
|
268 |
(aDataPtr3 != NULL) && !(3ul & (unsigned)aDataPtr3) && (aDataPtr4 != NULL) && !(3ul & (unsigned)aDataPtr4);
|
|
269 |
if (!result)
|
|
270 |
{
|
|
271 |
OPENVG_TRACE("TCheck::Chk4x32bitPtr setting VG_ILLEGAL_ARGUMENT_ERROR");
|
|
272 |
aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR);
|
|
273 |
}
|
|
274 |
return result;
|
|
275 |
}
|
|
276 |
|
|
277 |
|
|
278 |
/*
|
|
279 |
Returns false & sets VG error to VG_ILLEGAL_ARGUMENT_ERROR if aDataPtrN is not-NULL and not 32-bit aligned
|
|
280 |
*/
|
|
281 |
TBool TCheck::Chk2xOptional32bitPtr(MVgContext& aVgContext, const void* aDataPtr1, const void* aDataPtr2)
|
|
282 |
{
|
|
283 |
TBool result = !(3ul & (unsigned)aDataPtr1) && !(3ul & (unsigned)aDataPtr2);
|
|
284 |
if (!result)
|
|
285 |
{
|
|
286 |
OPENVG_TRACE("TCheck::Chk2xOptional32bitPtr setting VG_ILLEGAL_ARGUMENT_ERROR");
|
|
287 |
aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR);
|
|
288 |
}
|
|
289 |
return result;
|
|
290 |
}
|
|
291 |
|
|
292 |
|
|
293 |
/*
|
|
294 |
Returns false & sets VG error to VG_ILLEGAL_ARGUMENT_ERROR if aDataPtr is NULL or not 16-bit aligned
|
|
295 |
*/
|
|
296 |
TBool TCheck::Chk16bitPtr(MVgContext& aVgContext, const void* aDataPtr)
|
|
297 |
{
|
|
298 |
TBool result = (aDataPtr != NULL) && !(1ul & (unsigned)aDataPtr);
|
|
299 |
if (!result)
|
|
300 |
{
|
|
301 |
OPENVG_TRACE("TCheck::Chk16bitPtr setting VG_ILLEGAL_ARGUMENT_ERROR");
|
|
302 |
aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR);
|
|
303 |
}
|
|
304 |
return result;
|
|
305 |
}
|
|
306 |
|
|
307 |
|
|
308 |
/*
|
|
309 |
Returns false & sets VG error to VG_ILLEGAL_ARGUMENT_ERROR if either aDataPtr1 or aDataPtr2 is NULL or not 16-bit aligned
|
|
310 |
*/
|
|
311 |
TBool TCheck::Chk2x16bitPtr(MVgContext& aVgContext, const void* aDataPtr1, const void* aDataPtr2)
|
|
312 |
{
|
|
313 |
TBool result = (aDataPtr1 != NULL) && !(1ul & (unsigned)aDataPtr1) && (aDataPtr2 != NULL) && !(1ul & (unsigned)aDataPtr2);
|
|
314 |
if (!result)
|
|
315 |
{
|
|
316 |
OPENVG_TRACE("TCheck::Chk2x16bitPtr setting VG_ILLEGAL_ARGUMENT_ERROR");
|
|
317 |
aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR);
|
|
318 |
}
|
|
319 |
return result;
|
|
320 |
}
|
|
321 |
|
|
322 |
|
|
323 |
/*
|
|
324 |
Returns false & sets VG error to VG_UNSUPPORTED_PATH_FORMAT_ERROR if pathFormat is not a supported format
|
|
325 |
*/
|
|
326 |
TBool TCheck::ChkVGPathFormat(MVgContext& aVgContext, VGint aPathFormat)
|
|
327 |
{
|
|
328 |
switch (aPathFormat)
|
|
329 |
{
|
|
330 |
case VG_PATH_FORMAT_STANDARD:
|
|
331 |
return ETrue;
|
|
332 |
default:
|
|
333 |
OPENVG_TRACE("TCheck::ChkVGPathFormat setting VG_UNSUPPORTED_PATH_FORMAT_ERROR");
|
|
334 |
aVgContext.SetVgError(VG_UNSUPPORTED_PATH_FORMAT_ERROR);
|
|
335 |
return EFalse;
|
|
336 |
}
|
|
337 |
}
|
|
338 |
|
|
339 |
|
|
340 |
/*
|
|
341 |
Returns false & sets VG error to VG_ILLEGAL_ARGUMENT_ERROR if datatype is not a valid value from the VGPathDatatype enumeration
|
|
342 |
*/
|
|
343 |
TBool TCheck::ChkVGPathDataType(MVgContext& aVgContext, VGPathDatatype aDatatype)
|
|
344 |
{
|
|
345 |
switch (aDatatype)
|
|
346 |
{
|
|
347 |
case VG_PATH_DATATYPE_S_8:
|
|
348 |
case VG_PATH_DATATYPE_S_16:
|
|
349 |
case VG_PATH_DATATYPE_S_32:
|
|
350 |
case VG_PATH_DATATYPE_F:
|
|
351 |
return ETrue;
|
|
352 |
default:
|
|
353 |
OPENVG_TRACE("TCheck::ChkVGPathDataType setting VG_ILLEGAL_ARGUMENT_ERROR");
|
|
354 |
aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR);
|
|
355 |
return EFalse;
|
|
356 |
}
|
|
357 |
}
|
|
358 |
|
|
359 |
|
|
360 |
/*
|
|
361 |
aWidth & aHeight parameters must be >0, otherwise a VG_ILLEGAL_ARGUMENT_ERROR is flagged.
|
|
362 |
*/
|
|
363 |
TBool TCheck::ChkPositiveImageSize(MVgContext& aVgContext, VGint aWidth, VGint aHeight)
|
|
364 |
{
|
|
365 |
if ( (aWidth > 0) && (aHeight > 0) )
|
|
366 |
{
|
|
367 |
return ETrue;
|
|
368 |
}
|
|
369 |
OPENVG_TRACE("TCheck::ChkPositiveImageSize setting VG_ILLEGAL_ARGUMENT_ERROR");
|
|
370 |
aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR);
|
|
371 |
return EFalse;
|
|
372 |
}
|
|
373 |
|
|
374 |
|
|
375 |
/*
|
|
376 |
aWidth & aHeight parameters must be >0, otherwise a VG_ILLEGAL_ARGUMENT_ERROR is flagged.
|
|
377 |
*/
|
|
378 |
TBool TCheck::ChkNewImageSize(MVgContext& aVgContext, VGint aWidth, VGint aHeight)
|
|
379 |
{
|
|
380 |
// ToDo compare with max limits fetched from Host Open VG:VG_MAX_IMAGE_WIDTH, VG_MAX_IMAGE_HEIGHT & VG_MAX_IMAGE_PIXELS
|
|
381 |
if ( (aWidth > 0) && (aHeight > 0) )
|
|
382 |
{
|
|
383 |
return ETrue;
|
|
384 |
}
|
|
385 |
OPENVG_TRACE("TCheck::ChkNewImageSize setting VG_ILLEGAL_ARGUMENT_ERROR");
|
|
386 |
aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR);
|
|
387 |
return EFalse;
|
|
388 |
}
|
|
389 |
|
|
390 |
|
|
391 |
/*
|
|
392 |
Returns false & sets VG error to VG_ILLEGAL_ARGUMENT_ERROR if aPaintMode is not a valid VGPaintMode
|
|
393 |
*/
|
|
394 |
TBool TCheck::ChkVGPaintMode(MVgContext& aVgContext, VGPaintMode aPaintMode)
|
|
395 |
{
|
|
396 |
switch(aPaintMode)
|
|
397 |
{
|
|
398 |
case VG_STROKE_PATH:
|
|
399 |
case VG_FILL_PATH:
|
|
400 |
return ETrue;
|
|
401 |
default:
|
|
402 |
OPENVG_TRACE("TCheck::ChkVGPaintMode setting VG_ILLEGAL_ARGUMENT_ERROR");
|
|
403 |
aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR);
|
|
404 |
return EFalse;
|
|
405 |
}
|
|
406 |
}
|
|
407 |
|
|
408 |
|
|
409 |
/*
|
|
410 |
Returns false & sets VG error to VG_ILLEGAL_ARGUMENT_ERROR if aPaintModes has invalid VGPaintMode bits set
|
|
411 |
*/
|
|
412 |
TBool TCheck::ChkVGPaintModesCombination(MVgContext& aVgContext, VGbitfield aPaintModes)
|
|
413 |
{
|
|
414 |
if (aPaintModes & ~(VG_STROKE_PATH | VG_FILL_PATH))
|
|
415 |
{
|
|
416 |
OPENVG_TRACE("TCheck::ChkVGPaintModesCombination setting VG_ILLEGAL_ARGUMENT_ERROR");
|
|
417 |
aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR);
|
|
418 |
return EFalse;
|
|
419 |
}
|
|
420 |
return ETrue;
|
|
421 |
}
|
|
422 |
|
|
423 |
|
|
424 |
/*
|
|
425 |
Returns false & sets VG error to VG_ILLEGAL_ARGUMENT_ERROR if VGMaskOperation is not a supported operation
|
|
426 |
*/
|
|
427 |
TBool TCheck::ChkVGMaskOperation(MVgContext& aVgContext, VGMaskOperation aOperation)
|
|
428 |
{
|
|
429 |
switch (aOperation)
|
|
430 |
{
|
|
431 |
case VG_CLEAR_MASK:
|
|
432 |
case VG_FILL_MASK:
|
|
433 |
case VG_SET_MASK:
|
|
434 |
case VG_UNION_MASK:
|
|
435 |
case VG_INTERSECT_MASK:
|
|
436 |
case VG_SUBTRACT_MASK:
|
|
437 |
return ETrue;
|
|
438 |
default:
|
|
439 |
OPENVG_TRACE("TCheck::ChkVGMaskOperation setting VG_ILLEGAL_ARGUMENT_ERROR");
|
|
440 |
aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR);
|
|
441 |
return EFalse;
|
|
442 |
}
|
|
443 |
}
|
|
444 |
|
|
445 |
|
|
446 |
TBool TCheck::ChkVgImageFormat(MVgContext& aVgContext, VGImageFormat aFormat)
|
|
447 |
{
|
|
448 |
if ( ImageFormatByteDepth(aFormat) )
|
|
449 |
{
|
|
450 |
return ETrue;
|
|
451 |
}
|
|
452 |
OPENVG_TRACE("TCheck::ChkVgImageFormat setting VG_UNSUPPORTED_IMAGE_FORMAT_ERROR");
|
|
453 |
aVgContext.SetVgError(VG_UNSUPPORTED_IMAGE_FORMAT_ERROR);
|
|
454 |
return EFalse;
|
|
455 |
}
|
|
456 |
|
|
457 |
|
|
458 |
/*
|
|
459 |
Checks aData is aligned according to the specified VGImageFormet.
|
|
460 |
|
|
461 |
On failure sets these VgErrors:
|
|
462 |
VG_UNSUPPORTED_IMAGE_FORMAT_ERROR
|
|
463 |
– if aImageFormat is not a valid value from the VGImageFormat enumeration
|
|
464 |
VG_ILLEGAL_ARGUMENT_ERROR
|
|
465 |
– if width or height is less than or equal to 0
|
|
466 |
– if data is NULL
|
|
467 |
– if data is not properly aligned
|
|
468 |
|
|
469 |
*/
|
|
470 |
TBool TCheck::ChkImageAlignment(MVgContext& aVgContext, VGImageFormat aImageFormat, const void* aData)
|
|
471 |
{
|
|
472 |
TBool result = EFalse;
|
|
473 |
if (aData != NULL)
|
|
474 |
{
|
|
475 |
switch( ImageFormatByteDepth(aImageFormat) )
|
|
476 |
{
|
|
477 |
case 1:
|
|
478 |
result = ETrue;
|
|
479 |
break;
|
|
480 |
case 2:
|
|
481 |
result = !( 1ul & (unsigned)aData );
|
|
482 |
break;
|
|
483 |
case 4:
|
|
484 |
result = !( 3ul & (unsigned)aData );
|
|
485 |
break;
|
|
486 |
default:
|
|
487 |
OPENVG_TRACE("TCheck::ImageAlignment setting VG_UNSUPPORTED_IMAGE_FORMAT_ERROR");
|
|
488 |
aVgContext.SetVgError(VG_UNSUPPORTED_IMAGE_FORMAT_ERROR);
|
|
489 |
return EFalse;
|
|
490 |
}
|
|
491 |
}
|
|
492 |
if (!result)
|
|
493 |
{
|
|
494 |
OPENVG_TRACE("TCheck::ImageAlignment setting VG_ILLEGAL_ARGUMENT_ERROR");
|
|
495 |
aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR);
|
|
496 |
}
|
|
497 |
return result;
|
|
498 |
}
|
|
499 |
|
|
500 |
|
|
501 |
/*
|
|
502 |
Returns false & sets VG error to VG_ILLEGAL_ARGUMENT_ERROR if aTilingMode is not a valid value from the
|
|
503 |
VGTilingMode enumeration
|
|
504 |
*/
|
|
505 |
TBool TCheck::ChkVGTilingMode(MVgContext& aVgContext, VGTilingMode aTilingMode)
|
|
506 |
{
|
|
507 |
switch (aTilingMode)
|
|
508 |
{
|
|
509 |
case VG_TILE_FILL:
|
|
510 |
case VG_TILE_PAD:
|
|
511 |
case VG_TILE_REPEAT:
|
|
512 |
case VG_TILE_REFLECT:
|
|
513 |
return ETrue;
|
|
514 |
default:
|
|
515 |
OPENVG_TRACE("TCheck::ChkVGTilingMode setting VG_ILLEGAL_ARGUMENT_ERROR");
|
|
516 |
aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR);
|
|
517 |
return EFalse;
|
|
518 |
}
|
|
519 |
}
|
|
520 |
|
|
521 |
|
|
522 |
#endif // OPENVG_INL
|