Ignore:
Timestamp:
Mar 8, 2010, 12:52:58 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.2 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/openvg/qpixmapdata_vg.cpp

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4747
    4848#ifdef QT_SYMBIAN_SUPPORTS_SGIMAGE
     49#include <private/qt_s60_p.h>
     50#include <fbs.h>
    4951#include <graphics/sgimage.h>
    5052typedef EGLImageKHR (*pfnEglCreateImageKHR)(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, EGLint*);
    5153typedef EGLBoolean (*pfnEglDestroyImageKHR)(EGLDisplay, EGLImageKHR);
    5254typedef VGImage (*pfnVgCreateEGLImageTargetKHR)(VGeglImageKHR);
    53 #endif
     55#endif // QT_SYMBIAN_SUPPORTS_SGIMAGE
    5456
    5557QT_BEGIN_NAMESPACE
     
    426428
    427429#if defined(Q_OS_SYMBIAN)
     430
     431static 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
    428458void QVGPixmapData::cleanup()
    429459{
     
    511541        SgDriver::Close();
    512542    } 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;
    514586    }
    515587#else
     
    594666        return reinterpret_cast<void*>(sgImage);
    595667    } 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);
    597687    }
    598688#else
Note: See TracChangeset for help on using the changeset viewer.