src/gui/painting/qwindowsurface_s60.cpp
changeset 19 fcece45ef507
parent 18 2f34d5167611
child 30 5dc02b23752f
equal deleted inserted replaced
18:2f34d5167611 19:fcece45ef507
    68         mode = EColor16MA; // Try for transparency anyway
    68         mode = EColor16MA; // Try for transparency anyway
    69 
    69 
    70     // We create empty CFbsBitmap here -> it will be resized in setGeometry
    70     // We create empty CFbsBitmap here -> it will be resized in setGeometry
    71     CFbsBitmap *bitmap = q_check_ptr(new CFbsBitmap);	// CBase derived object needs check on new
    71     CFbsBitmap *bitmap = q_check_ptr(new CFbsBitmap);	// CBase derived object needs check on new
    72     qt_symbian_throwIfError( bitmap->Create( TSize(0, 0), mode ) );
    72     qt_symbian_throwIfError( bitmap->Create( TSize(0, 0), mode ) );
    73 	
    73 
    74     QS60PixmapData *data = new QS60PixmapData(QPixmapData::PixmapType);
    74     QS60PixmapData *data = new QS60PixmapData(QPixmapData::PixmapType);
    75     if (data) {
    75     if (data) {
    76         data->fromSymbianBitmap(bitmap, true);
    76         data->fromSymbianBitmap(bitmap, true);
    77         d_ptr->device = QPixmap(data);
    77         d_ptr->device = QPixmap(data);
    78     }
    78     }
    79         
    79 
    80     setStaticContentsSupport(true);
    80     setStaticContentsSupport(true);
    81 }
    81 }
    82 QS60WindowSurface::~QS60WindowSurface()
    82 QS60WindowSurface::~QS60WindowSurface()
    83 {
    83 {
    84     delete d_ptr;
    84     delete d_ptr;
    87 void QS60WindowSurface::beginPaint(const QRegion &rgn)
    87 void QS60WindowSurface::beginPaint(const QRegion &rgn)
    88 {
    88 {
    89     if (!qt_widget_private(window())->isOpaque) {
    89     if (!qt_widget_private(window())->isOpaque) {
    90         QS60PixmapData *pixmapData = static_cast<QS60PixmapData *>(d_ptr->device.data_ptr().data());
    90         QS60PixmapData *pixmapData = static_cast<QS60PixmapData *>(d_ptr->device.data_ptr().data());
    91         pixmapData->beginDataAccess();
    91         pixmapData->beginDataAccess();
    92         QImage &image = pixmapData->image;
       
    93         QRgb *data = reinterpret_cast<QRgb *>(image.bits());
       
    94         const int row_stride = image.bytesPerLine() / 4;
       
    95 
    92 
       
    93         QPainter p(&pixmapData->image);
       
    94         p.setCompositionMode(QPainter::CompositionMode_Source);
    96         const QVector<QRect> rects = rgn.rects();
    95         const QVector<QRect> rects = rgn.rects();
       
    96         const QColor blank = Qt::transparent;
    97         for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
    97         for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
    98             const int x_start = it->x();
    98             p.fillRect(*it, blank);
    99             const int width = it->width();
    99         }
   100 
   100 
   101             const int y_start = it->y();
       
   102             const int height = it->height();
       
   103 
       
   104             QRgb *row = data + row_stride * y_start;
       
   105             for (int y = 0; y < height; ++y) {
       
   106                 qt_memfill(row + x_start, 0U, width);
       
   107                 row += row_stride;
       
   108             }
       
   109         }
       
   110         pixmapData->endDataAccess();
   101         pixmapData->endDataAccess();
   111     }
   102     }
   112 }
   103 }
   113 
   104 
   114 void QS60WindowSurface::endPaint(const QRegion &)
   105 void QS60WindowSurface::endPaint(const QRegion &)
   126     if (!pdev)
   117     if (!pdev)
   127         return 0;
   118         return 0;
   128 
   119 
   129     const QPoint off = offset(widget);
   120     const QPoint off = offset(widget);
   130     QImage *img = &(static_cast<QS60PixmapData *>(d_ptr->device.data_ptr().data())->image);
   121     QImage *img = &(static_cast<QS60PixmapData *>(d_ptr->device.data_ptr().data())->image);
   131     
   122 
   132     QRect rect(off, widget->size());
   123     QRect rect(off, widget->size());
   133     rect &= QRect(QPoint(), img->size());
   124     rect &= QRect(QPoint(), img->size());
   134 
   125 
   135     if (rect.isEmpty())
   126     if (rect.isEmpty())
   136         return 0;
   127         return 0;