|
1 // Copyright (c) 2008-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 // Symbian Foundation Ltd- conversion from t_extendedbitmaprenderstage |
|
13 // |
|
14 // Description: |
|
15 // |
|
16 |
|
17 #include "nvgrenderstage.h" |
|
18 #include <graphics/wsrenderstage.h> |
|
19 #include <s32mem.h> |
|
20 #include <AknIconHeader.h> |
|
21 #include <AknIconUtils.h> |
|
22 |
|
23 TCachedConversion::TCachedConversion() : |
|
24 iLink(), iCachedResult(NULL) |
|
25 {} |
|
26 |
|
27 TCachedConversion::~TCachedConversion() |
|
28 { |
|
29 delete iCachedResult; |
|
30 } |
|
31 |
|
32 const TUid KUidNvgExtendedBitmap = {0x39b9273e}; |
|
33 |
|
34 CNvgRenderStage::CNvgRenderStage() : |
|
35 iExtendedBitmapError(KErrNone), |
|
36 iCache(_FOFF(TCachedConversion,iLink)), |
|
37 iCacheIterator(iCache), |
|
38 iCacheFree(MAX_NVG_CACHE_SIZE) |
|
39 { |
|
40 } |
|
41 |
|
42 /** Called by CNvgRenderStageFactory::CreateRenderStageL() and |
|
43 CNvgRenderStageFactory::CreateFinalRenderStageL() when a new render stage |
|
44 called "nvgbitmap" is to be created. The only parameter used by this render stage |
|
45 is aNextStage, the rest are commented out to prevent warnings. |
|
46 @see MWsRenderStageFactory::CreateRenderStageL() |
|
47 @see MWsRenderStageFactory::CreateFinalRenderStageL() |
|
48 */ |
|
49 CNvgRenderStage* CNvgRenderStage::NewL(MWsGraphicDrawerEnvironment* /*aEnv*/, MWsScreen* /*aScreen*/, MWsScreenRedraw* /*aScreenRedraw*/, CWsRenderStage* aNextStage) |
|
50 { |
|
51 CNvgRenderStage* stage = new(ELeave) CNvgRenderStage(); |
|
52 CleanupStack::PushL(stage); |
|
53 stage->ConstructL(aNextStage); |
|
54 CleanupStack::Pop(stage); |
|
55 return stage; |
|
56 } |
|
57 |
|
58 void CNvgRenderStage::ConstructL(CWsRenderStage* aNextStage) |
|
59 { |
|
60 iBrushPattern = new(ELeave) CFbsBitmap; |
|
61 iInternalBrushPattern = new(ELeave) CFbsBitmap; |
|
62 iGraphicsInterface = new(ELeave) CVGIGraphicsInterface; |
|
63 iNvgEngine = CNvgEngine::NewL(); |
|
64 iNvgEngine->SetVGImageBinder(iGraphicsInterface); |
|
65 |
|
66 BaseConstructL(); |
|
67 SetNext(aNextStage); |
|
68 } |
|
69 |
|
70 CNvgRenderStage::~CNvgRenderStage() |
|
71 { |
|
72 iEmptyRegion.Close(); |
|
73 delete iBrushPattern; |
|
74 delete iInternalBrushPattern; |
|
75 delete iNvgEngine; |
|
76 delete iGraphicsInterface; |
|
77 |
|
78 iCacheIterator.SetToFirst(); |
|
79 TCachedConversion* cached = iCacheIterator++; |
|
80 while (cached != NULL) |
|
81 { |
|
82 delete cached; |
|
83 cached = iCacheIterator++; |
|
84 } |
|
85 } |
|
86 |
|
87 /** The only interface returned by this render stage is MWsGraphicsContext. |
|
88 All other interface requests are passed to the base render stage class for resolving. |
|
89 |
|
90 @see CWsRenderStage::ResolveObjectInterface() |
|
91 |
|
92 @param aTypeId The type id of the interface to be retreived, must be one of the |
|
93 TSurfaceConfiguration interface extension IDs. |
|
94 |
|
95 @return Returns a pointer to an object that has the requested interface if found, |
|
96 otherwise returns NULL. |
|
97 */ |
|
98 TAny* CNvgRenderStage::ResolveObjectInterface(TUint aTypeId) |
|
99 { |
|
100 switch (aTypeId) |
|
101 { |
|
102 case MWsGraphicsContext::EWsObjectInterfaceId: |
|
103 return static_cast<MWsGraphicsContext*>(this); |
|
104 |
|
105 default: |
|
106 return CWsRenderStage::ResolveObjectInterface(aTypeId); |
|
107 } |
|
108 } |
|
109 |
|
110 /** Call Begin() for this render stage and for the next one as well. It is assumed |
|
111 that this renderstage is chained in front of a renderstage that can draw to a |
|
112 CGraphicsContext as this renderstage uses MWsGraphicsContext interface from the |
|
113 next stage to draw to. A pointer to the MWsGraphicsContext interface is saved here |
|
114 and is used for all subsequent MWsGraphicsContext operations called on this |
|
115 render stage. |
|
116 |
|
117 This render stage draws all extended bitmaps of type 0x39b9273e |
|
118 and passes all other drawing operations directly to the next render stage through |
|
119 its MWsGraphicsContext interface. |
|
120 |
|
121 @see CWsRenderStage::Begin() |
|
122 |
|
123 @param aRegion The dirty region for which drawing operations are about to be issued. |
|
124 |
|
125 @post An error of KErrNotFound is set for this render stage if the MWsGraphicsContext |
|
126 interface of the next render stage cannot be obtained. This render stage relies on |
|
127 the existence of a subsequent stage with a valid MWsGraphicsContext interface to send |
|
128 its draw operations to so will not be able to draw anything if no MWsGraphicsContext |
|
129 is returned by the next render stage. The current error for this render stage can be |
|
130 retreived by calling GetError(). |
|
131 */ |
|
132 void CNvgRenderStage::Begin(const TRegion* aRegion) |
|
133 { |
|
134 CWsRenderStage* nextStage = Next(); |
|
135 if (nextStage) |
|
136 { |
|
137 nextStage->Begin(aRegion); |
|
138 |
|
139 // Use the graphics context from the next render stage to draw to |
|
140 iGc = static_cast<MWsGraphicsContext*>(nextStage->ResolveObjectInterface(MWsGraphicsContext::EWsObjectInterfaceId)); |
|
141 if (iGc == NULL) |
|
142 { |
|
143 iExtendedBitmapError = KErrNotFound; |
|
144 } |
|
145 } |
|
146 } |
|
147 |
|
148 /** Signals that the currect batch of drawing operations is complete. This |
|
149 implementation of End() just calls End() for the next render stage in the chain. |
|
150 |
|
151 @see CWsRenderStage::End() |
|
152 |
|
153 @param aCompositorReady Will be completed when the render stage is ready to |
|
154 receive the next batch of drawing operations. |
|
155 */ |
|
156 void CNvgRenderStage::End(TRequestStatus* aCompositorReady) |
|
157 { |
|
158 if (Next()) |
|
159 { |
|
160 Next()->End(aCompositorReady); |
|
161 } |
|
162 } |
|
163 |
|
164 /** If the passed bitmap is an extended bitmap of type 0x39b9273e, draw it to the stored |
|
165 graphics context of the next render stage using DrawExtendedBitmap(), if the passed bitmap |
|
166 is not an extended bitmap just pass it on to the next render stage directly. |
|
167 |
|
168 @see CFbsBitGc::BitBlt(const TPoint&, const CFbsBitmap&) |
|
169 */ |
|
170 void CNvgRenderStage::BitBlt(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap) |
|
171 { |
|
172 if (iGc) |
|
173 { |
|
174 CFbsBitmap* sourceBitmap = const_cast<CFbsBitmap*>(&aSourceBitmap); |
|
175 |
|
176 if (aSourceBitmap.ExtendedBitmapType() == KUidNvgExtendedBitmap) |
|
177 { |
|
178 sourceBitmap = GetConvertedBitmap(aSourceBitmap); |
|
179 } |
|
180 |
|
181 iGc->BitBlt(aDestPos, *sourceBitmap); |
|
182 } |
|
183 } |
|
184 |
|
185 /** If the passed bitmap is an extended bitmap of type 0x39b9273e, draw it to the |
|
186 stored graphics context of the next render stage using DrawExtendedBitmap(), if the |
|
187 passed bitmap is not an extended bitmap just pass it on to the next render stage directly. |
|
188 |
|
189 @see CFbsBitGc::BitBlt(const TPoint&, const CFbsBitmap&, const TRect&) |
|
190 */ |
|
191 void CNvgRenderStage::BitBlt(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect) |
|
192 { |
|
193 if (iGc) |
|
194 { |
|
195 CFbsBitmap* sourceBitmap = const_cast<CFbsBitmap*>(&aSourceBitmap); |
|
196 |
|
197 if (aSourceBitmap.ExtendedBitmapType() == KUidNvgExtendedBitmap) |
|
198 { |
|
199 sourceBitmap = GetConvertedBitmap(aSourceBitmap); |
|
200 } |
|
201 |
|
202 iGc->BitBlt(aDestPos, *sourceBitmap, aSourceRect); |
|
203 } |
|
204 } |
|
205 |
|
206 /** If either of the passed bitmaps is an extended bitmap of type 0x39b9273e convert |
|
207 to a normal bitmap before passing to the next render stage, otherwise |
|
208 just pass to the next render stage directly. |
|
209 |
|
210 @see CFbsBitGc::BitBltMasked(const TPoint& aDestPos, const CFbsBitmap&, const TRect&, const CFbsBitmap&, TBool) |
|
211 */ |
|
212 void CNvgRenderStage::BitBltMasked(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect, const CFbsBitmap& aMaskBitmap, TBool aInvertMask) |
|
213 { |
|
214 if (iGc) |
|
215 { |
|
216 CFbsBitmap* sourceBitmap = const_cast<CFbsBitmap*>(&aSourceBitmap); |
|
217 CFbsBitmap* maskBitmap = const_cast<CFbsBitmap*>(&aMaskBitmap); |
|
218 |
|
219 if (aSourceBitmap.ExtendedBitmapType() == KUidNvgExtendedBitmap) |
|
220 { |
|
221 sourceBitmap = GetConvertedBitmap(aSourceBitmap); |
|
222 } |
|
223 |
|
224 if (aMaskBitmap.ExtendedBitmapType() == KUidNvgExtendedBitmap) |
|
225 { |
|
226 maskBitmap = GetConvertedBitmap(aMaskBitmap); |
|
227 } |
|
228 |
|
229 iGc->BitBltMasked(aDestPos, *sourceBitmap, aSourceRect, *maskBitmap, aInvertMask); |
|
230 } |
|
231 } |
|
232 |
|
233 /** If either of the passed bitmaps is an extended bitmap of type 0x39b9273e |
|
234 convert to a normal bitmap before passing to the next render stage, otherwise |
|
235 just pass to the next render stage directly. |
|
236 |
|
237 @see CFbsBitGc::BitBltMasked(const TPoint& aDestPos, const CFbsBitmap&, const TRect&, const CFbsBitmap&, TPoint) |
|
238 */ |
|
239 void CNvgRenderStage::BitBltMasked(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect, const CFbsBitmap& aMaskBitmap, const TPoint& aMaskPos) |
|
240 { |
|
241 if (iGc) |
|
242 { |
|
243 CFbsBitmap* sourceBitmap = const_cast<CFbsBitmap*>(&aSourceBitmap); |
|
244 CFbsBitmap* maskBitmap = const_cast<CFbsBitmap*>(&aMaskBitmap); |
|
245 |
|
246 if (aSourceBitmap.ExtendedBitmapType() == KUidNvgExtendedBitmap) |
|
247 { |
|
248 sourceBitmap = GetConvertedBitmap(aSourceBitmap); |
|
249 } |
|
250 |
|
251 if (aMaskBitmap.ExtendedBitmapType() == KUidNvgExtendedBitmap) |
|
252 { |
|
253 maskBitmap = GetConvertedBitmap(aMaskBitmap); |
|
254 } |
|
255 |
|
256 iGc->BitBltMasked(aDestPos, *sourceBitmap, aSourceRect, *maskBitmap, aMaskPos); |
|
257 } |
|
258 } |
|
259 |
|
260 /** @see CFbsBitGc::ResetClippingRegion() |
|
261 */ |
|
262 void CNvgRenderStage::ResetClippingRegion() |
|
263 { |
|
264 if (iGc) |
|
265 { |
|
266 iGc->ResetClippingRegion(); |
|
267 } |
|
268 } |
|
269 |
|
270 /** @see CFbsBitGc::Clear() |
|
271 */ |
|
272 void CNvgRenderStage::Clear() |
|
273 { |
|
274 if (iGc) |
|
275 { |
|
276 iGc->Clear(); |
|
277 } |
|
278 } |
|
279 |
|
280 /** @see CFbsBitGc::Clear(const TRect&) |
|
281 */ |
|
282 void CNvgRenderStage::Clear(const TRect& aRect) |
|
283 { |
|
284 if (iGc) |
|
285 { |
|
286 iGc->Clear(aRect); |
|
287 } |
|
288 } |
|
289 |
|
290 /** @see CFbsBitGc::ResetBrushPattern() |
|
291 */ |
|
292 void CNvgRenderStage::ResetBrushPattern() |
|
293 { |
|
294 if (iGc) |
|
295 { |
|
296 iGc->ResetBrushPattern(); |
|
297 } |
|
298 } |
|
299 |
|
300 /** @see CFbsBitGc::ResetFont() |
|
301 */ |
|
302 void CNvgRenderStage::ResetFont() |
|
303 { |
|
304 if (iGc) |
|
305 { |
|
306 iGc->ResetFont(); |
|
307 } |
|
308 } |
|
309 |
|
310 /** @see CFbsBitGc::DrawArc() |
|
311 */ |
|
312 void CNvgRenderStage::DrawArc(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd) |
|
313 { |
|
314 if (iGc) |
|
315 { |
|
316 iGc->DrawArc(aRect, aStart, aEnd); |
|
317 } |
|
318 } |
|
319 |
|
320 /** @see CFbsBitGc::DrawPie() |
|
321 */ |
|
322 void CNvgRenderStage::DrawPie(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd) |
|
323 { |
|
324 if (iGc) |
|
325 { |
|
326 iGc->DrawPie(aRect, aStart, aEnd); |
|
327 } |
|
328 } |
|
329 |
|
330 /** If the passed bitmap is an extended bitmap of type 0x39b9273e, draw it to the |
|
331 stored graphics context of the next render stage using DrawExtendedBitmap(), if the |
|
332 passed bitmap is not an extended bitmap just pass it on to the next render stage directly. |
|
333 |
|
334 @see CFbsBitGc::DrawBitmap(const TRect&, const CFbsBitmap&) |
|
335 */ |
|
336 void CNvgRenderStage::DrawBitmap(const TRect& aDestRect, const CFbsBitmap& aSourceBitmap) |
|
337 { |
|
338 if (iGc) |
|
339 { |
|
340 CFbsBitmap* sourceBitmap = const_cast<CFbsBitmap*>(&aSourceBitmap); |
|
341 |
|
342 if (aSourceBitmap.ExtendedBitmapType() == KUidNvgExtendedBitmap) |
|
343 { |
|
344 sourceBitmap = GetConvertedBitmap(aSourceBitmap); |
|
345 } |
|
346 |
|
347 iGc->DrawBitmap(aDestRect, *sourceBitmap); |
|
348 } |
|
349 } |
|
350 |
|
351 /** If the passed bitmap is an extended bitmap of type 0x39b9273e, draw it to the |
|
352 stored graphics context of the next render stage using DrawExtendedBitmap(), if the |
|
353 passed bitmap is not an extended bitmap just pass it on to the next render stage directly. |
|
354 |
|
355 @see CFbsBitGc::DrawBitmap(const TRect&, const CFbsBitmap&, const TRect&) |
|
356 */ |
|
357 void CNvgRenderStage::DrawBitmap(const TRect& aDestRect, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect) |
|
358 { |
|
359 if (iGc) |
|
360 { |
|
361 CFbsBitmap* sourceBitmap = const_cast<CFbsBitmap*>(&aSourceBitmap); |
|
362 |
|
363 if (aSourceBitmap.ExtendedBitmapType() == KUidNvgExtendedBitmap) |
|
364 { |
|
365 sourceBitmap = GetConvertedBitmap(aSourceBitmap); |
|
366 } |
|
367 |
|
368 iGc->DrawBitmap(aDestRect, *sourceBitmap, aSourceRect); |
|
369 } |
|
370 } |
|
371 |
|
372 /** If the passed bitmap or mask bitmap is an extended bitmap of type 0x39b9273e |
|
373 convert it to a normal bitmap before calling DrawBitmapMasked(), normal bitmaps |
|
374 are passed straight through to the next render stage without conversion. |
|
375 |
|
376 @see CFbsBitGc::DrawBitmapMasked(const TRect&, const CFbsBitmap&, const TRect&, const CFbsBitmap&, TBool) |
|
377 */ |
|
378 void CNvgRenderStage::DrawBitmapMasked(const TRect& aDestRect, const CFbsBitmap& aSourceBitmap,const TRect& aSourceRect, const CFbsBitmap& aMaskBitmap, TBool aInvertMask) |
|
379 { |
|
380 if (iGc) |
|
381 { |
|
382 CFbsBitmap* sourceBitmap = const_cast<CFbsBitmap*>(&aSourceBitmap); |
|
383 CFbsBitmap* maskBitmap = const_cast<CFbsBitmap*>(&aMaskBitmap); |
|
384 |
|
385 if (aSourceBitmap.ExtendedBitmapType() == KUidNvgExtendedBitmap) |
|
386 { |
|
387 sourceBitmap = GetConvertedBitmap(aSourceBitmap); |
|
388 } |
|
389 if (aMaskBitmap.ExtendedBitmapType() == KUidNvgExtendedBitmap) |
|
390 { |
|
391 maskBitmap = GetConvertedBitmap(aMaskBitmap); |
|
392 } |
|
393 |
|
394 iGc->DrawBitmapMasked(aDestRect, *sourceBitmap, aSourceRect, *maskBitmap, aInvertMask); |
|
395 } |
|
396 } |
|
397 |
|
398 /** @see CFbsBitGc::DrawRoundRect(const TRect&, const TSize&) |
|
399 */ |
|
400 void CNvgRenderStage::DrawRoundRect(const TRect& aRect, const TSize& aEllipse) |
|
401 { |
|
402 if (iGc) |
|
403 { |
|
404 iGc->DrawRoundRect(aRect, aEllipse); |
|
405 } |
|
406 } |
|
407 |
|
408 /** @see CFbsBitGc::DrawPolyLine(const TArray<TPoint>&) |
|
409 */ |
|
410 void CNvgRenderStage::DrawPolyLine(const TArray<TPoint>& aPointList) |
|
411 { |
|
412 if (iGc) |
|
413 { |
|
414 iGc->DrawPolyLine(aPointList); |
|
415 } |
|
416 } |
|
417 |
|
418 /** @see CFbsBitGc::DrawPolyLineNoEndPoint(const TArray<TPoint>&) |
|
419 */ |
|
420 void CNvgRenderStage::DrawPolyLineNoEndPoint(const TArray<TPoint>& aPointList) |
|
421 { |
|
422 if (iGc) |
|
423 { |
|
424 iGc->DrawPolyLineNoEndPoint(aPointList); |
|
425 } |
|
426 } |
|
427 |
|
428 /** @see CFbsBitGc::DrawPolygon(const TArray<TPoint>&, TFillRule) |
|
429 */ |
|
430 void CNvgRenderStage::DrawPolygon(const TArray<TPoint>& aPointList, TFillRule aFillRule) |
|
431 { |
|
432 if (iGc) |
|
433 { |
|
434 iGc->DrawPolygon(aPointList, aFillRule); |
|
435 } |
|
436 } |
|
437 |
|
438 /** @see CFbsBitGc::DrawEllipse(const TRect&) |
|
439 */ |
|
440 void CNvgRenderStage::DrawEllipse(const TRect& aRect) |
|
441 { |
|
442 if (iGc) |
|
443 { |
|
444 iGc->DrawEllipse(aRect); |
|
445 } |
|
446 } |
|
447 |
|
448 /** @see CFbsBitGc::DrawLine(const TPoint&, const TPoint&) |
|
449 */ |
|
450 void CNvgRenderStage::DrawLine(const TPoint& aStart, const TPoint& aEnd) |
|
451 { |
|
452 if (iGc) |
|
453 { |
|
454 iGc->DrawLine(aStart, aEnd); |
|
455 } |
|
456 } |
|
457 |
|
458 /** @see CFbsBitGc::DrawLineTo(const TPoint&) |
|
459 */ |
|
460 void CNvgRenderStage::DrawLineTo(const TPoint& aPoint) |
|
461 { |
|
462 if (iGc) |
|
463 { |
|
464 iGc->DrawLineTo(aPoint); |
|
465 } |
|
466 } |
|
467 |
|
468 /** @see CFbsBitGc::DrawLineBy(const TPoint&) |
|
469 */ |
|
470 void CNvgRenderStage::DrawLineBy(const TPoint& aVector) |
|
471 { |
|
472 if (iGc) |
|
473 { |
|
474 iGc->DrawLineBy(aVector); |
|
475 } |
|
476 } |
|
477 |
|
478 /** @see CFbsBitGc::DrawRect(const TRect&) |
|
479 */ |
|
480 void CNvgRenderStage::DrawRect(const TRect& aRect) |
|
481 { |
|
482 if (iGc) |
|
483 { |
|
484 iGc->DrawRect(aRect); |
|
485 } |
|
486 } |
|
487 |
|
488 /** @see CFbsBitGc::DrawText(const TDesC& aText, const TTextParameters*) |
|
489 */ |
|
490 void CNvgRenderStage::DrawText(const TDesC& aText, const TTextParameters* aParam) |
|
491 { |
|
492 if (iGc) |
|
493 { |
|
494 iGc->DrawText(aText, aParam); |
|
495 } |
|
496 } |
|
497 |
|
498 /** @see CFbsBitGc::DrawText(const TDesC& aText, const TTextParameters*, const TPoint&) |
|
499 */ |
|
500 void CNvgRenderStage::DrawText(const TDesC& aText, const TTextParameters* aParam, const TPoint& aPosition) |
|
501 { |
|
502 if (iGc) |
|
503 { |
|
504 iGc->DrawText(aText, aParam, aPosition); |
|
505 } |
|
506 } |
|
507 |
|
508 /** @see CFbsBitGc::DrawText(const TDesC& aText, const TTextParameters*, const TRect&) |
|
509 */ |
|
510 void CNvgRenderStage::DrawText(const TDesC& aText, const TTextParameters* aParam, const TRect& aClipRect) |
|
511 { |
|
512 if (iGc) |
|
513 { |
|
514 iGc->DrawText(aText, aParam, aClipRect); |
|
515 } |
|
516 } |
|
517 |
|
518 /** @see CFbsBitGc::DrawText(const TDesC& aText, const TTextParameters*, const TRect&, TInt, TTextAlign, TInt) |
|
519 */ |
|
520 void CNvgRenderStage::DrawText(const TDesC& aText, const TTextParameters* aParam, const TRect& aClipFillRect, TInt aBaselineOffset, TTextAlign aHrz, TInt aMargin) |
|
521 { |
|
522 if (iGc) |
|
523 { |
|
524 iGc->DrawText(aText, aParam, aClipFillRect, aBaselineOffset, aHrz, aMargin); |
|
525 } |
|
526 } |
|
527 |
|
528 /** @see CFbsBitGc::DrawTextVertical(const TDesC&, const TTextParameters*, TBool) |
|
529 */ |
|
530 void CNvgRenderStage::DrawTextVertical(const TDesC& aText, const TTextParameters* aParam, TBool aUp) |
|
531 { |
|
532 if (iGc) |
|
533 { |
|
534 iGc->DrawTextVertical(aText, aParam, aUp); |
|
535 } |
|
536 } |
|
537 |
|
538 /** @see CFbsBitGc::DrawTextVertical(const TDesC&, const TTextParameters*, const TPoint&, TBool) |
|
539 */ |
|
540 void CNvgRenderStage::DrawTextVertical(const TDesC& aText, const TTextParameters* aParam, const TPoint& aPosition, TBool aUp) |
|
541 { |
|
542 if (iGc) |
|
543 { |
|
544 iGc->DrawTextVertical(aText, aParam, aPosition, aUp); |
|
545 } |
|
546 } |
|
547 |
|
548 /** @see CFbsBitGc::DrawTextVertical(const TDesC&, const TTextParameters*, const TRect&, TBool) |
|
549 */ |
|
550 void CNvgRenderStage::DrawTextVertical(const TDesC& aText, const TTextParameters* aParam, const TRect& aClipRect, TBool aUp) |
|
551 { |
|
552 if (iGc) |
|
553 { |
|
554 iGc->DrawTextVertical(aText, aParam, aClipRect, aUp); |
|
555 } |
|
556 } |
|
557 |
|
558 /** @see CFbsBitGc::DrawTextVertical(const TDesC&, const TTextParameters*, const TRect&, TInt aBaselineOffset, TBool, TTextAlign, TInt) |
|
559 */ |
|
560 void CNvgRenderStage::DrawTextVertical(const TDesC& aText, const TTextParameters* aParam, const TRect& aClipRect, TInt aBaselineOffset, TBool aUp, TTextAlign aVert, TInt aMargin) |
|
561 { |
|
562 if (iGc) |
|
563 { |
|
564 iGc->DrawTextVertical(aText, aParam, aClipRect, aBaselineOffset, aUp, aVert, aMargin); |
|
565 } |
|
566 } |
|
567 |
|
568 /** @see CFbsBitGc::DrawTextVertical(const TDesC&, const TTextParameters*, const TRect&, TInt, TInt, TBool, TTextAlign, TInt) |
|
569 */ |
|
570 void CNvgRenderStage::DrawTextVertical(const TDesC& aText, const TTextParameters* aParam, const TRect& aClipRect, TInt aBaselineOffset, TInt aTextWidth, TBool aUp, TTextAlign aVert, TInt aMargin) |
|
571 { |
|
572 if (iGc) |
|
573 { |
|
574 iGc->DrawTextVertical(aText, aParam, aClipRect, aBaselineOffset, aTextWidth, aUp, aVert, aMargin); |
|
575 } |
|
576 } |
|
577 |
|
578 /** @see CFbsBitGc::MoveTo(const TPoint&) |
|
579 */ |
|
580 void CNvgRenderStage::MoveTo(const TPoint& aPoint) |
|
581 { |
|
582 if (iGc) |
|
583 { |
|
584 iGc->MoveTo(aPoint); |
|
585 } |
|
586 } |
|
587 |
|
588 /** @see CFbsBitGc::MoveBy(const TPoint&) |
|
589 */ |
|
590 void CNvgRenderStage::MoveBy(const TPoint& aVector) |
|
591 { |
|
592 if (iGc) |
|
593 { |
|
594 iGc->MoveBy(aVector); |
|
595 } |
|
596 } |
|
597 |
|
598 /** @see CFbsBitGc::Plot(const TPoint&) |
|
599 */ |
|
600 void CNvgRenderStage::Plot(const TPoint& aPoint) |
|
601 { |
|
602 if (iGc) |
|
603 { |
|
604 iGc->Plot(aPoint); |
|
605 } |
|
606 } |
|
607 |
|
608 /** @see CFbsBitGc::Reset() |
|
609 */ |
|
610 void CNvgRenderStage::Reset() |
|
611 { |
|
612 iExtendedBitmapError = KErrNone; |
|
613 iOrigin.SetXY(0,0); |
|
614 iBrushStyle = MWsGraphicsContext::ENullBrush; |
|
615 if (iGc) |
|
616 { |
|
617 iGc->Reset(); |
|
618 } |
|
619 } |
|
620 |
|
621 /** @see CFbsBitGc::SetBrushColor(const TRgb&) |
|
622 */ |
|
623 void CNvgRenderStage::SetBrushColor(const TRgb& aColor) |
|
624 { |
|
625 if (iGc) |
|
626 { |
|
627 iGc->SetBrushColor(aColor); |
|
628 } |
|
629 } |
|
630 |
|
631 /** @see CFbsBitGc::SetBrushOrigin(const TPoint&) |
|
632 */ |
|
633 void CNvgRenderStage::SetBrushOrigin(const TPoint& aOrigin) |
|
634 { |
|
635 if (iGc) |
|
636 { |
|
637 iGc->SetBrushOrigin(aOrigin); |
|
638 } |
|
639 } |
|
640 |
|
641 /** @see CFbsBitGc::SetBrushStyle(TBrushStyle) |
|
642 */ |
|
643 void CNvgRenderStage::SetBrushStyle(TBrushStyle aBrushStyle) |
|
644 { |
|
645 if (iGc) |
|
646 { |
|
647 iGc->SetBrushStyle(aBrushStyle); |
|
648 iBrushStyle = aBrushStyle; |
|
649 } |
|
650 } |
|
651 |
|
652 /** @see CFbsBitGc::SetClippingRegion(const TRegion&) |
|
653 */ |
|
654 void CNvgRenderStage::SetClippingRegion(const TRegion& aRegion) |
|
655 { |
|
656 if (iGc) |
|
657 { |
|
658 iGc->SetClippingRegion(aRegion); |
|
659 } |
|
660 } |
|
661 |
|
662 /** @see CFbsBitGc::SetDrawMode(TDrawMode) |
|
663 */ |
|
664 void CNvgRenderStage::SetDrawMode(TDrawMode aDrawMode) |
|
665 { |
|
666 if (iGc) |
|
667 { |
|
668 iGc->SetDrawMode(aDrawMode); |
|
669 } |
|
670 } |
|
671 |
|
672 /** @see CFbsBitGc::SetOrigin(const TPoint&) |
|
673 */ |
|
674 void CNvgRenderStage::SetOrigin(const TPoint& aPoint) |
|
675 { |
|
676 if (iGc) |
|
677 { |
|
678 iGc->SetOrigin(aPoint); |
|
679 iOrigin = aPoint; |
|
680 } |
|
681 } |
|
682 |
|
683 /** @see CFbsBitGc::SetPenColor(const TRgb&) |
|
684 */ |
|
685 void CNvgRenderStage::SetPenColor(const TRgb& aColor) |
|
686 { |
|
687 if (iGc) |
|
688 { |
|
689 iGc->SetPenColor(aColor); |
|
690 } |
|
691 } |
|
692 |
|
693 /** @see CFbsBitGc::SetPenStyle(TPenStyle) |
|
694 */ |
|
695 void CNvgRenderStage::SetPenStyle(TPenStyle aPenStyle) |
|
696 { |
|
697 if (iGc) |
|
698 { |
|
699 iGc->SetPenStyle(aPenStyle); |
|
700 } |
|
701 } |
|
702 |
|
703 /** @see CFbsBitGc::SetPenSize(const TSize&) |
|
704 */ |
|
705 void CNvgRenderStage::SetPenSize(const TSize& aSize) |
|
706 { |
|
707 if (iGc) |
|
708 { |
|
709 iGc->SetPenSize(aSize); |
|
710 } |
|
711 } |
|
712 |
|
713 /** @see CFbsBitGc::SetTextShadowColor(const TRgb&) |
|
714 */ |
|
715 void CNvgRenderStage::SetTextShadowColor(const TRgb& aColor) |
|
716 { |
|
717 if (iGc) |
|
718 { |
|
719 iGc->SetTextShadowColor(aColor); |
|
720 } |
|
721 } |
|
722 |
|
723 /** @see CFbsBitGc::SetCharJustification(TInt, TInt) |
|
724 */ |
|
725 void CNvgRenderStage::SetCharJustification(TInt aExcessWidth, TInt aNumChars) |
|
726 { |
|
727 if (iGc) |
|
728 { |
|
729 iGc->SetCharJustification(aExcessWidth, aNumChars); |
|
730 } |
|
731 } |
|
732 |
|
733 /** @see CFbsBitGc::SetWordJustification(TInt, TInt) |
|
734 */ |
|
735 void CNvgRenderStage::SetWordJustification(TInt aExcessWidth, TInt aNumGaps) |
|
736 { |
|
737 if (iGc) |
|
738 { |
|
739 iGc->SetWordJustification(aExcessWidth, aNumGaps); |
|
740 } |
|
741 } |
|
742 |
|
743 /** @see CFbsBitGc::SetUnderlineStyle(TFontUnderline) |
|
744 */ |
|
745 void CNvgRenderStage::SetUnderlineStyle(TFontUnderline aUnderlineStyle) |
|
746 { |
|
747 if (iGc) |
|
748 { |
|
749 iGc->SetUnderlineStyle(aUnderlineStyle); |
|
750 } |
|
751 } |
|
752 |
|
753 /** @see CFbsBitGc::SetStrikethroughStyle(TFontStrikethrough) |
|
754 */ |
|
755 void CNvgRenderStage::SetStrikethroughStyle(TFontStrikethrough aStrikethroughStyle) |
|
756 { |
|
757 if (iGc) |
|
758 { |
|
759 iGc->SetStrikethroughStyle(aStrikethroughStyle); |
|
760 } |
|
761 } |
|
762 |
|
763 /** If the passed bitmap is an extended bitmap of type 0x39b9273e |
|
764 convert the extended bitmap to a normal bitmap and set the converted bitmap |
|
765 as the current brush pattern. If the passed bitmap is a normal |
|
766 bitmap just pass it on to the next render stage. |
|
767 |
|
768 @see SetBrushPattern(TInt) |
|
769 @see CFbsBitGc::SetBrushPattern(const CFbsBitmap&) |
|
770 */ |
|
771 void CNvgRenderStage::SetBrushPattern(const CFbsBitmap& aBitmap) |
|
772 { |
|
773 SetBrushPattern(aBitmap.Handle()); |
|
774 } |
|
775 |
|
776 /** If the passed bitmap handle refers to an extended bitmap of type 0x39b9273e |
|
777 convert the extended bitmap to a normal bitmap and set the converted bitmap |
|
778 as the current brush pattern. If the passed bitmap handle refers to a normal |
|
779 bitmap just pass it on to the next render stage. |
|
780 |
|
781 @see SetBrushPattern(const CFbsBitmap&) |
|
782 @see CFbsBitGc::SetBrushPattern(TInt) |
|
783 */ |
|
784 void CNvgRenderStage::SetBrushPattern(TInt aFbsBitmapHandle) |
|
785 { |
|
786 if (iGc) |
|
787 { |
|
788 iBrushPattern->Duplicate(aFbsBitmapHandle); |
|
789 if (iBrushPattern->ExtendedBitmapType() == KUidNvgExtendedBitmap) |
|
790 { |
|
791 iInternalBrushPattern = GetConvertedBitmap(*iBrushPattern); |
|
792 iGc->SetBrushPattern(*iInternalBrushPattern); |
|
793 } |
|
794 else |
|
795 { |
|
796 iGc->SetBrushPattern(aFbsBitmapHandle); |
|
797 } |
|
798 } |
|
799 } |
|
800 |
|
801 /** @see CFbsBitGc::SetFont(const CFont*) |
|
802 */ |
|
803 void CNvgRenderStage::SetFont(const CFont* aFont) |
|
804 { |
|
805 if (iGc) |
|
806 { |
|
807 iGc->SetFont(aFont); |
|
808 } |
|
809 } |
|
810 |
|
811 /** @see CFbsBitGc::CopyRect(const TPoint&, const TRect&) |
|
812 */ |
|
813 void CNvgRenderStage::CopyRect(const TPoint& aOffset, const TRect& aRect) |
|
814 { |
|
815 if (iGc) |
|
816 { |
|
817 iGc->CopyRect(aOffset, aRect); |
|
818 } |
|
819 } |
|
820 |
|
821 /** @see CFbsBitGc::UpdateJustification(const TDesC&, const TTextParameters*) |
|
822 */ |
|
823 void CNvgRenderStage::UpdateJustification(const TDesC& aText, const TTextParameters* aParam) |
|
824 { |
|
825 if (iGc) |
|
826 { |
|
827 iGc->UpdateJustification(aText, aParam); |
|
828 } |
|
829 } |
|
830 |
|
831 /** @see CFbsBitGc::UpdateJustificationVertical(const TDesC&, const TTextParameters*, TBool) |
|
832 */ |
|
833 void CNvgRenderStage::UpdateJustificationVertical(const TDesC& aText, const TTextParameters* aParam, TBool aUp) |
|
834 { |
|
835 if (iGc) |
|
836 { |
|
837 iGc->UpdateJustificationVertical(aText, aParam, aUp); |
|
838 } |
|
839 } |
|
840 |
|
841 /** @see CFbsBitGc::SetFontNoDuplicate(const CFont*) |
|
842 */ |
|
843 void CNvgRenderStage::SetFontNoDuplicate(const CFont* aFont) |
|
844 { |
|
845 if (iGc) |
|
846 { |
|
847 iGc->SetFontNoDuplicate(aFont); |
|
848 } |
|
849 } |
|
850 |
|
851 /** @see CFbsBitGc::HasBrushPattern() |
|
852 */ |
|
853 TBool CNvgRenderStage::HasBrushPattern() const |
|
854 { |
|
855 if (iGc) |
|
856 { |
|
857 return iGc->HasBrushPattern(); |
|
858 } |
|
859 else |
|
860 { |
|
861 return EFalse; |
|
862 } |
|
863 } |
|
864 |
|
865 /** @see CFbsBitGc::HasFont() |
|
866 */ |
|
867 TBool CNvgRenderStage::HasFont() const |
|
868 { |
|
869 if (iGc) |
|
870 { |
|
871 return iGc->HasFont(); |
|
872 } |
|
873 else |
|
874 { |
|
875 return EFalse; |
|
876 } |
|
877 } |
|
878 |
|
879 /** @see CFbsBitGc::BrushColor() |
|
880 */ |
|
881 TRgb CNvgRenderStage::BrushColor() const |
|
882 { |
|
883 if (iGc) |
|
884 { |
|
885 return iGc->BrushColor(); |
|
886 } |
|
887 else |
|
888 { |
|
889 return KRgbWhite; |
|
890 } |
|
891 } |
|
892 |
|
893 /** @see CFbsBitGc::PenColor() |
|
894 */ |
|
895 TRgb CNvgRenderStage::PenColor() const |
|
896 { |
|
897 if (iGc) |
|
898 { |
|
899 return iGc->PenColor(); |
|
900 } |
|
901 else |
|
902 { |
|
903 return KRgbBlack; |
|
904 } |
|
905 } |
|
906 |
|
907 /** @see MWsGraphicsContext::TextShadowColor() |
|
908 */ |
|
909 TRgb CNvgRenderStage::TextShadowColor() const |
|
910 { |
|
911 if (iGc) |
|
912 { |
|
913 return iGc->TextShadowColor(); |
|
914 } |
|
915 else |
|
916 { |
|
917 return KRgbGray; |
|
918 } |
|
919 } |
|
920 |
|
921 /** If an error has been set by this render stage return that error, |
|
922 otherwise return the error from the graphics context of the next |
|
923 render stage. |
|
924 |
|
925 @see MWsGraphicsContext::GetError() |
|
926 */ |
|
927 TInt CNvgRenderStage::GetError() |
|
928 { |
|
929 if (iExtendedBitmapError != KErrNone) |
|
930 { |
|
931 return iExtendedBitmapError; |
|
932 } |
|
933 if (iGc) |
|
934 { |
|
935 return iGc->GetError(); |
|
936 } |
|
937 return KErrNone; |
|
938 } |
|
939 |
|
940 /** @see MWsGraphicsContext::Origin() |
|
941 */ |
|
942 TPoint CNvgRenderStage::Origin() const |
|
943 { |
|
944 if (iGc) |
|
945 { |
|
946 return iGc->Origin(); |
|
947 } |
|
948 else |
|
949 { |
|
950 return TPoint(0,0); |
|
951 } |
|
952 } |
|
953 |
|
954 /** @see MWsGraphicsContext::ClippingRegion() |
|
955 */ |
|
956 const TRegion& CNvgRenderStage::ClippingRegion() |
|
957 { |
|
958 if (iGc) |
|
959 { |
|
960 return iGc->ClippingRegion(); |
|
961 } |
|
962 else |
|
963 { |
|
964 return iEmptyRegion; |
|
965 } |
|
966 } |
|
967 |
|
968 /** @see MWsGraphicsContext::Push() |
|
969 */ |
|
970 TInt CNvgRenderStage::Push() |
|
971 { |
|
972 if (iGc) |
|
973 { |
|
974 return iGc->Push(); |
|
975 } |
|
976 else |
|
977 { |
|
978 return KErrGeneral; |
|
979 } |
|
980 } |
|
981 |
|
982 /** @see MWsGraphicsContext::Pop() |
|
983 */ |
|
984 void CNvgRenderStage::Pop() |
|
985 { |
|
986 if (iGc) |
|
987 { |
|
988 iGc->Pop(); |
|
989 } |
|
990 } |
|
991 |
|
992 |
|
993 /** Helper method that draws an NVG extended bitmap into a normal bitmap. |
|
994 |
|
995 @param aExtendedBitmapSrc The extended bitmap to draw |
|
996 |
|
997 @pre aExtendedBitmapSrc must be an extended bitmap of extended bitmap type 0x39b9273e |
|
998 */ |
|
999 |
|
1000 CFbsBitmap* CNvgRenderStage::GetConvertedBitmap(const CFbsBitmap& aExtendedBitmapSrc) |
|
1001 { |
|
1002 aExtendedBitmapSrc.BeginDataAccess(); |
|
1003 const TUint8* bmpData = (const TUint8*)aExtendedBitmapSrc.DataAddress(); |
|
1004 |
|
1005 TPtr8 IconHeaderPtr((TUint8*)bmpData, KIconHeaderLength, KIconHeaderLength); |
|
1006 TAknIconHeader iconheader(IconHeaderPtr); |
|
1007 |
|
1008 TUint32 bitmapid = iconheader.GetBitmapId(); |
|
1009 TUint32 handle = aExtendedBitmapSrc.Handle(); |
|
1010 aExtendedBitmapSrc.EndDataAccess(); |
|
1011 CFbsBitmap* error = const_cast<CFbsBitmap*>(&aExtendedBitmapSrc); // not renderable, but better than panic! |
|
1012 |
|
1013 // look to see if we have this in the cache |
|
1014 iCacheIterator.SetToFirst(); |
|
1015 TCachedConversion* cached = iCacheIterator++; |
|
1016 while (cached != NULL) |
|
1017 { |
|
1018 if (cached->iBitmapID == bitmapid && cached->iDiscriminator == handle) |
|
1019 { |
|
1020 // Cache hit |
|
1021 #ifdef DEBUG_NVG_RENDERSTAGE |
|
1022 RDebug::Printf("NVG Render cache hit for id %08x, handle %d\n", bitmapid, handle); |
|
1023 #endif |
|
1024 cached->Deque(); |
|
1025 iCache.AddFirst(*cached); // move to front of the list, to record use |
|
1026 return cached->iCachedResult; |
|
1027 } |
|
1028 cached = iCacheIterator++; |
|
1029 } |
|
1030 |
|
1031 // missed in the cache, need to perform the conversion |
|
1032 TInt err = KErrNone; |
|
1033 if (iCacheFree > 0) |
|
1034 { |
|
1035 // just allocate a new entry, which will be added to the end |
|
1036 TRAP(err, cached = new(ELeave) TCachedConversion); |
|
1037 if (err != KErrNone) |
|
1038 { |
|
1039 return error; |
|
1040 } |
|
1041 TRAP(err, cached->iCachedResult = new(ELeave) CFbsBitmap); |
|
1042 if (err != KErrNone) |
|
1043 { |
|
1044 delete cached; |
|
1045 return error; |
|
1046 } |
|
1047 } |
|
1048 else |
|
1049 { |
|
1050 // Remove the least recently used item |
|
1051 cached = iCache.Last(); |
|
1052 cached->Deque(); // remove from the cache |
|
1053 iCacheFree++; |
|
1054 #ifdef DEBUG_NVG_RENDERSTAGE |
|
1055 RDebug::Printf("NVG Render cache removing id %08x, handle %d\n", cached->iBitmapID, cached->iDiscriminator); |
|
1056 #endif |
|
1057 } |
|
1058 |
|
1059 // cached is now available to hold the new result |
|
1060 cached->iBitmapID = bitmapid; |
|
1061 cached->iDiscriminator = handle; |
|
1062 |
|
1063 CopyExtendedBitmapToNormalBitmap(aExtendedBitmapSrc, *cached->iCachedResult); |
|
1064 if (iExtendedBitmapError != KErrNone) |
|
1065 { |
|
1066 delete cached; |
|
1067 return error; |
|
1068 } |
|
1069 |
|
1070 // Newly cached bitmap is valid |
|
1071 iCache.AddFirst(*cached); |
|
1072 iCacheFree--; |
|
1073 #ifdef DEBUG_NVG_RENDERSTAGE |
|
1074 RDebug::Printf("NVG Render cache added id %08x, handle %d (%d free)\n", bitmapid, handle, iCacheFree); |
|
1075 #endif |
|
1076 return cached->iCachedResult; |
|
1077 } |
|
1078 |
|
1079 /** Helper method that draws an NVG extended bitmap into a normal bitmap. The normal |
|
1080 bitmap passed is resized before the extended bitmap is drawn into it. |
|
1081 |
|
1082 @param aExtendedBitmapSrc The extended bitmap to draw in to the normal bitmap aBitmapDest |
|
1083 @param aBitmapDest The normal bitmap that the extended bitmap is to be drawn into |
|
1084 |
|
1085 @pre aExtendedBitmapSrc must be an extended bitmap of extended bitmap type 0x39b9273e |
|
1086 @post aBitmapDest has been reset and resized and now contains a representation of the aExtendedBitmapSrc |
|
1087 */ |
|
1088 |
|
1089 void CNvgRenderStage::CopyExtendedBitmapToNormalBitmap(const CFbsBitmap& aExtendedBitmapSrc, CFbsBitmap& aBitmapDst) |
|
1090 { |
|
1091 TSize size = aExtendedBitmapSrc.SizeInPixels(); |
|
1092 TInt err = aBitmapDst.Create(size, aExtendedBitmapSrc.DisplayMode()); |
|
1093 if (err != KErrNone) |
|
1094 { |
|
1095 iExtendedBitmapError = err; |
|
1096 return; |
|
1097 } |
|
1098 |
|
1099 TRAP(err, iGraphicsInterface->InitializeL(size)); |
|
1100 if (err != KErrNone) |
|
1101 { |
|
1102 iExtendedBitmapError = err; |
|
1103 return; |
|
1104 } |
|
1105 |
|
1106 // Clear to White before doing anything else |
|
1107 VGfloat color[4] = { 1.0f, 1.0f, 1.0f, 0.0f }; |
|
1108 vgSeti(VG_SCISSORING, VG_FALSE); |
|
1109 vgSetfv(VG_CLEAR_COLOR, 4, color); |
|
1110 vgClear(0, 0, size.iWidth, size.iHeight); |
|
1111 |
|
1112 aExtendedBitmapSrc.BeginDataAccess(); |
|
1113 const TUint8* bmpData = (const TUint8*)aExtendedBitmapSrc.DataAddress(); |
|
1114 |
|
1115 TPtr8 IconHeaderPtr((TUint8*)bmpData, KIconHeaderLength, KIconHeaderLength); |
|
1116 TAknIconHeader iconheader(IconHeaderPtr); |
|
1117 |
|
1118 #ifdef DEBUG_NVG_RENDERSTAGE |
|
1119 RDebug::Printf("ConvertExtendedBitmap: id=%08x size (%d x %d)\n", iconheader.GetBitmapId(), size.iWidth, size.iHeight); |
|
1120 #endif |
|
1121 |
|
1122 TInt dataSize = aExtendedBitmapSrc.DataSize(); |
|
1123 // skip TNVGIconHeader structure - we only know about version 0 |
|
1124 if (bmpData[2] == 0) |
|
1125 { |
|
1126 TInt headerlength = bmpData[3]; // should be KIconHeaderLength |
|
1127 bmpData += headerlength; |
|
1128 dataSize -= headerlength; |
|
1129 } |
|
1130 TPtrC8 nvgData(bmpData,dataSize); |
|
1131 |
|
1132 TInt rotAngle = iconheader.GetRotation(); |
|
1133 // setting the rotation angle |
|
1134 iNvgEngine->Rotate(-rotAngle, size.iWidth >> 1, size.iHeight >>1); |
|
1135 |
|
1136 //setting preserve aspect ratio |
|
1137 TNvgAlignStatusType alignTypeValue = ENvgPreserveAspectRatio_XmidYmid; |
|
1138 TNvgMeetOrSliceType meetOrSliceTypeValue = ENvgMeet; |
|
1139 |
|
1140 switch ( iconheader.GetScaleMode() ) |
|
1141 { |
|
1142 case EAspectRatioPreserved: // fall through |
|
1143 { |
|
1144 // use default |
|
1145 break; |
|
1146 } |
|
1147 // Ensures NVG content fully covers the area of the icon whilst preserving aspect ratio. |
|
1148 case EAspectRatioPreservedSlice: |
|
1149 { |
|
1150 // alignTypeValue use default |
|
1151 meetOrSliceTypeValue = ENvgSlice; |
|
1152 break; |
|
1153 } |
|
1154 /* EAspectRatioPreservedAndUnusedSpaceRemoved is mapped to the same values as EAspectRatioNotPreserved |
|
1155 * because we already have a frame buffer with the dimensions that preserves the aspect ratio. |
|
1156 * This mapping ensures that NVG engine does not calculate aspect ratio twice and potentially resulting in precision loss.*/ |
|
1157 case EAspectRatioPreservedAndUnusedSpaceRemoved: |
|
1158 case EAspectRatioNotPreserved: |
|
1159 { |
|
1160 alignTypeValue = ENvgPreserveAspectRatio_None; |
|
1161 // meetOrSliceTypeValue use default |
|
1162 break; |
|
1163 } |
|
1164 } |
|
1165 iNvgEngine->SetPreserveAspectRatio(alignTypeValue, meetOrSliceTypeValue); |
|
1166 |
|
1167 TInt error = iNvgEngine->DrawNvg(nvgData, aExtendedBitmapSrc.SizeInPixels(), &aBitmapDst, NULL); |
|
1168 aExtendedBitmapSrc.EndDataAccess(ETrue); |
|
1169 |
|
1170 TRAP(err, iGraphicsInterface->CopyBitmapL(&aBitmapDst, NULL)); |
|
1171 if (err != KErrNone) |
|
1172 { |
|
1173 iExtendedBitmapError = err; |
|
1174 return; |
|
1175 } |
|
1176 } |