|
1 /* |
|
2 * Copyright (c) 2002 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: Graphics Extension Library source file |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "GfxGradientPaint.h" |
|
21 #include "GfxFloatFixPt.h" |
|
22 |
|
23 static inline void svgMatrix2x3Identity(SVGMatrix2x3* m) |
|
24 { |
|
25 TInt i, j; |
|
26 for (i=0; i<2; i++) |
|
27 for (j=0; j<3; j++) |
|
28 m->matrix[i][j] = (i == j) ? KFloatFixOne : KFloatFixZero; |
|
29 } |
|
30 |
|
31 // ========================================================================== |
|
32 // Common Constructor |
|
33 // ========================================================================== |
|
34 // -------------------------------------------------------------------------- |
|
35 // TGfxGradientPaint::TGfxGradientPaint(): iGradientUnits(KobjectBoundingBox), |
|
36 // --------------------------------------------------------------------------- |
|
37 TGfxGradientPaint::TGfxGradientPaint(): iGradientUnits(KobjectBoundingBox), |
|
38 iSpreadMethod(KspreadMethodPad) |
|
39 { |
|
40 |
|
41 svgMatrix2x3Identity(&iGradientTransform); |
|
42 |
|
43 } |
|
44 |
|
45 TGfxGradientPaint::~TGfxGradientPaint() |
|
46 { |
|
47 } |
|
48 |
|
49 // -------------------------------------------------------------------------- |
|
50 // void TGfxColor::SetFill(VGPaint aFillPaint) |
|
51 // --------------------------------------------------------------------------- |
|
52 void TGfxGradientPaint::SetFill(VGPaint aFillPaint, TGfxRectangle2D& aBBox, TFloatFixPt aOpacity,void* Renderer) |
|
53 { |
|
54 TGfxRectangle2D lBox = aBBox; |
|
55 TUint32 flatColor = GetColor(); |
|
56 TUint32 opacity = (TInt)(aOpacity * TFloatFixPt(255.0f)); |
|
57 // VGuint fillColor = ((flatColor&0x000000FF)<<24) | |
|
58 // ((flatColor&0x0000FF00)<<8) | |
|
59 // ((flatColor&0x00FF0000)>>8) | |
|
60 // opacity; |
|
61 CVGRenderer *aVgRenderer=(CVGRenderer*) Renderer; |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 aVgRenderer->vgSetParameteri( aFillPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR ); |
|
67 |
|
68 aVgRenderer->vgSetColor( aFillPaint, flatColor << 8 | opacity ); |
|
69 |
|
70 aVgRenderer->vgSetPaint( aFillPaint, VG_FILL_PATH ); |
|
71 |
|
72 } |
|
73 |
|
74 |
|
75 // ========================================================================== |
|
76 // Linear Gradient Constructor |
|
77 // ========================================================================== |
|
78 // -------------------------------------------------------------------------- |
|
79 // TGfxLinearGradientPaint::TGfxLinearGradientPaint():TGfxGradientPaint(), |
|
80 // --------------------------------------------------------------------------- |
|
81 TGfxLinearGradientPaint::TGfxLinearGradientPaint():TGfxGradientPaint(), |
|
82 iX1(0), |
|
83 iY1(0), |
|
84 iX2(1), |
|
85 iY2(0) |
|
86 { |
|
87 } |
|
88 |
|
89 // -------------------------------------------------------------------------- |
|
90 // void TGfxColor::SetFill(VGPaint aFillPaint) |
|
91 // --------------------------------------------------------------------------- |
|
92 |
|
93 void TGfxLinearGradientPaint::SetFill(VGPaint aFillPaint, TGfxRectangle2D& aBBox, TFloatFixPt aOpacity,void* aPseudo) |
|
94 { |
|
95 const TFloatFixPt KInverse255 = TFloatFixPt( 1.0f / 255.0f ); |
|
96 |
|
97 CVGRenderer *iVgRenderer=(CVGRenderer*) aPseudo; |
|
98 VGint colorRamp = VG_COLOR_RAMP_SPREAD_PAD; // default value |
|
99 VGfloat offsetVal = 0.0f; |
|
100 VGfloat rVal = 0.0f; |
|
101 VGfloat gVal = 0.0f; |
|
102 VGfloat bVal = 0.0f; |
|
103 |
|
104 VGfloat fX0 = 0.0f; |
|
105 VGfloat fY0 = 0.0f; |
|
106 VGfloat fX1 = 0.0f; |
|
107 VGfloat fY1 = 0.0f; |
|
108 |
|
109 iVgRenderer->vgSeti(VG_MATRIX_MODE, VG_MATRIX_FILL_PAINT_TO_USER); |
|
110 //vgLoadIdentity(); |
|
111 |
|
112 // need to determine the gradient units... determines how the gradient is applied. |
|
113 if(iGradientUnits==KobjectBoundingBox) |
|
114 { |
|
115 /* |
|
116 fX0 = (VGfloat)( aBBox.iX + ( aBBox.iWidth * iX1 ) ); |
|
117 fY0 = (VGfloat)( aBBox.iY + ( aBBox.iHeight* iY1 ) ); |
|
118 fX1 = (VGfloat)( aBBox.iX + ( aBBox.iWidth * iX2 ) ); |
|
119 fY1 = (VGfloat)( aBBox.iY + ( aBBox.iHeight* iY2 ) ); |
|
120 */ |
|
121 fX0 = (VGfloat)( iX1 ); |
|
122 fY0 = (VGfloat)( iY1 ); |
|
123 fX1 = (VGfloat)( iX2 ); |
|
124 fY1 = (VGfloat)( iY2 ); |
|
125 |
|
126 VGfloat gradientTrMatrix[] = |
|
127 { svgFixedToFloat(iGradientTransform.matrix[0][0]) , svgFixedToFloat(iGradientTransform.matrix[1][0]), 0, |
|
128 svgFixedToFloat(iGradientTransform.matrix[0][1]) , svgFixedToFloat(iGradientTransform.matrix[1][1]), 0, |
|
129 svgFixedToFloat(iGradientTransform.matrix[0][2]) , svgFixedToFloat(iGradientTransform.matrix[1][2]), 1 }; |
|
130 |
|
131 VGfloat boundsMatrix[] = |
|
132 { svgFixedToFloat(aBBox.iWidth.iValue) , 0, 0, |
|
133 0 , svgFixedToFloat(aBBox.iHeight.iValue), 0, |
|
134 svgFixedToFloat(aBBox.iX.iValue) , svgFixedToFloat(aBBox.iY.iValue), 1 }; |
|
135 |
|
136 iVgRenderer->vgLoadMatrix(boundsMatrix); |
|
137 iVgRenderer->vgMultMatrix(gradientTrMatrix); |
|
138 |
|
139 } |
|
140 else //KuserSpaceOnUse |
|
141 { |
|
142 fX0 = (VGfloat)iX1; |
|
143 fY0 = (VGfloat)iY1; |
|
144 fX1 = (VGfloat)iX2; |
|
145 fY1 = (VGfloat)iY2; |
|
146 VGfloat gradientMatrix[] = |
|
147 { svgFixedToFloat(iGradientTransform.matrix[0][0]) , svgFixedToFloat(iGradientTransform.matrix[1][0]), 0, |
|
148 svgFixedToFloat(iGradientTransform.matrix[0][1]) , svgFixedToFloat(iGradientTransform.matrix[1][1]), 0, |
|
149 svgFixedToFloat(iGradientTransform.matrix[0][2]) , svgFixedToFloat(iGradientTransform.matrix[1][2]), 1 }; |
|
150 |
|
151 iVgRenderer->vgLoadMatrix(gradientMatrix); |
|
152 } |
|
153 |
|
154 // format { x0, y0, x1, y1} |
|
155 VGfloat gradient[4] = { fX0, fY0, fX1, fY1 }; |
|
156 |
|
157 if (!iStopData) |
|
158 return; |
|
159 |
|
160 TInt stopCount = iStopData->Count(); |
|
161 |
|
162 |
|
163 |
|
164 //If no 'stop' elements are defined, then painting shall occur as if |
|
165 |
|
166 //none were specified as the paint style. |
|
167 |
|
168 if(0 == stopCount) |
|
169 { |
|
170 iVgRenderer->vgSetParameteri( aFillPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR ); |
|
171 VGfloat colorRGBA[] = {0.0f, 0.0f, 0.0f, 0.0f}; |
|
172 iVgRenderer->vgSetParameterfv( aFillPaint, VG_PAINT_COLOR, 4, colorRGBA); |
|
173 iVgRenderer->vgSetPaint( aFillPaint, VG_FILL_PATH ); |
|
174 return ; |
|
175 } |
|
176 // If one 'stop' is defined, then painting shall occur with the solid |
|
177 // color fill using the color defined for that gradient stop. |
|
178 else if(1 == stopCount) |
|
179 { |
|
180 VGfloat colorRGBA[4]; |
|
181 TInt col,r,g,b; |
|
182 VGfloat alpha; |
|
183 |
|
184 col = iStopData->operator[](0).iStopColor; |
|
185 alpha = (VGfloat)iStopData->operator[](0).iStopOpacity; |
|
186 r = (col & 0x00ff0000)>>16; |
|
187 g = (col & 0x0000ff00)>>8; |
|
188 b = (col & 0x000000ff); |
|
189 |
|
190 colorRGBA[0] = (VGfloat)(TFloatFixPt( r ) * KInverse255); |
|
191 colorRGBA[1] = (VGfloat)(TFloatFixPt( g ) * KInverse255); |
|
192 colorRGBA[2] = (VGfloat)(TFloatFixPt( b ) * KInverse255); |
|
193 colorRGBA[3] = alpha * (VGfloat)aOpacity; |
|
194 |
|
195 iVgRenderer->vgSetParameteri( aFillPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR ); |
|
196 iVgRenderer->vgSetParameterfv( aFillPaint, VG_PAINT_COLOR, 4, colorRGBA); |
|
197 iVgRenderer->vgSetPaint( aFillPaint, VG_FILL_PATH ); |
|
198 return ; |
|
199 } |
|
200 else if(stopCount > 0) |
|
201 { |
|
202 |
|
203 // Check if X1=X2 and Y1=Y2 , then the painting shall occur with the solid |
|
204 // color fill using the color defined in the last gradient stop. |
|
205 if( ( iX1 == iX2 ) && ( iY1 == iY2 ) && ( iGradientUnits == KuserSpaceOnUse) ) |
|
206 { |
|
207 VGfloat colorRGBA[4]; |
|
208 TInt col,r,g,b; |
|
209 VGfloat alpha; |
|
210 |
|
211 col = iStopData->operator[]( stopCount - 1 ).iStopColor; |
|
212 alpha = (VGfloat)iStopData->operator[]( stopCount - 1 ).iStopOpacity; |
|
213 r = (col & 0x00ff0000)>>16; |
|
214 g = (col & 0x0000ff00)>>8; |
|
215 b = (col & 0x000000ff); |
|
216 |
|
217 colorRGBA[0] = (VGfloat)(TFloatFixPt( r ) * KInverse255); |
|
218 colorRGBA[1] = (VGfloat)(TFloatFixPt( g ) * KInverse255); |
|
219 colorRGBA[2] = (VGfloat)(TFloatFixPt( b ) * KInverse255); |
|
220 colorRGBA[3] = alpha * (VGfloat)aOpacity; |
|
221 |
|
222 iVgRenderer->vgSetParameteri( aFillPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR ); |
|
223 iVgRenderer->vgSetParameterfv( aFillPaint, VG_PAINT_COLOR, 4, colorRGBA); |
|
224 iVgRenderer->vgSetPaint( aFillPaint, VG_FILL_PATH ); |
|
225 return ; |
|
226 } |
|
227 // Using non-ELeave version and checking for NULL to avoid (ELeave) and TRAP |
|
228 VGfloat *stops = new VGfloat [(stopCount+2)*5]; |
|
229 if ( !stops ) |
|
230 { |
|
231 return; |
|
232 } |
|
233 |
|
234 VGfloat *lclStop = stops; |
|
235 |
|
236 TInt i=0; |
|
237 |
|
238 TInt col,r,g,b; |
|
239 VGfloat alpha = 0.0f; |
|
240 TInt additionalStopsAdded = 0; |
|
241 |
|
242 if( iStopData->operator[](0).iOffset != TFloatFixPt(0) ) |
|
243 { |
|
244 //if the first stop didn't have an offset == 0 then we need to force a zero on it |
|
245 //for safety in OpenVG and VGR |
|
246 *lclStop++ = 0.0f; |
|
247 col = iStopData->operator[](0).iStopColor; |
|
248 alpha = (VGfloat)iStopData->operator[](0).iStopOpacity; |
|
249 r = (col & 0x00ff0000)>>16; |
|
250 g = (col & 0x0000ff00)>>8; |
|
251 b = (col & 0x000000ff); |
|
252 |
|
253 rVal = (VGfloat)(TFloatFixPt( r ) * KInverse255); |
|
254 *lclStop++ = rVal; |
|
255 |
|
256 gVal = (VGfloat)(TFloatFixPt( g ) * KInverse255); |
|
257 *lclStop++ = gVal; |
|
258 |
|
259 bVal = (VGfloat)(TFloatFixPt( b ) * KInverse255); |
|
260 *lclStop++ = bVal; |
|
261 |
|
262 *lclStop++ = alpha * (VGfloat)aOpacity; |
|
263 additionalStopsAdded++; |
|
264 } |
|
265 |
|
266 for( ; i < stopCount; i++) |
|
267 { |
|
268 offsetVal = (VGfloat)(iStopData->operator[](i).iOffset); |
|
269 *lclStop++ = offsetVal; |
|
270 |
|
271 col = iStopData->operator[](i).iStopColor; |
|
272 alpha = (VGfloat)iStopData->operator[](i).iStopOpacity; |
|
273 r = (col & 0x00ff0000)>>16; |
|
274 g = (col & 0x0000ff00)>>8; |
|
275 b = (col & 0x000000ff); |
|
276 |
|
277 rVal = (VGfloat)(TFloatFixPt( r ) * KInverse255); |
|
278 *lclStop++ = rVal; |
|
279 |
|
280 gVal = (VGfloat)(TFloatFixPt( g ) * KInverse255); |
|
281 *lclStop++ = gVal; |
|
282 |
|
283 bVal = (VGfloat)(TFloatFixPt( b ) * KInverse255); |
|
284 *lclStop++ = bVal; |
|
285 |
|
286 *lclStop++ = alpha * (VGfloat)aOpacity; |
|
287 } |
|
288 |
|
289 if (offsetVal != 1.0f) |
|
290 { |
|
291 //if the last stop didn't have an offset == 1 then we need to force one on it |
|
292 //for safety in OpenVG and VGR |
|
293 *lclStop++ = 1.0f; |
|
294 col = iStopData->operator[](i-1).iStopColor; |
|
295 r = (col & 0x00ff0000)>>16; |
|
296 g = (col & 0x0000ff00)>>8; |
|
297 b = (col & 0x000000ff); |
|
298 |
|
299 rVal = (VGfloat)(TFloatFixPt( r ) * KInverse255); |
|
300 *lclStop++ = rVal; |
|
301 |
|
302 gVal = (VGfloat)(TFloatFixPt( g ) * KInverse255); |
|
303 *lclStop++ = gVal; |
|
304 |
|
305 bVal = (VGfloat)(TFloatFixPt( b ) * KInverse255); |
|
306 *lclStop++ = bVal; |
|
307 |
|
308 *lclStop++ = alpha * (VGfloat)aOpacity; |
|
309 additionalStopsAdded++; |
|
310 } |
|
311 |
|
312 iVgRenderer->vgSetParameterfv( aFillPaint, VG_PAINT_COLOR_RAMP_STOPS, (stopCount+additionalStopsAdded)*5, stops ); |
|
313 delete [] stops; |
|
314 } |
|
315 |
|
316 iVgRenderer->vgSetParameteri( aFillPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_LINEAR_GRADIENT ); |
|
317 |
|
318 if(iSpreadMethod==KspreadMethodReflect) |
|
319 { |
|
320 colorRamp = VG_COLOR_RAMP_SPREAD_REFLECT; |
|
321 } |
|
322 else if(iSpreadMethod==KspreadMethodRepeat) |
|
323 { |
|
324 colorRamp = VG_COLOR_RAMP_SPREAD_REPEAT; |
|
325 } |
|
326 |
|
327 |
|
328 |
|
329 |
|
330 iVgRenderer->vgSetParameteri( aFillPaint, VG_PAINT_COLOR_RAMP_SPREAD_MODE, colorRamp ); |
|
331 iVgRenderer->vgSetParameterfv( aFillPaint, VG_PAINT_LINEAR_GRADIENT, 4, gradient); |
|
332 iVgRenderer->vgSetPaint( aFillPaint, VG_FILL_PATH ); |
|
333 } |
|
334 |
|
335 // ========================================================================== |
|
336 // Radial Gradient Constructor |
|
337 // ========================================================================== |
|
338 // -------------------------------------------------------------------------- |
|
339 // TGfxRadialGradientPaint::TGfxRadialGradientPaint():TGfxGradientPaint(), |
|
340 // --------------------------------------------------------------------------- |
|
341 TGfxRadialGradientPaint::TGfxRadialGradientPaint():TGfxGradientPaint(), |
|
342 iCx(TReal32(0.5)), |
|
343 iCy(TReal32(0.5)), |
|
344 iR(TReal32(0.5)), |
|
345 iFx( KMAXFLOATFIX ), |
|
346 iFy( KMAXFLOATFIX ) |
|
347 |
|
348 // iFx(0x7fff), |
|
349 // iFy(0x7fff) |
|
350 // iFx(1e38), |
|
351 // iFy(1e38) |
|
352 |
|
353 { |
|
354 } |
|
355 |
|
356 |
|
357 |
|
358 // -------------------------------------------------------------------------- |
|
359 // void TGfxColor::SetFill(VGPaint aFillPaint) |
|
360 // --------------------------------------------------------------------------- |
|
361 |
|
362 void TGfxRadialGradientPaint::SetFill(VGPaint aFillPaint, TGfxRectangle2D& aBBox, TFloatFixPt aOpacity,void* aPseudo) |
|
363 { |
|
364 const TFloatFixPt KInverse255 = TFloatFixPt( 1.0f / 255.0f ); |
|
365 CVGRenderer *iVgRenderer=(CVGRenderer*) aPseudo; |
|
366 VGint colorRamp = VG_COLOR_RAMP_SPREAD_PAD; // default value |
|
367 |
|
368 //TGfxRectangle2D lBox = aBBox; |
|
369 TFloatFixPt invalid(KMAXFLOATFIX); |
|
370 VGfloat offsetVal = 0.0f; |
|
371 VGfloat rVal = 0.0f; |
|
372 VGfloat gVal = 0.0f; |
|
373 VGfloat bVal = 0.0f; |
|
374 VGfloat fCx = 0.0f; |
|
375 VGfloat fCy = 0.0f; |
|
376 VGfloat fR = 0.0f; |
|
377 VGfloat fFx = 0.0f; |
|
378 VGfloat fFy = 0.0f; |
|
379 |
|
380 |
|
381 iVgRenderer->vgSeti(VG_MATRIX_MODE, VG_MATRIX_FILL_PAINT_TO_USER); |
|
382 //vgLoadIdentity(); |
|
383 |
|
384 if(iGradientUnits==KobjectBoundingBox) |
|
385 { |
|
386 fCx = (VGfloat)iCx; |
|
387 fCy = (VGfloat)iCy; |
|
388 |
|
389 fR = (VGfloat)iR; |
|
390 |
|
391 fFx = (VGfloat)iFx; |
|
392 if(iFx == invalid) |
|
393 fFx = fCx; //Fx was not set |
|
394 else |
|
395 fFx = (VGfloat)iFx; |
|
396 |
|
397 fFy = (VGfloat)iFy; |
|
398 if(iFy == invalid) |
|
399 fFy = fCy; //Fy was not set |
|
400 else |
|
401 fFy = (VGfloat)iFy; |
|
402 VGfloat gradientTrMatrix[] = |
|
403 { svgFixedToFloat(iGradientTransform.matrix[0][0]) , svgFixedToFloat(iGradientTransform.matrix[1][0]), 0, |
|
404 svgFixedToFloat(iGradientTransform.matrix[0][1]) , svgFixedToFloat(iGradientTransform.matrix[1][1]), 0, |
|
405 svgFixedToFloat(iGradientTransform.matrix[0][2]) , svgFixedToFloat(iGradientTransform.matrix[1][2]), 1 }; |
|
406 |
|
407 VGfloat boundsMatrix[] = |
|
408 { svgFixedToFloat(aBBox.iWidth.iValue) , 0, 0, |
|
409 0 , svgFixedToFloat(aBBox.iHeight.iValue), 0, |
|
410 svgFixedToFloat(aBBox.iX.iValue) , svgFixedToFloat(aBBox.iY.iValue), 1 }; |
|
411 |
|
412 iVgRenderer->vgLoadMatrix(boundsMatrix); |
|
413 iVgRenderer->vgMultMatrix(gradientTrMatrix); |
|
414 |
|
415 } |
|
416 else //if(iGradientUnits==KuserSpaceOnUse) |
|
417 { |
|
418 // values are user defined coordinates |
|
419 fCx = (VGfloat)iCx; |
|
420 fCy = (VGfloat)iCy; |
|
421 |
|
422 fR = (VGfloat)iR; |
|
423 |
|
424 fFx = (VGfloat)iFx; |
|
425 if(iFx == invalid) |
|
426 fFx = fCx; //Fx was not set |
|
427 else |
|
428 fFx = (VGfloat)iFx; |
|
429 |
|
430 fFy = (VGfloat)iFy; |
|
431 if(iFy == invalid) |
|
432 fFy = fCy; //Fy was not set |
|
433 else |
|
434 fFy = (VGfloat)iFy; |
|
435 |
|
436 VGfloat gradientMatrix[] = |
|
437 { svgFixedToFloat(iGradientTransform.matrix[0][0]) , svgFixedToFloat(iGradientTransform.matrix[1][0]), 0, |
|
438 svgFixedToFloat(iGradientTransform.matrix[0][1]) , svgFixedToFloat(iGradientTransform.matrix[1][1]), 0, |
|
439 svgFixedToFloat(iGradientTransform.matrix[0][2]) , svgFixedToFloat(iGradientTransform.matrix[1][2]), 1 }; |
|
440 iVgRenderer->vgLoadMatrix(gradientMatrix); |
|
441 } |
|
442 |
|
443 // format { cx, cy, fx, fy, r} |
|
444 VGfloat gradient[5] = { fCx, fCy, fFx, fFy, fR}; |
|
445 |
|
446 if (!iStopData) |
|
447 return; |
|
448 |
|
449 |
|
450 |
|
451 |
|
452 TInt stopCount = iStopData->Count(); |
|
453 |
|
454 //If no 'stop' elements are defined, then painting shall occur as if |
|
455 //none were specified as the paint style. |
|
456 if(0 == stopCount) |
|
457 { |
|
458 iVgRenderer->vgSetParameteri( aFillPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR ); |
|
459 VGfloat colorRGBA[] = {0.0f, 0.0f, 0.0f, 0.0f}; |
|
460 iVgRenderer->vgSetParameterfv( aFillPaint, VG_PAINT_COLOR, 4, colorRGBA); |
|
461 iVgRenderer->vgSetPaint( aFillPaint, VG_FILL_PATH ); |
|
462 return ; |
|
463 } |
|
464 // If one 'stop' is defined, then painting shall occur with the solid |
|
465 // color fill using the color defined for that gradient stop. |
|
466 else if(1 == stopCount) |
|
467 { |
|
468 VGfloat colorRGBA[4]; |
|
469 TInt col,r,g,b; |
|
470 VGfloat alpha=0.0f; |
|
471 |
|
472 col = iStopData->operator[](0).iStopColor; |
|
473 alpha = (VGfloat)iStopData->operator[](0).iStopOpacity; |
|
474 r = (col & 0x00ff0000)>>16; |
|
475 g = (col & 0x0000ff00)>>8; |
|
476 b = (col & 0x000000ff); |
|
477 |
|
478 colorRGBA[0] = (VGfloat)(TFloatFixPt( r ) * KInverse255); |
|
479 colorRGBA[1] = (VGfloat)(TFloatFixPt( g ) * KInverse255); |
|
480 colorRGBA[2] = (VGfloat)(TFloatFixPt( b ) * KInverse255); |
|
481 colorRGBA[3] = alpha * (VGfloat)aOpacity; |
|
482 |
|
483 iVgRenderer->vgSetParameteri( aFillPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR ); |
|
484 iVgRenderer->vgSetParameterfv( aFillPaint, VG_PAINT_COLOR, 4, colorRGBA); |
|
485 iVgRenderer->vgSetPaint( aFillPaint, VG_FILL_PATH ); |
|
486 return ; |
|
487 } |
|
488 else if(stopCount > 0) |
|
489 { |
|
490 // Using non-ELeave version and checking for NULL to avoid (ELeave) and TRAP |
|
491 VGfloat *stops = new VGfloat [(stopCount+2)*5]; |
|
492 if ( !stops ) |
|
493 { |
|
494 return; |
|
495 } |
|
496 |
|
497 VGfloat *lclStop = stops; |
|
498 |
|
499 TInt i=0; |
|
500 TInt col,r,g,b; |
|
501 VGfloat alpha; |
|
502 TInt additionalStopsAdded = 0; |
|
503 |
|
504 if( iStopData->operator[](0).iOffset != TFloatFixPt(0) ) |
|
505 { |
|
506 //if the first stop didn't have an offset == 0 then we need to force a zero on it |
|
507 //for safety in OpenVG and VGR |
|
508 *lclStop++ = 0.0f; |
|
509 col = iStopData->operator[](0).iStopColor; |
|
510 alpha = (VGfloat)iStopData->operator[](0).iStopOpacity; |
|
511 r = (col & 0x00ff0000)>>16; |
|
512 g = (col & 0x0000ff00)>>8; |
|
513 b = (col & 0x000000ff); |
|
514 |
|
515 rVal = (VGfloat)(TFloatFixPt( r ) * KInverse255); |
|
516 *lclStop++ = rVal; |
|
517 |
|
518 gVal = (VGfloat)(TFloatFixPt( g )* KInverse255); |
|
519 *lclStop++ = gVal; |
|
520 |
|
521 bVal = (VGfloat)(TFloatFixPt( b ) * KInverse255); |
|
522 *lclStop++ = bVal; |
|
523 |
|
524 *lclStop++ = alpha * (VGfloat)aOpacity; |
|
525 additionalStopsAdded++; |
|
526 |
|
527 } |
|
528 for( ; i < stopCount; i++) |
|
529 { |
|
530 offsetVal = (VGfloat)(iStopData->operator[](i).iOffset); |
|
531 *lclStop++ = offsetVal; |
|
532 |
|
533 col = iStopData->operator[](i).iStopColor; |
|
534 alpha = (VGfloat)iStopData->operator[](i).iStopOpacity; |
|
535 r = (col & 0x00ff0000)>>16; |
|
536 g = (col & 0x0000ff00)>>8; |
|
537 b = (col & 0x000000ff); |
|
538 |
|
539 rVal = (VGfloat)(TFloatFixPt( r ) * KInverse255); |
|
540 *lclStop++ = rVal; |
|
541 |
|
542 gVal = (VGfloat)(TFloatFixPt( g ) * KInverse255); |
|
543 *lclStop++ = gVal; |
|
544 |
|
545 bVal = (VGfloat)(TFloatFixPt( b ) * KInverse255); |
|
546 *lclStop++ = bVal; |
|
547 |
|
548 *lclStop++ = alpha * (VGfloat)aOpacity; |
|
549 } |
|
550 |
|
551 if (offsetVal != 1.0f) |
|
552 { |
|
553 //if the last stop didn't have an offset == 1 then we need to force one on it |
|
554 //for safety in OpenVG and VGR |
|
555 *lclStop++ = 1.0f; |
|
556 col = iStopData->operator[](i-1).iStopColor; |
|
557 alpha = (VGfloat)iStopData->operator[](i-1).iStopOpacity; |
|
558 r = (col & 0x00ff0000)>>16; |
|
559 g = (col & 0x0000ff00)>>8; |
|
560 b = (col & 0x000000ff); |
|
561 |
|
562 rVal = (VGfloat)(TFloatFixPt( r ) * KInverse255); |
|
563 *lclStop++ = rVal; |
|
564 |
|
565 gVal = (VGfloat)(TFloatFixPt( g ) * KInverse255); |
|
566 *lclStop++ = gVal; |
|
567 |
|
568 bVal = (VGfloat)(TFloatFixPt( b ) * KInverse255); |
|
569 *lclStop++ = bVal; |
|
570 |
|
571 *lclStop++ = alpha * (VGfloat)aOpacity; |
|
572 additionalStopsAdded++; |
|
573 } |
|
574 |
|
575 iVgRenderer->vgSetParameterfv( aFillPaint, VG_PAINT_COLOR_RAMP_STOPS, (stopCount+additionalStopsAdded)*5, stops ); |
|
576 delete [] stops; |
|
577 } |
|
578 |
|
579 iVgRenderer->vgSetParameteri( aFillPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_RADIAL_GRADIENT ); |
|
580 |
|
581 if(iSpreadMethod==KspreadMethodReflect) |
|
582 { |
|
583 colorRamp = VG_COLOR_RAMP_SPREAD_REFLECT; |
|
584 } |
|
585 else if(iSpreadMethod==KspreadMethodRepeat) |
|
586 { |
|
587 colorRamp = VG_COLOR_RAMP_SPREAD_REPEAT; |
|
588 } |
|
589 |
|
590 |
|
591 iVgRenderer->vgSetParameteri( aFillPaint, VG_PAINT_COLOR_RAMP_SPREAD_MODE, colorRamp ); |
|
592 iVgRenderer->vgSetParameterfv( aFillPaint, VG_PAINT_RADIAL_GRADIENT, 5, gradient); |
|
593 iVgRenderer->vgSetPaint( aFillPaint, VG_FILL_PATH ); |
|
594 } |