From 45134e5dda238e42b89a407464911ac05f214cac Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Fri, 24 Sep 2010 16:47:41 +0200 Subject: Make sure the QS60PaintEngine can draw other classes of pixmap data The QS60PaintEngine should not assume that the pixmap is always of type 'Raster'. It should check the classId and if it is not 'Raster' it should forward the call to QRasterPaintEngine which already handles this scenario by converting the pixmap to a QImage and drawing that instead. Reviewed-by: Jani Hautakangas --- src/gui/painting/qpaintengine_s60.cpp | 63 +++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/src/gui/painting/qpaintengine_s60.cpp b/src/gui/painting/qpaintengine_s60.cpp index 068ca0c..d7fc0af 100644 --- a/src/gui/painting/qpaintengine_s60.cpp +++ b/src/gui/painting/qpaintengine_s60.cpp @@ -59,44 +59,63 @@ bool QS60PaintEngine::begin(QPaintDevice *device) { Q_D(QS60PaintEngine); - pixmapData->beginDataAccess(); - bool ret = QRasterPaintEngine::begin(device); - // Make sure QPaintEngine::paintDevice() returns the proper device. - // QRasterPaintEngine changes pdev to QImage in case of RasterClass QPixmapData - // which is incorrect in Symbian. - d->pdev = device; - return ret; + if (pixmapData->classId() == QPixmapData::RasterClass) { + pixmapData->beginDataAccess(); + bool ret = QRasterPaintEngine::begin(device); + // Make sure QPaintEngine::paintDevice() returns the proper device. + // QRasterPaintEngine changes pdev to QImage in case of RasterClass QPixmapData + // which is incorrect in Symbian. + d->pdev = device; + return ret; + } + + return QRasterPaintEngine::begin(device); } bool QS60PaintEngine::end() { - bool ret = QRasterPaintEngine::end(); - pixmapData->endDataAccess(); - return ret; + if (pixmapData->classId() == QPixmapData::RasterClass) { + bool ret = QRasterPaintEngine::end(); + pixmapData->endDataAccess(); + return ret; + } + return QRasterPaintEngine::end(); } void QS60PaintEngine::drawPixmap(const QPointF &p, const QPixmap &pm) { - QS60PixmapData *srcData = static_cast(pm.pixmapData()); - srcData->beginDataAccess(); - QRasterPaintEngine::drawPixmap(p, pm); - srcData->endDataAccess(); + if (pm.pixmapData()->classId() == QPixmapData::RasterClass) { + QS60PixmapData *srcData = static_cast(pm.pixmapData()); + srcData->beginDataAccess(); + QRasterPaintEngine::drawPixmap(p, pm); + srcData->endDataAccess(); + } else { + QRasterPaintEngine::drawPixmap(p, pm); + } } void QS60PaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) { - QS60PixmapData *srcData = static_cast(pm.pixmapData()); - srcData->beginDataAccess(); - QRasterPaintEngine::drawPixmap(r, pm, sr); - srcData->endDataAccess(); + if (pm.pixmapData()->classId() == QPixmapData::RasterClass) { + QS60PixmapData *srcData = static_cast(pm.pixmapData()); + srcData->beginDataAccess(); + QRasterPaintEngine::drawPixmap(r, pm, sr); + srcData->endDataAccess(); + } else { + QRasterPaintEngine::drawPixmap(r, pm, sr); + } } void QS60PaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &sr) { - QS60PixmapData *srcData = static_cast(pm.pixmapData()); - srcData->beginDataAccess(); - QRasterPaintEngine::drawTiledPixmap(r, pm, sr); - srcData->endDataAccess(); + if (pm.pixmapData()->classId() == QPixmapData::RasterClass) { + QS60PixmapData *srcData = static_cast(pm.pixmapData()); + srcData->beginDataAccess(); + QRasterPaintEngine::drawTiledPixmap(r, pm, sr); + srcData->endDataAccess(); + } else { + QRasterPaintEngine::drawTiledPixmap(r, pm, sr); + } } void QS60PaintEngine::prepare(QImage *image) -- cgit v0.12 From 83567e2dd93ad46cff2b3b611e298148e7d60f62 Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Mon, 27 Sep 2010 10:54:38 +0200 Subject: Minor OpenVG optimization when setting the EGL surface attribute. Calling eglGetError() is expensive so we should avoid doing it unless we know there actually is an error. The function returns EGL_FALSE upon error so we can test for that instead of using eglGetError(). Reviewed-by: Jani Hautakangas --- src/openvg/qwindowsurface_vgegl.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/openvg/qwindowsurface_vgegl.cpp b/src/openvg/qwindowsurface_vgegl.cpp index e3f52f4e..37e5f40 100644 --- a/src/openvg/qwindowsurface_vgegl.cpp +++ b/src/openvg/qwindowsurface_vgegl.cpp @@ -709,10 +709,9 @@ QEglContext *QVGEGLWindowSurfaceDirect::ensureContext(QWidget *widget) #if !defined(QVG_NO_PRESERVED_SWAP) // Try to force the surface back buffer to preserve its contents. if (needToSwap) { - eglGetError(); // Clear error state first. - eglSurfaceAttrib(QEgl::display(), windowSurface, + bool succeeded = eglSurfaceAttrib(QEgl::display(), windowSurface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED); - if (eglGetError() != EGL_SUCCESS) { + if (!succeeded && eglGetError() != EGL_SUCCESS) { qWarning("QVG: could not enable preserved swap"); } } -- cgit v0.12