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