1 /* |
|
2 * Copyright (c) 2005-2006 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: Render context implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <eikenv.h> // CCoeEnv |
|
20 #include <graphics.h> |
|
21 |
|
22 #include "CM2GRenderContext.h" |
|
23 #include "MM2GSVGProxy.h" |
|
24 #include "svgtbitmap.h" |
|
25 #include <ImageConversion.h> |
|
26 #include <f32file.h> |
|
27 |
|
28 M2G_NS_START |
|
29 |
|
30 // EXTERNAL DATA STRUCTURES |
|
31 |
|
32 // EXTERNAL FUNCTION PROTOTYPES |
|
33 |
|
34 // CONSTANTS |
|
35 /* static */ const TReal32 MM2GRenderContext::KFullOpaque = 1.0; |
|
36 /* static */ |
|
37 const TReal32 MM2GRenderContext::KFullTransparency = 0.0; |
|
38 /* static */ |
|
39 const TUint8 MM2GRenderContext::KMaxAlphaValue = 255; |
|
40 /* static */ |
|
41 const TDisplayMode MM2GRenderContext::KDefaultDisplayMode = EColor16MA; |
|
42 /* static */ |
|
43 const TDisplayMode MM2GRenderContext::KMaskDisplayMode = EGray256; |
|
44 |
|
45 // MACROS |
|
46 |
|
47 // LOCAL CONSTANTS AND MACROS |
|
48 |
|
49 // MODULE DATA STRUCTURES |
|
50 |
|
51 // LOCAL FUNCTION PROTOTYPES |
|
52 |
|
53 // FORWARD DECLARATIONS |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CM2GRenderContext::CM2GRenderContext |
|
57 // ----------------------------------------------------------------------------- |
|
58 CM2GRenderContext::CM2GRenderContext() |
|
59 : CBase(), |
|
60 iProxy(NULL), |
|
61 iEngineHandle(M2G_INVALID_HANDLE), |
|
62 iAlpha(MM2GRenderContext::KFullOpaque), |
|
63 iScaledAlpha(MM2GRenderContext::KMaxAlphaValue), |
|
64 iImgBmp(NULL), |
|
65 iWindowSurface(NULL) |
|
66 { |
|
67 M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::CM2GRenderContext"); |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CM2GRenderContext::NewL |
|
72 // ----------------------------------------------------------------------------- |
|
73 CM2GRenderContext* CM2GRenderContext::NewL(MM2GSVGProxy* aProxy) |
|
74 { |
|
75 M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::NewL()"); |
|
76 |
|
77 CM2GRenderContext* self = new(ELeave) CM2GRenderContext; |
|
78 CleanupStack::PushL(self); |
|
79 |
|
80 self->ConstructL(aProxy); |
|
81 |
|
82 CleanupStack::Pop(); |
|
83 |
|
84 return self; |
|
85 } |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CM2GRenderContext::~CM2GRenderContext |
|
88 // ----------------------------------------------------------------------------- |
|
89 CM2GRenderContext::~CM2GRenderContext() |
|
90 { |
|
91 M2G_DEBUG_2("M2G_DEBUG: CM2GRenderContext::~CM2GRenderContext() - proxy=%d, engine=%d", iProxy, iEngineHandle); |
|
92 if ((iEngineHandle != M2G_INVALID_HANDLE) && (iProxy != NULL)) |
|
93 { |
|
94 TRAP_IGNORE(iProxy->DeleteSvgEngineL(iEngineHandle)); |
|
95 } |
|
96 if(iWindowSurface) |
|
97 { |
|
98 delete iWindowSurface; |
|
99 } |
|
100 if(targetBitmap) |
|
101 { |
|
102 delete targetBitmap; |
|
103 } |
|
104 if(iTargetQImage) |
|
105 { |
|
106 delete iTargetQImage; |
|
107 } |
|
108 if(tempBitmapForMask) |
|
109 { |
|
110 delete tempBitmapForMask; |
|
111 } |
|
112 delete iImgBmp; |
|
113 iFbsSession.Disconnect(); |
|
114 } |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // CM2GRenderContext::BindL |
|
118 // ----------------------------------------------------------------------------- |
|
119 void CM2GRenderContext::BindL(TInt& aTargetHandle) |
|
120 { |
|
121 M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::BindL()"); |
|
122 // get the screen size |
|
123 TSize screenSize = CEikonEnv::Static()->ScreenDevice()->SizeInPixels(); |
|
124 |
|
125 iWindowSurface = (reinterpret_cast<Java::GFX::WindowSurface*>(aTargetHandle)); |
|
126 //wSurfaceType = (Java::GFX::WindowSurfaceType)iWindowSurface->getType(); |
|
127 wSurfaceType = Java::GFX::WsTypeQtImage; |
|
128 |
|
129 iWindowSurface->bind(wSurfaceType); |
|
130 |
|
131 switch(wSurfaceType) |
|
132 { |
|
133 case Java::GFX::WsTypeQtImage: |
|
134 User::LeaveIfNull(iOffScreenQImage = iWindowSurface->getQtImage()); |
|
135 targetBitmap = new CSvgtBitmap ((TInt8*)iOffScreenQImage->bits(), |
|
136 TSize(iOffScreenQImage->size().width(),iOffScreenQImage->size().height()), |
|
137 EColor16MU,iOffScreenQImage->bytesPerLine()); |
|
138 break; |
|
139 |
|
140 /*TODO for time being..case Java::GFX::WsTypeQtImage: |
|
141 User::LeaveIfNull(iTargetQImage = iWindowSurface->getQtImage()); |
|
142 InitializeQImageOffscreenBufferL(screenSize,iTargetQImage); |
|
143 break;*/ |
|
144 |
|
145 case Java::GFX::WsTypeSymbianBitmap: |
|
146 CFbsBitmap* tempBitmap; |
|
147 User::LeaveIfNull(tempBitmap = (reinterpret_cast<Java::GFX::WindowSurface*>(aTargetHandle)->getSymbianBitmap())); |
|
148 InitializeCFbsBitmapOffscreenBufferL(screenSize,tempBitmap); |
|
149 //iOffScreenBitmap = new(ELeave) CFbsBitmap(); |
|
150 break; |
|
151 |
|
152 default: |
|
153 User::Leave(KErrNotSupported); |
|
154 break; |
|
155 } |
|
156 |
|
157 } |
|
158 |
|
159 // ----------------------------------------------------------------------------- |
|
160 // CM2GRenderContext::InitializeQImageOffscreenBufferL |
|
161 // ----------------------------------------------------------------------------- |
|
162 void CM2GRenderContext::InitializeQImageOffscreenBufferL(TSize aScreenSize,QImage* aQimage) |
|
163 { |
|
164 QSize aSize; |
|
165 aSize.setHeight(aScreenSize.iHeight); |
|
166 aSize.setWidth(aScreenSize.iWidth); |
|
167 iOffScreenQImage = new QImage(aSize,aQimage->format()); |
|
168 |
|
169 //TODO For time being the format is EColor16MU |
|
170 targetBitmap = new CSvgtBitmap ((TInt8*)iOffScreenQImage->bits(), |
|
171 TSize(iOffScreenQImage->size().width(),iOffScreenQImage->size().height()), |
|
172 EColor16MU,iOffScreenQImage->bytesPerLine()); |
|
173 } |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // CM2GRenderContext::InitializeCFbsBitmapOffscreenBufferL |
|
177 // ----------------------------------------------------------------------------- |
|
178 void CM2GRenderContext::InitializeCFbsBitmapOffscreenBufferL(TSize aScreenSize,CFbsBitmap* aBitmap) |
|
179 { |
|
180 |
|
181 iOffScreenBitmap = new(ELeave) CFbsBitmap(); |
|
182 User::LeaveIfError( |
|
183 iOffScreenBitmap->Create(aScreenSize, aBitmap->DisplayMode())); |
|
184 |
|
185 // TODO check for stride in case of bitmap. |
|
186 // iTargetBitmap = new CSvgtBitmap( (TInt8*)iOffScreenBitmap->DataAddress() ,aScreenSize,iOffScreenBitmap->DisplayMode()/*KDefaultDisplayMode TODO chk this*/,iOffScreenBitmap->ScanLineLength(iOffScreenBitmap->SizeInPixels().iWidth,KDefaultDisplayMode) ); |
|
187 } |
|
188 |
|
189 // ----------------------------------------------------------------------------- |
|
190 // CM2GRenderContext::GetImgHandleL |
|
191 // ----------------------------------------------------------------------------- |
|
192 /* |
|
193 * TODO we don't need method anymore as now we need Surface handle |
|
194 * TM2GBitmapHandle CM2GRenderContext::GetImgHandleL() const |
|
195 { |
|
196 User::LeaveIfNull(iImgBmp); |
|
197 |
|
198 return REINTERPRET_CAST(TM2GBitmapHandle, iImgBmp); |
|
199 }*/ |
|
200 |
|
201 |
|
202 // ----------------------------------------------------------------------------- |
|
203 // CM2GRenderContext::InitImageBitmapL |
|
204 // ----------------------------------------------------------------------------- |
|
205 void CM2GRenderContext::InitImageBitmapL() |
|
206 { |
|
207 M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::InitImageBitmapL() - begin"); |
|
208 // get the screen size |
|
209 TSize screenSize = CEikonEnv::Static()->ScreenDevice()->SizeInPixels(); |
|
210 switch (wSurfaceType) |
|
211 { |
|
212 case Java::GFX::WsTypeQtImage: |
|
213 { |
|
214 break; |
|
215 } |
|
216 case Java::GFX::WsTypeSymbianBitmap: |
|
217 { |
|
218 break; |
|
219 } |
|
220 |
|
221 default: |
|
222 break; |
|
223 } |
|
224 M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::InitImageBitmapL() - end"); |
|
225 } |
|
226 // ----------------------------------------------------------------------------- |
|
227 // CM2GRenderContext::ReleaseL |
|
228 // ----------------------------------------------------------------------------- |
|
229 void CM2GRenderContext::ReleaseL() |
|
230 { |
|
231 M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::ReleaseL() - begin"); |
|
232 |
|
233 iTargetQImage = NULL; |
|
234 iOffScreenQImage = NULL; |
|
235 iWindowSurface->release(); |
|
236 |
|
237 M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::ReleaseL() - end"); |
|
238 } |
|
239 |
|
240 // ----------------------------------------------------------------------------- |
|
241 // CM2GRenderContext::RenderL |
|
242 // ----------------------------------------------------------------------------- |
|
243 void CM2GRenderContext::RenderLCDUIL( |
|
244 TM2GSvgDocumentHandle& aSvgDocHandle, |
|
245 const TReal32 aCurrentTime, |
|
246 TInt aSvgW, TInt aSvgH, |
|
247 TM2GRenderRect& aRect |
|
248 ) |
|
249 { |
|
250 // prepare viewbox |
|
251 TRect viewbox; |
|
252 TPoint anchor; |
|
253 |
|
254 PrepareViewbox(aRect, aSvgW, aSvgH, viewbox, anchor); |
|
255 RenderLCDUIL(aSvgDocHandle, aCurrentTime, viewbox, anchor); |
|
256 } |
|
257 |
|
258 // ----------------------------------------------------------------------------- |
|
259 void CM2GRenderContext::RenderESWTL( |
|
260 TM2GSvgDocumentHandle& aSvgDocHandle, |
|
261 const TReal32 aCurrentTime, |
|
262 TInt aSvgW, TInt aSvgH, |
|
263 TM2GRenderRect& aRect, |
|
264 TBool aUseNativeClear, |
|
265 TInt* aReturnData) |
|
266 { |
|
267 // prepare viewbox |
|
268 TRect viewbox; |
|
269 TPoint anchor; |
|
270 |
|
271 PrepareViewbox(aRect, aSvgW, aSvgH, viewbox, anchor); |
|
272 |
|
273 aReturnData[0] = 0; |
|
274 aReturnData[1] = 0; |
|
275 aReturnData[2] = 0; |
|
276 aReturnData[3] = 0; |
|
277 aReturnData[4] = anchor.iX; |
|
278 aReturnData[5] = anchor.iY; |
|
279 aReturnData[6] = viewbox.iTl.iX; |
|
280 aReturnData[7] = viewbox.iTl.iY; |
|
281 aReturnData[8] = viewbox.Width(); |
|
282 aReturnData[9] = viewbox.Height(); |
|
283 |
|
284 RenderESWTL(aSvgDocHandle, aCurrentTime, viewbox, anchor, aUseNativeClear, aReturnData); |
|
285 |
|
286 return; |
|
287 } |
|
288 // CM2GRenderContext::SetRenderingQualityL |
|
289 // ----------------------------------------------------------------------------- |
|
290 void CM2GRenderContext::SetRenderingQualityL(TInt aMode) |
|
291 { |
|
292 M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::SetRenderingQualityL()"); |
|
293 User::LeaveIfNull(iProxy); |
|
294 iProxy->RenderQualityL(iEngineHandle, aMode); |
|
295 } |
|
296 |
|
297 // ----------------------------------------------------------------------------- |
|
298 // CM2GRenderContext::SetTransparencyL |
|
299 // ----------------------------------------------------------------------------- |
|
300 void CM2GRenderContext::SetTransparency(TReal32 aAlpha) |
|
301 { |
|
302 iAlpha = aAlpha; |
|
303 iScaledAlpha = STATIC_CAST(TUint8, (aAlpha * MM2GRenderContext::KMaxAlphaValue)); |
|
304 } |
|
305 |
|
306 // ----------------------------------------------------------------------------- |
|
307 // CM2GRenderContext::ConstructL |
|
308 // ----------------------------------------------------------------------------- |
|
309 void CM2GRenderContext::ConstructL(MM2GSVGProxy* aProxy) |
|
310 { |
|
311 // Init member variables |
|
312 SetTransparency(MM2GRenderContext::KFullOpaque); |
|
313 |
|
314 M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::ConstructL() - begin"); |
|
315 |
|
316 if (aProxy) |
|
317 { |
|
318 iProxy = aProxy; |
|
319 iProxy->CreateSvgEngineL(iEngineHandle); |
|
320 M2G_DEBUG_2("M2G_DEBUG: CM2GRenderContext::ConstructL() - proxy: %d, new engine: %d", iProxy, iEngineHandle); |
|
321 } |
|
322 else |
|
323 { |
|
324 M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::ConstructL() - proxy is invalid"); |
|
325 M2G_THROW(KM2GArgNotOk); |
|
326 } |
|
327 |
|
328 User::LeaveIfError(iFbsSession.Connect()); |
|
329 M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::ConstructL() - end"); |
|
330 } |
|
331 // ----------------------------------------------------------------------------- |
|
332 // CM2GRenderContext::PrepareViewbox |
|
333 // ----------------------------------------------------------------------------- |
|
334 void CM2GRenderContext::PrepareViewbox( |
|
335 TM2GRenderRect& aRr, |
|
336 TInt aSvgW, TInt aSvgH, |
|
337 TRect& aViewbox, TPoint& aAnchor) |
|
338 { |
|
339 M2G_DEBUG_6("M2G_DEBUG: CM2GRenderContext::PrepareViewbox() cX=%d, cY=%d, cW=%d, cH=%d, anchorX=%d, anchorY=%d - begin", aRr.GetClipX(), aRr.GetClipY(), aRr.GetClipW(), aRr.GetClipH(), aRr.GetAnchorX(), aRr.GetAnchorY()); |
|
340 |
|
341 // Create an anchor point and an svg render area rect |
|
342 aAnchor.SetXY(aRr.GetAnchorX(), aRr.GetAnchorY()); |
|
343 aViewbox.SetRect(aAnchor, TSize(aSvgW, aSvgH)); |
|
344 |
|
345 // NOTE: It's already verified in Java side that the SVG render area and |
|
346 // the clip area intersects each other |
|
347 aViewbox.Intersection(aRr); |
|
348 |
|
349 // Check if the clip rect has changes the svg rect |
|
350 if (aViewbox.iTl != aAnchor) |
|
351 { |
|
352 // Update anchor position |
|
353 TPoint oldAnchor(aAnchor); |
|
354 aAnchor = aViewbox.iTl; |
|
355 |
|
356 // Update svg rect |
|
357 aViewbox.Move((-oldAnchor.iX), (-oldAnchor.iY)); |
|
358 } |
|
359 else |
|
360 { |
|
361 // The clip rect has not changed the svg rect. Only the |
|
362 // anchor position need to be updated |
|
363 aViewbox.Move(-aAnchor.iX, -aAnchor.iY); |
|
364 } |
|
365 M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::PrepareViewbox() - end"); |
|
366 } |
|
367 |
|
368 void CM2GRenderContext::RenderLCDUIL( |
|
369 TM2GSvgDocumentHandle& aSvgDocHandle, |
|
370 TReal32 aCurrentTime, |
|
371 const TRect& aViewbox, |
|
372 const TPoint& aAnchor) |
|
373 { |
|
374 M2G_DEBUG_4("M2G_DEBUG: CM2GRenderContext::RenderL() viewbox: x=%d, y=%d, w=%d, h=%d begin", aViewbox.iTl.iX, aViewbox.iTl.iY, aViewbox.Size().iWidth, aViewbox.Size().iHeight); |
|
375 |
|
376 // No need to render if content is fully transparency (i.e. alpha=0) |
|
377 if (iScaledAlpha == 0) |
|
378 { |
|
379 return; |
|
380 } |
|
381 |
|
382 QStringList list; |
|
383 list <<"QImage-Format_RGB32"; |
|
384 TBuf8<32> fname; |
|
385 |
|
386 // 1: render the svg document on the iImgBmp |
|
387 iProxy->RenderDocumentL( |
|
388 iEngineHandle, |
|
389 aSvgDocHandle, |
|
390 (TM2GSvgBitmapHandle)targetBitmap |
|
391 , (TUint)NULL, aCurrentTime); |
|
392 |
|
393 fname.Zero(); |
|
394 fname.Format(_L8("c:\\%s.bmp"), list.at(0).toLocal8Bit().constData()); |
|
395 TBool ret = iOffScreenQImage->save((const char*)fname.PtrZ()); |
|
396 |
|
397 QPixmap pixmap = QPixmap::fromImage(*iOffScreenQImage); |
|
398 tempBitmapForMask = pixmap.toSymbianCFbsBitmap(); |
|
399 |
|
400 TFileName bitmapFilename; |
|
401 bitmapFilename.Copy(_L("c:\\bugbitmap")); |
|
402 bitmapFilename.AppendNum(tempBitmapForMask->Handle()); |
|
403 bitmapFilename.Append(_L(".bmp")); |
|
404 SaveBitmapL(*tempBitmapForMask, bitmapFilename); |
|
405 |
|
406 iWindowSurface->release(); |
|
407 M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::RenderL() end"); |
|
408 } |
|
409 |
|
410 // ----------------------------------------------------------------------------- |
|
411 /*TODO |
|
412 * Write the separate RenderDocumentL method for QImage and CFbsBitmap |
|
413 * also handle subsequent BitBlt and |
|
414 * CreateAlphaBlendMaskL |
|
415 * */ |
|
416 void CM2GRenderContext::RenderESWTL( |
|
417 TM2GSvgDocumentHandle& aSvgDocHandle, |
|
418 TReal32 aCurrentTime, |
|
419 const TRect& aViewbox, |
|
420 const TPoint& aAnchor, |
|
421 TBool /*aUseNativeClear*/, |
|
422 TInt* aReturnData) |
|
423 { |
|
424 |
|
425 } |
|
426 // CM2GRenderContext::CreateAlphaBlendMask |
|
427 // ----------------------------------------------------------------------------- |
|
428 // ----------------------------------------------------------------------------- |
|
429 // CM2GRenderContext::ClearBitmapL |
|
430 // ----------------------------------------------------------------------------- |
|
431 void CM2GRenderContext::ClearBitmapL(CFbsBitmap* aBmp) |
|
432 { |
|
433 M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::ClearBitmap - begin"); |
|
434 |
|
435 User::LeaveIfNull(aBmp); |
|
436 |
|
437 TM2GBitmapLock lock(aBmp); |
|
438 |
|
439 TSize size = aBmp->SizeInPixels(); |
|
440 TInt scanlineLength = aBmp->ScanLineLength(size.iWidth, aBmp->DisplayMode()); |
|
441 |
|
442 TUint32* buf = aBmp->DataAddress(); |
|
443 char* bufBytes = REINTERPRET_CAST(char*, buf); |
|
444 |
|
445 Mem::FillZ(bufBytes, size.iHeight * scanlineLength); |
|
446 |
|
447 M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::ClearBitmap - end"); |
|
448 } |
|
449 |
|
450 |
|
451 void CM2GRenderContext::ClearSurfaceL(TM2GSvgBitmapHandle aSvgtBmpHandle ) |
|
452 { |
|
453 M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::ClearBitmap - begin"); |
|
454 //TODO As Currently we are not using this functionality. |
|
455 /* switch(wSurfaceType) |
|
456 { |
|
457 case Java::GFX::WsTypeQtImage: |
|
458 QImage* tempQImage; |
|
459 User::LeaveIfNull(tempQImage = (reinterpret_cast<Java::GFX::WindowSurface*>(aSvgtBmpHandle)->getQtImage())); |
|
460 //TODO Do we need to lock the qimage as implemented below TM2GBitmapLock lock(tempBitmap);? |
|
461 QSize sizeQimage = tempQImage->size();//TODO Check for SizeInPixels |
|
462 TInt scanlineLengthQimage = tempQImage->bytesPerLine(); |
|
463 //uchar* bufBytesQimage = REINTERPRET_CAST(uchar*, tempQImage->bits()); |
|
464 |
|
465 Mem::FillZ(tempQImage->bits(), sizeQimage.height() * scanlineLengthQimage); |
|
466 |
|
467 M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::ClearSurface Qimage Clear function- end"); |
|
468 break; |
|
469 |
|
470 case Java::GFX::WsTypeSymbianBitmap: |
|
471 CFbsBitmap* tempBitmap; |
|
472 User::LeaveIfNull(tempBitmap = (reinterpret_cast<Java::GFX::WindowSurface*>(aSvgtBmpHandle)->getSymbianBitmap())); |
|
473 TM2GBitmapLock lock(tempBitmap); |
|
474 TSize sizeBmp = tempBitmap->SizeInPixels(); |
|
475 TInt scanlineLengthBmp = tempBitmap->ScanLineLength(sizeBmp.iWidth, tempBitmap->DisplayMode()); |
|
476 TUint32* bufBmp = tempBitmap->DataAddress(); |
|
477 char* bufBytesBmp = REINTERPRET_CAST(char*, bufBmp); |
|
478 |
|
479 Mem::FillZ(bufBytesBmp, sizeBmp.iHeight * scanlineLengthBmp); |
|
480 |
|
481 M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::ClearSurface Bitmap Clear function- end"); |
|
482 break; |
|
483 |
|
484 default: |
|
485 M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::ClearBitmap Type Not Supported.- end"); |
|
486 User::Leave(KErrNotSupported); |
|
487 break; |
|
488 } |
|
489 */ |
|
490 } |
|
491 |
|
492 // ----------------------------------------------------------------------------- |
|
493 // CM2GRenderContext::FillBitmapL |
|
494 // ----------------------------------------------------------------------------- |
|
495 void CM2GRenderContext::FillBitmapL(CFbsBitmap* aBmp, const TUint8& aChar) |
|
496 { |
|
497 M2G_DEBUG_1("M2G_DEBUG: CM2GRenderContext::FillBitmap() filled with=%d - begin", aChar); |
|
498 User::LeaveIfNull(aBmp); |
|
499 TM2GBitmapLock lock(aBmp); |
|
500 |
|
501 TSize size = aBmp->SizeInPixels(); |
|
502 TInt scanlineLength = aBmp->ScanLineLength(size.iWidth, aBmp->DisplayMode()); |
|
503 |
|
504 TUint32* buf = aBmp->DataAddress(); |
|
505 char* bufBytes = REINTERPRET_CAST(char*, buf); |
|
506 |
|
507 Mem::Fill(bufBytes, size.iHeight * scanlineLength, aChar); |
|
508 |
|
509 M2G_DEBUG_0("M2G_DEBUG: CM2GRenderContext::FillBitmap - end"); |
|
510 } |
|
511 |
|
512 // ----------------------------------------------------------------------------- |
|
513 // CM2GRenderContext::GetBufferHandleL |
|
514 // ----------------------------------------------------------------------------- |
|
515 TM2GSvgBitmapHandle CM2GRenderContext::GetBufferHandleL() const |
|
516 { |
|
517 switch(wSurfaceType) |
|
518 { |
|
519 case Java::GFX::WsTypeQtImage: |
|
520 User::LeaveIfNull(iOffScreenQImage); |
|
521 return REINTERPRET_CAST(TM2GSvgBitmapHandle , iOffScreenQImage); |
|
522 break; |
|
523 |
|
524 case Java::GFX::WsTypeSymbianBitmap: |
|
525 User::LeaveIfNull(iOffScreenBitmap); |
|
526 return REINTERPRET_CAST(TM2GSvgBitmapHandle , iOffScreenBitmap); |
|
527 break; |
|
528 |
|
529 default: |
|
530 User::Leave(KErrNotSupported); |
|
531 break; |
|
532 } |
|
533 |
|
534 } |
|
535 |
|
536 //CODE to check the Bitmap Contain. |
|
537 TInt CM2GRenderContext::SaveBitmapL(const CFbsBitmap& aNVGBitmap, const TFileName& aFileName) |
|
538 { |
|
539 TFileName bitmapFilename; |
|
540 bitmapFilename.Copy(aFileName); |
|
541 RFs aFs; |
|
542 User::LeaveIfError(aFs.Connect()); |
|
543 CImageEncoder * imgEncoder = 0; |
|
544 TRequestStatus requesStatus = 0; |
|
545 imgEncoder = CImageEncoder::FileNewL(aFs, bitmapFilename, _L8("image/bmp"), CImageEncoder::EOptionAlwaysThread); |
|
546 imgEncoder->Convert(&requesStatus, aNVGBitmap); |
|
547 User::WaitForRequest(requesStatus); |
|
548 delete imgEncoder; |
|
549 aFs.Close(); |
|
550 return 0; |
|
551 } |
|
552 |
|
553 M2G_NS_END |
|