|
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 // C++ version of Open VG API. |
|
15 |
|
16 #include "openvg.inl" |
|
17 #include "remotefunctioncall.h" |
|
18 #include "openvgrfc.h" |
|
19 |
|
20 |
|
21 // normalized IEEE 754 representations |
|
22 const float KFloatMinusOne = -1.0f; |
|
23 const float KFloatZero = 0.0f; |
|
24 |
|
25 const TInt KTransformMatrixSize = 9; |
|
26 |
|
27 ///////////////////////////////////////////////////////////////////////////////////////////// |
|
28 // TGuestOpenVg |
|
29 ///////////////////////////////////////////////////////////////////////////////////////////// |
|
30 |
|
31 // --------------------------------------------------------------------- |
|
32 // TGuestOpenVg - private inline & paramater checking functions |
|
33 |
|
34 // helper function |
|
35 /////////////////////////////////////////////////////////////////////////////////////////////// |
|
36 // Implementation of Open VG APIs ... with comments summarising possible errors. |
|
37 |
|
38 //////////////////////////////////////////////////////////////////////////////////////////// |
|
39 //Functions returning value |
|
40 //////////////////////////////////////////////////////////////////////////////////////////// |
|
41 |
|
42 /* |
|
43 ERRORS |
|
44 VG_ILLEGAL_ARGUMENT_ERROR |
|
45 – if paintMode is not a valid value from the VGPaintMode enumeration |
|
46 */ |
|
47 VGPaint TGuestOpenVg::vgGetPaint(VGPaintMode aPaintMode) |
|
48 { |
|
49 VGPaint paintHandle = VG_INVALID_HANDLE; |
|
50 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
51 if (vgContext && TCheck::ChkVGPaintMode(*vgContext, aPaintMode)) |
|
52 { |
|
53 TCleanupVgLocks vgLock(*vgContext); |
|
54 paintHandle = vgLock.GetPaint(aPaintMode); |
|
55 } |
|
56 else if (!vgContext) |
|
57 { |
|
58 OPENVG_TRACE(" TGuestOpenVg::vgGetPaint - no VG context"); |
|
59 } |
|
60 else |
|
61 { |
|
62 OPENVG_TRACE(" TGuestOpenVg::vgGetPaint - ParamCheck failed"); |
|
63 } |
|
64 return paintHandle; |
|
65 } |
|
66 |
|
67 |
|
68 /* |
|
69 If insufficient memory is available to allocate a new object, VG_INVALID_HANDLE is returned. |
|
70 */ |
|
71 VGPaint TGuestOpenVg::vgCreatePaint() |
|
72 { |
|
73 VGPaint paintHandle = VG_INVALID_HANDLE; |
|
74 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
75 if (vgContext) |
|
76 { |
|
77 TCleanupVgLocks vgLock(*vgContext); |
|
78 paintHandle = vgLock.CreatePaint(); |
|
79 } |
|
80 else |
|
81 { |
|
82 OPENVG_TRACE(" TGuestOpenVg::vgCreatePaint - no VG context"); |
|
83 } |
|
84 |
|
85 return paintHandle; |
|
86 } |
|
87 |
|
88 |
|
89 /* |
|
90 ERRORS |
|
91 VG_BAD_HANDLE_ERROR |
|
92 – if any of dstPath, startPath, or endPath is not a valid path handle, or is |
|
93 not shared with the current context |
|
94 VG_PATH_CAPABILITY_ERROR |
|
95 – if VG_PATH_CAPABILITY_INTERPOLATE_TO is not enabled for dstPath |
|
96 – if VG_PATH_CAPABILITY_INTERPOLATE_FROM is not enabled for startPath or endPath |
|
97 */ |
|
98 VGboolean TGuestOpenVg::vgInterpolatePath(VGPath aDstPath, VGPath aStartPath, VGPath aEndPath, VGfloat aAmount) |
|
99 { |
|
100 VGboolean result = VG_FALSE; |
|
101 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
102 |
|
103 if ( vgContext ) |
|
104 { |
|
105 CVgPathInfo* dstPathInfo = NULL; |
|
106 CVgPathInfo* startPathInfo = NULL; |
|
107 CVgPathInfo* endPathInfo = NULL; |
|
108 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
109 |
|
110 if ( vgLock.CheckVGPath(aDstPath, &dstPathInfo, VG_PATH_CAPABILITY_INTERPOLATE_TO) && |
|
111 vgLock.CheckVGPath(aStartPath, &startPathInfo, VG_PATH_CAPABILITY_INTERPOLATE_FROM) && |
|
112 vgLock.CheckVGPath(aEndPath, &endPathInfo, VG_PATH_CAPABILITY_INTERPOLATE_FROM) ) |
|
113 { |
|
114 result = dstPathInfo->InterpolatePath(*vgContext, *startPathInfo, *endPathInfo, aAmount); |
|
115 } |
|
116 } |
|
117 return result; |
|
118 } |
|
119 |
|
120 |
|
121 /* |
|
122 ERRORS |
|
123 VG_BAD_HANDLE_ERROR |
|
124 – if path is not a valid path handle, or is not shared with the current context |
|
125 VG_PATH_CAPABILITY_ERROR |
|
126 – if VG_PATH_CAPABILITY_PATH_LENGTH is not enabled for path |
|
127 VG_ILLEGAL_ARGUMENT_ERROR |
|
128 – if startSegment is less than 0 or greater than the index of the final path |
|
129 segment |
|
130 – if numSegments is less than or equal to 0 |
|
131 – if (startSegment + numSegments – 1) is greater than the index of the final |
|
132 path segment |
|
133 */ |
|
134 VGfloat TGuestOpenVg::vgPathLength(VGPath aPath, VGint aStartSegment, VGint aNumSegments) |
|
135 { |
|
136 VGfloat result = KFloatMinusOne; |
|
137 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
138 if ( vgContext ) |
|
139 { |
|
140 CVgPathInfo* pathInfo = NULL; |
|
141 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
142 |
|
143 if ( vgLock.CheckVGPath(aPath, &pathInfo, VG_PATH_CAPABILITY_PATH_LENGTH) ) |
|
144 { |
|
145 if ( (aStartSegment < 0) || (aNumSegments <= 0) ) |
|
146 { |
|
147 vgContext->SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); |
|
148 } |
|
149 else |
|
150 { |
|
151 result = pathInfo->PathLength(*vgContext, aStartSegment, aNumSegments); |
|
152 } |
|
153 } |
|
154 } |
|
155 return result; |
|
156 } |
|
157 |
|
158 |
|
159 /* |
|
160 ERRORS |
|
161 VG_BAD_HANDLE_ERROR |
|
162 – if path is not a valid path handle, or is not shared with the current context |
|
163 */ |
|
164 VGbitfield TGuestOpenVg::vgGetPathCapabilities(VGPath aPath) |
|
165 { |
|
166 VGbitfield result = 0; |
|
167 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
168 if ( vgContext ) |
|
169 { |
|
170 CVgPathInfo* pathInfo = NULL; |
|
171 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
172 |
|
173 if ( vgLock.CheckVGPath(aPath, &pathInfo) ) |
|
174 { |
|
175 result = pathInfo->GetPathCapabilities(*vgContext); |
|
176 } |
|
177 } |
|
178 return result; |
|
179 } |
|
180 |
|
181 |
|
182 /* |
|
183 ERRORS |
|
184 VG_UNSUPPORTED_PATH_FORMAT_ERROR |
|
185 – if pathFormat is not a supported format |
|
186 VG_ILLEGAL_ARGUMENT_ERROR |
|
187 – if datatype is not a valid value from the VGPathDatatype enumeration |
|
188 – if scale is equal to 0 |
|
189 */ |
|
190 VGPath TGuestOpenVg::vgCreatePath(VGint aPathFormat, VGPathDatatype aDatatype, VGfloat aScale, VGfloat aBias, |
|
191 VGint aSegmentCapacityHint, VGint aCoordCapacityHint, VGbitfield aCapabilities) |
|
192 { |
|
193 VGPath pathHandle = VG_INVALID_HANDLE; |
|
194 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
195 if ( vgContext && TCheck::ChkVGPathFormat(*vgContext, aPathFormat) && TCheck::ChkVGPathDataType(*vgContext, aDatatype) ) |
|
196 { |
|
197 if (aScale == KFloatZero) |
|
198 { |
|
199 vgContext->SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); |
|
200 } |
|
201 else |
|
202 { |
|
203 TCleanupVgLocks vgLock(*vgContext); // Waits & holds VG mutex until destruction |
|
204 pathHandle = vgLock.CreatePath(aPathFormat, aDatatype, aScale, aBias, aSegmentCapacityHint, aCoordCapacityHint, aCapabilities); |
|
205 } |
|
206 } |
|
207 else if (!vgContext) |
|
208 { |
|
209 OPENVG_TRACE(" TGuestOpenVg::vgCreatePath - no VG context"); |
|
210 } |
|
211 else |
|
212 { |
|
213 OPENVG_TRACE(" TGuestOpenVg::vgCreatePath - ParamCheck failed"); |
|
214 } |
|
215 |
|
216 return pathHandle; |
|
217 } |
|
218 |
|
219 |
|
220 /* For vgGeti, vgGetf, and vgGetVectorSize. |
|
221 If an error occurs during a call to vgGetf, vgGeti, or vgGetVectorSize, the return value |
|
222 is undefined. |
|
223 |
|
224 ERRORS |
|
225 VG_ILLEGAL_ARGUMENT_ERROR |
|
226 – if paramType is not a valid value from the VGParamType enumeration |
|
227 – if paramType refers to a vector parameter in vgGetf or vgGeti |
|
228 */ |
|
229 VGint TGuestOpenVg::HostGeti(MVgContext& aVgContext, VGParamType aType) |
|
230 { |
|
231 RemoteFunctionCallData data; OpenVgRFC vgApiData(data); |
|
232 vgApiData.Init(OpenVgRFC::EvgGeti); |
|
233 vgApiData.AppendParam(aType); |
|
234 VGPANIC_ASSERT_DEBUG(vgApiData.Data().Header().iOpType == RemoteFunctionCallData::EOpRequestWithReply, EVgPanicNotReplyOpcode); |
|
235 aVgContext.ExecuteVgCommand(vgApiData); |
|
236 return static_cast<VGint>(vgApiData.ReturnValue()); |
|
237 } |
|
238 |
|
239 |
|
240 VGfloat TGuestOpenVg::HostGetf(MVgContext& aVgContext, VGParamType aType) |
|
241 { |
|
242 RemoteFunctionCallData data; OpenVgRFC vgApiData(data); |
|
243 vgApiData.Init(OpenVgRFC::EvgGetf); |
|
244 vgApiData.AppendParam(aType); |
|
245 VGPANIC_ASSERT_DEBUG(vgApiData.Data().Header().iOpType == RemoteFunctionCallData::EOpRequestWithReply, EVgPanicNotReplyOpcode); |
|
246 aVgContext.ExecuteVgCommand(vgApiData); |
|
247 return static_cast<VGfloat>(vgApiData.ReturnValue()); |
|
248 } |
|
249 |
|
250 |
|
251 VGint TGuestOpenVg::vgGeti(VGParamType aType) |
|
252 { |
|
253 // TODO validate aType |
|
254 VGint result = 0; |
|
255 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
256 if (vgContext) |
|
257 { |
|
258 result = HostGeti(*vgContext, aType); |
|
259 } |
|
260 return result; |
|
261 } |
|
262 |
|
263 |
|
264 VGfloat TGuestOpenVg::vgGetf(VGParamType aType) |
|
265 { |
|
266 // TODO validate aType |
|
267 VGfloat result = KFloatMinusOne; |
|
268 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
269 if (vgContext) |
|
270 { |
|
271 result = HostGetf(*vgContext, aType); |
|
272 } |
|
273 return result; |
|
274 } |
|
275 |
|
276 |
|
277 /* |
|
278 ERRORS |
|
279 VG_BAD_HANDLE_ERROR |
|
280 – if object is not a valid handle, or is not shared with the current context |
|
281 VG_ILLEGAL_ARGUMENT_ERROR |
|
282 – if paramType is not a valid value from the appropriate enumeration |
|
283 – if paramType refers to a vector parameter in vgGetParameterf or |
|
284 vgGetParameteri |
|
285 */ |
|
286 VGint TGuestOpenVg::vgGetParameteri(VGHandle aObject, VGint aParamType) |
|
287 { |
|
288 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
289 if ( vgContext ) |
|
290 { |
|
291 CVgHandleBase* handleInfo; |
|
292 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
293 |
|
294 if ( vgLock.CheckVGAnyHandle(aObject, &handleInfo) ) |
|
295 { |
|
296 return handleInfo->GetParameteri(*vgContext, aParamType); |
|
297 } |
|
298 } |
|
299 return 0; |
|
300 } |
|
301 |
|
302 |
|
303 VGint TGuestOpenVg::HostGetVectorSize(MVgContext& aVgContext, VGParamType aType) |
|
304 { |
|
305 RemoteFunctionCallData data; OpenVgRFC vgApiData(data); |
|
306 vgApiData.Init(OpenVgRFC::EvgGetVectorSize); |
|
307 vgApiData.AppendParam(aType); |
|
308 VGPANIC_ASSERT_DEBUG(vgApiData.Data().Header().iOpType == RemoteFunctionCallData::EOpRequestWithReply, EVgPanicNotReplyOpcode); |
|
309 aVgContext.ExecuteVgCommand(vgApiData); |
|
310 return static_cast<VGint>(vgApiData.ReturnValue()); |
|
311 } |
|
312 |
|
313 |
|
314 VGint TGuestOpenVg::vgGetVectorSize(VGParamType aType) |
|
315 { |
|
316 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
317 if (vgContext) |
|
318 { // **** Desirable: check aType |
|
319 return HostGetVectorSize(*vgContext, aType); |
|
320 } |
|
321 return 0; |
|
322 } |
|
323 |
|
324 |
|
325 VGfloat TGuestOpenVg::vgGetParameterf(VGHandle aObject, VGint aParamType) |
|
326 { |
|
327 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
328 if ( vgContext ) |
|
329 { |
|
330 CVgHandleBase* handleInfo; |
|
331 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
332 |
|
333 if ( vgLock.CheckVGAnyHandle(aObject, &handleInfo) ) |
|
334 { |
|
335 return handleInfo->GetParameterf(*vgContext, aParamType); |
|
336 } |
|
337 } |
|
338 return KFloatMinusOne; |
|
339 } |
|
340 |
|
341 |
|
342 /* |
|
343 ERRORS |
|
344 VG_BAD_HANDLE_ERROR |
|
345 – if object is not a valid handle, or is not shared with the current context |
|
346 VG_ILLEGAL_ARGUMENT_ERROR |
|
347 – if paramType is not a valid value from the appropriate enumeration |
|
348 */ |
|
349 VGint TGuestOpenVg::vgGetParameterVectorSize(VGHandle aObject, VGint aParamType) |
|
350 { |
|
351 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
352 if ( vgContext ) |
|
353 { |
|
354 CVgHandleBase* handleInfo; |
|
355 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
356 |
|
357 // **** Desirable: check aParamType |
|
358 if ( vgLock.CheckVGAnyHandle(aObject, &handleInfo) ) |
|
359 { |
|
360 return handleInfo->GetParameterVectorSize(*vgContext, aParamType); |
|
361 } |
|
362 } |
|
363 return 0; |
|
364 } |
|
365 |
|
366 |
|
367 /* |
|
368 ERRORS |
|
369 VG_ILLEGAL_ARGUMENT_ERROR |
|
370 – if width or height are less than or equal to 0 |
|
371 – if width is greater than VG_MAX_IMAGE_WIDTH |
|
372 – if height is greater than VG_MAX_IMAGE_HEIGHT |
|
373 – if width*height is greater than VG_MAX_IMAGE_PIXELS |
|
374 */ |
|
375 VGMaskLayer TGuestOpenVg::vgCreateMaskLayer(VGint aWidth, VGint aHeight) |
|
376 { |
|
377 VGMaskLayer maskLayerHandle = VG_INVALID_HANDLE; |
|
378 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
379 if ( vgContext && TCheck::ChkNewImageSize(*vgContext, aWidth, aHeight) ) |
|
380 { |
|
381 TCleanupVgLocks vgLock(*vgContext); |
|
382 maskLayerHandle = vgLock.CreateMaskLayer(aWidth, aHeight); |
|
383 } |
|
384 else if (!vgContext) |
|
385 { |
|
386 OPENVG_TRACE(" TGuestOpenVg::vgCreateMaskLayer - no VG context"); |
|
387 } |
|
388 else |
|
389 { |
|
390 OPENVG_TRACE(" TGuestOpenVg::vgCreateMaskLayer - ParamCheck failed"); |
|
391 } |
|
392 |
|
393 return maskLayerHandle; |
|
394 } |
|
395 |
|
396 |
|
397 /* |
|
398 ERRORS |
|
399 VG_BAD_HANDLE_ERROR |
|
400 – if paint is not a valid paint handle, or is not shared with the current context |
|
401 */ |
|
402 VGuint TGuestOpenVg::vgGetColor(VGPaint aPaint) |
|
403 { |
|
404 VGuint result = 0; |
|
405 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
406 if ( vgContext ) |
|
407 { |
|
408 CVgPaintInfo* paintInfo = NULL; |
|
409 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
410 |
|
411 if ( vgLock.CheckVGPaint(aPaint, &paintInfo) ) |
|
412 { |
|
413 result = paintInfo->GetColor(*vgContext); |
|
414 } |
|
415 } |
|
416 return result; |
|
417 } |
|
418 |
|
419 |
|
420 /* |
|
421 ERRORS |
|
422 VG_UNSUPPORTED_IMAGE_FORMAT_ERROR |
|
423 – if format is not a valid value from the VGImageFormat enumeration |
|
424 VG_ILLEGAL_ARGUMENT_ERROR |
|
425 – if width or height are less than or equal to 0 |
|
426 – if width is greater than VG_MAX_IMAGE_WIDTH |
|
427 – if height is greater than VG_MAX_IMAGE_HEIGHT |
|
428 – if width*height is greater than VG_MAX_IMAGE_PIXELS |
|
429 – if width*height*(pixel size of format) is greater than |
|
430 VG_MAX_IMAGE_BYTES |
|
431 – if allowedQuality is not a bitwise OR of values from the |
|
432 VGImageQuality enumeration |
|
433 */ |
|
434 VGImage TGuestOpenVg::vgCreateImage(VGImageFormat aFormat, VGint aWidth, VGint aHeight, VGbitfield aAllowedQuality) |
|
435 { |
|
436 VGHandle imageHandle = VG_INVALID_HANDLE; |
|
437 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
438 if ( vgContext && TCheck::ChkNewImageSize(*vgContext, aWidth, aHeight) && TCheck::ChkVgImageFormat(*vgContext, aFormat) ) |
|
439 { // width > 0 && height > 0 |
|
440 TCleanupVgLocks vgLock(*vgContext); |
|
441 imageHandle = vgLock.CreateImage(aFormat, aWidth, aHeight, aAllowedQuality); |
|
442 } |
|
443 else if (!vgContext) |
|
444 { |
|
445 OPENVG_TRACE(" TGuestOpenVg::vgCreateImage - no VG context"); |
|
446 } |
|
447 else |
|
448 { |
|
449 OPENVG_TRACE(" TGuestOpenVg::vgCreateImage - ParamCheck failed"); |
|
450 } |
|
451 |
|
452 return imageHandle; |
|
453 } |
|
454 |
|
455 |
|
456 /* |
|
457 Returns a new VGImage handle that refers to a portion of the parent image. The |
|
458 region is given by the intersection of the bounds of the parent image with the |
|
459 rectangle beginning at pixel (x, y) with dimensions width and height, which |
|
460 must define a positive region contained entirely within parent. |
|
461 |
|
462 ERRORS |
|
463 VG_BAD_HANDLE_ERROR |
|
464 – if parent is not a valid image handle, or is not shared with the current |
|
465 context |
|
466 VG_IMAGE_IN_USE_ERROR |
|
467 – if parent is currently a rendering target |
|
468 VG_ILLEGAL_ARGUMENT_ERROR |
|
469 – if x is less than 0 or greater than or equal to the parent width |
|
470 – if y is less than 0 or greater than or equal to the parent height |
|
471 – if width or height is less than or equal to 0 |
|
472 – if x + width is greater than the parent width |
|
473 – if y + height is greater than the parent height |
|
474 */ |
|
475 VGImage TGuestOpenVg::vgChildImage(VGImage aParent, VGint aX, VGint aY, VGint aWidth, VGint aHeight) |
|
476 { |
|
477 VGHandle imageHandle = VG_INVALID_HANDLE; |
|
478 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
479 if ( vgContext ) |
|
480 { |
|
481 CVgImageInfo* parentInfo = NULL; |
|
482 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
483 |
|
484 if ( vgLock.CheckVGImage(aParent, &parentInfo) && TCheck::ChkAreaIsWithinImage(*vgContext, parentInfo, aX, aY, aWidth, aHeight) ) |
|
485 { // child image area is within parent image |
|
486 imageHandle = vgLock.ChildImage(*parentInfo, aX, aY, aWidth, aHeight); |
|
487 } |
|
488 } |
|
489 else |
|
490 { |
|
491 OPENVG_TRACE(" TGuestOpenVg::vgChildImage - no VG context"); |
|
492 } |
|
493 |
|
494 return imageHandle; |
|
495 } |
|
496 |
|
497 |
|
498 /* |
|
499 ERRORS |
|
500 VG_BAD_HANDLE_ERROR |
|
501 – if image is not a valid image handle, or is not shared with the current |
|
502 context |
|
503 VG_IMAGE_IN_USE_ERROR |
|
504 – if image is currently a rendering target |
|
505 */ |
|
506 VGImage TGuestOpenVg::vgGetParent(VGImage aImage) |
|
507 { |
|
508 VGImage parentImage = VG_INVALID_HANDLE; |
|
509 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
510 if ( vgContext ) |
|
511 { |
|
512 CVgImageInfo* imageInfo = NULL; |
|
513 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
514 |
|
515 if ( vgLock.CheckVGImage(aImage, &imageInfo) ) |
|
516 { |
|
517 // baseline for a valid image is to return its own ClientHandle |
|
518 parentImage = aImage; |
|
519 // try to find a non-destroyed ancestor |
|
520 // ToDo add getParent Api to CVgImageInfo |
|
521 CVgImageInfo* parentInfo = imageInfo->Parent(); |
|
522 while (parentInfo) |
|
523 { |
|
524 if ( !parentInfo->IsDestroyed() ) |
|
525 { // nearest an ancestor |
|
526 parentImage = parentInfo->ClientHandle(); |
|
527 break; |
|
528 } |
|
529 parentInfo = parentInfo->Parent(); |
|
530 } |
|
531 } |
|
532 } |
|
533 return parentImage; |
|
534 } |
|
535 |
|
536 |
|
537 /* |
|
538 ERRORS |
|
539 VG_ILLEGAL_ARGUMENT_ERROR |
|
540 – if glyphCapacityHint is negative |
|
541 */ |
|
542 VGFont TGuestOpenVg::vgCreateFont(VGint aGlyphCapacityHint) |
|
543 { |
|
544 VGHandle fontHandle = VG_INVALID_HANDLE; |
|
545 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
546 if (vgContext) |
|
547 { |
|
548 TCleanupVgLocks vgLock(*vgContext); |
|
549 fontHandle = vgLock.CreateFont(aGlyphCapacityHint); |
|
550 } |
|
551 else |
|
552 { |
|
553 OPENVG_TRACE(" TGuestOpenVg::vgCreateFont - no VG context"); |
|
554 } |
|
555 |
|
556 return fontHandle; |
|
557 } |
|
558 |
|
559 |
|
560 /* Hardware Queries */ |
|
561 |
|
562 /* |
|
563 ERRORS |
|
564 VG_ILLEGAL_ARGUMENT_ERROR |
|
565 – if key is not one of the values from the VGHardwareQueryType enumeration |
|
566 – if setting is not one of the values from the enumeration associated with |
|
567 key |
|
568 */ |
|
569 VGHardwareQueryResult TGuestOpenVg::vgHardwareQuery(VGHardwareQueryType aKey, VGint aSetting) |
|
570 { |
|
571 TBool paramsValid = EFalse; |
|
572 |
|
573 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
574 if (vgContext) |
|
575 { |
|
576 switch (aKey) |
|
577 { |
|
578 case VG_IMAGE_FORMAT_QUERY: |
|
579 if (TCheck::ImageFormatByteDepth(static_cast<VGImageFormat>(aSetting)) > 0) |
|
580 paramsValid = ETrue; |
|
581 break; |
|
582 case VG_PATH_DATATYPE_QUERY: |
|
583 switch (aSetting) |
|
584 { |
|
585 case VG_PATH_DATATYPE_S_8: |
|
586 case VG_PATH_DATATYPE_S_16: |
|
587 case VG_PATH_DATATYPE_S_32: |
|
588 case VG_PATH_DATATYPE_F: |
|
589 paramsValid = ETrue; |
|
590 } |
|
591 break; |
|
592 } |
|
593 if (paramsValid) |
|
594 { |
|
595 RemoteFunctionCallData data; OpenVgRFC vgApiData(data); |
|
596 vgApiData.Init(OpenVgRFC::EvgHardwareQuery); |
|
597 vgApiData.AppendParam(aKey); |
|
598 vgApiData.AppendParam(aSetting); |
|
599 VGPANIC_ASSERT_DEBUG(vgApiData.Data().Header().iOpType == RemoteFunctionCallData::EOpRequestWithReply, EVgPanicNotReplyOpcode); |
|
600 vgContext->ExecuteVgCommand(vgApiData); |
|
601 return static_cast<VGHardwareQueryResult>(vgApiData.ReturnValue()); |
|
602 } |
|
603 vgContext->SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); |
|
604 } |
|
605 return VG_HARDWARE_UNACCELERATED; |
|
606 } |
|
607 |
|
608 |
|
609 /* |
|
610 ERRORS |
|
611 VG_BAD_HANDLE_ERROR |
|
612 – if object is not a valid handle, or is not shared with the current context |
|
613 VG_ILLEGAL_ARGUMENT_ERROR |
|
614 – if paramType is not a valid value from the appropriate enumeration |
|
615 – if values is NULL in vgGetParameterfv or vgGetParameteriv |
|
616 – if values is not properly aligned in vgGetParameterfv or vgGetParameteriv |
|
617 – if count is less than or equal to 0 in vgGetParameterfv or vgGetParameteriv |
|
618 – if count is greater than the value returned by vgGetParameterVectorSize for |
|
619 the given parameter in vgGetParameterfv or vgGetParameteriv |
|
620 */ |
|
621 void TGuestOpenVg::vgGetParameterfv(VGHandle aObject, VGint aParamType, VGint aCount, VGfloat * aValues) |
|
622 { |
|
623 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
624 if ( vgContext ) |
|
625 { |
|
626 CVgHandleBase* handleInfo; |
|
627 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
628 |
|
629 if ( vgLock.CheckVGAnyHandle(aObject, &handleInfo) && TCheck::Chk32bitPtr(*vgContext, aValues) ) |
|
630 { |
|
631 handleInfo->GetParameterfv(*vgContext, aParamType, aCount, aValues); |
|
632 } |
|
633 } |
|
634 } |
|
635 |
|
636 |
|
637 void TGuestOpenVg::vgGetParameteriv(VGHandle aObject, VGint aParamType, VGint aCount, VGint * aValues) |
|
638 { |
|
639 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
640 if ( vgContext ) |
|
641 { |
|
642 CVgHandleBase* handleInfo; |
|
643 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
644 |
|
645 if ( vgLock.CheckVGAnyHandle(aObject, &handleInfo) && TCheck::Chk32bitPtr(*vgContext, aValues) ) |
|
646 { |
|
647 handleInfo->GetParameteriv(*vgContext, aParamType, aCount, aValues); |
|
648 } |
|
649 } |
|
650 } |
|
651 |
|
652 |
|
653 /* Renderer and Extension Information */ |
|
654 |
|
655 /* Getxv supports vgGetfv & vgGetiv APIs. |
|
656 |
|
657 ERRORS |
|
658 VG_ILLEGAL_ARGUMENT_ERROR |
|
659 – if paramType is not a valid value from the VGParamType enumeration |
|
660 – if values is NULL in vgGetfv or vgGetiv |
|
661 – if values is not properly aligned in vgGetfv or vgGetiv |
|
662 – if count is less than or equal to 0 in vgGetfv or vgGetiv |
|
663 – if count is greater than the value returned by vgGetVectorSize for the |
|
664 given parameter in vgGetfv or vgGetiv |
|
665 */ |
|
666 // **** Desirable: can probably do common VGParamType checking for Getx & Getxv, Setx, & Setxv. |
|
667 void TGuestOpenVg::vgGetfv(VGParamType aType, VGint aCount, const VGfloat * aValues) |
|
668 { |
|
669 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
670 if (vgContext && TCheck::Chk32bitPtr(*vgContext, aValues)) |
|
671 { |
|
672 // **** Desirable: check all parameters |
|
673 if ( (aCount <= 0) || (aCount > HostGetVectorSize(*vgContext, aType)) ) |
|
674 { |
|
675 vgContext->SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); |
|
676 } |
|
677 else |
|
678 { |
|
679 RemoteFunctionCallData data; OpenVgRFC vgApiData(data); |
|
680 vgApiData.Init(OpenVgRFC::EvgGetfv); |
|
681 vgApiData.AppendParam(aType); |
|
682 vgApiData.AppendParam(aCount); |
|
683 vgApiData.AppendVector(aValues, aCount, RemoteFunctionCallData::EOut); |
|
684 vgContext->ExecuteVgCommand(vgApiData); |
|
685 } |
|
686 } |
|
687 } |
|
688 |
|
689 |
|
690 void TGuestOpenVg::vgGetiv(VGParamType aType, VGint aCount, const VGint * aValues) |
|
691 { |
|
692 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
693 if ( vgContext && TCheck::Chk32bitPtr(*vgContext, aValues) ) |
|
694 { |
|
695 // **** Desirable: check all parameters |
|
696 if ( (aCount <= 0) || (aCount > HostGetVectorSize(*vgContext, aType)) ) |
|
697 { |
|
698 vgContext->SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); |
|
699 } |
|
700 else |
|
701 { |
|
702 RemoteFunctionCallData data; OpenVgRFC vgApiData(data); |
|
703 vgApiData.Init(OpenVgRFC::EvgGetiv); |
|
704 vgApiData.AppendParam(aType); |
|
705 vgApiData.AppendParam(aCount); |
|
706 vgApiData.AppendVector(aValues, aCount, RemoteFunctionCallData::EOut); |
|
707 vgContext->ExecuteVgCommand(vgApiData); |
|
708 } |
|
709 } |
|
710 } |
|
711 |
|
712 |
|
713 /* |
|
714 ERRORS |
|
715 VG_ILLEGAL_ARGUMENT_ERROR |
|
716 – if m is NULL |
|
717 – if m is not properly aligned |
|
718 */ |
|
719 void TGuestOpenVg::vgGetMatrix(VGfloat* aM) |
|
720 { |
|
721 // check mat pointer is 32-bit aligned |
|
722 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
723 if ( vgContext && TCheck::Chk32bitPtr(*vgContext, aM) ) |
|
724 { |
|
725 RemoteFunctionCallData data; OpenVgRFC vgApiData(data); |
|
726 vgApiData.Init(OpenVgRFC::EvgGetMatrix); |
|
727 vgApiData.AppendVector(aM, KTransformMatrixSize, RemoteFunctionCallData::EOut); |
|
728 vgContext->ExecuteVgCommand(vgApiData); |
|
729 } |
|
730 } |
|
731 |
|
732 |
|
733 /* |
|
734 ERRORS |
|
735 VG_BAD_HANDLE_ERROR |
|
736 – if image is not a valid image handle, or is not shared with the current context |
|
737 VG_IMAGE_IN_USE_ERROR |
|
738 – if image is currently a rendering target |
|
739 VG_UNSUPPORTED_IMAGE_FORMAT_ERROR |
|
740 – if dataFormat is not a valid value from the VGImageFormat enumeration |
|
741 VG_ILLEGAL_ARGUMENT_ERROR |
|
742 – if width or height is less than or equal to 0 |
|
743 – if data is NULL |
|
744 – if data is not properly aligned |
|
745 */ |
|
746 void TGuestOpenVg::vgGetImageSubData(VGImage aImage, void* aData, VGint aDataStride, VGImageFormat aDataFormat, |
|
747 VGint aX, VGint aY, VGint aWidth, VGint aHeight) |
|
748 { |
|
749 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
750 if ( vgContext ) |
|
751 { |
|
752 CVgImageInfo* imageInfo = NULL; |
|
753 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
754 |
|
755 if ( vgLock.CheckVGImage(aImage, &imageInfo) && TCheck::ChkImageAlignment(*vgContext, aDataFormat, aData) && |
|
756 TCheck::ChkPositiveImageSize(*vgContext, aWidth, aHeight) ) |
|
757 { |
|
758 imageInfo->GetImageSubData(*vgContext, aData, aDataStride, aDataFormat, aX, aY, aWidth, aHeight); |
|
759 } |
|
760 } |
|
761 } |
|
762 |
|
763 |
|
764 /* |
|
765 ERRORS |
|
766 VG_UNSUPPORTED_IMAGE_FORMAT_ERROR |
|
767 – if dataFormat is not a valid value from the VGImageFormat enumeration |
|
768 VG_ILLEGAL_ARGUMENT_ERROR |
|
769 – if width or height is less than or equal to 0 |
|
770 – if data is NULL |
|
771 – if data is not properly aligned |
|
772 */ |
|
773 void TGuestOpenVg::HostVgReadPixels(MVgContext& aVgContext, void* aPixmap, size_t aPixmapSize, VGint aHostDataStride, |
|
774 VGImageFormat aDataFormat, VGint aSx, VGint aSy, VGint aWidth, VGint aHeight) |
|
775 { |
|
776 VGPANIC_ASSERT(aPixmap != NULL, EVgPanicNullPixmapPointer); |
|
777 VGPANIC_ASSERT(aPixmapSize >= (aHostDataStride * aHeight), EVgPanicPixmapSizeError); |
|
778 RemoteFunctionCallData rfcdata; OpenVgRFC vgApiData(rfcdata); |
|
779 vgApiData.Init(OpenVgRFC::EvgReadPixels); |
|
780 vgApiData.AppendVector(aPixmap, aPixmapSize, RemoteFunctionCallData::EOut); |
|
781 vgApiData.AppendParam(aHostDataStride); |
|
782 vgApiData.AppendParam(aDataFormat); |
|
783 vgApiData.AppendParam(aSx); |
|
784 vgApiData.AppendParam(aSy); |
|
785 vgApiData.AppendParam(aWidth); |
|
786 vgApiData.AppendParam(aHeight); |
|
787 vgApiData.AppendParam((VGint)aPixmapSize); |
|
788 aVgContext.ExecuteVgCommand(vgApiData); |
|
789 } |
|
790 |
|
791 |
|
792 void TGuestOpenVg::vgReadPixels(void* aData, VGint aDataStride, VGImageFormat aDataFormat, VGint aSx, VGint aSy, |
|
793 VGint aWidth, VGint aHeight) |
|
794 { |
|
795 // **** Desirable: check all parameters |
|
796 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
797 if ( vgContext && TCheck::ChkImageAlignment(*vgContext, aDataFormat, aData) && TCheck::ChkPositiveImageSize(*vgContext, aWidth, aHeight) ) |
|
798 { // width > 0 && height > 0 |
|
799 TInt bitsPerPixel = CVgImageInfo::BitsPerPixelForVgImageFormat(aDataFormat); |
|
800 TUint32 lineLength = static_cast<TUint32>(aWidth) * static_cast<TUint32>(bitsPerPixel); |
|
801 TUint32 tailBits = lineLength & 7; |
|
802 lineLength = (lineLength + 7) / 8; |
|
803 OPENVG_TRACE("vgReadPixels.1 bitsPerPixel=%d, lineLength=%d, tailBits=%d", bitsPerPixel, lineLength, tailBits); |
|
804 // ToDo clip aWidth & aHeight to the surface width & height |
|
805 |
|
806 if (bitsPerPixel <= 0) |
|
807 { |
|
808 vgContext->SetVgError(VG_UNSUPPORTED_IMAGE_FORMAT_ERROR); |
|
809 } |
|
810 else |
|
811 { |
|
812 if (lineLength == aDataStride) |
|
813 { // use original params |
|
814 OPENVG_TRACE("vgReadPixels.2a: lineLength == dataStride"); |
|
815 HostVgReadPixels(*vgContext, aData, aDataStride * aHeight, aDataStride, aDataFormat, aSx, aSy, aWidth, aHeight); |
|
816 } |
|
817 else if (0 == aDataStride) |
|
818 { // unlikely unless aHeight = 1, but symmetric to fill function for vgWritePixels |
|
819 OPENVG_TRACE("vgReadPixels.2b: 0 == dataStride"); |
|
820 HostVgReadPixels(*vgContext, aData, lineLength, aDataStride, aDataFormat, aSx, aSy, aWidth, aHeight); |
|
821 } |
|
822 else |
|
823 { // datastride maybe negative or simply > lineLength |
|
824 TInt pixmapSize = lineLength * aHeight; |
|
825 TUint8* localBuffer = (TUint8*) CVghwUtils::Alloc(pixmapSize); |
|
826 OPENVG_TRACE("vgReadPixels.2c: dataStride not 0 or lineLength, localBuffer=0x%x", localBuffer); |
|
827 |
|
828 if (localBuffer != NULL) |
|
829 { // read pixels into temporary buffer |
|
830 HostVgReadPixels(*vgContext, localBuffer, pixmapSize, lineLength, aDataFormat, aSx, aSy, aWidth, aHeight); |
|
831 // reformat into client memory |
|
832 CVgImageInfo::PixmapBlit(static_cast<TUint8*>(aData), localBuffer, aDataStride, lineLength, aHeight, lineLength, tailBits); |
|
833 CVghwUtils::Free(localBuffer); |
|
834 } |
|
835 else |
|
836 { // alloc failed, so do VG operation row by row |
|
837 TUint8* dest = static_cast<TUint8*>(aData); |
|
838 for (VGint row = 0; row < aHeight; ++row) |
|
839 { |
|
840 HostVgReadPixels(*vgContext, dest, lineLength, lineLength, aDataFormat, aSx + row, aSy, aWidth, 1); |
|
841 dest += aDataStride; |
|
842 } |
|
843 } |
|
844 } |
|
845 } |
|
846 } |
|
847 } |
|
848 |
|
849 |
|
850 /* |
|
851 ERRORS |
|
852 VG_BAD_HANDLE_ERROR |
|
853 – if path is not a valid path handle, or is not shared with the current context |
|
854 VG_ILLEGAL_ARGUMENT_ERROR |
|
855 – if minX, minY, width, or height is NULL |
|
856 – if minX, minY, width, or height is not properly aligned |
|
857 VG_PATH_CAPABILITY_ERROR |
|
858 – if VG_PATH_CAPABILITY_PATH_BOUNDS is not enabled for path |
|
859 */ |
|
860 void TGuestOpenVg::vgPathBounds(VGPath aPath, VGfloat* aMinX, VGfloat* aMinY, VGfloat* aWidth, VGfloat* aHeight) |
|
861 { |
|
862 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
863 if ( vgContext ) |
|
864 { |
|
865 CVgPathInfo* pathInfo = NULL; |
|
866 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
867 |
|
868 if ( vgLock.CheckVGPath(aPath, &pathInfo, VG_PATH_CAPABILITY_PATH_BOUNDS) ) |
|
869 { |
|
870 pathInfo->PathBounds(*vgContext, aMinX, aMinY, aWidth, aHeight); |
|
871 } |
|
872 } |
|
873 } |
|
874 |
|
875 |
|
876 /* |
|
877 ERRORS |
|
878 VG_BAD_HANDLE_ERROR |
|
879 – if path is not a valid path handle, or is not shared with the current context |
|
880 VG_ILLEGAL_ARGUMENT_ERROR |
|
881 – if minX, minY, width, or height is NULL |
|
882 – if minX, minY, width, or height is not properly aligned |
|
883 VG_PATH_CAPABILITY_ERROR |
|
884 – if VG_PATH_CAPABILITY_PATH_TRANSFORMED_BOUNDS is not enabled |
|
885 for path |
|
886 */ |
|
887 void TGuestOpenVg::vgPathTransformedBounds(VGPath aPath, VGfloat* aMinX, VGfloat* aMinY, VGfloat* aWidth, VGfloat* aHeight) |
|
888 { |
|
889 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
890 if ( vgContext ) |
|
891 { |
|
892 CVgPathInfo* pathInfo = NULL; |
|
893 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
894 |
|
895 if ( vgLock.CheckVGPath(aPath, &pathInfo, VG_PATH_CAPABILITY_PATH_TRANSFORMED_BOUNDS) ) |
|
896 { |
|
897 pathInfo->PathTransformedBounds(*vgContext, aMinX, aMinY, aWidth, aHeight); |
|
898 } |
|
899 } |
|
900 } |
|
901 |
|
902 |
|
903 //////////////////////////////////////////////////////////////////////////////////////////// |
|
904 //Functions not returning value (possible to buffer) |
|
905 //////////////////////////////////////////////////////////////////////////////////////////// |
|
906 /* Getters and Setters */ |
|
907 |
|
908 /* |
|
909 vgSeti and vgSetf |
|
910 |
|
911 ERRORS |
|
912 VG_ILLEGAL_ARGUMENT_ERROR |
|
913 – if paramType is not a valid value from the VGParamType enumeration |
|
914 – if paramType refers to a vector parameter in vgSetf or vgSeti |
|
915 – if value is not a legal enumerated value for the given parameter in vgSetf or |
|
916 vgSeti |
|
917 */ |
|
918 void TGuestOpenVg::vgSeti(VGParamType aType, VGint aValue) |
|
919 { |
|
920 // **** Desirable: check aType |
|
921 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
922 if (vgContext) |
|
923 { |
|
924 RemoteFunctionCallData data; OpenVgRFC vgApiData(data); |
|
925 vgApiData.Init(OpenVgRFC::EvgSeti, RemoteFunctionCallData::EOpRequest); |
|
926 vgApiData.AppendParam(aType); |
|
927 vgApiData.AppendParam(aValue); |
|
928 vgContext->ExecuteVgCommand(vgApiData); |
|
929 } |
|
930 } |
|
931 |
|
932 |
|
933 void TGuestOpenVg::vgSetf(VGParamType aType, VGfloat aValue) |
|
934 { |
|
935 // **** Desirable: check aType |
|
936 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
937 if (vgContext) |
|
938 { |
|
939 RemoteFunctionCallData data; OpenVgRFC vgApiData(data); |
|
940 vgApiData.Init(OpenVgRFC::EvgSetf, RemoteFunctionCallData::EOpRequest); |
|
941 vgApiData.AppendParam(aType); |
|
942 vgApiData.AppendParam(aValue); |
|
943 vgContext->ExecuteVgCommand(vgApiData); |
|
944 } |
|
945 } |
|
946 |
|
947 |
|
948 /* |
|
949 vgSetiv and vgSetfv |
|
950 |
|
951 ERRORS |
|
952 VG_ILLEGAL_ARGUMENT_ERROR |
|
953 – if paramType is not a valid value from the VGParamType enumeration |
|
954 – if paramType refers to a scalar parameter in vgSetfv or vgSetiv and count is |
|
955 not equal to 1 |
|
956 – if values[i] is not a legal enumerated value for the given parameter in vgSetfv |
|
957 or vgSetiv for 0 <= i < count |
|
958 – if values is NULL in vgSetfv or vgSetiv and count is greater than 0 |
|
959 – if values is not properly aligned in vgSetfv or vgSetiv |
|
960 – if count is less than 0 in vgSetfv or vgSetiv |
|
961 – if count is not a valid value for the given parameter |
|
962 */ |
|
963 void TGuestOpenVg::vgSetfv(VGParamType aType, VGint aCount, const VGfloat * aValues) |
|
964 { |
|
965 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
966 if (vgContext && TCheck::Chk32bitPtr(*vgContext, aValues)) |
|
967 { |
|
968 // **** Desirable: check all params |
|
969 // we should check count for not being too large for serialization, but |
|
970 // there is no limit in spec for VG_SCISSOR_RECTS and VG_STROKE_DASH_PATTERN |
|
971 if ( (aCount < 0) || (aCount > 100000) ) |
|
972 { |
|
973 vgContext->SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); |
|
974 } |
|
975 else |
|
976 { |
|
977 RemoteFunctionCallData data; OpenVgRFC vgApiData(data); |
|
978 vgApiData.Init(OpenVgRFC::EvgSetfv, RemoteFunctionCallData::EOpRequest); |
|
979 vgApiData.AppendParam(aType); |
|
980 vgApiData.AppendParam(aCount); |
|
981 vgApiData.AppendVector(aValues, aCount); |
|
982 vgContext->ExecuteVgCommand(vgApiData); |
|
983 } |
|
984 } |
|
985 } |
|
986 |
|
987 |
|
988 void TGuestOpenVg::vgSetiv(VGParamType aType, VGint aCount, const VGint * aValues) |
|
989 { |
|
990 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
991 if ( vgContext && TCheck::Chk32bitPtr(*vgContext, aValues) ) |
|
992 { |
|
993 // **** Desirable: check all params |
|
994 // we should check count for not being too large for serialization, but |
|
995 // there is no limit in spec for VG_SCISSOR_RECTS and VG_STROKE_DASH_PATTERN |
|
996 if ( (aCount < 0) || (aCount > 100000) ) |
|
997 { |
|
998 vgContext->SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); |
|
999 } |
|
1000 else |
|
1001 { |
|
1002 RemoteFunctionCallData data; OpenVgRFC vgApiData(data); |
|
1003 vgApiData.Init(OpenVgRFC::EvgSetiv, RemoteFunctionCallData::EOpRequest); |
|
1004 vgApiData.AppendParam(aType); |
|
1005 vgApiData.AppendParam(aCount); |
|
1006 vgApiData.AppendVector(aValues, aCount); |
|
1007 vgContext->ExecuteVgCommand(vgApiData); |
|
1008 } |
|
1009 } |
|
1010 } |
|
1011 |
|
1012 |
|
1013 /* |
|
1014 For vgSetParameterf and vgSetParameteri. |
|
1015 |
|
1016 ERRORS |
|
1017 VG_BAD_HANDLE_ERROR |
|
1018 – if object is not a valid handle, or is not shared with the current context |
|
1019 VG_ILLEGAL_ARGUMENT_ERROR |
|
1020 – if paramType is not a valid value from the appropriate enumeration |
|
1021 – if paramType refers to a vector parameter in vgSetParameterf or |
|
1022 vgSetParameteri |
|
1023 – if value is not a legal enumerated value for the given parameter in |
|
1024 vgSetParameterf or vgSetParameteri |
|
1025 */ |
|
1026 |
|
1027 void TGuestOpenVg::vgSetParameteri(VGHandle aObject, VGint aParamType, VGint aValue) |
|
1028 { |
|
1029 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1030 if ( vgContext ) |
|
1031 { |
|
1032 CVgHandleBase* handleInfo; |
|
1033 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
1034 |
|
1035 if ( vgLock.CheckVGAnyHandle(aObject, &handleInfo) ) |
|
1036 { |
|
1037 handleInfo->SetParameteri(*vgContext, aParamType, aValue); |
|
1038 } |
|
1039 } |
|
1040 } |
|
1041 |
|
1042 |
|
1043 void TGuestOpenVg::vgSetParameterf(VGHandle aObject, VGint aParamType, VGfloat aValue) |
|
1044 { |
|
1045 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1046 if ( vgContext ) |
|
1047 { |
|
1048 CVgHandleBase* handleInfo; |
|
1049 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
1050 |
|
1051 if ( vgLock.CheckVGAnyHandle(aObject, &handleInfo) ) |
|
1052 { |
|
1053 handleInfo->SetParameterf(*vgContext, aParamType, aValue); |
|
1054 } |
|
1055 } |
|
1056 } |
|
1057 |
|
1058 |
|
1059 /* |
|
1060 For vgSetParameterfv and vgSetParameteriv. |
|
1061 |
|
1062 The vgSetParameter functions set the value of a parameter on a given VGHandlebased |
|
1063 object. |
|
1064 |
|
1065 ERRORS |
|
1066 VG_BAD_HANDLE_ERROR |
|
1067 – if object is not a valid handle, or is not shared with the current context |
|
1068 VG_ILLEGAL_ARGUMENT_ERROR |
|
1069 – if paramType is not a valid value from the appropriate enumeration |
|
1070 – if paramType refers to a scalar parameter in vgSetParameterfv or |
|
1071 vgSetParameteriv and count is not equal to 1 |
|
1072 – if values[i] is not a legal enumerated value for the given parameter |
|
1073 in vgSetParameterfv or vgSetParameteriv for 0 <= i < count |
|
1074 – if values is NULL in vgSetParameterfv or vgSetParameteriv and count is |
|
1075 greater than 0 |
|
1076 – if values is not properly aligned in vgSetParameterfv or vgSetParameteriv |
|
1077 – if count is less than 0 in vgSetParameterfv or vgSetParameteriv |
|
1078 – if count is not a valid value for the given parameter |
|
1079 */ |
|
1080 void TGuestOpenVg::vgSetParameterfv(VGHandle aObject, VGint aParamType, VGint aCount, const VGfloat * aValues) |
|
1081 { |
|
1082 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1083 if ( vgContext ) |
|
1084 { |
|
1085 CVgHandleBase* handleInfo; |
|
1086 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
1087 |
|
1088 // ToDo review overlapping checks between TCheck::ParamCountAndValuesPtr to SetParameterfv |
|
1089 if ( vgLock.CheckVGAnyHandle(aObject, &handleInfo) && TCheck::ChkParamCountAndValuesPtr(*vgContext, aCount, aValues) ) |
|
1090 { |
|
1091 handleInfo->SetParameterfv(*vgContext, aParamType, aCount, aValues); |
|
1092 } |
|
1093 } |
|
1094 } |
|
1095 |
|
1096 |
|
1097 void TGuestOpenVg::vgSetParameteriv(VGHandle aObject, VGint aParamType, VGint aCount, const VGint * aValues) |
|
1098 { |
|
1099 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1100 if ( vgContext ) |
|
1101 { |
|
1102 CVgHandleBase* handleInfo; |
|
1103 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
1104 |
|
1105 if ( vgLock.CheckVGAnyHandle(aObject, &handleInfo) && TCheck::ChkParamCountAndValuesPtr(*vgContext, aCount, aValues) ) |
|
1106 { |
|
1107 handleInfo->SetParameteriv(*vgContext, aParamType, aCount, aValues); |
|
1108 } |
|
1109 } |
|
1110 } |
|
1111 |
|
1112 |
|
1113 /* Matrix Manipulation */ |
|
1114 /* |
|
1115 No errors if Context is valid. |
|
1116 */ |
|
1117 void TGuestOpenVg::vgLoadIdentity() |
|
1118 { |
|
1119 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1120 if (vgContext) |
|
1121 { |
|
1122 RemoteFunctionCallData data; OpenVgRFC vgApiData(data); |
|
1123 vgApiData.Init(OpenVgRFC::EvgLoadIdentity, RemoteFunctionCallData::EOpRequest); |
|
1124 vgContext->ExecuteVgCommand(vgApiData); |
|
1125 } |
|
1126 } |
|
1127 |
|
1128 |
|
1129 /* |
|
1130 ERRORS |
|
1131 VG_ILLEGAL_ARGUMENT_ERROR |
|
1132 – if m is NULL |
|
1133 – if m is not properly aligned |
|
1134 */ |
|
1135 void TGuestOpenVg::vgLoadMatrix(const VGfloat* aM) |
|
1136 { |
|
1137 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1138 if ( vgContext && TCheck::Chk32bitPtr(*vgContext, aM) ) |
|
1139 { |
|
1140 RemoteFunctionCallData data; OpenVgRFC vgApiData(data); |
|
1141 vgApiData.Init(OpenVgRFC::EvgLoadMatrix, RemoteFunctionCallData::EOpRequest); |
|
1142 vgApiData.AppendVector(aM, KTransformMatrixSize); |
|
1143 vgContext->ExecuteVgCommand(vgApiData); |
|
1144 } |
|
1145 } |
|
1146 |
|
1147 |
|
1148 /* |
|
1149 ERRORS |
|
1150 VG_ILLEGAL_ARGUMENT_ERROR |
|
1151 – if m is NULL |
|
1152 – if m is not properly aligned |
|
1153 */ |
|
1154 void TGuestOpenVg::vgMultMatrix(const VGfloat* aM) |
|
1155 { |
|
1156 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1157 if ( vgContext && TCheck::Chk32bitPtr(*vgContext, aM) ) |
|
1158 { |
|
1159 RemoteFunctionCallData data; OpenVgRFC vgApiData(data); |
|
1160 vgApiData.Init(OpenVgRFC::EvgMultMatrix, RemoteFunctionCallData::EOpRequest); |
|
1161 vgApiData.AppendVector(aM, KTransformMatrixSize); |
|
1162 vgContext->ExecuteVgCommand(vgApiData); |
|
1163 } |
|
1164 } |
|
1165 |
|
1166 |
|
1167 /* |
|
1168 No errors if Context is valid. |
|
1169 */ |
|
1170 void TGuestOpenVg::vgTranslate(VGfloat aTx, VGfloat aTy) |
|
1171 { |
|
1172 // **** Desirable: check all parameters |
|
1173 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1174 if (vgContext) |
|
1175 { |
|
1176 RemoteFunctionCallData data; OpenVgRFC vgApiData(data); |
|
1177 vgApiData.Init(OpenVgRFC::EvgTranslate, RemoteFunctionCallData::EOpRequest); |
|
1178 vgApiData.AppendParam(aTx); |
|
1179 vgApiData.AppendParam(aTy); |
|
1180 vgContext->ExecuteVgCommand(vgApiData); |
|
1181 } |
|
1182 } |
|
1183 |
|
1184 |
|
1185 /* |
|
1186 No errors if Context is valid. |
|
1187 */ |
|
1188 // **** Desirable: Coalesce with vgTranslate |
|
1189 void TGuestOpenVg::vgScale(VGfloat aSx, VGfloat aSy) |
|
1190 { |
|
1191 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1192 if (vgContext) |
|
1193 { |
|
1194 RemoteFunctionCallData data; OpenVgRFC vgApiData(data); |
|
1195 vgApiData.Init(OpenVgRFC::EvgScale, RemoteFunctionCallData::EOpRequest); |
|
1196 vgApiData.AppendParam(aSx); |
|
1197 vgApiData.AppendParam(aSy); |
|
1198 vgContext->ExecuteVgCommand(vgApiData); |
|
1199 } |
|
1200 } |
|
1201 |
|
1202 |
|
1203 /* |
|
1204 No errors if Context is valid. |
|
1205 */ |
|
1206 // **** Desirable: Coalesce with vgTranslate |
|
1207 void TGuestOpenVg::vgShear(VGfloat aShx, VGfloat aShy) |
|
1208 { |
|
1209 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1210 if (vgContext) |
|
1211 { |
|
1212 RemoteFunctionCallData data; OpenVgRFC vgApiData(data); |
|
1213 vgApiData.Init(OpenVgRFC::EvgShear, RemoteFunctionCallData::EOpRequest); |
|
1214 vgApiData.AppendParam(aShx); |
|
1215 vgApiData.AppendParam(aShy); |
|
1216 vgContext->ExecuteVgCommand(vgApiData); |
|
1217 } |
|
1218 } |
|
1219 |
|
1220 |
|
1221 /* |
|
1222 No errors if Context is valid. |
|
1223 */ |
|
1224 void TGuestOpenVg::vgRotate(VGfloat aAngle) |
|
1225 { |
|
1226 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1227 if (vgContext) |
|
1228 { |
|
1229 RemoteFunctionCallData data; OpenVgRFC vgApiData(data); |
|
1230 vgApiData.Init(OpenVgRFC::EvgRotate, RemoteFunctionCallData::EOpRequest); |
|
1231 vgApiData.AppendParam(aAngle); |
|
1232 vgContext->ExecuteVgCommand(vgApiData); |
|
1233 } |
|
1234 } |
|
1235 |
|
1236 |
|
1237 /* |
|
1238 ERRORS |
|
1239 VG_BAD_HANDLE_ERROR |
|
1240 – if operation is not VG_CLEAR_MASK or VG_FILL_MASK, and mask is not a |
|
1241 valid mask layer or image handle, or is not shared with the current context |
|
1242 VG_IMAGE_IN_USE_ERROR |
|
1243 – if mask is a VGImage that is currently a rendering target |
|
1244 VG_ILLEGAL_ARGUMENT_ERROR |
|
1245 – if operation is not a valid value from the VGMaskOperation |
|
1246 enumeration |
|
1247 – if width or height is less than or equal to 0 |
|
1248 – if mask is a VGMaskLayer and is not compatible with the current surface |
|
1249 mask |
|
1250 */ |
|
1251 void TGuestOpenVg::vgMask(VGHandle aMask, VGMaskOperation aOperation, VGint aX, VGint aY, VGint aWidth, VGint aHeight) |
|
1252 { |
|
1253 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1254 if ( vgContext ) |
|
1255 { |
|
1256 CVgImageBase* maskInfo = NULL; |
|
1257 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
1258 |
|
1259 // **** Desirable: mask/surface compatibility check |
|
1260 if ( vgLock.CheckVGMaskOperationAndHandle(aOperation, aMask, &maskInfo) && TCheck::ChkPositiveImageSize(*vgContext, aWidth, aHeight) ) |
|
1261 { |
|
1262 RemoteFunctionCallData data; OpenVgRFC vgApiData(data); |
|
1263 vgApiData.Init(OpenVgRFC::EvgMask, RemoteFunctionCallData::EOpRequest); |
|
1264 vgApiData.AppendParam( (maskInfo == NULL) ? VG_INVALID_HANDLE : maskInfo->HostHandle() ); |
|
1265 vgApiData.AppendParam(aOperation); |
|
1266 vgApiData.AppendParam(aX); |
|
1267 vgApiData.AppendParam(aY); |
|
1268 vgApiData.AppendParam(aWidth); |
|
1269 vgApiData.AppendParam(aHeight); |
|
1270 TUint64 sgId(0L); |
|
1271 if ( maskInfo && (maskInfo->HandleType() == EVgHandleForImage) ) |
|
1272 { |
|
1273 CVgImageInfo* imageInfo = (CVgImageInfo*)maskInfo; |
|
1274 if (imageInfo->IsEglSibling()) |
|
1275 { |
|
1276 sgId = imageInfo->SgImageId(); |
|
1277 } |
|
1278 } |
|
1279 vgApiData.AppendTUint64(sgId); |
|
1280 vgContext->ExecuteVgCommand(vgApiData); |
|
1281 } |
|
1282 } |
|
1283 } |
|
1284 |
|
1285 |
|
1286 /* |
|
1287 ERRORS |
|
1288 VG_BAD_HANDLE_ERROR |
|
1289 – if path is not a valid path handle |
|
1290 VG_ILLEGAL_ARGUMENT_ERROR |
|
1291 – if paintModes is not a valid bitwise OR of values from the VGPaintMode |
|
1292 enumeration |
|
1293 – if operation is not a valid value from the VGMaskOperation enumeration |
|
1294 */ |
|
1295 void TGuestOpenVg::vgRenderToMask(VGPath aPath, VGbitfield aPaintModes, VGMaskOperation aOperation) |
|
1296 { |
|
1297 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1298 if ( vgContext ) |
|
1299 { |
|
1300 CVgPathInfo* pathInfo = NULL; |
|
1301 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
1302 |
|
1303 if ( vgLock.CheckVGPath(aPath, &pathInfo) ) |
|
1304 { |
|
1305 pathInfo->RenderToMask(*vgContext, aPaintModes, aOperation); |
|
1306 } |
|
1307 } |
|
1308 } |
|
1309 |
|
1310 |
|
1311 /* |
|
1312 ERRORS |
|
1313 VG_BAD_HANDLE_ERROR |
|
1314 – if maskLayer is not a valid mask handle |
|
1315 */ |
|
1316 void TGuestOpenVg::vgDestroyMaskLayer(VGMaskLayer aMaskLayer) |
|
1317 { |
|
1318 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1319 if (vgContext) |
|
1320 { |
|
1321 CVgMaskLayerInfo* maskLayerInfo = NULL; |
|
1322 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
1323 |
|
1324 if ( vgLock.CheckVGMaskLayer(aMaskLayer, &maskLayerInfo) ) |
|
1325 { |
|
1326 maskLayerInfo->Destroy(*vgContext); |
|
1327 } |
|
1328 } |
|
1329 } |
|
1330 |
|
1331 |
|
1332 /* |
|
1333 ERRORS |
|
1334 VG_BAD_HANDLE_ERROR |
|
1335 – if maskLayer is not a valid mask layer handle, or is not shared with the |
|
1336 current context |
|
1337 VG_ILLEGAL_ARGUMENT_ERROR |
|
1338 – if value is less than 0 or greater than 1 |
|
1339 – if width or height is less than or equal to 0 |
|
1340 – if x or y is less than 0 |
|
1341 – if x + width is greater than the width of the mask |
|
1342 – if y + height is greater than the height of the mask |
|
1343 */ |
|
1344 void TGuestOpenVg::vgFillMaskLayer(VGMaskLayer aMaskLayer, VGint aX, VGint aY, VGint aWidth, VGint aHeight, VGfloat aValue) |
|
1345 { |
|
1346 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1347 if ( vgContext ) |
|
1348 { |
|
1349 CVgMaskLayerInfo* maskLayerInfo = NULL; |
|
1350 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
1351 |
|
1352 if ( vgLock.CheckVGMaskLayer(aMaskLayer, &maskLayerInfo) && TCheck::ChkAreaIsWithinImage(*vgContext, maskLayerInfo, aX, aY, aWidth, aHeight) ) |
|
1353 { |
|
1354 maskLayerInfo->FillMaskLayer(*vgContext, aX, aY, aWidth, aHeight, aValue); |
|
1355 } |
|
1356 } |
|
1357 } |
|
1358 |
|
1359 |
|
1360 /* |
|
1361 ERRORS |
|
1362 VG_BAD_HANDLE_ERROR |
|
1363 – if maskLayer is not a valid mask layer handle |
|
1364 VG_ILLEGAL_ARGUMENT_ERROR |
|
1365 – if width or height are less than or equal to 0 |
|
1366 – if maskLayer is not compatible with the current surface mask |
|
1367 */ |
|
1368 void TGuestOpenVg::vgCopyMask(VGMaskLayer aMaskLayer, VGint aSx, VGint aSy, VGint aDx, VGint aDy, VGint aWidth, VGint aHeight) |
|
1369 { |
|
1370 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1371 if ( vgContext ) |
|
1372 { |
|
1373 CVgMaskLayerInfo* maskLayerInfo = NULL; |
|
1374 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
1375 |
|
1376 if ( vgLock.CheckVGMaskLayer(aMaskLayer, &maskLayerInfo) && TCheck::ChkPositiveImageSize(*vgContext, aWidth, aHeight) ) |
|
1377 { |
|
1378 maskLayerInfo->CopyMask(*vgContext, aSx, aSy, aDx, aDy, aWidth, aHeight); |
|
1379 } |
|
1380 } |
|
1381 } |
|
1382 |
|
1383 |
|
1384 /* |
|
1385 ERRORS |
|
1386 VG_ILLEGAL_ARGUMENT_ERROR |
|
1387 – if width or height is less than or equal to 0 |
|
1388 */ |
|
1389 void TGuestOpenVg::vgClear(VGint aX, VGint aY, VGint aWidth, VGint aHeight) |
|
1390 { |
|
1391 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1392 if ( vgContext && TCheck::ChkPositiveImageSize(*vgContext, aWidth, aHeight) ) |
|
1393 { // width > 0 && height > 0 |
|
1394 RemoteFunctionCallData data; OpenVgRFC vgApiData(data); |
|
1395 vgApiData.Init(OpenVgRFC::EvgClear, RemoteFunctionCallData::EOpRequest); |
|
1396 vgApiData.AppendParam(aX); |
|
1397 vgApiData.AppendParam(aY); |
|
1398 vgApiData.AppendParam(aWidth); |
|
1399 vgApiData.AppendParam(aHeight); |
|
1400 vgContext->ExecuteVgCommand(vgApiData); |
|
1401 } |
|
1402 } |
|
1403 |
|
1404 |
|
1405 /* Paths */ |
|
1406 |
|
1407 /* |
|
1408 ERRORS |
|
1409 VG_BAD_HANDLE_ERROR |
|
1410 – if path is not a valid path handle, or is not shared with the current context |
|
1411 */ |
|
1412 void TGuestOpenVg::vgClearPath(VGPath aPath, VGbitfield aCapabilities) |
|
1413 { |
|
1414 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1415 if ( vgContext ) |
|
1416 { |
|
1417 CVgPathInfo* pathInfo = NULL; |
|
1418 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
1419 |
|
1420 if ( vgLock.CheckVGPath(aPath, &pathInfo) ) |
|
1421 { |
|
1422 pathInfo->ClearPath(*vgContext, aCapabilities); |
|
1423 } |
|
1424 } |
|
1425 } |
|
1426 |
|
1427 |
|
1428 /* |
|
1429 ERRORS |
|
1430 VG_BAD_HANDLE_ERROR |
|
1431 – if path is not a valid path handle, or is not shared with the current context |
|
1432 */ |
|
1433 void TGuestOpenVg::vgDestroyPath(VGPath aPath) |
|
1434 { |
|
1435 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1436 if ( vgContext ) |
|
1437 { |
|
1438 CVgPathInfo* pathInfo = NULL; |
|
1439 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
1440 |
|
1441 if ( vgLock.CheckVGPath(aPath, &pathInfo) ) |
|
1442 { |
|
1443 pathInfo->Destroy(*vgContext); |
|
1444 } |
|
1445 } |
|
1446 } |
|
1447 |
|
1448 |
|
1449 /* |
|
1450 ERRORS |
|
1451 VG_BAD_HANDLE_ERROR |
|
1452 – if path is not a valid path handle, or is not shared with the current context |
|
1453 */ |
|
1454 void TGuestOpenVg::vgRemovePathCapabilities(VGPath aPath, VGbitfield aCapabilities) |
|
1455 { |
|
1456 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1457 if ( vgContext ) |
|
1458 { |
|
1459 CVgPathInfo* pathInfo = NULL; |
|
1460 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
1461 |
|
1462 if ( vgLock.CheckVGPath(aPath, &pathInfo) ) |
|
1463 { |
|
1464 pathInfo->RemovePathCapabilities(*vgContext, aCapabilities); |
|
1465 } |
|
1466 } |
|
1467 } |
|
1468 |
|
1469 |
|
1470 /* |
|
1471 ERRORS |
|
1472 VG_BAD_HANDLE_ERROR |
|
1473 – if either dstPath or srcPath is not a valid path handle, or is not shared |
|
1474 with the current context |
|
1475 VG_PATH_CAPABILITY_ERROR |
|
1476 – if VG_PATH_CAPABILITY_APPEND_FROM is not enabled for srcPath |
|
1477 – if VG_PATH_CAPABILITY_APPEND_TO is not enabled for dstPath |
|
1478 */ |
|
1479 void TGuestOpenVg::vgAppendPath(VGPath aDstPath, VGPath aSrcPath) |
|
1480 { |
|
1481 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1482 if ( vgContext ) |
|
1483 { |
|
1484 CVgPathInfo* dstPathInfo = NULL; |
|
1485 CVgPathInfo* srcPathInfo = NULL; |
|
1486 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
1487 |
|
1488 if ( vgLock.CheckVGPath(aDstPath, &dstPathInfo, VG_PATH_CAPABILITY_APPEND_TO) && |
|
1489 vgLock.CheckVGPath(aSrcPath, &srcPathInfo, VG_PATH_CAPABILITY_APPEND_FROM) ) |
|
1490 { |
|
1491 dstPathInfo->AppendPath(*vgContext, *srcPathInfo); |
|
1492 } |
|
1493 } |
|
1494 } |
|
1495 |
|
1496 |
|
1497 /* |
|
1498 ERRORS |
|
1499 VG_BAD_HANDLE_ERROR |
|
1500 – if dstPath is not a valid path handle, or is not shared with the current |
|
1501 context |
|
1502 VG_PATH_CAPABILITY_ERROR |
|
1503 – if VG_PATH_CAPABILITY_APPEND_TO is not enabled for dstPath |
|
1504 VG_ILLEGAL_ARGUMENT_ERROR |
|
1505 – if pathSegments or pathData is NULL |
|
1506 – if pathData is not properly aligned |
|
1507 – if numSegments is less than or equal to 0 |
|
1508 – if pathSegments contains an illegal command |
|
1509 */ |
|
1510 void TGuestOpenVg::vgAppendPathData(VGPath aDstPath, VGint aNumSegments, const VGubyte* aPathSegments, const void* aPathData) |
|
1511 { |
|
1512 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1513 if ( vgContext ) |
|
1514 { |
|
1515 CVgPathInfo* dstPathInfo = NULL; |
|
1516 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
1517 |
|
1518 if ( vgLock.CheckVGPath(aDstPath, &dstPathInfo, VG_PATH_CAPABILITY_APPEND_TO) ) |
|
1519 { |
|
1520 dstPathInfo->AppendPathData(*vgContext, aNumSegments, aPathSegments, aPathData); |
|
1521 } |
|
1522 } |
|
1523 } |
|
1524 |
|
1525 |
|
1526 /* |
|
1527 ERRORS |
|
1528 VG_BAD_HANDLE_ERROR |
|
1529 – if dstPath is not a valid path handle, or is not shared with the current |
|
1530 context |
|
1531 VG_PATH_CAPABILITY_ERROR |
|
1532 – if VG_PATH_CAPABILITY_MODIFY is not enabled for dstPath |
|
1533 VG_ILLEGAL_ARGUMENT_ERROR |
|
1534 – if pathData is NULL |
|
1535 – if pathData is not properly aligned |
|
1536 – if startIndex is less than 0 |
|
1537 – if numSegments is less than or equal to 0 |
|
1538 – if startIndex + numSegments is greater than the number of segments in the path |
|
1539 */ |
|
1540 void TGuestOpenVg::vgModifyPathCoords(VGPath aDstPath, VGint aStartIndex, VGint aNumSegments, const void* aPathData) |
|
1541 { |
|
1542 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1543 if ( vgContext ) |
|
1544 { |
|
1545 CVgPathInfo* dstPathInfo = NULL; |
|
1546 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
1547 |
|
1548 if ( vgLock.CheckVGPath(aDstPath, &dstPathInfo, VG_PATH_CAPABILITY_MODIFY) ) |
|
1549 { |
|
1550 if ( (aStartIndex < 0) || (aNumSegments <= 0) ) |
|
1551 { |
|
1552 vgContext->SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); |
|
1553 } |
|
1554 else |
|
1555 { |
|
1556 dstPathInfo->ModifyPathCoords(*vgContext, aStartIndex, aNumSegments, aPathData); |
|
1557 } |
|
1558 } |
|
1559 } |
|
1560 } |
|
1561 |
|
1562 |
|
1563 /* |
|
1564 ERRORS |
|
1565 VG_BAD_HANDLE_ERROR |
|
1566 – if either dstPath or srcPath is not a valid path handle, or is not shared with |
|
1567 the current context |
|
1568 VG_PATH_CAPABILITY_ERROR |
|
1569 – if VG_PATH_CAPABILITY_TRANSFORM_FROM is not enabled for srcPath |
|
1570 – if VG_PATH_CAPABILITY_TRANSFORM_TO is not enabled for dstPath |
|
1571 */ |
|
1572 void TGuestOpenVg::vgTransformPath(VGPath aDstPath, VGPath aSrcPath) |
|
1573 { |
|
1574 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1575 if ( vgContext ) |
|
1576 { |
|
1577 CVgPathInfo* dstPathInfo = NULL; |
|
1578 CVgPathInfo* srcPathInfo = NULL; |
|
1579 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
1580 |
|
1581 if ( vgLock.CheckVGPath(aDstPath, &dstPathInfo, VG_PATH_CAPABILITY_TRANSFORM_TO) && |
|
1582 vgLock.CheckVGPath(aSrcPath, &srcPathInfo, VG_PATH_CAPABILITY_TRANSFORM_FROM) ) |
|
1583 { |
|
1584 dstPathInfo->TransformPath(*vgContext, *srcPathInfo); |
|
1585 } |
|
1586 } |
|
1587 } |
|
1588 |
|
1589 |
|
1590 /* |
|
1591 ERRORS |
|
1592 VG_BAD_HANDLE_ERROR |
|
1593 – if path is not a valid path handle, or is not shared with the current context |
|
1594 VG_PATH_CAPABILITY_ERROR |
|
1595 – If x and y are both non-NULL, and the VG_PATH_CAPABILITY_POINT_ALONG_PATH is |
|
1596 not enabled for path |
|
1597 – If tangentX and tangentY are both non-NULL, and the |
|
1598 VG_PATH_CAPABILITY_TANGENT_ALONG_PATH capability is not enabled for path |
|
1599 VG_ILLEGAL_ARGUMENT_ERROR |
|
1600 – if startSegment is less than 0 or greater than the index of the final path |
|
1601 segment |
|
1602 – if numSegments is less than or equal to 0 |
|
1603 – if (startSegment + numSegments – 1) is less than 0 or greater than the index |
|
1604 of the final path segment |
|
1605 – if x, y, tangentX or tangentY is not properly aligned |
|
1606 */ |
|
1607 void TGuestOpenVg::vgPointAlongPath(VGPath aPath, VGint aStartSegment, VGint aNumSegments, VGfloat aDistance, |
|
1608 VGfloat* aX, VGfloat* aY, VGfloat* aTangentX, VGfloat* aTangentY) |
|
1609 { |
|
1610 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1611 if ( vgContext ) |
|
1612 { |
|
1613 CVgPathInfo* pathInfo = NULL; |
|
1614 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
1615 |
|
1616 TBool getPoint = (aX && aY); |
|
1617 TBool getTangent = (aTangentX && aTangentY); |
|
1618 VGbitfield reqdCapabilities = 0; |
|
1619 if (getPoint) |
|
1620 { |
|
1621 reqdCapabilities |= VG_PATH_CAPABILITY_POINT_ALONG_PATH; |
|
1622 } |
|
1623 if (getTangent) |
|
1624 { |
|
1625 reqdCapabilities |= VG_PATH_CAPABILITY_TANGENT_ALONG_PATH; |
|
1626 } |
|
1627 if ( vgLock.CheckVGPath(aPath, &pathInfo, reqdCapabilities) ) |
|
1628 { |
|
1629 if ( (aStartSegment < 0) || (aNumSegments <= 0) ) |
|
1630 { |
|
1631 vgContext->SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); |
|
1632 } |
|
1633 else |
|
1634 { |
|
1635 pathInfo->PointAlongPath(*vgContext, aStartSegment, aNumSegments, aDistance, aX, aY, aTangentX, aTangentY); |
|
1636 } |
|
1637 } |
|
1638 } |
|
1639 } |
|
1640 |
|
1641 |
|
1642 /* |
|
1643 ERRORS |
|
1644 VG_BAD_HANDLE_ERROR |
|
1645 – if path is not a valid path handle, or is not shared with the current context |
|
1646 VG_ILLEGAL_ARGUMENT_ERROR |
|
1647 – if paintModes is not a valid bitwise OR of values from the VGPaintMode |
|
1648 enumeration |
|
1649 */ |
|
1650 void TGuestOpenVg::vgDrawPath(VGPath aPath, VGbitfield aPaintModes) |
|
1651 { |
|
1652 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1653 if ( vgContext ) |
|
1654 { |
|
1655 CVgPathInfo* pathInfo = NULL; |
|
1656 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
1657 |
|
1658 if ( vgLock.CheckVGPath(aPath, &pathInfo) ) |
|
1659 { |
|
1660 pathInfo->DrawPath(*vgContext, aPaintModes); |
|
1661 } |
|
1662 } |
|
1663 } |
|
1664 |
|
1665 |
|
1666 /* Paint */ |
|
1667 |
|
1668 /* |
|
1669 ERRORS |
|
1670 VG_BAD_HANDLE_ERROR |
|
1671 – if paint is not a valid paint handle, or is not shared with the current context |
|
1672 */ |
|
1673 void TGuestOpenVg::vgDestroyPaint(VGPaint aPaint) |
|
1674 { |
|
1675 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1676 if ( vgContext ) |
|
1677 { |
|
1678 CVgPaintInfo* paintInfo = NULL; |
|
1679 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
1680 |
|
1681 if ( vgLock.CheckVGPaint(aPaint, &paintInfo) ) |
|
1682 { |
|
1683 paintInfo->Destroy(*vgContext); |
|
1684 } |
|
1685 } |
|
1686 } |
|
1687 |
|
1688 |
|
1689 /* |
|
1690 ERRORS |
|
1691 VG_BAD_HANDLE_ERROR |
|
1692 – if paint is neither a valid paint handle nor equal to VG_INVALID_HANDLE, |
|
1693 or is not shared with the current context |
|
1694 VG_ILLEGAL_ARGUMENT_ERROR |
|
1695 – if paintModes is not a valid bitwise OR of values from the VGPaintMode |
|
1696 enumeration |
|
1697 */ |
|
1698 void TGuestOpenVg::vgSetPaint(VGPaint aPaint, VGbitfield aPaintModes) |
|
1699 { |
|
1700 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1701 if ( vgContext ) |
|
1702 { |
|
1703 CVgPaintInfo* paintInfo = NULL; |
|
1704 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
1705 |
|
1706 if ( vgLock.CheckOptionalVGPaint(aPaint, &paintInfo) && TCheck::ChkVGPaintModesCombination(*vgContext, aPaintModes)) |
|
1707 { |
|
1708 if (paintInfo) |
|
1709 { |
|
1710 paintInfo->SetPaint(*vgContext, aPaintModes); |
|
1711 } |
|
1712 else |
|
1713 { |
|
1714 CVgPaintInfo::ResetPaint(*vgContext); |
|
1715 } |
|
1716 } |
|
1717 } |
|
1718 } |
|
1719 |
|
1720 |
|
1721 /* |
|
1722 ERRORS |
|
1723 VG_BAD_HANDLE_ERROR |
|
1724 – if paint is not a valid paint handle, or is not shared with the current context |
|
1725 */ |
|
1726 void TGuestOpenVg::vgSetColor(VGPaint aPaint, VGuint aRgba) |
|
1727 { |
|
1728 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1729 if ( vgContext ) |
|
1730 { |
|
1731 CVgPaintInfo* paintInfo = NULL; |
|
1732 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
1733 |
|
1734 if ( vgLock.CheckVGPaint(aPaint, &paintInfo) ) |
|
1735 { |
|
1736 paintInfo->SetColor(*vgContext, aRgba); |
|
1737 } |
|
1738 } |
|
1739 } |
|
1740 |
|
1741 |
|
1742 /* |
|
1743 ERRORS |
|
1744 VG_BAD_HANDLE_ERROR |
|
1745 – if paint is not a valid paint handle, or is not shared with the current context |
|
1746 – if pattern is neither a valid image handle nor equal to VG_INVALID_HANDLE, or is |
|
1747 not shared with the current context |
|
1748 VG_IMAGE_IN_USE_ERROR |
|
1749 – if pattern is currently a rendering target |
|
1750 */ |
|
1751 void TGuestOpenVg::vgPaintPattern(VGPaint aPaint, VGImage aPattern) |
|
1752 { |
|
1753 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1754 if ( vgContext ) |
|
1755 { |
|
1756 CVgPaintInfo* paintInfo = NULL; |
|
1757 CVgImageInfo* imageInfo = NULL; |
|
1758 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
1759 |
|
1760 if ( vgLock.CheckVGPaint(aPaint, &paintInfo) && vgLock.CheckOptionalVGImage(aPattern, &imageInfo) ) |
|
1761 { |
|
1762 paintInfo->PaintPattern(*vgContext, imageInfo); |
|
1763 } |
|
1764 } |
|
1765 } |
|
1766 |
|
1767 |
|
1768 /* Images */ |
|
1769 |
|
1770 /* |
|
1771 ERRORS |
|
1772 VG_BAD_HANDLE_ERROR |
|
1773 – if image is not a valid image handle, or is not shared with the current |
|
1774 context |
|
1775 */ |
|
1776 void TGuestOpenVg::vgDestroyImage(VGImage aImage) |
|
1777 { |
|
1778 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1779 if ( vgContext ) |
|
1780 { |
|
1781 CVgImageInfo* imageInfo = NULL; |
|
1782 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
1783 |
|
1784 if ( vgLock.CheckVGImage(aImage, &imageInfo) ) |
|
1785 { |
|
1786 imageInfo->Destroy(*vgContext); |
|
1787 } |
|
1788 } |
|
1789 } |
|
1790 |
|
1791 |
|
1792 /* |
|
1793 ERRORS |
|
1794 VG_BAD_HANDLE_ERROR |
|
1795 – if image is not a valid image handle, or is not shared with the current |
|
1796 context |
|
1797 VG_IMAGE_IN_USE_ERROR |
|
1798 – if image is currently a rendering target |
|
1799 VG_ILLEGAL_ARGUMENT_ERROR |
|
1800 – if width or height is less than or equal to 0 |
|
1801 */ |
|
1802 void TGuestOpenVg::vgClearImage(VGImage aImage, VGint aX, VGint aY, VGint aWidth, VGint aHeight) |
|
1803 { |
|
1804 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1805 if ( vgContext ) |
|
1806 { |
|
1807 CVgImageInfo* imageInfo = NULL; |
|
1808 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
1809 |
|
1810 if ( vgLock.CheckVGImage(aImage, &imageInfo) && TCheck::ChkPositiveImageSize(*vgContext, aWidth, aHeight) ) |
|
1811 { |
|
1812 imageInfo->ClearImage(*vgContext, aX, aY, aWidth, aHeight); |
|
1813 } |
|
1814 } |
|
1815 } |
|
1816 |
|
1817 |
|
1818 /* |
|
1819 ERRORS |
|
1820 VG_BAD_HANDLE_ERROR |
|
1821 – if image is not a valid image handle, or is not shared with the current |
|
1822 context |
|
1823 VG_IMAGE_IN_USE_ERROR |
|
1824 – if image is currently a rendering target |
|
1825 VG_UNSUPPORTED_IMAGE_FORMAT_ERROR |
|
1826 – if dataFormat is not a valid value from the VGImageFormat enumeration |
|
1827 VG_ILLEGAL_ARGUMENT_ERROR |
|
1828 – if width or height is less than or equal to 0 |
|
1829 – if data is NULL |
|
1830 – if data is not properly aligned |
|
1831 */ |
|
1832 void TGuestOpenVg::vgImageSubData(VGImage aImage, const void* aData, VGint aDataStride, VGImageFormat aDataFormat, |
|
1833 VGint aX, VGint aY, VGint aWidth, VGint aHeight) |
|
1834 { |
|
1835 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1836 if ( vgContext ) |
|
1837 { |
|
1838 CVgImageInfo* imageInfo = NULL; |
|
1839 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
1840 |
|
1841 if ( vgLock.CheckVGImage(aImage, &imageInfo) && TCheck::ChkImageAlignment(*vgContext, aDataFormat, aData) && |
|
1842 TCheck::ChkPositiveImageSize(*vgContext, aWidth, aHeight) ) |
|
1843 { |
|
1844 imageInfo->ImageSubData(*vgContext, aData, aDataStride, aDataFormat, aX, aY, aWidth, aHeight); |
|
1845 } |
|
1846 } |
|
1847 } |
|
1848 |
|
1849 |
|
1850 /* |
|
1851 ERRORS |
|
1852 VG_BAD_HANDLE_ERROR |
|
1853 – if either dst or src is not a valid image handle, or is not shared with the |
|
1854 current context |
|
1855 VG_IMAGE_IN_USE_ERROR |
|
1856 – if either dst or src is currently a rendering target |
|
1857 VG_ILLEGAL_ARGUMENT_ERROR |
|
1858 – if width or height is less than or equal to 0 |
|
1859 */ |
|
1860 void TGuestOpenVg::vgCopyImage(VGImage aDst, VGint aDx, VGint aDy, VGImage aSrc, VGint aSx, VGint aSy, |
|
1861 VGint aWidth, VGint aHeight, VGboolean aDither) |
|
1862 { |
|
1863 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1864 if ( vgContext ) |
|
1865 { |
|
1866 CVgImageInfo* dstImageInfo = NULL; |
|
1867 CVgImageInfo* srcImageInfo = NULL; |
|
1868 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
1869 |
|
1870 if ( vgLock.Check2VGImages(aDst, &dstImageInfo, aSrc, &srcImageInfo) && TCheck::ChkPositiveImageSize(*vgContext, aWidth, aHeight) ) |
|
1871 { |
|
1872 dstImageInfo->CopyImage(*vgContext, aDx, aDy, *srcImageInfo, aSx, aSy, aWidth, aHeight, aDither); |
|
1873 } |
|
1874 } |
|
1875 } |
|
1876 |
|
1877 |
|
1878 /* |
|
1879 ERRORS |
|
1880 VG_BAD_HANDLE_ERROR |
|
1881 – if image is not a valid image handle, or is not shared with the current |
|
1882 context |
|
1883 VG_IMAGE_IN_USE_ERROR |
|
1884 – if image is currently a rendering target |
|
1885 */ |
|
1886 void TGuestOpenVg::vgDrawImage(VGImage aImage) |
|
1887 { |
|
1888 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1889 if ( vgContext ) |
|
1890 { |
|
1891 CVgImageInfo* imageInfo = NULL; |
|
1892 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
1893 |
|
1894 if ( vgLock.CheckVGImage(aImage, &imageInfo) ) |
|
1895 { |
|
1896 imageInfo->DrawImage(*vgContext); |
|
1897 } |
|
1898 } |
|
1899 } |
|
1900 |
|
1901 |
|
1902 /* |
|
1903 ERRORS |
|
1904 VG_BAD_HANDLE_ERROR |
|
1905 – if src is not a valid image handle, or is not shared with the current context |
|
1906 VG_IMAGE_IN_USE_ERROR |
|
1907 – if src is currently a rendering target |
|
1908 VG_ILLEGAL_ARGUMENT_ERROR |
|
1909 – if width or height is less than or equal to 0 |
|
1910 */ |
|
1911 void TGuestOpenVg::vgSetPixels(VGint aDx, VGint aDy, VGImage aSrc, VGint aSx, VGint aSy, VGint aWidth, VGint aHeight) |
|
1912 { |
|
1913 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1914 if ( vgContext ) |
|
1915 { |
|
1916 CVgImageInfo* imageInfo = NULL; |
|
1917 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
1918 |
|
1919 if ( vgLock.CheckVGImage(aSrc, &imageInfo) && TCheck::ChkPositiveImageSize(*vgContext, aWidth, aHeight) ) |
|
1920 { |
|
1921 imageInfo->SetPixels(*vgContext, aDx, aDy, aSx, aSy, aWidth, aHeight); |
|
1922 } |
|
1923 } |
|
1924 } |
|
1925 |
|
1926 |
|
1927 /* |
|
1928 ERRORS |
|
1929 VG_UNSUPPORTED_IMAGE_FORMAT_ERROR |
|
1930 – if dataFormat is not a valid value from the VGImageFormat enumeration |
|
1931 VG_ILLEGAL_ARGUMENT_ERROR |
|
1932 – if width or height is less than or equal to 0 |
|
1933 – if data is NULL |
|
1934 – if data is not properly aligned |
|
1935 */ |
|
1936 void TGuestOpenVg::HostVgWritePixels(MVgContext& aVgContext, const void* aPixmap, size_t aPixmapSize, VGint aHostDataStride, |
|
1937 VGImageFormat aDataFormat, VGint aDx, VGint aDy, VGint aWidth, VGint aHeight) |
|
1938 { |
|
1939 VGPANIC_ASSERT(aPixmap != NULL, EVgPanicNullPixmapPointer); |
|
1940 VGPANIC_ASSERT(aPixmapSize >= (aHostDataStride * aHeight), EVgPanicPixmapSizeError); |
|
1941 RemoteFunctionCallData rfcdata; OpenVgRFC vgApiData(rfcdata); |
|
1942 vgApiData.Init(OpenVgRFC::EvgWritePixels, RemoteFunctionCallData::EOpRequest); |
|
1943 vgApiData.AppendVector(aPixmap, aPixmapSize); |
|
1944 vgApiData.AppendParam(aHostDataStride); |
|
1945 vgApiData.AppendParam(aDataFormat); |
|
1946 vgApiData.AppendParam(aDx); |
|
1947 vgApiData.AppendParam(aDy); |
|
1948 vgApiData.AppendParam(aWidth); |
|
1949 vgApiData.AppendParam(aHeight); |
|
1950 aVgContext.ExecuteVgCommand(vgApiData); |
|
1951 } |
|
1952 |
|
1953 |
|
1954 void TGuestOpenVg::vgWritePixels(const void* aData, VGint aDataStride, VGImageFormat aDataFormat, VGint aDx, VGint aDy, |
|
1955 VGint aWidth, VGint aHeight) |
|
1956 { |
|
1957 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
1958 if ( vgContext && TCheck::ChkImageAlignment(*vgContext, aDataFormat, aData) && |
|
1959 TCheck::ChkPositiveImageSize(*vgContext, aWidth, aHeight) ) |
|
1960 { |
|
1961 TInt bitsPerPixel = CVgImageInfo::BitsPerPixelForVgImageFormat(aDataFormat); |
|
1962 size_t lineLength = ((static_cast<size_t>(aWidth) * static_cast<size_t>(bitsPerPixel)) + 7) / 8; |
|
1963 OPENVG_TRACE("vgWritePixels.1 bitsPerPixel=%d, lineLength=%d", bitsPerPixel, lineLength); |
|
1964 // ToDo clip aWidth & aHeight to the surface width & height |
|
1965 |
|
1966 if (bitsPerPixel <= 0) |
|
1967 { |
|
1968 vgContext->SetVgError(VG_UNSUPPORTED_IMAGE_FORMAT_ERROR); |
|
1969 } |
|
1970 else |
|
1971 { |
|
1972 if (lineLength == aDataStride) |
|
1973 { // use original parameters |
|
1974 OPENVG_TRACE("vgWritePixels.2a: lineLength == dataStride"); |
|
1975 HostVgWritePixels(*vgContext, aData, aDataStride * aHeight, aDataStride, aDataFormat, aDx, aDy, aWidth, aHeight); |
|
1976 } |
|
1977 else if (0 == aDataStride) |
|
1978 { // Fill operation: pixmap size for the memcpy between Symbian & Host EGL is the lineLength |
|
1979 OPENVG_TRACE("vgWritePixels.2b: 0 == dataStride"); |
|
1980 HostVgWritePixels(*vgContext, aData, lineLength, aDataStride, aDataFormat, aDx, aDy, aWidth, aHeight); |
|
1981 } |
|
1982 else |
|
1983 { // datastride maybe negative or simply > lineLength |
|
1984 size_t pixmapSize = lineLength * aHeight; |
|
1985 TUint8* localBuffer = (TUint8*) CVghwUtils::Alloc(pixmapSize); |
|
1986 OPENVG_TRACE("vgWritePixels.2c: dataStride not 0 or lineLength, localBuffer=0x%x", localBuffer); |
|
1987 if (localBuffer != NULL) |
|
1988 { // reformat data into temporary buffer |
|
1989 CVgImageInfo::PixmapBlit(localBuffer, static_cast<const TUint8*>(aData), lineLength, aDataStride, aHeight, lineLength); |
|
1990 HostVgWritePixels(*vgContext, localBuffer, pixmapSize, lineLength, aDataFormat, aDx, aDy, aWidth, aHeight); |
|
1991 CVghwUtils::Free(localBuffer); |
|
1992 } |
|
1993 else |
|
1994 { // alloc failed, so do VG operation row by row |
|
1995 const TUint8* source = static_cast<const TUint8*>(aData); |
|
1996 for (VGint row = 0; row < aHeight; ++row) |
|
1997 { |
|
1998 HostVgWritePixels(*vgContext, source, lineLength, lineLength, aDataFormat, aDx + row, aDy, aWidth, 1); |
|
1999 source += aDataStride; |
|
2000 } |
|
2001 } |
|
2002 } |
|
2003 } |
|
2004 } |
|
2005 } |
|
2006 |
|
2007 |
|
2008 /* |
|
2009 ERRORS |
|
2010 VG_BAD_HANDLE_ERROR |
|
2011 – if dst is not a valid image handle, or is not shared with the current context |
|
2012 VG_IMAGE_IN_USE_ERROR |
|
2013 – if dst is currently a rendering target |
|
2014 VG_ILLEGAL_ARGUMENT_ERROR |
|
2015 – if width or height is less than or equal to 0 |
|
2016 */ |
|
2017 void TGuestOpenVg::vgGetPixels(VGImage aDst, VGint aDx, VGint aDy, VGint aSx, VGint aSy, VGint aWidth, VGint aHeight) |
|
2018 { |
|
2019 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
2020 if ( vgContext ) |
|
2021 { |
|
2022 CVgImageInfo* imageInfo = NULL; |
|
2023 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
2024 |
|
2025 if ( vgLock.CheckVGImage(aDst, &imageInfo) && TCheck::ChkPositiveImageSize(*vgContext, aWidth, aHeight) ) |
|
2026 { |
|
2027 imageInfo->GetPixels(*vgContext, aDx, aDy, aSx, aSy, aWidth, aHeight); |
|
2028 } |
|
2029 } |
|
2030 } |
|
2031 |
|
2032 |
|
2033 /* |
|
2034 ERRORS |
|
2035 VG_ILLEGAL_ARGUMENT_ERROR |
|
2036 – if width or height is less than or equal to 0 |
|
2037 */ |
|
2038 void TGuestOpenVg::vgCopyPixels(VGint aDx, VGint aDy, VGint aSx, VGint aSy, VGint aWidth, VGint aHeight) |
|
2039 { |
|
2040 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
2041 if ( vgContext && TCheck::ChkPositiveImageSize(*vgContext, aWidth, aHeight) ) |
|
2042 { |
|
2043 RemoteFunctionCallData data; OpenVgRFC vgApiData(data); |
|
2044 vgApiData.Init(OpenVgRFC::EvgCopyPixels, RemoteFunctionCallData::EOpRequest); |
|
2045 vgApiData.AppendParam(aDx); |
|
2046 vgApiData.AppendParam(aDy); |
|
2047 vgApiData.AppendParam(aSx); |
|
2048 vgApiData.AppendParam(aSy); |
|
2049 vgApiData.AppendParam(aWidth); |
|
2050 vgApiData.AppendParam(aHeight); |
|
2051 vgContext->ExecuteVgCommand(vgApiData); |
|
2052 } |
|
2053 } |
|
2054 |
|
2055 |
|
2056 /* |
|
2057 ERRORS |
|
2058 VG_BAD_HANDLE_ERROR |
|
2059 – if font is not a valid font handle, or is not shared with the current context |
|
2060 */ |
|
2061 void TGuestOpenVg::vgDestroyFont(VGFont aFont) |
|
2062 { |
|
2063 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
2064 if ( vgContext ) |
|
2065 { |
|
2066 CVgFontInfo* fontInfo = NULL; |
|
2067 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
2068 |
|
2069 if ( vgLock.CheckVGFont(aFont, &fontInfo) ) |
|
2070 { |
|
2071 fontInfo->Destroy(*vgContext); |
|
2072 } |
|
2073 } |
|
2074 } |
|
2075 |
|
2076 |
|
2077 /* |
|
2078 ERRORS |
|
2079 VG_BAD_HANDLE_ERROR |
|
2080 – if font is not a valid font handle, or is not shared with the current context |
|
2081 – if path is not a valid path handle or VG_INVALID_HANDLE, or is not shared |
|
2082 with the current context |
|
2083 VG_ILLEGAL_ARGUMENT_ERROR |
|
2084 – if the pointer to glyphOrigin or escapement is NULL or is not properly |
|
2085 aligned |
|
2086 */ |
|
2087 void TGuestOpenVg::vgSetGlyphToPath(VGFont aFont, VGuint aGlyphIndex, VGPath aPath, VGboolean aIsHinted, |
|
2088 const VGfloat aGlyphOrigin [2], const VGfloat aEscapement[2]) |
|
2089 { |
|
2090 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
2091 if ( vgContext ) |
|
2092 { |
|
2093 CVgFontInfo* fontInfo = NULL; |
|
2094 CVgPathInfo* pathInfo = NULL; |
|
2095 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
2096 |
|
2097 if ( vgLock.CheckVGFont(aFont, &fontInfo) && vgLock.CheckOptionalVGPath(aPath, &pathInfo) && |
|
2098 TCheck::Chk2x32bitPtr(*vgContext, aGlyphOrigin, aEscapement) ) |
|
2099 { |
|
2100 fontInfo->SetGlyphToPath(*vgContext, aGlyphIndex, pathInfo, aIsHinted, aGlyphOrigin, aEscapement); |
|
2101 } |
|
2102 } |
|
2103 } |
|
2104 |
|
2105 |
|
2106 /* |
|
2107 ERRORS |
|
2108 VG_BAD_HANDLE_ERROR |
|
2109 – if font is not a valid font handle, or is not shared with the current context |
|
2110 – if image is not a valid image handle or VG_INVALID_HANDLE, or is not |
|
2111 shared with the current context |
|
2112 VG_ILLEGAL_ARGUMENT_ERROR |
|
2113 – if the pointer to glyphOrigin or escapement is NULL or is not properly |
|
2114 aligned |
|
2115 VG_IMAGE_IN_USE_ERROR |
|
2116 – if image is currently a rendering target |
|
2117 */ |
|
2118 void TGuestOpenVg::vgSetGlyphToImage(VGFont aFont, VGuint aGlyphIndex, VGImage aImage, const VGfloat aGlyphOrigin [2], |
|
2119 const VGfloat aEscapement[2]) |
|
2120 { |
|
2121 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
2122 if ( vgContext ) |
|
2123 { |
|
2124 CVgFontInfo* fontInfo = NULL; |
|
2125 CVgImageInfo* imageInfo = NULL; |
|
2126 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
2127 |
|
2128 if ( vgLock.CheckVGFont(aFont, &fontInfo) && TCheck::Chk2x32bitPtr(*vgContext, aGlyphOrigin, aEscapement) && |
|
2129 vgLock.CheckOptionalVGImage(aImage, &imageInfo) ) |
|
2130 { |
|
2131 fontInfo->SetGlyphToImage(*vgContext, aGlyphIndex, imageInfo, aGlyphOrigin, aEscapement); |
|
2132 } |
|
2133 } |
|
2134 } |
|
2135 |
|
2136 |
|
2137 /* |
|
2138 ERRORS |
|
2139 VG_BAD_HANDLE_ERROR |
|
2140 – if font is not a valid font handle, or is not shared with the current context |
|
2141 VG_ILLEGAL_ARGUMENT_ERROR |
|
2142 – if glyphIndex is not defined for the font |
|
2143 */ |
|
2144 void TGuestOpenVg::vgClearGlyph(VGFont aFont, VGuint aGlyphIndex) |
|
2145 { |
|
2146 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
2147 if ( vgContext ) |
|
2148 { |
|
2149 CVgFontInfo* fontInfo = NULL; |
|
2150 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
2151 |
|
2152 if ( vgLock.CheckVGFont(aFont, &fontInfo) ) |
|
2153 { |
|
2154 fontInfo->ClearGlyph(*vgContext, aGlyphIndex); |
|
2155 } |
|
2156 } |
|
2157 } |
|
2158 |
|
2159 |
|
2160 /* |
|
2161 ERRORS |
|
2162 VG_BAD_HANDLE_ERROR |
|
2163 – if font is not a valid font handle, or is not shared with the current context |
|
2164 VG_ILLEGAL_ARGUMENT_ERROR |
|
2165 – if glyphIndex has not been defined for a given font object |
|
2166 – if paintModes is not a valid bitwise OR of values from the VGPaintMode |
|
2167 enumeration, or 0 |
|
2168 */ |
|
2169 void TGuestOpenVg::vgDrawGlyph(VGFont aFont, VGuint aGlyphIndex, VGbitfield aPaintModes, VGboolean aAllowAutoHinting) |
|
2170 { |
|
2171 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
2172 if ( vgContext ) |
|
2173 { |
|
2174 CVgFontInfo* fontInfo = NULL; |
|
2175 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
2176 |
|
2177 if ( vgLock.CheckVGFont(aFont, &fontInfo) && TCheck::ChkVGPaintModesCombination(*vgContext, aPaintModes) ) |
|
2178 { |
|
2179 fontInfo->DrawGlyph(*vgContext, aGlyphIndex, aPaintModes, aAllowAutoHinting); |
|
2180 } |
|
2181 } |
|
2182 } |
|
2183 |
|
2184 |
|
2185 /* |
|
2186 ERRORS |
|
2187 VG_BAD_HANDLE_ERROR |
|
2188 – if font is not a valid font handle, or is not shared with the current context |
|
2189 VG_ILLEGAL_ARGUMENT_ERROR |
|
2190 – if glyphCount is zero or a negative value |
|
2191 – if the pointer to the glyphIndices array is NULL or is not properly |
|
2192 aligned |
|
2193 – if a pointer to either of the adjustments_x or adjustments_y arrays are |
|
2194 non-NULL and are not properly aligned |
|
2195 – if any of the glyphIndices has not been defined in a given font object |
|
2196 – if paintModes is not a valid bitwise OR of values from the VGPaintMode |
|
2197 enumeration, or 0 |
|
2198 */ |
|
2199 void TGuestOpenVg::vgDrawGlyphs(VGFont aFont, VGint aGlyphCount, const VGuint* aGlyphIndices, |
|
2200 const VGfloat* aAdjustmentsX, const VGfloat* aAdjustmentsY, VGbitfield aPaintModes, VGboolean aAllowAutoHinting) |
|
2201 { |
|
2202 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
2203 if ( vgContext ) |
|
2204 { |
|
2205 CVgFontInfo* fontInfo = NULL; |
|
2206 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
2207 |
|
2208 if ( vgLock.CheckVGFont(aFont, &fontInfo) && TCheck::Chk32bitPtr(*vgContext, aGlyphIndices) && |
|
2209 TCheck::ChkVGPaintModesCombination(*vgContext, aPaintModes) && |
|
2210 TCheck::Chk2xOptional32bitPtr(*vgContext, aAdjustmentsX, aAdjustmentsY) ) |
|
2211 { |
|
2212 fontInfo->DrawGlyphs(*vgContext, aGlyphCount, aGlyphIndices, aAdjustmentsX, aAdjustmentsY, aPaintModes, aAllowAutoHinting); |
|
2213 } |
|
2214 } |
|
2215 } |
|
2216 |
|
2217 |
|
2218 /* Image Filters */ |
|
2219 |
|
2220 /* |
|
2221 ERRORS |
|
2222 VG_BAD_HANDLE_ERROR |
|
2223 – if either dst or src is not a valid image handle, or is not shared with the |
|
2224 current context |
|
2225 VG_IMAGE_IN_USE_ERROR |
|
2226 – if either dst or src is currently a rendering target |
|
2227 VG_ILLEGAL_ARGUMENT_ERROR |
|
2228 – if src and dst overlap |
|
2229 – if matrix is NULL |
|
2230 – if matrix is not properly aligned |
|
2231 */ |
|
2232 void TGuestOpenVg::vgColorMatrix(VGImage aDst, VGImage aSrc, const VGfloat* aMatrix) |
|
2233 { |
|
2234 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
2235 if ( vgContext ) |
|
2236 { |
|
2237 // **** Desirable: check that neither aDst or aSrc are current rendering targets, or overlapping |
|
2238 CVgImageInfo* dstImageInfo = NULL; |
|
2239 CVgImageInfo* srcImageInfo = NULL; |
|
2240 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
2241 |
|
2242 if ( vgLock.Check2VGImages(aDst, &dstImageInfo, aSrc, &srcImageInfo) && TCheck::Chk32bitPtr(*vgContext, aMatrix) ) |
|
2243 { |
|
2244 dstImageInfo->ColorMatrix(*vgContext, *srcImageInfo, aMatrix); |
|
2245 } |
|
2246 } |
|
2247 } |
|
2248 |
|
2249 |
|
2250 /* |
|
2251 ERRORS |
|
2252 VG_BAD_HANDLE_ERROR |
|
2253 – if either dst or src is not a valid image handle, or is not shared with the |
|
2254 current context |
|
2255 VG_IMAGE_IN_USE_ERROR |
|
2256 – if either dst or src is currently a rendering target |
|
2257 VG_ILLEGAL_ARGUMENT_ERROR |
|
2258 – if src and dst overlap |
|
2259 – if kernelWidth or kernelHeight is less than or equal to 0 or greater than |
|
2260 VG_MAX_KERNEL_SIZE |
|
2261 – if kernel is NULL |
|
2262 – if kernel is not properly aligned |
|
2263 – if tilingMode is not one of the values from the VGTilingMode enumeration |
|
2264 */ |
|
2265 void TGuestOpenVg::vgConvolve(VGImage aDst, VGImage aSrc, VGint aKernelWidth, VGint aKernelHeight, |
|
2266 VGint aShiftX, VGint aShiftY, const VGshort* aKernel, VGfloat aScale, VGfloat aBias, VGTilingMode aTilingMode) |
|
2267 { |
|
2268 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
2269 if ( vgContext ) |
|
2270 { |
|
2271 CVgImageInfo* dstImageInfo = NULL; |
|
2272 CVgImageInfo* srcImageInfo = NULL; |
|
2273 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
2274 |
|
2275 if ( vgLock.Check2VGImages(aDst, &dstImageInfo, aSrc, &srcImageInfo) && TCheck::Chk16bitPtr(*vgContext, aKernel) && |
|
2276 TCheck::ChkVGTilingMode(*vgContext, aTilingMode) && |
|
2277 vgLock.CheckKernelWidthAndHeight(aKernelHeight, aKernelWidth, VG_MAX_KERNEL_SIZE) ) |
|
2278 { |
|
2279 dstImageInfo->Convolve(*vgContext, *srcImageInfo, aKernelWidth, aKernelHeight, |
|
2280 aShiftX, aShiftY, aKernel, aScale, aBias, aTilingMode); |
|
2281 } |
|
2282 } |
|
2283 } |
|
2284 |
|
2285 |
|
2286 /* |
|
2287 ERRORS |
|
2288 VG_BAD_HANDLE_ERROR |
|
2289 – if either dst or src is not a valid image handle, or is not shared with the |
|
2290 current context |
|
2291 VG_IMAGE_IN_USE_ERROR |
|
2292 – if either dst or src is currently a rendering target |
|
2293 VG_ILLEGAL_ARGUMENT_ERROR |
|
2294 – if src and dst overlap |
|
2295 – if kernelWidth or kernelHeight is less than or equal to 0 or greater than |
|
2296 VG_MAX_SEPARABLE_KERNEL_SIZE |
|
2297 – if kernelX or kernelY is NULL |
|
2298 – if kernelX or kernelY is not properly aligned |
|
2299 – if tilingMode is not one of the values from the VGTilingMode |
|
2300 enumeration |
|
2301 */ |
|
2302 void TGuestOpenVg::vgSeparableConvolve(VGImage aDst, VGImage aSrc, VGint aKernelWidth, VGint aKernelHeight, |
|
2303 VGint aShiftX, VGint aShiftY, const VGshort* aKernelX, const VGshort* aKernelY, VGfloat aScale, VGfloat aBias, VGTilingMode aTilingMode) |
|
2304 { |
|
2305 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
2306 if ( vgContext ) |
|
2307 { |
|
2308 CVgImageInfo* dstImageInfo = NULL; |
|
2309 CVgImageInfo* srcImageInfo = NULL; |
|
2310 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
2311 |
|
2312 if ( vgLock.Check2VGImages(aDst, &dstImageInfo, aSrc, &srcImageInfo) && |
|
2313 TCheck::Chk2x16bitPtr(*vgContext, aKernelX, aKernelY) && TCheck::ChkVGTilingMode(*vgContext, aTilingMode) && |
|
2314 vgLock.CheckKernelWidthAndHeight(aKernelWidth, aKernelHeight, VG_MAX_SEPARABLE_KERNEL_SIZE) ) |
|
2315 { |
|
2316 dstImageInfo->SeparableConvolve(*vgContext, *srcImageInfo, aKernelWidth, aKernelHeight, |
|
2317 aShiftX, aShiftY, aKernelX, aKernelY, aScale, aBias, aTilingMode); |
|
2318 } |
|
2319 } |
|
2320 } |
|
2321 |
|
2322 |
|
2323 /* |
|
2324 ERRORS |
|
2325 VG_BAD_HANDLE_ERROR |
|
2326 – if either dst or src is not a valid image handle, or is not shared with the |
|
2327 current context |
|
2328 VG_IMAGE_IN_USE_ERROR |
|
2329 – if either dst or src is currently a rendering target |
|
2330 VG_ILLEGAL_ARGUMENT_ERROR |
|
2331 – if src and dst overlap |
|
2332 – if stdDeviationX or stdDeviationY is less than or equal to 0 or greater |
|
2333 than VG_MAX_GAUSSIAN_STD_DEVIATION |
|
2334 – if tilingMode is not one of the values from the VGTilingMode |
|
2335 enumeration |
|
2336 */ |
|
2337 void TGuestOpenVg::vgGaussianBlur(VGImage aDst, VGImage aSrc, VGfloat aStdDeviationX, VGfloat aStdDeviationY, VGTilingMode aTilingMode) |
|
2338 { |
|
2339 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
2340 if ( vgContext ) |
|
2341 { |
|
2342 CVgImageInfo* dstImageInfo = NULL; |
|
2343 CVgImageInfo* srcImageInfo = NULL; |
|
2344 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
2345 |
|
2346 if ( vgLock.Check2VGImages(aDst, &dstImageInfo, aSrc, &srcImageInfo) && TCheck::ChkVGTilingMode(*vgContext, aTilingMode) ) |
|
2347 { |
|
2348 // **** Desirable: check against VG_MAX_GAUSSIAN_STD_DEVIATION limit from x86 VG implementation |
|
2349 if ( (aStdDeviationX <= KFloatZero) || (aStdDeviationY <= KFloatZero)) |
|
2350 { |
|
2351 vgContext->SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); |
|
2352 } |
|
2353 else |
|
2354 { |
|
2355 dstImageInfo->GaussianBlur(*vgContext, *srcImageInfo, aStdDeviationX, aStdDeviationY, aTilingMode); |
|
2356 } |
|
2357 } |
|
2358 } |
|
2359 } |
|
2360 |
|
2361 |
|
2362 /* |
|
2363 ERRORS |
|
2364 VG_BAD_HANDLE_ERROR |
|
2365 – if either dst or src is not a valid image handle, or is not shared with the |
|
2366 current context |
|
2367 VG_IMAGE_IN_USE_ERROR |
|
2368 – if either dst or src is currently a rendering target |
|
2369 VG_ILLEGAL_ARGUMENT_ERROR |
|
2370 – if src and dst overlap |
|
2371 – if any pointer parameter is NULL |
|
2372 */ |
|
2373 void TGuestOpenVg::vgLookup(VGImage aDst, VGImage aSrc, const VGubyte* aRedLUT, const VGubyte* aGreenLUT, |
|
2374 const VGubyte* aBlueLUT, const VGubyte* aAlphaLUT, VGboolean aOutputLinear, VGboolean aOutputPremultiplied) |
|
2375 { |
|
2376 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
2377 if ( vgContext ) |
|
2378 { |
|
2379 CVgImageInfo* dstImageInfo = NULL; |
|
2380 CVgImageInfo* srcImageInfo = NULL; |
|
2381 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
2382 |
|
2383 if ( vgLock.Check2VGImages(aDst, &dstImageInfo, aSrc, &srcImageInfo) ) |
|
2384 { |
|
2385 if ( (aRedLUT == NULL) || (aGreenLUT == NULL) || (aBlueLUT == NULL) || (aAlphaLUT == NULL) ) |
|
2386 { |
|
2387 vgContext->SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); |
|
2388 } |
|
2389 else |
|
2390 { |
|
2391 dstImageInfo->Lookup(*vgContext, *srcImageInfo, aRedLUT, aGreenLUT, aBlueLUT, aAlphaLUT, aOutputLinear, aOutputPremultiplied); |
|
2392 } |
|
2393 } |
|
2394 } |
|
2395 } |
|
2396 |
|
2397 |
|
2398 /* |
|
2399 ERRORS |
|
2400 VG_BAD_HANDLE_ERROR |
|
2401 – if either dst or src is not a valid image handle, or is not shared with the |
|
2402 current context |
|
2403 VG_IMAGE_IN_USE_ERROR |
|
2404 – if either dst or src is currently a rendering target |
|
2405 VG_ILLEGAL_ARGUMENT_ERROR |
|
2406 – if src and dst overlap |
|
2407 – if src is in an RGB pixel format and sourceChannel is not one of VG_RED, |
|
2408 VG_GREEN, VG_BLUE or VG_ALPHA from the VGImageChannel enumeration |
|
2409 – if lookupTable is NULL |
|
2410 – if lookupTable is not properly aligned |
|
2411 */ |
|
2412 void TGuestOpenVg::vgLookupSingle(VGImage aDst, VGImage aSrc, const VGuint* aLookupTable, |
|
2413 VGImageChannel aSourceChannel, VGboolean aOutputLinear, VGboolean aOutputPremultiplied) |
|
2414 { |
|
2415 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
2416 if ( vgContext ) |
|
2417 { |
|
2418 CVgImageInfo* dstImageInfo = NULL; |
|
2419 CVgImageInfo* srcImageInfo = NULL; |
|
2420 TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction |
|
2421 |
|
2422 if ( vgLock.Check2VGImages(aDst, &dstImageInfo, aSrc, &srcImageInfo) && TCheck::Chk32bitPtr(*vgContext, aLookupTable) ) |
|
2423 { |
|
2424 dstImageInfo->LookupSingle(*vgContext, *srcImageInfo, aLookupTable, |
|
2425 aSourceChannel, aOutputLinear, aOutputPremultiplied); |
|
2426 } |
|
2427 } |
|
2428 } |
|
2429 |
|
2430 |
|
2431 /* |
|
2432 ERRORS |
|
2433 VG_UNSUPPORTED_IMAGE_FORMAT_ERROR |
|
2434 - if the OpenVG implementation is not able to create a VGImage |
|
2435 compatible with the provided VGeglImageKHR for an implementation- |
|
2436 dependent reason (this could be caused by, but not limited to, |
|
2437 reasons such as unsupported pixel formats, anti-aliasing quality, |
|
2438 etc.). |
|
2439 |
|
2440 VG_ILLEGAL_ARGUMENT_ERROR |
|
2441 - if <image> is not a valid VGeglImageKHR. |
|
2442 */ |
|
2443 VGImage TGuestOpenVg::vgCreateEGLImageTargetKHR(VGeglImageKHR aImage) |
|
2444 { |
|
2445 VGImage imageHandle = VG_INVALID_HANDLE; |
|
2446 MVgContext* vgContext = CVghwUtils::VgContext(); |
|
2447 if (vgContext) |
|
2448 { |
|
2449 TCleanupVgLocks vgLock(*vgContext); |
|
2450 imageHandle = vgLock.CreateEGLImageTargetKHR(aImage); |
|
2451 } |
|
2452 else |
|
2453 { |
|
2454 OPENVG_TRACE(" TGuestOpenVg::vgCreateEGLImageTargetKHR - no VG context"); |
|
2455 } |
|
2456 |
|
2457 return imageHandle; |
|
2458 } |
|
2459 |
|
2460 |
|
2461 // end of file vgapi.cpp |