44 #include <QtGui/private/qdrawhelper_p.h> |
44 #include <QtGui/private/qdrawhelper_p.h> |
45 #include "qvg_p.h" |
45 #include "qvg_p.h" |
46 #include "qvgimagepool_p.h" |
46 #include "qvgimagepool_p.h" |
47 |
47 |
48 #ifdef QT_SYMBIAN_SUPPORTS_SGIMAGE |
48 #ifdef QT_SYMBIAN_SUPPORTS_SGIMAGE |
|
49 #include <private/qt_s60_p.h> |
|
50 #include <fbs.h> |
49 #include <graphics/sgimage.h> |
51 #include <graphics/sgimage.h> |
50 typedef EGLImageKHR (*pfnEglCreateImageKHR)(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, EGLint*); |
52 typedef EGLImageKHR (*pfnEglCreateImageKHR)(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, EGLint*); |
51 typedef EGLBoolean (*pfnEglDestroyImageKHR)(EGLDisplay, EGLImageKHR); |
53 typedef EGLBoolean (*pfnEglDestroyImageKHR)(EGLDisplay, EGLImageKHR); |
52 typedef VGImage (*pfnVgCreateEGLImageTargetKHR)(VGeglImageKHR); |
54 typedef VGImage (*pfnVgCreateEGLImageTargetKHR)(VGeglImageKHR); |
53 #endif |
55 #endif // QT_SYMBIAN_SUPPORTS_SGIMAGE |
54 |
56 |
55 QT_BEGIN_NAMESPACE |
57 QT_BEGIN_NAMESPACE |
56 |
58 |
57 static int qt_vg_pixmap_serial = 0; |
59 static int qt_vg_pixmap_serial = 0; |
58 |
60 |
423 } |
425 } |
424 return VG_INVALID_HANDLE; |
426 return VG_INVALID_HANDLE; |
425 } |
427 } |
426 |
428 |
427 #if defined(Q_OS_SYMBIAN) |
429 #if defined(Q_OS_SYMBIAN) |
|
430 |
|
431 static CFbsBitmap* createBlitCopy(CFbsBitmap* bitmap) |
|
432 { |
|
433 CFbsBitmap *copy = q_check_ptr(new CFbsBitmap); |
|
434 if(!copy) |
|
435 return 0; |
|
436 |
|
437 if (copy->Create(bitmap->SizeInPixels(), bitmap->DisplayMode()) != KErrNone) { |
|
438 delete copy; |
|
439 copy = 0; |
|
440 |
|
441 return 0; |
|
442 } |
|
443 |
|
444 CFbsBitmapDevice* bitmapDevice = 0; |
|
445 CFbsBitGc *bitmapGc = 0; |
|
446 QT_TRAP_THROWING(bitmapDevice = CFbsBitmapDevice::NewL(copy)); |
|
447 QT_TRAP_THROWING(bitmapGc = CFbsBitGc::NewL()); |
|
448 bitmapGc->Activate(bitmapDevice); |
|
449 |
|
450 bitmapGc->BitBlt(TPoint(), bitmap); |
|
451 |
|
452 delete bitmapGc; |
|
453 delete bitmapDevice; |
|
454 |
|
455 return copy; |
|
456 } |
|
457 |
428 void QVGPixmapData::cleanup() |
458 void QVGPixmapData::cleanup() |
429 { |
459 { |
430 is_null = w = h = 0; |
460 is_null = w = h = 0; |
431 recreate = false; |
461 recreate = false; |
432 source = QImage(); |
462 source = QImage(); |
508 setSerialNumber(++qt_vg_pixmap_serial); |
538 setSerialNumber(++qt_vg_pixmap_serial); |
509 // release stuff |
539 // release stuff |
510 eglDestroyImageKHR(context->display(), eglImage); |
540 eglDestroyImageKHR(context->display(), eglImage); |
511 SgDriver::Close(); |
541 SgDriver::Close(); |
512 } else if (type == QPixmapData::FbsBitmap) { |
542 } else if (type == QPixmapData::FbsBitmap) { |
513 |
543 CFbsBitmap *bitmap = reinterpret_cast<CFbsBitmap*>(pixmap); |
|
544 |
|
545 bool deleteSourceBitmap = false; |
|
546 |
|
547 #ifdef Q_SYMBIAN_HAS_EXTENDED_BITMAP_TYPE |
|
548 |
|
549 // Rasterize extended bitmaps |
|
550 |
|
551 TUid extendedBitmapType = bitmap->ExtendedBitmapType(); |
|
552 if (extendedBitmapType != KNullUid) { |
|
553 bitmap = createBlitCopy(bitmap); |
|
554 deleteSourceBitmap = true; |
|
555 } |
|
556 #endif |
|
557 |
|
558 if (bitmap->IsCompressedInRAM()) { |
|
559 bitmap = createBlitCopy(bitmap); |
|
560 deleteSourceBitmap = true; |
|
561 } |
|
562 |
|
563 TDisplayMode displayMode = bitmap->DisplayMode(); |
|
564 QImage::Format format = qt_TDisplayMode2Format(displayMode); |
|
565 |
|
566 TSize size = bitmap->SizeInPixels(); |
|
567 |
|
568 bitmap->BeginDataAccess(); |
|
569 uchar *bytes = (uchar*)bitmap->DataAddress(); |
|
570 QImage img = QImage(bytes, size.iWidth, size.iHeight, format); |
|
571 img = img.copy(); |
|
572 bitmap->EndDataAccess(); |
|
573 |
|
574 if(displayMode == EGray2) { |
|
575 //Symbian thinks set pixels are white/transparent, Qt thinks they are foreground/solid |
|
576 //So invert mono bitmaps so that masks work correctly. |
|
577 img.invertPixels(); |
|
578 } else if(displayMode == EColor16M) { |
|
579 img = img.rgbSwapped(); // EColor16M is BGR |
|
580 } |
|
581 |
|
582 fromImage(img, Qt::AutoColor); |
|
583 |
|
584 if(deleteSourceBitmap) |
|
585 delete bitmap; |
514 } |
586 } |
515 #else |
587 #else |
516 Q_UNUSED(pixmap); |
588 Q_UNUSED(pixmap); |
517 Q_UNUSED(type); |
589 Q_UNUSED(type); |
518 #endif |
590 #endif |
591 vgDestroyImage(dstVgImage); |
663 vgDestroyImage(dstVgImage); |
592 eglDestroyImageKHR(context->display(), eglImage); |
664 eglDestroyImageKHR(context->display(), eglImage); |
593 SgDriver::Close(); |
665 SgDriver::Close(); |
594 return reinterpret_cast<void*>(sgImage); |
666 return reinterpret_cast<void*>(sgImage); |
595 } else if (type == QPixmapData::FbsBitmap) { |
667 } else if (type == QPixmapData::FbsBitmap) { |
596 return 0; |
668 CFbsBitmap *bitmap = q_check_ptr(new CFbsBitmap); |
|
669 |
|
670 if (bitmap) { |
|
671 if (bitmap->Create(TSize(source.width(), source.height()), |
|
672 EColor16MAP) == KErrNone) { |
|
673 const uchar *sptr = qt_vg_imageBits(source); |
|
674 bitmap->BeginDataAccess(); |
|
675 |
|
676 uchar *dptr = (uchar*)bitmap->DataAddress(); |
|
677 Mem::Copy(dptr, sptr, source.byteCount()); |
|
678 |
|
679 bitmap->EndDataAccess(); |
|
680 } else { |
|
681 delete bitmap; |
|
682 bitmap = 0; |
|
683 } |
|
684 } |
|
685 |
|
686 return reinterpret_cast<void*>(bitmap); |
597 } |
687 } |
598 #else |
688 #else |
599 Q_UNUSED(type); |
689 Q_UNUSED(type); |
600 return 0; |
690 return 0; |
601 #endif |
691 #endif |