124 m_size = IntSize(bitmap->SizeInPixels()); |
124 m_size = IntSize(bitmap->SizeInPixels()); |
125 } |
125 } |
126 |
126 |
127 BitmapImage::~BitmapImage() |
127 BitmapImage::~BitmapImage() |
128 { |
128 { |
|
129 //find if m_maskedbitmap is in m_frames so it wont get deleted twice |
|
130 for(TInt i=0; i<m_frames.size(); i++) |
|
131 { |
|
132 if(m_maskedBitmap==m_frames[i].m_frame) |
|
133 { |
|
134 //masked bitmap gets deleted when decoded data is destroyed, |
|
135 m_maskedBitmap = NULL; |
|
136 } |
|
137 } |
129 destroyDecodedData(); |
138 destroyDecodedData(); |
130 stopAnimation(); |
139 stopAnimation(); |
|
140 delete m_maskedBitmap; |
|
141 m_maskedBitmap = NULL; |
131 invalidatePlatformData(); |
142 invalidatePlatformData(); |
|
143 |
|
144 for(TInt i=0; i<m_frames.size(); i++) |
|
145 { |
|
146 m_frames[i].clear(); |
|
147 } |
|
148 m_frames.clear(); |
132 } |
149 } |
133 |
150 |
134 void BitmapImage::destroyDecodedData(bool) |
151 void BitmapImage::destroyDecodedData(bool) |
135 { |
152 { |
136 // Destroy the cached images and release them, |
153 // Destroy the cached images and release them, |
311 resourceIds.set("radioButtonOff", &radioButtonOffData); |
328 resourceIds.set("radioButtonOff", &radioButtonOffData); |
312 resourceIds.set("checkBoxOn", &checkBoxOnData); |
329 resourceIds.set("checkBoxOn", &checkBoxOnData); |
313 resourceIds.set("checkBoxOff", &checkBoxOffData); |
330 resourceIds.set("checkBoxOff", &checkBoxOffData); |
314 } |
331 } |
315 if (const IconData* data = resourceIds.get(name)) { |
332 if (const IconData* data = resourceIds.get(name)) { |
316 CMaskedBitmap* bm = loadAknIcon(data->m_id,data->m_sizeAdjust); |
333 CMaskedBitmap* bm = NULL; |
|
334 TRAP_IGNORE(bm = loadAknIconL(data->m_id,data->m_sizeAdjust)); |
317 if (bm) { |
335 if (bm) { |
318 BitmapImage* im = new BitmapImage(bm); |
336 BitmapImage* im = new BitmapImage(bm); |
319 return im; |
337 return im; |
320 } |
338 } |
321 } |
339 } |
323 } |
341 } |
324 |
342 |
325 void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst, const FloatRect& src, CompositeOperator op) |
343 void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst, const FloatRect& src, CompositeOperator op) |
326 { |
344 { |
327 WebCoreGraphicsContext* context = ctxt->platformContext(); |
345 WebCoreGraphicsContext* context = ctxt->platformContext(); |
|
346 |
328 if (!context) { |
347 if (!context) { |
329 return; |
348 return; |
330 } |
349 } |
331 |
350 |
332 CMaskedBitmap* bm = frameAtIndex(m_currentFrame); |
351 CMaskedBitmap* bm = frameAtIndex(m_currentFrame); |
346 _LIT( KBrowserSvgFile, "Webkiticons_gcce.mif" ); |
365 _LIT( KBrowserSvgFile, "Webkiticons_gcce.mif" ); |
347 #else |
366 #else |
348 _LIT( KBrowserSvgFile, "webkiticons.mif" ); |
367 _LIT( KBrowserSvgFile, "webkiticons.mif" ); |
349 #endif |
368 #endif |
350 |
369 |
|
370 static HBufC* iconFileNameBuf = NULL; |
|
371 struct cleanupIconFileName { |
|
372 ~cleanupIconFileName() { |
|
373 delete iconFileNameBuf; |
|
374 iconFileNameBuf = NULL; |
|
375 } |
|
376 }; |
|
377 struct cleanupIconFileName cleanIconFileName; |
|
378 |
351 TPtrC iconFileName() |
379 TPtrC iconFileName() |
352 { |
380 { |
353 static HBufC* filename = 0; |
381 if (!iconFileNameBuf) { |
354 if (!filename) { |
|
355 TFileName mbmDrive; |
382 TFileName mbmDrive; |
356 TParse parse; |
383 TParse parse; |
357 Dll::FileName( mbmDrive ); |
384 Dll::FileName( mbmDrive ); |
358 Dll::FileName( mbmDrive ); |
385 Dll::FileName( mbmDrive ); |
359 parse.Set( mbmDrive, NULL, NULL ); |
386 parse.Set( mbmDrive, NULL, NULL ); |
360 mbmDrive = parse.Drive(); |
387 mbmDrive = parse.Drive(); |
361 filename = HBufC::New( KMaxFileName ); |
388 iconFileNameBuf = HBufC::New( KMaxFileName ); |
362 filename->Des().Append( mbmDrive ); |
389 iconFileNameBuf->Des().Append( mbmDrive ); |
363 filename->Des().Append( KDC_APP_BITMAP_DIR ); |
390 iconFileNameBuf->Des().Append( KDC_APP_BITMAP_DIR ); |
364 filename->Des().Append( KBrowserSvgFile ); |
391 iconFileNameBuf->Des().Append( KBrowserSvgFile ); |
365 } |
392 } |
366 return *filename; |
393 return *iconFileNameBuf; |
367 } |
394 } |
368 |
395 |
369 CMaskedBitmap* loadAknIcon(int id, float sizeAdjust) |
396 CMaskedBitmap* loadAknIconL(int id, float sizeAdjust) |
370 { |
397 { |
371 CEikonEnv* eikEnv = CEikonEnv::Static(); |
398 CEikonEnv* eikEnv = CEikonEnv::Static(); |
372 CWsScreenDevice& screenDev = *eikEnv->ScreenDevice(); |
399 CWsScreenDevice& screenDev = *eikEnv->ScreenDevice(); |
|
400 CMaskedBitmap* result = NULL; |
373 |
401 |
374 int dpi = screenDev.VerticalTwipsToPixels(KTwipsPerInch); |
402 int dpi = screenDev.VerticalTwipsToPixels(KTwipsPerInch); |
375 int px = (int)10*sizeAdjust; |
403 int px = (int)10*sizeAdjust; |
376 // dpi adjustments |
404 // dpi adjustments |
377 if ((200 > dpi) && (dpi >= 120)) |
405 if ((200 > dpi) && (dpi >= 120)) |
384 px *= 4.2; |
412 px *= 4.2; |
385 |
413 |
386 CFbsBitmap* bitmap=0; |
414 CFbsBitmap* bitmap=0; |
387 CFbsBitmap* mask=0; |
415 CFbsBitmap* mask=0; |
388 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
416 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
389 TRAPD(error, AknsUtils::CreateIconL( skin, |
417 |
|
418 AknsUtils::CreateIconLC( skin, |
390 KAknsIIDDefault, |
419 KAknsIIDDefault, |
391 bitmap, |
420 bitmap, |
392 mask, |
421 mask, |
393 iconFileName(), |
422 iconFileName(), |
394 id, |
423 id, |
395 id+1)); |
424 id+1); |
396 if (error!=KErrNone) |
|
397 return 0; |
|
398 |
425 |
399 AknIconUtils::SetSize(bitmap,TSize(px,px)); //rect.Rect().Size()); |
426 AknIconUtils::SetSize(bitmap,TSize(px,px)); //rect.Rect().Size()); |
400 AknIconUtils::SetSize(mask,TSize(px,px)); //rect.Rect().Size()); |
427 AknIconUtils::SetSize(mask,TSize(px,px)); //rect.Rect().Size()); |
401 return new CMaskedBitmap(bitmap,mask); |
428 result = new (ELeave) CMaskedBitmap(bitmap,mask); |
|
429 CleanupStack::Pop( 2 );//bitmap, mask |
|
430 return result; |
402 } |
431 } |
403 |
432 |
404 CMaskedBitmap* BitmapImage::getMaskedBitmap() |
433 CMaskedBitmap* BitmapImage::getMaskedBitmap() |
405 { |
434 { |
406 if (m_maskedBitmap) |
435 if (m_maskedBitmap) |
407 return m_maskedBitmap; |
436 return m_maskedBitmap; |
408 |
437 |
409 m_maskedBitmap = m_source.createFrameAtIndex(0); |
438 return m_source.createFrameAtIndex(0); |
410 return m_maskedBitmap; |
|
411 } |
439 } |
412 |
440 |
413 void BitmapImage::drawPattern(GraphicsContext* ctxt, const FloatRect& srcRect, const AffineTransform& patternTransform, |
441 void BitmapImage::drawPattern(GraphicsContext* ctxt, const FloatRect& srcRect, const AffineTransform& patternTransform, |
414 const FloatPoint& phase, CompositeOperator, const FloatRect& dstRect) |
442 const FloatPoint& phase, CompositeOperator, const FloatRect& dstRect) |
415 { |
443 { |