1333 vgLoadIdentity(); |
1333 vgLoadIdentity(); |
1334 |
1334 |
1335 // Render the NVGtexture into the image buffer. No transformations are done for this. |
1335 // Render the NVGtexture into the image buffer. No transformations are done for this. |
1336 SetNvgParamsFromIconHeader(*aNvgEngine, aNVGData); |
1336 SetNvgParamsFromIconHeader(*aNvgEngine, aNVGData); |
1337 |
1337 |
|
1338 // 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) |
|
1340 VGint blendMode = vgGeti(VG_BLEND_MODE); |
|
1341 vgSeti(VG_BLEND_MODE, VG_BLEND_SRC_OVER); |
1338 if (iIconCommands) |
1342 if (iIconCommands) |
1339 { |
1343 { |
1340 //HUI_DEBUG(_L("CHuiVg10Texture::CreateRenderedImage() - Drawing iIconCommands")); |
1344 //HUI_DEBUG(_L("CHuiVg10Texture::CreateRenderedImage() - Drawing iIconCommands")); |
1341 iIconCommands->Draw(aDestSize, aNvgEngine); |
1345 iIconCommands->Draw(aDestSize, aNvgEngine); |
1342 } |
1346 } |
1343 else |
1347 else |
1344 { |
1348 { |
1345 // If ObjectCached version failed, try to use the old way |
1349 // If ObjectCached version failed, try to use the old way |
1346 //HUI_DEBUG(_L("CHuiVg10Texture::CreateRenderedImage() - Drawing with DrawNvg")); |
1350 //HUI_DEBUG(_L("CHuiVg10Texture::CreateRenderedImage() - Drawing with DrawNvg")); |
1347 VGint blendMode = vgGeti(VG_BLEND_MODE); |
|
1348 vgSeti(VG_BLEND_MODE, VG_BLEND_SRC_OVER); |
|
1349 aNvgEngine->DrawNvg(GetNvgDataWithoutHeader(aNVGData), aDestSize, NULL, NULL); |
1351 aNvgEngine->DrawNvg(GetNvgDataWithoutHeader(aNVGData), aDestSize, NULL, NULL); |
1350 vgSeti(VG_BLEND_MODE, blendMode); |
|
1351 } |
1352 } |
1352 |
1353 |
1353 // NVG-TLV icon margin special case check: |
1354 // NVG-TLV icon margin special case check: |
1354 // Check, if the icon has to be margin corrected |
1355 // Check, if the icon has to be margin corrected |
1355 TAknIconHeader iconheader = GetNvgIconHeader(aNVGData); |
1356 TAknIconHeader iconheader = GetNvgIconHeader(aNVGData); |
1364 iIconCommands->Draw(size, aNvgEngine); |
1365 iIconCommands->Draw(size, aNvgEngine); |
1365 else |
1366 else |
1366 aNvgEngine->DrawNvg(GetNvgDataWithoutHeader(aNVGData), size, NULL, NULL); |
1367 aNvgEngine->DrawNvg(GetNvgDataWithoutHeader(aNVGData), size, NULL, NULL); |
1367 } |
1368 } |
1368 } |
1369 } |
1369 |
1370 |
|
1371 // restore the old surface before restoring original modes |
|
1372 oldSurface->MakeCurrent(); // This will also call the SetCurrentRenderSurface |
|
1373 |
|
1374 // Return the original blend mode |
|
1375 vgSeti(VG_BLEND_MODE, blendMode); |
1370 // The NVG draw messes up the paint, scissoring & rects, so mark them as dirty |
1376 // The NVG draw messes up the paint, scissoring & rects, so mark them as dirty |
1371 TInt dirtyFlags = EHuiVg10GcStateFlagDirtyPaint | |
1377 TInt dirtyFlags = EHuiVg10GcStateFlagDirtyPaint | |
1372 EHuiVg10GcStateFlagDirtyScissor | |
1378 EHuiVg10GcStateFlagDirtyScissor | |
1373 EHuiVg10GcStateFlagDirtyScissorRects; |
1379 EHuiVg10GcStateFlagDirtyScissorRects; |
1374 iRenderPlugin.AddRestoreStateFlags(dirtyFlags); |
1380 iRenderPlugin.AddRestoreStateFlags(dirtyFlags); |
1385 |
1391 |
1386 HUI_VG_INVARIANT(); |
1392 HUI_VG_INVARIANT(); |
1387 |
1393 |
1388 vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); |
1394 vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); |
1389 vgLoadMatrix(matrix); |
1395 vgLoadMatrix(matrix); |
1390 oldSurface->MakeCurrent(); // This will also call the SetCurrentRenderSurface |
|
1391 |
1396 |
1392 // Now we should have a rendered image in the image variable! |
1397 // Now we should have a rendered image in the image variable! |
1393 // Release the surface, but not the context because we used a shared context |
1398 // Release the surface, but not the context because we used a shared context |
1394 if ( newSurface != EGL_NO_SURFACE ) |
1399 if ( newSurface != EGL_NO_SURFACE ) |
1395 { |
1400 { |
1510 } |
1515 } |
1511 |
1516 |
1512 TSize CHuiVg10Texture::ApplyMargin(VGImage aImage, TSize aSize, EGLDisplay aDisplay, EGLSurface aSurface, EGLContext aContext) |
1517 TSize CHuiVg10Texture::ApplyMargin(VGImage aImage, TSize aSize, EGLDisplay aDisplay, EGLSurface aSurface, EGLContext aContext) |
1513 { |
1518 { |
1514 HUI_VG_INVARIANT(); |
1519 HUI_VG_INVARIANT(); |
1515 #ifdef __WINSCW__ |
1520 |
1516 if ( eglMakeCurrent( aDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT ) == EGL_FALSE ) |
1521 #ifndef __WINSCW__ // Should possibly query the supported mode instead? |
1517 { |
|
1518 HUI_DEBUG1(_L("CHuiVg10Texture::ApplyMargin() - EGL NO_Surface could not be made current, eglErr: %04x"), eglGetError()); |
|
1519 return aSize; |
|
1520 } |
|
1521 #endif |
|
1522 #ifndef __WINS__ // Should possibly query the supported mode instead? |
|
1523 VGImageFormat imageInternalFormat = VG_sARGB_8888_PRE; |
1522 VGImageFormat imageInternalFormat = VG_sARGB_8888_PRE; |
1524 #else |
1523 #else |
1525 // This doesn't work in the Emulator anyways.. => remove? |
1524 // This doesn't work in the Emulator anyways.. => remove? |
1526 VGImageFormat imageInternalFormat = VG_sARGB_8888; |
1525 VGImageFormat imageInternalFormat = VG_sARGB_8888; |
|
1526 |
|
1527 // If the icon is also a current EGL surface, the getImageSubData |
|
1528 // won't succeed and return "image in use" -error.. |
|
1529 if ( eglMakeCurrent( aDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT ) == EGL_FALSE ) |
|
1530 { |
|
1531 HUI_DEBUG1(_L("CHuiVg10Texture::ApplyMargin() - EGL NO_Surface could not be made current, eglErr: %04x"), eglGetError()); |
|
1532 return aSize; |
|
1533 } |
1527 #endif |
1534 #endif |
1528 |
1535 |
1529 TInt stride = aSize.iWidth * 4; // VG_sARGB_8888(_PRE) is four bytes long (8888) |
1536 TInt stride = aSize.iWidth * 4; // VG_sARGB_8888(_PRE) is four bytes long (8888) |
1530 HBufC8* buf = HBufC8::New(stride); |
1537 HBufC8* buf = HBufC8::New(stride); |
1531 if (!buf) |
1538 if (!buf) |
1565 } |
1572 } |
1566 } |
1573 } |
1567 } |
1574 } |
1568 delete buf; |
1575 delete buf; |
1569 HUI_VG_INVARIANT(); |
1576 HUI_VG_INVARIANT(); |
1570 #ifdef __WINSCW__ |
1577 |
|
1578 #ifdef __WINSCW__ |
1571 // Make the PBuffer surface current again |
1579 // Make the PBuffer surface current again |
1572 if ( eglMakeCurrent(aDisplay, aSurface, aSurface, aContext) == EGL_FALSE ) |
1580 if ( eglMakeCurrent(aDisplay, aSurface, aSurface, aContext) == EGL_FALSE ) |
1573 { |
1581 { |
1574 HUI_DEBUG1(_L("CHuiVg10Texture::ApplyMargin() - EGL aSurface could not be made current, eglErr: %04x"), eglGetError()); |
1582 HUI_DEBUG1(_L("CHuiVg10Texture::ApplyMargin() - EGL aSurface could not be made current, eglErr: %04x"), eglGetError()); |
1575 return aSize; |
1583 return aSize; |
1576 } |
1584 } |
1577 #endif |
1585 #endif |
|
1586 |
1578 // If icon size has to be changed, clear out old area for new DrawNVG round! |
1587 // If icon size has to be changed, clear out old area for new DrawNVG round! |
1579 if(aSize.iHeight > HaN) |
1588 if(aSize.iHeight > HaN) |
1580 { |
1589 { |
1581 vgLoadIdentity(); |
1590 vgLoadIdentity(); |
1582 |
1591 |