1337 |
1340 |
1338 // Always set blending mode to SRC_OVER before drawing NVG content (so that the |
1341 // Always set blending mode to SRC_OVER before drawing NVG content (so that the |
1339 // drawn icons would show correctly, and no issues with transparency would arise) |
1342 // drawn icons would show correctly, and no issues with transparency would arise) |
1340 VGint blendMode = vgGeti(VG_BLEND_MODE); |
1343 VGint blendMode = vgGeti(VG_BLEND_MODE); |
1341 vgSeti(VG_BLEND_MODE, VG_BLEND_SRC_OVER); |
1344 vgSeti(VG_BLEND_MODE, VG_BLEND_SRC_OVER); |
1342 if (iIconCommands) |
1345 TAknIconHeader iconheader = GetNvgIconHeader(aNVGData); |
1343 { |
1346 TBool direct = EFalse; |
1344 //HUI_DEBUG(_L("CHuiVg10Texture::CreateRenderedImage() - Drawing iIconCommands")); |
1347 if (iconheader.IsMarginCorrection() && aSerialNumber) |
1345 iIconCommands->Draw(aDestSize, aNvgEngine); |
1348 { |
1346 } |
1349 CFbsBitmap* entry = CHuiStatic::Env().AppIconCache().Find(aSerialNumber, aDestSize); |
1347 else |
1350 if (entry) |
1348 { |
1351 { |
1349 // If ObjectCached version failed, try to use the old way |
1352 TSize entrySize = entry->SizeInPixels(); |
1350 //HUI_DEBUG(_L("CHuiVg10Texture::CreateRenderedImage() - Drawing with DrawNvg")); |
1353 entry->BeginDataAccess(); |
1351 aNvgEngine->DrawNvg(GetNvgDataWithoutHeader(aNVGData), aDestSize, NULL, NULL); |
1354 TUint8* dataPtr = (TUint8*)entry->DataAddress(); |
|
1355 vgImageSubData(image, dataPtr, CFbsBitmap::ScanLineLength(entrySize.iWidth, EColor16MAP), VG_sARGB_8888_PRE, 0, 0, entrySize.iWidth, entrySize.iHeight); |
|
1356 entry->EndDataAccess(); |
|
1357 direct = ETrue; |
|
1358 } |
|
1359 } |
|
1360 |
|
1361 if (!direct) |
|
1362 { |
|
1363 if (iIconCommands) |
|
1364 { |
|
1365 //HUI_DEBUG(_L("CHuiVg10Texture::CreateRenderedImage() - Drawing iIconCommands")); |
|
1366 iIconCommands->Draw(aDestSize, aNvgEngine); |
|
1367 } |
|
1368 else |
|
1369 { |
|
1370 // If ObjectCached version failed, try to use the old way |
|
1371 //HUI_DEBUG(_L("CHuiVg10Texture::CreateRenderedImage() - Drawing with DrawNvg")); |
|
1372 aNvgEngine->DrawNvg(GetNvgDataWithoutHeader(aNVGData), aDestSize, NULL, NULL); |
|
1373 } |
1352 } |
1374 } |
1353 |
1375 |
1354 // NVG-TLV icon margin special case check: |
1376 // NVG-TLV icon margin special case check: |
1355 // Check, if the icon has to be margin corrected |
1377 // Check, if the icon has to be margin corrected |
1356 TAknIconHeader iconheader = GetNvgIconHeader(aNVGData); |
|
1357 TSize size = aDestSize; // For using the correct size also later on |
1378 TSize size = aDestSize; // For using the correct size also later on |
1358 if (iconheader.IsMarginCorrection()) |
1379 if (iconheader.IsMarginCorrection() && !direct) |
1359 { |
1380 { |
1360 size = ApplyMargin(image, aDestSize, display, newSurface, context); |
1381 size = ApplyMargin(image, aDestSize, display, newSurface, context); |
1361 if( size != aDestSize) |
1382 if( size != aDestSize) |
1362 { |
1383 { |
1363 // Redo the drawing, this time to the correct size |
1384 // Redo the drawing, this time to the correct size |
1364 if (iIconCommands) |
1385 if (iIconCommands) |
1365 iIconCommands->Draw(size, aNvgEngine); |
1386 iIconCommands->Draw(size, aNvgEngine); |
1366 else |
1387 else |
1367 aNvgEngine->DrawNvg(GetNvgDataWithoutHeader(aNVGData), size, NULL, NULL); |
1388 aNvgEngine->DrawNvg(GetNvgDataWithoutHeader(aNVGData), size, NULL, NULL); |
|
1389 } |
|
1390 // assume 32bpp for the icon, don't cache if it's too large |
|
1391 TInt bitmapBytes = aDestSize.iWidth*aDestSize.iHeight*4; |
|
1392 if (bitmapBytes < 128*128*4) |
|
1393 { |
|
1394 // can't leave here (we would screw up the transformation matrix |
|
1395 // for the primary surface) |
|
1396 CFbsBitmap* rasterizedIcon = new CFbsBitmap; |
|
1397 TInt rastererr(KErrNone); |
|
1398 if (rasterizedIcon) |
|
1399 { |
|
1400 rastererr = rasterizedIcon->Create(aDestSize, EColor16MAP); |
|
1401 } |
|
1402 if (!rastererr) |
|
1403 { |
|
1404 rasterizedIcon->BeginDataAccess(); |
|
1405 TUint8* dataPtr = (TUint8*)rasterizedIcon->DataAddress(); |
|
1406 vgGetImageSubData(image, dataPtr, CFbsBitmap::ScanLineLength(aDestSize.iWidth, EColor16MAP), VG_sARGB_8888_PRE, 0, 0, aDestSize.iWidth, aDestSize.iHeight); |
|
1407 rasterizedIcon->EndDataAccess(); |
|
1408 // store for future use.... |
|
1409 TRasterizedBitmap rbmp(aSerialNumber, rasterizedIcon); |
|
1410 rastererr = CHuiStatic::Env().AppIconCache().Insert(rbmp); |
|
1411 } |
|
1412 // either the bitmap creation failed, or cache insert failed |
|
1413 // delete the bitmap so that we don't leak memory |
|
1414 if (rastererr) |
|
1415 { |
|
1416 delete rasterizedIcon; |
|
1417 } |
1368 } |
1418 } |
1369 } |
1419 } |
1370 |
1420 |
1371 // restore the old surface before restoring original modes |
1421 // restore the old surface before restoring original modes |
1372 oldSurface->MakeCurrent(); // This will also call the SetCurrentRenderSurface |
1422 oldSurface->MakeCurrent(); // This will also call the SetCurrentRenderSurface |