46
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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: NVG Decoder source file
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "NVGCSIcon.h"
|
|
19 |
#include "NVGIconData.h"
|
|
20 |
#include "nvgfittoviewbox.h"
|
|
21 |
#include "nvg.h"
|
|
22 |
#include "NVGUtil.h"
|
|
23 |
#include "OpenVGHandleStore.h"
|
|
24 |
|
|
25 |
#include <string.h>
|
|
26 |
#include <e32math.h>
|
|
27 |
|
|
28 |
|
|
29 |
CNVGCSIcon::CNVGCSIcon()
|
|
30 |
: iNVGIconData(0),
|
|
31 |
iPath(VG_INVALID_HANDLE),
|
|
32 |
iFillPaint(VG_INVALID_HANDLE),
|
|
33 |
iStrokePaint(VG_INVALID_HANDLE),
|
|
34 |
iLastFillPaintType(0),
|
|
35 |
iLastStrokePaintType(0),
|
|
36 |
iLastFillPaintColor(0),
|
|
37 |
iLastStrkePaintColor(0),
|
|
38 |
iResetFillPaint(0),
|
|
39 |
iResetStrokePaint(0)
|
|
40 |
{
|
|
41 |
}
|
|
42 |
|
|
43 |
CNVGCSIcon::~CNVGCSIcon()
|
|
44 |
{
|
|
45 |
vgSetPaint(VG_INVALID_HANDLE, VG_FILL_PATH);
|
|
46 |
vgSetPaint(VG_INVALID_HANDLE, VG_STROKE_PATH);
|
|
47 |
|
|
48 |
delete iNVGIconData;
|
|
49 |
delete iOpenVGHandles;
|
|
50 |
}
|
|
51 |
|
|
52 |
CNVGCSIcon * CNVGCSIcon::NewL(const TDesC8& aBuf)
|
|
53 |
{
|
|
54 |
CNVGCSIcon* self = CNVGCSIcon::NewLC(aBuf);
|
|
55 |
|
|
56 |
CleanupStack::Pop(self);
|
|
57 |
return self;
|
|
58 |
}
|
|
59 |
|
|
60 |
CNVGCSIcon * CNVGCSIcon::NewLC(const TDesC8& aBuf)
|
|
61 |
{
|
|
62 |
CNVGCSIcon* self = new (ELeave) CNVGCSIcon;
|
|
63 |
CleanupStack::PushL(self);
|
|
64 |
|
|
65 |
self->ConstructL(aBuf);
|
|
66 |
|
|
67 |
return self;
|
|
68 |
}
|
|
69 |
|
|
70 |
void CNVGCSIcon::ConstructL(const TDesC8& aBuf)
|
|
71 |
{
|
|
72 |
iNVGIconData = CNVGIconData::NewL(aBuf.Length());
|
|
73 |
iOpenVGHandles = COpenVGHandleStore::NewL();
|
|
74 |
|
|
75 |
if (iPath == VG_INVALID_HANDLE)
|
|
76 |
{
|
|
77 |
iPath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
|
|
78 |
VG_PATH_DATATYPE_S_32, 1.0f/65536.0f, 0.0f, 0, 0,
|
|
79 |
VG_PATH_CAPABILITY_APPEND_TO);
|
|
80 |
iOpenVGHandles->AddPathDHL(iPath);
|
|
81 |
}
|
|
82 |
|
|
83 |
if (iFillPaint == VG_INVALID_HANDLE)
|
|
84 |
{
|
|
85 |
iFillPaint = vgCreatePaint();
|
|
86 |
iOpenVGHandles->AddPaintDHL(iFillPaint);
|
|
87 |
}
|
|
88 |
vgSetPaint(iFillPaint, VG_FILL_PATH);
|
|
89 |
|
|
90 |
if (iStrokePaint == VG_INVALID_HANDLE)
|
|
91 |
{
|
|
92 |
iStrokePaint = vgCreatePaint();
|
|
93 |
iOpenVGHandles->AddPaintDHL(iStrokePaint);
|
|
94 |
}
|
|
95 |
vgSetPaint(iStrokePaint, VG_STROKE_PATH);
|
|
96 |
}
|
|
97 |
|
|
98 |
TInt CNVGCSIcon::SetViewBox(TReal32 x, TReal32 y, TReal32 w, TReal32 h) __SOFTFP
|
|
99 |
{
|
|
100 |
iViewBoxX = x;
|
|
101 |
iViewBoxY = y;
|
|
102 |
iViewBoxW = w;
|
|
103 |
iViewBoxH = h;
|
|
104 |
|
|
105 |
return KErrNone;
|
|
106 |
}
|
|
107 |
|
|
108 |
TInt CNVGCSIcon::SetPreserveAspectRatio(TInt aPreserveAspectSetting,
|
|
109 |
TInt aSmilFitSetting)
|
|
110 |
{
|
|
111 |
iPreserveAspectSetting = aPreserveAspectSetting;
|
|
112 |
iSmilFitSetting = aSmilFitSetting;
|
|
113 |
|
|
114 |
return KErrNone;
|
|
115 |
}
|
|
116 |
|
|
117 |
TInt CNVGCSIcon::Rotate(TReal32 aAngle, TReal32 aX, TReal32 aY) __SOFTFP
|
|
118 |
{
|
|
119 |
iRotationAngle = aAngle;
|
|
120 |
iRotationX = aX;
|
|
121 |
iRotationY = aY;
|
|
122 |
|
|
123 |
return KErrNone;
|
|
124 |
}
|
|
125 |
|
|
126 |
void CNVGCSIcon::AddPathDataL(VGint numSegments, const VGubyte * pathSegments, const void * pathData)
|
|
127 |
{
|
|
128 |
iNVGIconData->EncodeInt32L(EPathData);
|
|
129 |
iNVGIconData->EncodeInt32L(numSegments);
|
|
130 |
iNVGIconData->EncodeDataL(pathSegments, numSegments);
|
|
131 |
|
|
132 |
TInt coordinateCount = 0;
|
|
133 |
for (TInt i = 0; i < numSegments; ++i)
|
|
134 |
{
|
|
135 |
switch (pathSegments[i])
|
|
136 |
{
|
|
137 |
case VG_HLINE_TO:
|
|
138 |
case VG_VLINE_TO:
|
|
139 |
coordinateCount += 1;
|
|
140 |
break;
|
|
141 |
case VG_MOVE_TO:
|
|
142 |
case VG_LINE_TO:
|
|
143 |
case VG_SQUAD_TO:
|
|
144 |
coordinateCount += 2;
|
|
145 |
break;
|
|
146 |
case VG_QUAD_TO:
|
|
147 |
case VG_SCUBIC_TO:
|
|
148 |
coordinateCount += 4;
|
|
149 |
break;
|
|
150 |
case VG_SCCWARC_TO:
|
|
151 |
case VG_SCWARC_TO:
|
|
152 |
case VG_LCCWARC_TO:
|
|
153 |
case VG_LCWARC_TO:
|
|
154 |
coordinateCount += 5;
|
|
155 |
break;
|
|
156 |
case VG_CUBIC_TO:
|
|
157 |
coordinateCount += 6;
|
|
158 |
break;
|
|
159 |
default:
|
|
160 |
break;
|
|
161 |
}
|
|
162 |
}
|
|
163 |
iNVGIconData->EncodeInt16L(coordinateCount);
|
|
164 |
iNVGIconData->EncodeDataL(pathData, coordinateCount * 4);
|
|
165 |
}
|
|
166 |
|
|
167 |
void CNVGCSIcon::AddDrawPathCommandL(VGPath aPath, VGbitfield aPaintMode)
|
|
168 |
{
|
|
169 |
iOpenVGHandles->AddPathDHL(aPath);
|
|
170 |
iNVGIconData->EncodeInt32L(EPath);
|
|
171 |
iNVGIconData->EncodeInt32L(aPath);
|
|
172 |
iNVGIconData->EncodeInt32L(aPaintMode);
|
|
173 |
}
|
|
174 |
|
|
175 |
void CNVGCSIcon::AddLinearGradientCommandL(VGint aCount, VGfloat* aGradientData, VGfloat* aGradientMatrix, VGPaint aPaint)
|
|
176 |
{
|
|
177 |
iOpenVGHandles->AddPaintDHL(aPaint);
|
|
178 |
iNVGIconData->EncodeInt32L(EPaint);
|
|
179 |
AddLinearGradientCommandDataL(aPaint, aCount, aGradientData, aGradientMatrix);
|
|
180 |
}
|
|
181 |
|
|
182 |
void CNVGCSIcon::AddRadialGradientCommandL(VGint aCount, VGfloat* aGradientData, VGfloat* aGradientMatrix, VGPaint aPaint)
|
|
183 |
{
|
|
184 |
iOpenVGHandles->AddPaintDHL(aPaint);
|
|
185 |
iNVGIconData->EncodeInt32L(EPaint);
|
|
186 |
AddRadialGradientCommandDataL(aPaint, aCount, aGradientData, aGradientMatrix);
|
|
187 |
}
|
|
188 |
|
|
189 |
void CNVGCSIcon::AddSetColorCommandL(VGuint aRgba)
|
|
190 |
{
|
|
191 |
iNVGIconData->EncodeInt32L(EPaint);
|
|
192 |
iNVGIconData->EncodeInt32L(VG_PAINT_TYPE_COLOR);
|
|
193 |
iNVGIconData->EncodeInt32L(aRgba);
|
|
194 |
}
|
|
195 |
|
|
196 |
void CNVGCSIcon::AddColorRampCommandL(VGPaint aPaint)
|
|
197 |
{
|
|
198 |
iNVGIconData->EncodeInt32L(EColorRamp);
|
|
199 |
iNVGIconData->EncodeInt32L(aPaint);
|
|
200 |
}
|
|
201 |
|
|
202 |
void CNVGCSIcon::AddSetTransformCommandL(const VGfloat* aTransformMatrix, TInt aFlag)
|
|
203 |
{
|
|
204 |
iNVGIconData->EncodeInt32L(ETransform);
|
|
205 |
iNVGIconData->EncodeDataL(aTransformMatrix, 9 * sizeof(VGfloat));
|
|
206 |
iNVGIconData->EncodeInt32L(aFlag);
|
|
207 |
}
|
|
208 |
|
|
209 |
void CNVGCSIcon::AddSetStrokeWidthCommandL(VGfloat aStrokeWidth)
|
|
210 |
{
|
|
211 |
iNVGIconData->EncodeInt32L(EStrokeWidth);
|
|
212 |
iNVGIconData->EncodeReal32L(aStrokeWidth);
|
|
213 |
}
|
|
214 |
|
|
215 |
void CNVGCSIcon::AddSetStrokeMiterLimitCommandL(VGfloat aMiterLimit)
|
|
216 |
{
|
|
217 |
iNVGIconData->EncodeInt32L(EStrokeMiterLimit);
|
|
218 |
iNVGIconData->EncodeReal32L(aMiterLimit);
|
|
219 |
}
|
|
220 |
|
|
221 |
void CNVGCSIcon::AddStrokeLineJoinCapCommandL(VGint aCapStyle, VGint aJoinStyle)
|
|
222 |
{
|
|
223 |
iNVGIconData->EncodeInt32L(EStrokeLineJoinCap);
|
|
224 |
iNVGIconData->EncodeInt32L(aCapStyle);
|
|
225 |
iNVGIconData->EncodeInt32L(aJoinStyle);
|
|
226 |
}
|
|
227 |
|
|
228 |
void CNVGCSIcon::AddStrokeLinearGradientCommandL(VGint aCount, VGfloat* aGradientData, VGfloat* aGradientMatrix, VGPaint aPaint)
|
|
229 |
{
|
|
230 |
iOpenVGHandles->AddPaintDHL(aPaint);
|
|
231 |
iNVGIconData->EncodeInt32L(EStrokePaint);
|
|
232 |
AddLinearGradientCommandDataL(aPaint, aCount, aGradientData, aGradientMatrix);
|
|
233 |
}
|
|
234 |
|
|
235 |
void CNVGCSIcon::AddStrokeRadialGradientCommandL(VGint aCount, VGfloat* aGradientData, VGfloat* aGradientMatrix, VGPaint aPaint)
|
|
236 |
{
|
|
237 |
iOpenVGHandles->AddPaintDHL(aPaint);
|
|
238 |
iNVGIconData->EncodeInt32L(EStrokePaint);
|
|
239 |
AddRadialGradientCommandDataL(aPaint, aCount, aGradientData, aGradientMatrix);
|
|
240 |
}
|
|
241 |
|
|
242 |
void CNVGCSIcon::AddStrokeSetColorCommandL(VGuint aRgba)
|
|
243 |
{
|
|
244 |
iNVGIconData->EncodeInt32L(EStrokePaint);
|
|
245 |
AddSetColorCommandDataL(aRgba);
|
|
246 |
}
|
|
247 |
|
|
248 |
void CNVGCSIcon::AddStrokeColorRampCommandL(VGPaint aPaint)
|
|
249 |
{
|
|
250 |
iNVGIconData->EncodeInt32L(EStrokeColorRamp);
|
|
251 |
iNVGIconData->EncodeInt32L(aPaint);
|
|
252 |
}
|
|
253 |
|
|
254 |
void CNVGCSIcon::AddLinearGradientCommandDataL(VGPaint aPaint, VGint aCount, VGfloat* aGradientData, VGfloat* aGradientMatrix)
|
|
255 |
{
|
|
256 |
iNVGIconData->EncodeInt32L(VG_PAINT_TYPE_LINEAR_GRADIENT);
|
|
257 |
iNVGIconData->EncodeInt32L(aPaint);
|
|
258 |
iNVGIconData->EncodeInt32L(aCount);
|
|
259 |
iNVGIconData->EncodeDataL(aGradientData, aCount * sizeof(VGfloat));
|
|
260 |
iNVGIconData->EncodeDataL(aGradientMatrix, 9 * sizeof(VGfloat));
|
|
261 |
}
|
|
262 |
|
|
263 |
void CNVGCSIcon::AddRadialGradientCommandDataL(VGPaint aPaint, VGint aCount, VGfloat* aGradientData, VGfloat* aGradientMatrix)
|
|
264 |
{
|
|
265 |
iNVGIconData->EncodeInt32L(VG_PAINT_TYPE_RADIAL_GRADIENT);
|
|
266 |
iNVGIconData->EncodeInt32L(aPaint);
|
|
267 |
iNVGIconData->EncodeInt32L(aCount);
|
|
268 |
iNVGIconData->EncodeDataL(aGradientData, aCount * sizeof(VGfloat));
|
|
269 |
iNVGIconData->EncodeDataL(aGradientMatrix, 9 * sizeof(VGfloat));
|
|
270 |
}
|
|
271 |
|
|
272 |
void CNVGCSIcon::AddSetColorCommandDataL(VGuint aRgba)
|
|
273 |
{
|
|
274 |
iNVGIconData->EncodeInt32L(VG_PAINT_TYPE_COLOR);
|
|
275 |
iNVGIconData->EncodeInt32L(aRgba);
|
|
276 |
}
|
|
277 |
|
|
278 |
TInt CNVGCSIcon::Draw(const TSize aSize, CNvgEngine * aNVGEngine)
|
|
279 |
{
|
|
280 |
NVG_DEBUGP2("DRAWING NVGCSIcon %s, ", __FUNCTION__);
|
|
281 |
|
|
282 |
TInt error = KErrNone;
|
|
283 |
|
|
284 |
iNVGEngine = aNVGEngine;
|
|
285 |
|
|
286 |
// Get Matrix modes and all caller matrices (must be restored afterwards)
|
|
287 |
UpdateClientMatrices();
|
|
288 |
|
|
289 |
TRAP(error, DoDrawL(aSize));
|
|
290 |
|
|
291 |
// restore everything as we may have changed matrix mode
|
|
292 |
RestoreClientMatrices();
|
|
293 |
|
|
294 |
return error;
|
|
295 |
}
|
|
296 |
|
|
297 |
TInt CNVGCSIcon::DoDrawL(const TSize aSize)
|
|
298 |
{
|
|
299 |
TInt ret = KErrNone;
|
|
300 |
|
|
301 |
vgSetPaint(iFillPaint, VG_FILL_PATH);
|
|
302 |
vgSetPaint(iStrokePaint, VG_STROKE_PATH);
|
|
303 |
iLastFillPaintColor = 0;
|
|
304 |
iLastStrkePaintColor = 0;
|
|
305 |
iLastFillPaintType = 0;
|
|
306 |
iLastStrokePaintType = 0;
|
|
307 |
|
|
308 |
VGfloat lCurrentPathMatrix[9];
|
|
309 |
vgGetMatrix(lCurrentPathMatrix);
|
|
310 |
|
|
311 |
vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
|
|
312 |
vgLoadMatrix(lCurrentPathMatrix);
|
|
313 |
SetRotation();
|
|
314 |
#ifdef __MIRROR_
|
|
315 |
vgScale(1.0f, -1.0f);
|
|
316 |
vgTranslate(0, (VGfloat)(-aSize.iHeight) );
|
|
317 |
#endif
|
|
318 |
|
|
319 |
SetViewBoxToViewTransformationL(aSize);
|
|
320 |
|
|
321 |
|
|
322 |
vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
|
|
323 |
|
|
324 |
VGfloat currentMatrix[9];
|
|
325 |
|
|
326 |
vgGetMatrix(currentMatrix);
|
|
327 |
|
|
328 |
iNVGIconData->BeginRead();
|
|
329 |
|
|
330 |
while (!iNVGIconData->EOF())
|
|
331 |
{
|
|
332 |
switch (iNVGIconData->ReadInt32L())
|
|
333 |
{
|
|
334 |
case EPath:
|
|
335 |
{
|
|
336 |
VGPath path = (VGPath)iNVGIconData->ReadInt32L();
|
|
337 |
VGPaintMode paintMode = (VGPaintMode)iNVGIconData->ReadInt32L();
|
|
338 |
|
|
339 |
if (path == VG_INVALID_HANDLE)
|
|
340 |
{
|
|
341 |
vgDrawPath(iPath, paintMode);
|
|
342 |
}
|
|
343 |
else
|
|
344 |
{
|
|
345 |
vgDrawPath(path, paintMode);
|
|
346 |
}
|
|
347 |
|
|
348 |
break;
|
|
349 |
}
|
|
350 |
case EPathData:
|
|
351 |
{
|
|
352 |
if (iPath != VG_INVALID_HANDLE)
|
|
353 |
{
|
|
354 |
VGint numSegments;
|
|
355 |
VGubyte * pathSegments = 0;
|
|
356 |
VGubyte * pathData = 0;
|
|
357 |
|
|
358 |
numSegments = iNVGIconData->ReadInt32L();
|
|
359 |
pathSegments = new (ELeave) VGubyte[numSegments];
|
|
360 |
CleanupStack::PushL(TCleanupItem(CleanupArray, pathSegments));
|
|
361 |
if (pathSegments)
|
|
362 |
{
|
|
363 |
iNVGIconData->ReadL(pathSegments, numSegments);
|
|
364 |
VGint coordinateCount = iNVGIconData->ReadInt32L();
|
|
365 |
pathData = new (ELeave) VGubyte[coordinateCount * 4];
|
|
366 |
if (pathData)
|
|
367 |
{
|
|
368 |
CleanupStack::PushL(TCleanupItem(CleanupArray, pathData));
|
|
369 |
iNVGIconData->ReadL(pathData, coordinateCount * 4);
|
|
370 |
vgClearPath(iPath, VG_PATH_CAPABILITY_APPEND_TO);
|
|
371 |
vgAppendPathData(iPath, numSegments, pathSegments, pathData);
|
|
372 |
CleanupStack::PopAndDestroy();
|
|
373 |
}
|
|
374 |
}
|
|
375 |
CleanupStack::PopAndDestroy();
|
|
376 |
}
|
|
377 |
break;
|
|
378 |
}
|
|
379 |
case EPaint:
|
|
380 |
{
|
|
381 |
DrawPaintL(iFillPaint, VG_MATRIX_FILL_PAINT_TO_USER, iLastFillPaintType, iLastFillPaintColor, VG_FILL_PATH);
|
|
382 |
break;
|
|
383 |
}
|
|
384 |
case EColorRamp:
|
|
385 |
{
|
|
386 |
iNVGIconData->ReadInt32L();
|
|
387 |
break;
|
|
388 |
}
|
|
389 |
case ETransform:
|
|
390 |
{
|
|
391 |
TInt flag;
|
|
392 |
VGfloat transformMatrix[9];
|
|
393 |
|
|
394 |
TPtr8 tmPtr((TUint8 *)transformMatrix, 9 * sizeof(VGfloat));
|
|
395 |
|
|
396 |
iNVGIconData->ReadL(tmPtr, 9 * sizeof(VGfloat));
|
|
397 |
flag = iNVGIconData->ReadInt32L();
|
|
398 |
|
|
399 |
vgLoadMatrix(currentMatrix);
|
|
400 |
if (flag)
|
|
401 |
{
|
|
402 |
vgMultMatrix(transformMatrix);
|
|
403 |
}
|
|
404 |
}
|
|
405 |
break;
|
|
406 |
case EStrokeWidth:
|
|
407 |
{
|
|
408 |
VGfloat strokeWidth = iNVGIconData->ReadReal32L();
|
|
409 |
vgSetf(VG_STROKE_LINE_WIDTH, strokeWidth);
|
|
410 |
break;
|
|
411 |
}
|
|
412 |
case EStrokeMiterLimit:
|
|
413 |
{
|
|
414 |
VGfloat miterLimit = iNVGIconData->ReadReal32L();
|
|
415 |
vgSetf(VG_STROKE_MITER_LIMIT, miterLimit);
|
|
416 |
break;
|
|
417 |
}
|
|
418 |
case EStrokeLineJoinCap:
|
|
419 |
{
|
|
420 |
VGint lineJoin = iNVGIconData->ReadInt32L();
|
|
421 |
VGint cap = iNVGIconData->ReadInt32L();
|
|
422 |
|
|
423 |
vgSeti(VG_STROKE_JOIN_STYLE, (VGJoinStyle)lineJoin);
|
|
424 |
vgSeti(VG_STROKE_CAP_STYLE, (VGCapStyle)cap);
|
|
425 |
break;
|
|
426 |
}
|
|
427 |
case EStrokePaint:
|
|
428 |
{
|
|
429 |
DrawPaintL(iStrokePaint, VG_MATRIX_STROKE_PAINT_TO_USER, iLastStrokePaintType, iLastStrkePaintColor, VG_STROKE_PATH);
|
|
430 |
break;
|
|
431 |
}
|
|
432 |
case EStrokeColorRamp:
|
|
433 |
{
|
|
434 |
iNVGIconData->ReadInt32L();
|
|
435 |
break;
|
|
436 |
}
|
|
437 |
default:
|
|
438 |
{
|
|
439 |
User::Leave(KErrCorrupt);
|
|
440 |
break;
|
|
441 |
}
|
|
442 |
}
|
|
443 |
}
|
|
444 |
|
|
445 |
iNVGIconData->EndRead();
|
|
446 |
|
|
447 |
return ret;
|
|
448 |
}
|
|
449 |
|
|
450 |
void CNVGCSIcon::DrawColorRampL(VGPaint aPaint)
|
|
451 |
{
|
|
452 |
TInt stopCount = iNVGIconData->ReadInt32L();
|
|
453 |
VGfloat * colorRamps = new (ELeave) VGfloat[stopCount];
|
|
454 |
CleanupStack::PushL(TCleanupItem(CleanupArray, colorRamps));
|
|
455 |
|
|
456 |
iNVGIconData->ReadL((TUint8 *)colorRamps, stopCount * sizeof(VGfloat));
|
|
457 |
vgSetParameteri(aPaint, VG_PAINT_COLOR_RAMP_SPREAD_MODE, VG_COLOR_RAMP_SPREAD_PAD);
|
|
458 |
vgSetParameterfv(aPaint, VG_PAINT_COLOR_RAMP_STOPS, stopCount, colorRamps);
|
|
459 |
|
|
460 |
CleanupStack::PopAndDestroy();
|
|
461 |
}
|
|
462 |
|
|
463 |
void CNVGCSIcon::DrawPaintL(VGPaint aPaint, VGMatrixMode aMatrixMode, TUint & aLastPaintType, TUint & aLastPaintColor, VGPaintMode aPaintMode)
|
|
464 |
{
|
|
465 |
VGPaintType paintType = (VGPaintType)iNVGIconData->ReadInt32L();
|
|
466 |
|
|
467 |
if (paintType == VG_PAINT_TYPE_LINEAR_GRADIENT ||
|
|
468 |
paintType == VG_PAINT_TYPE_RADIAL_GRADIENT)
|
|
469 |
{
|
|
470 |
VGPaintParamType paintPType = VG_PAINT_LINEAR_GRADIENT;
|
|
471 |
if (paintType == VG_PAINT_TYPE_RADIAL_GRADIENT)
|
|
472 |
{
|
|
473 |
paintPType = VG_PAINT_RADIAL_GRADIENT;
|
|
474 |
}
|
|
475 |
|
|
476 |
VGPaint paintHandle = iNVGIconData->ReadInt32L();
|
|
477 |
TInt count = iNVGIconData->ReadInt32L();
|
|
478 |
VGfloat gradientData[5];
|
|
479 |
VGfloat gradientMatrix[9];
|
|
480 |
|
|
481 |
iNVGIconData->ReadL((TUint8 *)gradientData, count * sizeof(VGfloat));
|
|
482 |
iNVGIconData->ReadL((TUint8 *)gradientMatrix, 9 * sizeof(VGfloat));
|
|
483 |
|
|
484 |
if (paintHandle)
|
|
485 |
{
|
|
486 |
vgSetPaint(paintHandle, aPaintMode);
|
|
487 |
vgSeti(VG_MATRIX_MODE, aMatrixMode);
|
|
488 |
vgLoadMatrix(gradientMatrix);
|
|
489 |
if (aPaintMode == VG_FILL_PATH)
|
|
490 |
{
|
|
491 |
iResetFillPaint = 1;
|
|
492 |
}
|
|
493 |
else
|
|
494 |
{
|
|
495 |
iResetStrokePaint = 1;
|
|
496 |
}
|
|
497 |
}
|
|
498 |
else
|
|
499 |
{
|
|
500 |
if (aLastPaintType != paintType)
|
|
501 |
{
|
|
502 |
vgSetParameteri(aPaint, VG_PAINT_TYPE, paintType);
|
|
503 |
}
|
|
504 |
vgSetParameterfv(aPaint, paintPType, count, gradientData);
|
|
505 |
|
|
506 |
vgSeti(VG_MATRIX_MODE, aMatrixMode);
|
|
507 |
vgLoadMatrix(gradientMatrix);
|
|
508 |
}
|
|
509 |
vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
|
|
510 |
}
|
|
511 |
else if (paintType == VG_PAINT_TYPE_COLOR)
|
|
512 |
{
|
|
513 |
if (aPaintMode == VG_FILL_PATH && iResetFillPaint)
|
|
514 |
{
|
|
515 |
iResetFillPaint = 0;
|
|
516 |
vgSetPaint(aPaint, aPaintMode);
|
|
517 |
}
|
|
518 |
else if (aPaintMode == VG_STROKE_PATH && iResetStrokePaint)
|
|
519 |
{
|
|
520 |
iResetStrokePaint = 0;
|
|
521 |
vgSetPaint(aPaint, aPaintMode);
|
|
522 |
}
|
|
523 |
TUint color = static_cast<TUint>(iNVGIconData->ReadInt32L());
|
|
524 |
if (aLastPaintType != paintType)
|
|
525 |
{
|
|
526 |
vgSetParameteri(aPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
|
|
527 |
vgSetColor(aPaint, color);
|
|
528 |
}
|
|
529 |
else
|
|
530 |
{
|
|
531 |
if (aLastPaintColor != color)
|
|
532 |
{
|
|
533 |
vgSetColor(aPaint, color);
|
|
534 |
}
|
|
535 |
}
|
|
536 |
aLastPaintColor = color;
|
|
537 |
}
|
|
538 |
else
|
|
539 |
{
|
|
540 |
User::Leave(KErrCorrupt);
|
|
541 |
}
|
|
542 |
aLastPaintType = paintType;
|
|
543 |
}
|
|
544 |
|
|
545 |
void CNVGCSIcon::SetViewBoxToViewTransformationL(const TSize aSize)
|
|
546 |
{
|
|
547 |
CNvgFitToViewBoxImpl * fitToViewBoxImpl = CNvgFitToViewBoxImpl::NewLC();
|
|
548 |
|
|
549 |
fitToViewBoxImpl->SetAlign((TNvgAlignStatusType)iPreserveAspectSetting);
|
|
550 |
fitToViewBoxImpl->SetScaling((TNvgMeetOrSliceType)iSmilFitSetting);
|
|
551 |
|
|
552 |
fitToViewBoxImpl->SetViewBox(iViewBoxX, iViewBoxY, iViewBoxW, iViewBoxH);
|
|
553 |
|
|
554 |
fitToViewBoxImpl->SetWindowViewportTrans(TRect(0, 0, aSize.iWidth, aSize.iHeight), TSize(0, 0));
|
|
555 |
|
|
556 |
CleanupStack::PopAndDestroy(fitToViewBoxImpl);
|
|
557 |
}
|
|
558 |
|
|
559 |
void CNVGCSIcon::SetRotation()
|
|
560 |
{
|
|
561 |
if (iRotationAngle)
|
|
562 |
{
|
|
563 |
vgTranslate(iRotationX, iRotationY);
|
|
564 |
|
|
565 |
vgRotate(iRotationAngle);
|
|
566 |
|
|
567 |
vgTranslate(-iRotationX, -iRotationY);
|
|
568 |
}
|
|
569 |
}
|
|
570 |
|
|
571 |
void CNVGCSIcon::UpdateClientMatrices()
|
|
572 |
{
|
|
573 |
iMatrixMode = vgGeti(VG_MATRIX_MODE);
|
|
574 |
vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
|
|
575 |
vgGetMatrix(iPathMatrix);
|
|
576 |
vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
|
|
577 |
vgGetMatrix(iImageMatrix);
|
|
578 |
vgSeti(VG_MATRIX_MODE, iMatrixMode);
|
|
579 |
}
|
|
580 |
|
|
581 |
void CNVGCSIcon::RestoreClientMatrices()
|
|
582 |
{
|
|
583 |
vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
|
|
584 |
vgLoadMatrix(iPathMatrix);
|
|
585 |
vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
|
|
586 |
vgLoadMatrix(iImageMatrix);
|
|
587 |
vgSeti(VG_MATRIX_MODE, iMatrixMode);
|
|
588 |
}
|