author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:50:15 +0300 | |
branch | RCL_3 |
changeset 72 | a5e7a4f63858 |
parent 64 | 85902f042028 |
permissions | -rw-r--r-- |
56 | 1 |
/* |
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
// INCLUDE FILES |
|
19 |
||
20 |
#include "HgVgHelper.h" |
|
21 |
#include "HgVgDrawBuffer.h" |
|
22 |
#include "HgVgImageCreator.h" |
|
23 |
||
24 |
#include <e32math.h> |
|
25 |
#include <gulicon.h> |
|
26 |
#include <fbs.h> |
|
27 |
#include <nvg.h> |
|
28 |
#include <AknIconHeader.h> |
|
29 |
#include <AknIconUtils.h> |
|
30 |
||
31 |
const TInt KVertexX(0); |
|
32 |
const TInt KVertexY(1); |
|
33 |
const TInt KVertexZ(2); |
|
34 |
const TInt KNumColorValues(4); |
|
35 |
const TInt KNumColorTransformValues(8); |
|
36 |
const VGfloat KColorByteToFloatFactor(255.0f); |
|
37 |
||
38 |
||
39 |
namespace HgVgHelper |
|
40 |
{ |
|
41 |
||
42 |
// --------------------------------------------------------------------------- |
|
43 |
// CreateNonMaskedVgImageL() |
|
44 |
// --------------------------------------------------------------------------- |
|
45 |
// |
|
46 |
static VGImage CreateNonMaskedVgImageL( const CFbsBitmap& aBitmap ) |
|
47 |
{ |
|
48 |
TSize size = aBitmap.SizeInPixels(); |
|
49 |
VGImage image = vgCreateImage(VG_sRGB_565, size.iWidth, size.iHeight,VG_IMAGE_QUALITY_NONANTIALIASED); |
|
50 |
||
51 |
if ( image != VG_INVALID_HANDLE ) // to check if the image was created |
|
52 |
{ |
|
53 |
if (aBitmap.DisplayMode() == EColor64K && !aBitmap.IsCompressedInRAM()) |
|
54 |
{ |
|
55 |
aBitmap.BeginDataAccess(); |
|
56 |
TInt stride = aBitmap.DataStride(); |
|
57 |
TUint8* ptr = (TUint8*)aBitmap.DataAddress(); |
|
58 |
||
59 |
vgGetError(); // to zero the error flag |
|
60 |
vgImageSubData (image, ptr, stride, VG_sRGB_565, 0, 0, size.iWidth, size.iHeight ); |
|
61 |
||
62 |
if(vgGetError() != VG_NO_ERROR) |
|
63 |
{ |
|
64 |
vgDestroyImage(image); |
|
65 |
image = VG_INVALID_HANDLE; |
|
66 |
} |
|
67 |
aBitmap.EndDataAccess(); |
|
68 |
} |
|
69 |
else |
|
70 |
{ |
|
71 |
TSize size = aBitmap.SizeInPixels(); |
|
72 |
CHgVgDrawBuffer* temp = CHgVgDrawBuffer::NewL(size, EColor64K); |
|
73 |
temp->Gc().BitBlt(TPoint(0,0), &aBitmap); |
|
74 |
temp->GetDrawBufferToVgImage(size, TPoint(0,0), image, |
|
75 |
VG_sRGB_565); |
|
76 |
delete temp; |
|
77 |
} |
|
78 |
} |
|
79 |
||
80 |
return image; |
|
81 |
} |
|
82 |
||
83 |
// --------------------------------------------------------------------------- |
|
84 |
// CreateMaskedVgImageL() |
|
85 |
// --------------------------------------------------------------------------- |
|
86 |
// |
|
87 |
static VGImage CreateMaskedVgImageL( CFbsBitmap* aBitmap, CFbsBitmap* aMask ) |
|
88 |
{ |
|
89 |
TSize size = aBitmap->SizeInPixels(); |
|
90 |
CHgVgDrawBuffer* temp = CHgVgDrawBuffer::NewL(size, EColor16MA); |
|
91 |
temp->Gc().SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); |
|
92 |
temp->Gc().SetBrushColor(TRgb(0,0,0,0)); |
|
93 |
temp->Gc().Clear(); |
|
94 |
temp->Gc().BitBltMasked(TPoint(0,0), aBitmap, size, aMask, EFalse); |
|
95 |
||
96 |
VGImage image = vgCreateImage(VG_sRGBA_8888, size.iWidth, size.iHeight,VG_IMAGE_QUALITY_NONANTIALIASED); |
|
97 |
temp->GetDrawBufferToVgImage(size, TPoint(0,0), image, |
|
98 |
VG_sARGB_8888); |
|
99 |
||
100 |
delete temp; |
|
101 |
return image; |
|
102 |
} |
|
103 |
||
104 |
// --------------------------------------------------------------------------- |
|
105 |
// HgVgHelper::CreateVgImageFromIconL() |
|
106 |
// --------------------------------------------------------------------------- |
|
107 |
// |
|
108 |
VGImage CreateVgImageFromIconL(const CGulIcon& aIcon) |
|
109 |
{ |
|
72
a5e7a4f63858
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
110 |
|
56 | 111 |
CFbsBitmap* bitmap = aIcon.Bitmap(); |
112 |
User::LeaveIfNull(bitmap); |
|
113 |
CFbsBitmap* mask = aIcon.Mask(); |
|
114 |
||
115 |
// if this is NVG image, rasterize it using |
|
116 |
// nvg engine |
|
117 |
if (bitmap->ExtendedBitmapType() != KNullUid) |
|
118 |
{ |
|
119 |
return CHgVgImageCreator::InstanceL()->RenderImageFromIconL(bitmap); |
|
120 |
} |
|
121 |
else |
|
122 |
{ |
|
123 |
// otherwise just blit/copy to vg image. |
|
124 |
if (mask) |
|
125 |
{ |
|
126 |
return CreateMaskedVgImageL(bitmap, mask); |
|
127 |
} |
|
128 |
else |
|
129 |
{ |
|
130 |
return CreateNonMaskedVgImageL(*bitmap); |
|
131 |
} |
|
132 |
} |
|
133 |
||
134 |
} |
|
135 |
||
136 |
// --------------------------------------------------------------------------- |
|
137 |
// HgVgHelper::Clamp() |
|
138 |
// --------------------------------------------------------------------------- |
|
139 |
// |
|
140 |
VGfloat Clamp(VGfloat value, VGfloat min, VGfloat max) |
|
141 |
{ |
|
142 |
VGfloat result = (value < min) ? min : value; |
|
143 |
return (result > max) ? max : result; |
|
144 |
} |
|
145 |
||
146 |
// --------------------------------------------------------------------------- |
|
147 |
// HgVgHelper::Lerp() |
|
148 |
// --------------------------------------------------------------------------- |
|
149 |
// |
|
150 |
VGfloat Lerp(VGfloat start, VGfloat end, VGfloat t) |
|
151 |
{ |
|
152 |
return start * (1.0f - t) + end * t; |
|
153 |
} |
|
154 |
||
155 |
// --------------------------------------------------------------------------- |
|
156 |
// HgVgHelper::Abs() |
|
157 |
// --------------------------------------------------------------------------- |
|
158 |
// |
|
159 |
VGfloat Abs(VGfloat value) |
|
160 |
{ |
|
161 |
return (value < 0) ? -value : value; |
|
162 |
} |
|
163 |
||
164 |
// --------------------------------------------------------------------------- |
|
165 |
// HgVgHelper::CalculateBoudingRect() |
|
166 |
// --------------------------------------------------------------------------- |
|
167 |
// |
|
168 |
void CalculateBoundingRect(TRect& aRect, VGfloat* aPoints, TInt aNumPoints, |
|
169 |
const TRect& aWindowRect) |
|
170 |
{ |
|
171 |
TInt height = aWindowRect.Height(); |
|
172 |
||
173 |
TPoint min((TInt)aPoints[0], height - (TInt)aPoints[1]); |
|
174 |
TPoint max((TInt)aPoints[0], height - (TInt)aPoints[1]); |
|
175 |
||
176 |
for (TInt i = 0; i < aNumPoints; i++) |
|
177 |
{ |
|
178 |
||
179 |
TPoint temp((TInt)aPoints[i*2+0], height - (TInt)aPoints[i*2+1]); |
|
180 |
||
181 |
min.iX = (temp.iX < min.iX) ? temp.iX : min.iX; |
|
182 |
max.iX = (temp.iX > max.iX) ? temp.iX : max.iX; |
|
183 |
||
184 |
min.iY = (temp.iY < min.iY) ? temp.iY : min.iY; |
|
185 |
max.iY = (temp.iY > max.iY) ? temp.iY : max.iY; |
|
186 |
||
187 |
} |
|
188 |
||
189 |
// Top Left |
|
190 |
aRect.iTl = min; |
|
191 |
||
192 |
// Bottom Right |
|
193 |
aRect.iBr = max; |
|
194 |
||
195 |
} |
|
196 |
||
197 |
void TVertex::ProjectPoint(VGfloat aScreenWidth, VGfloat aScreenHeight, VGfloat aFov) |
|
198 |
{ |
|
199 |
VGfloat hw = aScreenWidth * 0.5f; |
|
200 |
VGfloat hh = aScreenHeight * 0.5f; |
|
201 |
VGfloat alpha = aFov / 2.0f; |
|
202 |
double tanAlpha; |
|
203 |
Math::Tan(tanAlpha, alpha); |
|
204 |
VGfloat d = hw / tanAlpha; |
|
205 |
iScreenX = (VGfloat)(hw + d * iTx / iTz); |
|
206 |
iScreenY = (VGfloat)(hh + d * iTy / iTz); |
|
207 |
} |
|
208 |
||
209 |
void TVertex::TransformPoint(const TMatrix& aMatrix) |
|
210 |
{ |
|
211 |
iTx = iX * aMatrix.iM[0][0] + iY * aMatrix.iM[1][0] + iZ * aMatrix.iM[2][0] + aMatrix.iM[3][0]; |
|
212 |
iTy = iX * aMatrix.iM[0][1] + iY * aMatrix.iM[1][1] + iZ * aMatrix.iM[2][1] + aMatrix.iM[3][1]; |
|
213 |
iTz = iX * aMatrix.iM[0][2] + iY * aMatrix.iM[1][2] + iZ * aMatrix.iM[2][2] + aMatrix.iM[3][2]; |
|
214 |
} |
|
215 |
||
216 |
TMatrix::TMatrix() |
|
217 |
{ |
|
218 |
} |
|
219 |
||
220 |
TMatrix::TMatrix(const TMatrix& rhs) |
|
221 |
{ |
|
222 |
(*this) = rhs; |
|
223 |
} |
|
224 |
||
225 |
TMatrix::~TMatrix() |
|
226 |
{ |
|
227 |
} |
|
228 |
||
229 |
TMatrix& TMatrix::operator=(const TMatrix& rhs) |
|
230 |
{ |
|
231 |
for (int i = 0; i < 4; ++i) |
|
232 |
{ |
|
233 |
for (int j = 0; j < 4; ++j) |
|
234 |
{ |
|
235 |
iM[i][j] = rhs.iM[i][j]; |
|
236 |
} |
|
237 |
} |
|
238 |
return *this; |
|
239 |
} |
|
240 |
||
241 |
void TMatrix::Identity() |
|
242 |
{ |
|
243 |
iM[0][0] = 1.0f; |
|
244 |
iM[0][1] = 0.0f; |
|
245 |
iM[0][2] = 0.0f; |
|
246 |
iM[0][3] = 0.0f; |
|
247 |
||
248 |
iM[1][0] = 0.0f; |
|
249 |
iM[1][1] = 1.0f; |
|
250 |
iM[1][2] = 0.0f; |
|
251 |
iM[1][3] = 0.0f; |
|
252 |
||
253 |
iM[2][0] = 0.0f; |
|
254 |
iM[2][1] = 0.0f; |
|
255 |
iM[2][2] = 1.0f; |
|
256 |
iM[2][3] = 0.0f; |
|
257 |
||
258 |
iM[3][0] = 0.0f; |
|
259 |
iM[3][1] = 0.0f; |
|
260 |
iM[3][2] = 0.0f; |
|
261 |
iM[3][3] = 1.0f; |
|
262 |
} |
|
263 |
||
264 |
||
265 |
void TMatrix::Multiply(const TMatrix& rhs) |
|
266 |
{ |
|
267 |
VGfloat temp[4][4]; |
|
268 |
for (int i = 0; i < 4; ++i) |
|
269 |
{ |
|
270 |
for (int j = 0; j < 4; ++j) |
|
271 |
{ |
|
272 |
temp[i][j] = |
|
273 |
iM[i][0] * rhs.iM[0][j] + |
|
274 |
iM[i][1] * rhs.iM[1][j] + |
|
275 |
iM[i][2] * rhs.iM[2][j] + |
|
276 |
iM[i][3] * rhs.iM[3][j]; |
|
277 |
} |
|
278 |
} |
|
279 |
for (int i = 0; i < 4; ++i) |
|
280 |
{ |
|
281 |
for (int j = 0; j < 4; ++j) |
|
282 |
{ |
|
283 |
iM[i][j] = temp[i][j]; |
|
284 |
} |
|
285 |
} |
|
286 |
} |
|
287 |
||
288 |
||
289 |
void TMatrix::RotationX(VGfloat angle) |
|
290 |
{ |
|
291 |
double sa, ca; |
|
292 |
Math::Sin(sa, angle); |
|
293 |
Math::Cos(ca, angle); |
|
294 |
||
295 |
iM[0][0] = 1.0f; |
|
296 |
iM[0][1] = 0.0f; |
|
297 |
iM[0][2] = 0.0f; |
|
298 |
iM[0][3] = 0.0f; |
|
299 |
||
300 |
iM[1][0] = 0.0f; |
|
301 |
iM[1][1] = ca; |
|
302 |
iM[1][2] = sa; |
|
303 |
iM[1][3] = 0.0f; |
|
304 |
||
305 |
iM[2][0] = 0.0f; |
|
306 |
iM[2][1] = -sa; |
|
307 |
iM[2][2] = ca; |
|
308 |
iM[2][3] = 0.0f; |
|
309 |
||
310 |
iM[3][0] = 0.0f; |
|
311 |
iM[3][1] = 0.0f; |
|
312 |
iM[3][2] = 0.0f; |
|
313 |
iM[3][3] = 1.0f; |
|
314 |
} |
|
315 |
||
316 |
||
317 |
void TMatrix::RotationY(float angle) |
|
318 |
{ |
|
319 |
double sa, ca; |
|
320 |
Math::Sin(sa, angle); |
|
321 |
Math::Cos(ca, angle); |
|
322 |
||
323 |
iM[0][0] = ca; |
|
324 |
iM[0][1] = 0.0f; |
|
325 |
iM[0][2] = -sa; |
|
326 |
iM[0][3] = 0.0f; |
|
327 |
||
328 |
iM[1][0] = 0.0f; |
|
329 |
iM[1][1] = 1.0f; |
|
330 |
iM[1][2] = 0.0f; |
|
331 |
iM[1][3] = 0.0f; |
|
332 |
||
333 |
iM[2][0] = sa; |
|
334 |
iM[2][1] = 0.0f; |
|
335 |
iM[2][2] = ca; |
|
336 |
iM[2][3] = 0.0f; |
|
337 |
||
338 |
iM[3][0] = 0.0f; |
|
339 |
iM[3][1] = 0.0f; |
|
340 |
iM[3][2] = 0.0f; |
|
341 |
iM[3][3] = 1.0f; |
|
342 |
} |
|
343 |
||
344 |
void TMatrix::Scale(VGfloat aSx, VGfloat aSy, VGfloat aSz) |
|
345 |
{ |
|
346 |
Identity(); |
|
347 |
iM[0][0] = aSx; |
|
348 |
iM[1][1] = aSy; |
|
349 |
iM[2][2] = aSz; |
|
350 |
} |
|
351 |
||
352 |
void TMatrix::Translation(VGfloat aX, VGfloat aY, VGfloat aZ) |
|
353 |
{ |
|
354 |
Identity(); |
|
355 |
||
356 |
iM[3][0] = aX; |
|
357 |
iM[3][1] = aY; |
|
358 |
iM[3][2] = aZ; |
|
359 |
} |
|
360 |
||
361 |
||
362 |
// --------------------------------------------------------------------------- |
|
363 |
// HgVgHelper::ComputeRotationMatrixByY |
|
364 |
// --------------------------------------------------------------------------- |
|
365 |
// |
|
366 |
void ComputeRotationMatrixByY(VGfloat* matrix, VGfloat angle) |
|
367 |
{ |
|
368 |
// Build rotation matrix around Y-axis |
|
369 |
double sinrad, cosrad; |
|
370 |
Math::Sin (sinrad, angle ); |
|
371 |
Math::Cos (cosrad, angle ); |
|
372 |
VGfloat sa = sinrad; |
|
373 |
VGfloat ca = cosrad; |
|
374 |
||
375 |
VGfloat rotMatrix[] = |
|
376 |
{ |
|
377 |
ca, 0, sa, |
|
378 |
0, 1, 0, |
|
379 |
sa, 0, -ca |
|
380 |
}; |
|
381 |
||
382 |
// copy to result. |
|
383 |
for (int i = 0; i < 9; i++ ) |
|
384 |
matrix[i] = rotMatrix[i]; |
|
385 |
} |
|
386 |
||
387 |
||
388 |
// --------------------------------------------------------------------------- |
|
389 |
// HgVgHelper::MultiplyMatrix() |
|
390 |
// --------------------------------------------------------------------------- |
|
391 |
// |
|
392 |
void MultiplyMatrix(VGfloat* aResult, VGfloat* aA, VGfloat* aB) |
|
393 |
{ |
|
394 |
for (VGint i = 0; i < 3; ++i) |
|
395 |
{ |
|
396 |
for (VGint j = 0; j < 3; ++j) |
|
397 |
{ |
|
398 |
aResult[i*3+j] = |
|
399 |
aA[j*3+0] * aB[i*3+0] + |
|
400 |
aA[j*3+1] * aB[i*3+1] + |
|
401 |
aA[j*3+2] * aB[i*3+2]; |
|
402 |
} |
|
403 |
} |
|
404 |
} |
|
405 |
||
406 |
||
407 |
// --------------------------------------------------------------------------- |
|
408 |
// HgVgHelper::TransformVertex |
|
409 |
// --------------------------------------------------------------------------- |
|
410 |
// |
|
411 |
void TransformVertex(const VGfloat* inVertex, VGfloat* outVertex, |
|
412 |
const VGfloat* matrix) |
|
413 |
{ |
|
414 |
VGfloat x = inVertex[KVertexX]; |
|
415 |
VGfloat y = inVertex[KVertexY]; |
|
416 |
VGfloat z = inVertex[KVertexZ]; |
|
417 |
||
418 |
outVertex[KVertexX] = x * matrix[0] + y * matrix[3] + z * matrix[6]; |
|
419 |
outVertex[KVertexY] = x * matrix[1] + y * matrix[4] + z * matrix[7]; |
|
420 |
outVertex[KVertexZ] = x * matrix[2] + y * matrix[5] + z * matrix[8]; |
|
421 |
} |
|
422 |
||
423 |
// --------------------------------------------------------------------------- |
|
424 |
// HgVgHelper::PerspectiveTransformVertex |
|
425 |
// --------------------------------------------------------------------------- |
|
426 |
// |
|
427 |
void PerspectiveTransformVertex(VGfloat* aInVertex, VGfloat* aOutVertex, |
|
428 |
VGfloat aScreenWidth, VGfloat aScreenHeight, VGfloat aFov) |
|
429 |
{ |
|
430 |
/* VGfloat x = inVertex[KVertexX]; |
|
431 |
VGfloat y = inVertex[KVertexY]; |
|
432 |
VGfloat z = inVertex[KVertexZ]; |
|
433 |
||
434 |
outVertex[KVertexX] = screenWidth * 0.5f + fov * x / z; |
|
435 |
outVertex[KVertexY] = screenHeight * 0.5f + fov * y / z; |
|
436 |
*/ |
|
437 |
VGfloat hw = aScreenWidth * 0.5f; |
|
438 |
VGfloat hh = aScreenHeight * 0.5f; |
|
439 |
VGfloat alpha = aFov / 2.0f; |
|
440 |
double tanAlpha; |
|
441 |
Math::Tan(tanAlpha, alpha); |
|
442 |
VGfloat d = hw / tanAlpha; |
|
443 |
aOutVertex[KVertexX] = (VGfloat)(hw + d * aInVertex[KVertexX] / aInVertex[KVertexZ]); |
|
444 |
aOutVertex[KVertexY] = (VGfloat)(hh + d * aInVertex[KVertexY] / aInVertex[KVertexZ]); |
|
445 |
||
446 |
} |
|
447 |
||
448 |
// --------------------------------------------------------------------------- |
|
449 |
// HgVgHelper::DrawAlphaImage() |
|
450 |
// --------------------------------------------------------------------------- |
|
451 |
// |
|
452 |
void DrawImage(VGImage aImage, |
|
453 |
const TPoint& aPos, const TRect& aWindowRect, TBool aCentered, TBool aLandscape) |
|
454 |
{ |
|
455 |
||
456 |
vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); |
|
457 |
vgLoadIdentity(); |
|
458 |
if (aLandscape) |
|
459 |
{ |
|
460 |
vgTranslate(0.0f, 640.0f); |
|
461 |
vgRotate(-90.0f); |
|
462 |
} |
|
463 |
||
464 |
if (!aCentered) |
|
465 |
{ |
|
466 |
vgScale(1, -1); |
|
467 |
vgTranslate(aPos.iX, -(aWindowRect.Height() - aPos.iY)); |
|
468 |
} |
|
469 |
else |
|
470 |
{ |
|
471 |
VGint w = vgGetParameteri(aImage, VG_IMAGE_WIDTH); |
|
472 |
VGint h = vgGetParameteri(aImage, VG_IMAGE_HEIGHT); |
|
473 |
vgTranslate(aPos.iX, (aWindowRect.Height() - aPos.iY)); |
|
474 |
vgScale(1, -1); |
|
475 |
vgTranslate(-(VGfloat)w/2,-(VGfloat)h/2); |
|
476 |
} |
|
477 |
||
478 |
vgDrawImage(aImage); |
|
479 |
||
480 |
} |
|
481 |
||
482 |
// --------------------------------------------------------------------------- |
|
483 |
// HgVgHelper::DrawImageColorized |
|
484 |
// --------------------------------------------------------------------------- |
|
485 |
// |
|
486 |
void DrawImageColorized(VGImage aImage, const TRgb& aColor, |
|
487 |
const TPoint& aPos, const TRect& aWindowRect, TBool aCentered, TBool aLandscape) |
|
488 |
{ |
|
489 |
||
490 |
VGfloat values[] = { 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 }; |
|
491 |
||
492 |
values[0] = (VGfloat)aColor.Red() / KColorByteToFloatFactor; |
|
493 |
values[1] = (VGfloat)aColor.Green() / KColorByteToFloatFactor; |
|
494 |
values[2] = (VGfloat)aColor.Blue() / KColorByteToFloatFactor; |
|
495 |
values[3] = (VGfloat)aColor.Alpha() / KColorByteToFloatFactor; |
|
496 |
||
497 |
vgSetfv(VG_COLOR_TRANSFORM_VALUES, KNumColorTransformValues, values); |
|
498 |
vgSeti(VG_COLOR_TRANSFORM, VG_TRUE); |
|
499 |
||
500 |
HgVgHelper::DrawImage(aImage, aPos, aWindowRect, aCentered, aLandscape); |
|
501 |
||
502 |
vgSeti(VG_COLOR_TRANSFORM, VG_FALSE); |
|
503 |
} |
|
504 |
||
505 |
||
506 |
||
507 |
// --------------------------------------------------------------------------- |
|
508 |
// HgVgHelper::CreatePath() |
|
509 |
// --------------------------------------------------------------------------- |
|
510 |
// |
|
511 |
VGPath CreatePath(VGuint aNumSegments, const VGubyte* aSegments, const VGfloat* aPoints) |
|
512 |
{ |
|
513 |
VGPath path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, |
|
514 |
1.0f, 0.0f, 4, 4, (unsigned int)VG_PATH_CAPABILITY_ALL); |
|
515 |
||
516 |
vgAppendPathData(path, aNumSegments, aSegments, aPoints); |
|
517 |
||
518 |
return path; |
|
519 |
} |
|
520 |
||
521 |
// --------------------------------------------------------------------------- |
|
522 |
// HgVgHelper::CreateColorPaint() |
|
523 |
// --------------------------------------------------------------------------- |
|
524 |
// |
|
525 |
VGPaint CreateColorPaint(const VGfloat* aColor) |
|
526 |
{ |
|
527 |
VGPaint paint = vgCreatePaint(); |
|
528 |
||
529 |
vgSetParameteri(paint, VG_PAINT_TYPE, |
|
530 |
VG_PAINT_TYPE_COLOR); |
|
531 |
||
532 |
vgSetParameterfv(paint, VG_PAINT_COLOR, |
|
533 |
KNumColorValues, aColor); |
|
534 |
||
535 |
return paint; |
|
536 |
} |
|
537 |
||
538 |
// --------------------------------------------------------------------------- |
|
539 |
// HgVgHelper::CreateColorPaint() |
|
540 |
// --------------------------------------------------------------------------- |
|
541 |
// |
|
542 |
VGPaint CreateColorPaint(const TRgb& aColor) |
|
543 |
{ |
|
544 |
VGfloat values[4]; |
|
545 |
||
546 |
values[0] = (VGfloat)aColor.Red() / KColorByteToFloatFactor; |
|
547 |
values[1] = (VGfloat)aColor.Green() / KColorByteToFloatFactor; |
|
548 |
values[2] = (VGfloat)aColor.Blue() / KColorByteToFloatFactor; |
|
549 |
values[3] = (VGfloat)aColor.Alpha() / KColorByteToFloatFactor; |
|
550 |
||
551 |
return CreateColorPaint(values); |
|
552 |
} |
|
553 |
||
554 |
} |
|
555 |
||
556 |
// End of File |