summaryrefslogtreecommitdiffstats
path: root/src/openvg
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@nokia.com>2009-09-30 12:00:23 (GMT)
committerPaul Olav Tvete <paul.tvete@nokia.com>2009-09-30 12:00:23 (GMT)
commit801a3780c9d029a288f60ddc4485ce34bd7fa94f (patch)
treeff0728320e1938908912506ab776299af6d45543 /src/openvg
parent2ff6c9e8d89590c8180769bd54e545f40ca9a56f (diff)
parent8d3d7d411491e50c1c6a62f473a1fa69a3ca2773 (diff)
downloadQt-801a3780c9d029a288f60ddc4485ce34bd7fa94f.zip
Qt-801a3780c9d029a288f60ddc4485ce34bd7fa94f.tar.gz
Qt-801a3780c9d029a288f60ddc4485ce34bd7fa94f.tar.bz2
Merge branch '4.6' into lighthouse
Conflicts: configure src/gui/image/qpixmapdatafactory.cpp src/gui/kernel/qapplication_p.h src/gui/painting/qgraphicssystem.cpp
Diffstat (limited to 'src/openvg')
-rw-r--r--src/openvg/qpaintengine_vg.cpp169
-rw-r--r--src/openvg/qpaintengine_vg_p.h12
-rw-r--r--src/openvg/qpixmapdata_vg.cpp203
-rw-r--r--src/openvg/qpixmapdata_vg_p.h22
-rw-r--r--src/openvg/qpixmapfilter_vg.cpp8
-rw-r--r--src/openvg/qpixmapfilter_vg_p.h8
-rw-r--r--src/openvg/qvg.h8
-rw-r--r--src/openvg/qvg_p.h17
-rw-r--r--src/openvg/qvgcompositionhelper_p.h8
-rw-r--r--src/openvg/qwindowsurface_vg.cpp9
-rw-r--r--src/openvg/qwindowsurface_vg_p.h8
-rw-r--r--src/openvg/qwindowsurface_vgegl.cpp147
-rw-r--r--src/openvg/qwindowsurface_vgegl_p.h8
13 files changed, 428 insertions, 199 deletions
diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp
index e9e1137..b129164 100644
--- a/src/openvg/qpaintengine_vg.cpp
+++ b/src/openvg/qpaintengine_vg.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtOpenVG module of the Qt Toolkit.
@@ -20,10 +21,9 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
@@ -52,6 +52,7 @@
#include <QtGui/private/qtextureglyphcache_p.h>
#include <QtGui/private/qtextengine_p.h>
#include <QtGui/private/qfontengine_p.h>
+#include <QtGui/private/qpainterpath_p.h>
#include <QDebug>
#include <QSet>
@@ -131,6 +132,7 @@ public:
void fill(VGPath path, const QBrush& brush, VGint rule = VG_EVEN_ODD);
VGPath vectorPathToVGPath(const QVectorPath& path);
VGPath painterPathToVGPath(const QPainterPath& path);
+ VGPath roundedRectPath(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode);
VGPaintType setBrush
(VGPaint paint, const QBrush& brush, VGMatrixMode mode,
VGPaintType prevPaintType);
@@ -172,6 +174,7 @@ public:
#if !defined(QVG_NO_MODIFY_PATH)
VGPath rectPath; // Cached path for quick drawing of rectangles.
VGPath linePath; // Cached path for quick drawing of lines.
+ VGPath roundRectPath; // Cached path for quick drawing of rounded rects.
#endif
QTransform transform; // Currently active transform.
@@ -211,6 +214,11 @@ public:
QVGFontEngineCleaner *fontEngineCleaner;
#endif
+ QScopedPointer<QPixmapFilter> convolutionFilter;
+ QScopedPointer<QPixmapFilter> colorizeFilter;
+ QScopedPointer<QPixmapFilter> dropShadowFilter;
+ QScopedPointer<QPixmapFilter> blurFilter;
+
// Ensure that the path transform is properly set in the VG context
// before we perform a vgDrawPath() operation.
inline void ensurePathTransform()
@@ -336,6 +344,7 @@ void QVGPaintEnginePrivate::init()
#if !defined(QVG_NO_MODIFY_PATH)
rectPath = 0;
linePath = 0;
+ roundRectPath = 0;
#endif
simpleTransform = true;
@@ -448,6 +457,8 @@ void QVGPaintEnginePrivate::destroy()
vgDestroyPath(rectPath);
if (linePath)
vgDestroyPath(linePath);
+ if (roundRectPath)
+ vgDestroyPath(roundRectPath);
#endif
#if !defined(QVG_NO_DRAW_GLYPHS)
@@ -555,11 +566,11 @@ VGPath QVGPaintEnginePrivate::vectorPathToVGPath(const QVectorPath& path)
case QPainterPath::LineToElement:
segments.append(VG_LINE_TO_ABS); break;
- case QPainterPath::CurveToElement: break;
-
- case QPainterPath::CurveToDataElement:
+ case QPainterPath::CurveToElement:
segments.append(VG_CUBIC_TO_ABS); break;
+ case QPainterPath::CurveToDataElement: break;
+
}
}
if (path.hasImplicitClose())
@@ -874,6 +885,83 @@ VGPath QVGPaintEnginePrivate::painterPathToVGPath(const QPainterPath& path)
return vgpath;
}
+VGPath QVGPaintEnginePrivate::roundedRectPath(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode)
+{
+ static VGubyte roundedrect_types[] = {
+ VG_MOVE_TO_ABS,
+ VG_LINE_TO_ABS,
+ VG_CUBIC_TO_ABS,
+ VG_LINE_TO_ABS,
+ VG_CUBIC_TO_ABS,
+ VG_LINE_TO_ABS,
+ VG_CUBIC_TO_ABS,
+ VG_LINE_TO_ABS,
+ VG_CUBIC_TO_ABS,
+ VG_CLOSE_PATH
+ };
+
+ qreal x1 = rect.left();
+ qreal x2 = rect.right();
+ qreal y1 = rect.top();
+ qreal y2 = rect.bottom();
+
+ if (mode == Qt::RelativeSize) {
+ xRadius = xRadius * rect.width() / 200.;
+ yRadius = yRadius * rect.height() / 200.;
+ }
+
+ xRadius = qMin(xRadius, rect.width() / 2);
+ yRadius = qMin(yRadius, rect.height() / 2);
+
+ VGfloat pts[] = {
+ x1 + xRadius, y1, // MoveTo
+ x2 - xRadius, y1, // LineTo
+ x2 - (1 - KAPPA) * xRadius, y1, // CurveTo
+ x2, y1 + (1 - KAPPA) * yRadius,
+ x2, y1 + yRadius,
+ x2, y2 - yRadius, // LineTo
+ x2, y2 - (1 - KAPPA) * yRadius, // CurveTo
+ x2 - (1 - KAPPA) * xRadius, y2,
+ x2 - xRadius, y2,
+ x1 + xRadius, y2, // LineTo
+ x1 + (1 - KAPPA) * xRadius, y2, // CurveTo
+ x1, y2 - (1 - KAPPA) * yRadius,
+ x1, y2 - yRadius,
+ x1, y1 + yRadius, // LineTo
+ x1, y1 + KAPPA * yRadius, // CurveTo
+ x1 + (1 - KAPPA) * xRadius, y1,
+ x1 + xRadius, y1
+ };
+
+#if !defined(QVG_NO_MODIFY_PATH)
+ VGPath vgpath = roundRectPath;
+ if (!vgpath) {
+ vgpath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
+ VG_PATH_DATATYPE_F,
+ 1.0f, // scale
+ 0.0f, // bias
+ 10, // segmentCapacityHint
+ 17 * 2, // coordCapacityHint
+ VG_PATH_CAPABILITY_ALL);
+ vgAppendPathData(vgpath, 10, roundedrect_types, pts);
+ roundRectPath = vgpath;
+ } else {
+ vgModifyPathCoords(vgpath, 0, 9, pts);
+ }
+#else
+ VGPath vgpath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
+ VG_PATH_DATATYPE_F,
+ 1.0f, // scale
+ 0.0f, // bias
+ 10, // segmentCapacityHint
+ 17 * 2, // coordCapacityHint
+ VG_PATH_CAPABILITY_ALL);
+ vgAppendPathData(vgpath, 10, roundedrect_types, pts);
+#endif
+
+ return vgpath;
+}
+
extern QImage qt_imageForBrush(int style, bool invert);
static QImage colorizeBitmap(const QImage &image, const QColor &color)
@@ -2004,7 +2092,7 @@ void QVGPaintEngine::updateScissor()
if (region.isEmpty())
region = d->maskRect;
else
- region.intersect(d->maskRect);
+ region = region.intersect(d->maskRect);
if (isDefaultClipRegion(region)) {
// The scissor region is the entire drawing surface,
// so there is no point doing any scissoring.
@@ -2327,6 +2415,21 @@ void QVGPaintEngine::fillRect(const QRectF &rect, const QColor &color)
#endif
}
+void QVGPaintEngine::drawRoundedRect(const QRectF &rect, qreal xrad, qreal yrad, Qt::SizeMode mode)
+{
+ Q_D(QVGPaintEngine);
+ if (d->simpleTransform) {
+ QVGPainterState *s = state();
+ VGPath vgpath = d->roundedRectPath(rect, xrad, yrad, mode);
+ d->draw(vgpath, s->pen, s->brush);
+#if defined(QVG_NO_MODIFY_PATH)
+ vgDestroyPath(vgpath);
+#endif
+ } else {
+ QPaintEngineEx::drawRoundedRect(rect, xrad, yrad, mode);
+ }
+}
+
void QVGPaintEngine::drawRects(const QRect *rects, int rectCount)
{
#if !defined(QVG_NO_MODIFY_PATH)
@@ -2920,20 +3023,6 @@ void QVGFontGlyphCache::cacheGlyphs
VGImage vgImage = VG_INVALID_HANDLE;
metrics = ti.fontEngine->boundingBox(glyph);
if (!scaledImage.isNull()) { // Not a space character
- // The QPF implementation of alphaMapForGlyph() uses the color
- // RGBA = (value, value, value, 255) instead of the color
- // RGBA = (0, 0, 0, value) that the other font engines use.
- // We modify the image colors to rectify this situation.
- QFontEngine::Type type = ti.fontEngine->type();
- if (type == QFontEngine::QPF1 || type == QFontEngine::QPF2) {
- if (scaledImage.format() == QImage::Format_Indexed8) {
- for (int i = 0; i < 256; ++i)
- scaledImage.setColor(i, qRgba(0, 0, 0, i));
- } else if (scaledImage.format() == QImage::Format_Mono) {
- scaledImage.setColor(0, qRgba(0, 0, 0, 0));
- scaledImage.setColor(1, qRgba(0, 0, 0, 255));
- }
- }
if (scaledImage.format() == QImage::Format_Indexed8) {
vgImage = vgCreateImage(VG_A_8, scaledImage.width(), scaledImage.height(), VG_IMAGE_QUALITY_FASTER);
vgImageSubData(vgImage, scaledImage.bits(), scaledImage.bytesPerLine(), VG_A_8, 0, 0, scaledImage.width(), scaledImage.height());
@@ -3110,20 +3199,34 @@ void QVGPaintEngine::endNativePainting()
vgSetPaint(d->brushPaint, VG_FILL_PATH);
}
-QPixmapFilter *QVGPaintEngine::createPixmapFilter(int type) const
+QPixmapFilter *QVGPaintEngine::pixmapFilter(int type, const QPixmapFilter *prototype)
{
#if !defined(QT_SHIVAVG)
- if (type == QPixmapFilter::ConvolutionFilter)
- return new QVGPixmapConvolutionFilter;
- else if (type == QPixmapFilter::ColorizeFilter)
- return new QVGPixmapColorizeFilter;
- else if (type == QPixmapFilter::DropShadowFilter)
- return new QVGPixmapDropShadowFilter;
- else if (type == QPixmapFilter::BlurFilter)
- return new QVGPixmapBlurFilter;
- else
+ Q_D(QVGPaintEngine);
+ switch (type) {
+ case QPixmapFilter::ConvolutionFilter:
+ if (!d->convolutionFilter)
+ d->convolutionFilter.reset(new QVGPixmapConvolutionFilter);
+ return d->convolutionFilter.data();
+ case QPixmapFilter::ColorizeFilter:
+ // Strength parameter does not work with current implementation.
+ if ((static_cast<const QPixmapColorizeFilter *>(prototype))->strength() != 1.0f)
+ break;
+ if (!d->colorizeFilter)
+ d->colorizeFilter.reset(new QVGPixmapColorizeFilter);
+ return d->colorizeFilter.data();
+ case QPixmapFilter::DropShadowFilter:
+ if (!d->dropShadowFilter)
+ d->dropShadowFilter.reset(new QVGPixmapDropShadowFilter);
+ return d->dropShadowFilter.data();
+ case QPixmapFilter::BlurFilter:
+ if (!d->blurFilter)
+ d->blurFilter.reset(new QVGPixmapBlurFilter);
+ return d->blurFilter.data();
+ default: break;
+ }
#endif
- return QPaintEngineEx::createPixmapFilter(type);
+ return QPaintEngineEx::pixmapFilter(type, prototype);
}
void QVGPaintEngine::restoreState(QPaintEngine::DirtyFlags dirty)
diff --git a/src/openvg/qpaintengine_vg_p.h b/src/openvg/qpaintengine_vg_p.h
index 31b2983..a3487dc 100644
--- a/src/openvg/qpaintengine_vg_p.h
+++ b/src/openvg/qpaintengine_vg_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtOpenVG module of the Qt Toolkit.
@@ -20,10 +21,9 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
@@ -108,6 +108,8 @@ public:
void fillRect(const QRectF &rect, const QBrush &brush);
void fillRect(const QRectF &rect, const QColor &color);
+ void drawRoundedRect(const QRectF &rect, qreal xrad, qreal yrad, Qt::SizeMode mode);
+
void drawRects(const QRect *rects, int rectCount);
void drawRects(const QRectF *rects, int rectCount);
@@ -143,7 +145,7 @@ public:
void beginNativePainting();
void endNativePainting();
- QPixmapFilter *createPixmapFilter(int type) const;
+ QPixmapFilter *pixmapFilter(int type, const QPixmapFilter *prototype);
QVGPaintEnginePrivate *vgPrivate() { Q_D(QVGPaintEngine); return d; }
diff --git a/src/openvg/qpixmapdata_vg.cpp b/src/openvg/qpixmapdata_vg.cpp
index 1dfca86..2003f3b 100644
--- a/src/openvg/qpixmapdata_vg.cpp
+++ b/src/openvg/qpixmapdata_vg.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtOpenVG module of the Qt Toolkit.
@@ -20,10 +21,9 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
@@ -44,6 +44,13 @@
#include <QtGui/private/qdrawhelper_p.h>
#include "qvg_p.h"
+#ifdef QT_SYMBIAN_SUPPORTS_SGIMAGE
+#include <graphics/sgimage.h>
+typedef EGLImageKHR (*pfnEglCreateImageKHR)(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, EGLint*);
+typedef EGLBoolean (*pfnEglDestroyImageKHR)(EGLDisplay, EGLImageKHR);
+typedef VGImage (*pfnVgCreateEGLImageTargetKHR)(VGeglImageKHR);
+#endif
+
QT_BEGIN_NAMESPACE
static int qt_vg_pixmap_serial = 0;
@@ -75,12 +82,11 @@ QVGPixmapData::~QVGPixmapData()
// We don't currently have a widget surface active, but we
// need a surface to make the context current. So use the
// shared pbuffer surface instead.
- qt_vg_make_current(context, qt_vg_shared_surface());
+ context->makeCurrent(qt_vg_shared_surface());
vgDestroyImage(vgImage);
if (vgImageOpacity != VG_INVALID_HANDLE)
vgDestroyImage(vgImageOpacity);
- qt_vg_done_current(context);
- context->setSurface(EGL_NO_SURFACE);
+ context->lazyDoneCurrent();
}
#else
vgDestroyImage(vgImage);
@@ -366,4 +372,187 @@ Q_OPENVG_EXPORT VGImage qPixmapToVGImage(const QPixmap& pixmap)
return VG_INVALID_HANDLE;
}
+#if defined(Q_OS_SYMBIAN)
+void QVGPixmapData::cleanup()
+{
+ is_null = w = h = 0;
+ recreate = false;
+ source = QImage();
+}
+
+void QVGPixmapData::fromNativeType(void* pixmap, NativeType type)
+{
+#if defined(QT_SYMBIAN_SUPPORTS_SGIMAGE) && !defined(QT_NO_EGL)
+ if (type == QPixmapData::SgImage && pixmap) {
+ RSgImage *sgImage = reinterpret_cast<RSgImage*>(pixmap);
+ // when "0" used as argument then
+ // default display, context are used
+ if (!context)
+ context = qt_vg_create_context(0);
+
+ if (vgImage != VG_INVALID_HANDLE) {
+ vgDestroyImage(vgImage);
+ vgImage = VG_INVALID_HANDLE;
+ }
+ if (vgImageOpacity != VG_INVALID_HANDLE) {
+ vgDestroyImage(vgImageOpacity);
+ vgImageOpacity = VG_INVALID_HANDLE;
+ }
+
+ TInt err = 0;
+
+ err = SgDriver::Open();
+ if(err != KErrNone) {
+ cleanup();
+ return;
+ }
+
+ if(sgImage->IsNull()) {
+ cleanup();
+ SgDriver::Close();
+ return;
+ }
+
+ TSgImageInfo sgImageInfo;
+ err = sgImage->GetInfo(sgImageInfo);
+ if(err != KErrNone) {
+ cleanup();
+ SgDriver::Close();
+ return;
+ }
+
+ pfnEglCreateImageKHR eglCreateImageKHR = (pfnEglCreateImageKHR) eglGetProcAddress("eglCreateImageKHR");
+ pfnEglDestroyImageKHR eglDestroyImageKHR = (pfnEglDestroyImageKHR) eglGetProcAddress("eglDestroyImageKHR");
+ pfnVgCreateEGLImageTargetKHR vgCreateEGLImageTargetKHR = (pfnVgCreateEGLImageTargetKHR) eglGetProcAddress("vgCreateEGLImageTargetKHR");
+
+ if(eglGetError() != EGL_SUCCESS || !eglCreateImageKHR || !eglDestroyImageKHR || !vgCreateEGLImageTargetKHR) {
+ cleanup();
+ SgDriver::Close();
+ return;
+ }
+
+ const EGLint KEglImageAttribs[] = {EGL_IMAGE_PRESERVED_SYMBIAN, EGL_TRUE, EGL_NONE};
+ EGLImageKHR eglImage = eglCreateImageKHR(context->display(),
+ EGL_NO_CONTEXT,
+ EGL_NATIVE_PIXMAP_KHR,
+ (EGLClientBuffer)sgImage,
+ (EGLint*)KEglImageAttribs);
+
+ if(eglGetError() != EGL_SUCCESS) {
+ cleanup();
+ SgDriver::Close();
+ return;
+ }
+
+ vgImage = vgCreateEGLImageTargetKHR(eglImage);
+ if(vgGetError() != VG_NO_ERROR) {
+ cleanup();
+ eglDestroyImageKHR(context->display(), eglImage);
+ SgDriver::Close();
+ return;
+ }
+
+ w = sgImageInfo.iSizeInPixels.iWidth;
+ h = sgImageInfo.iSizeInPixels.iHeight;
+ d = 32; // We always use ARGB_Premultiplied for VG pixmaps.
+ is_null = (w <= 0 || h <= 0);
+ source = QImage();
+ recreate = false;
+ setSerialNumber(++qt_vg_pixmap_serial);
+ // release stuff
+ eglDestroyImageKHR(context->display(), eglImage);
+ SgDriver::Close();
+ } else if (type == QPixmapData::FbsBitmap) {
+
+ }
+#else
+ Q_UNUSED(pixmap);
+ Q_UNUSED(type);
+#endif
+}
+
+void* QVGPixmapData::toNativeType(NativeType type)
+{
+#if defined(QT_SYMBIAN_SUPPORTS_SGIMAGE) && !defined(QT_NO_EGL)
+ if (type == QPixmapData::SgImage) {
+ toVGImage();
+
+ if(!isValid() || vgImage == VG_INVALID_HANDLE)
+ return 0;
+
+ TInt err = 0;
+
+ err = SgDriver::Open();
+ if(err != KErrNone)
+ return 0;
+
+ TSgImageInfo sgInfo;
+ sgInfo.iPixelFormat = EUidPixelFormatARGB_8888_PRE;
+ sgInfo.iSizeInPixels.SetSize(w, h);
+ sgInfo.iUsage = ESgUsageOpenVgImage | ESgUsageOpenVgTarget;
+ sgInfo.iShareable = ETrue;
+ sgInfo.iCpuAccess = ESgCpuAccessNone;
+ sgInfo.iScreenId = KSgScreenIdMain; //KSgScreenIdAny;
+ sgInfo.iUserAttributes = NULL;
+ sgInfo.iUserAttributeCount = 0;
+
+ RSgImage *sgImage = q_check_ptr(new RSgImage());
+ err = sgImage->Create(sgInfo, NULL, NULL);
+ if(err != KErrNone) {
+ SgDriver::Close();
+ return 0;
+ }
+
+ pfnEglCreateImageKHR eglCreateImageKHR = (pfnEglCreateImageKHR) eglGetProcAddress("eglCreateImageKHR");
+ pfnEglDestroyImageKHR eglDestroyImageKHR = (pfnEglDestroyImageKHR) eglGetProcAddress("eglDestroyImageKHR");
+ pfnVgCreateEGLImageTargetKHR vgCreateEGLImageTargetKHR = (pfnVgCreateEGLImageTargetKHR) eglGetProcAddress("vgCreateEGLImageTargetKHR");
+
+ if(eglGetError() != EGL_SUCCESS || !eglCreateImageKHR || !eglDestroyImageKHR || !vgCreateEGLImageTargetKHR) {
+ SgDriver::Close();
+ return 0;
+ }
+
+ const EGLint KEglImageAttribs[] = {EGL_IMAGE_PRESERVED_SYMBIAN, EGL_TRUE, EGL_NONE};
+ EGLImageKHR eglImage = eglCreateImageKHR(context->display(),
+ EGL_NO_CONTEXT,
+ EGL_NATIVE_PIXMAP_KHR,
+ (EGLClientBuffer)sgImage,
+ (EGLint*)KEglImageAttribs);
+ if(eglGetError() != EGL_SUCCESS) {
+ sgImage->Close();
+ SgDriver::Close();
+ return 0;
+ }
+
+ VGImage dstVgImage = vgCreateEGLImageTargetKHR(eglImage);
+ if(vgGetError() != VG_NO_ERROR) {
+ eglDestroyImageKHR(context->display(), eglImage);
+ sgImage->Close();
+ SgDriver::Close();
+ return 0;
+ }
+
+ vgCopyImage(dstVgImage, 0, 0,
+ vgImage, 0, 0,
+ w, h, VG_FALSE);
+
+ if(vgGetError() != VG_NO_ERROR) {
+ sgImage->Close();
+ sgImage = 0;
+ }
+ // release stuff
+ vgDestroyImage(dstVgImage);
+ eglDestroyImageKHR(context->display(), eglImage);
+ SgDriver::Close();
+ return reinterpret_cast<void*>(sgImage);
+ } else if (type == QPixmapData::FbsBitmap) {
+ return 0;
+ }
+#else
+ Q_UNUSED(type);
+ return 0;
+#endif
+}
+#endif //Q_OS_SYMBIAN
+
QT_END_NAMESPACE
diff --git a/src/openvg/qpixmapdata_vg_p.h b/src/openvg/qpixmapdata_vg_p.h
index 73d1966..99115df 100644
--- a/src/openvg/qpixmapdata_vg_p.h
+++ b/src/openvg/qpixmapdata_vg_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtOpenVG module of the Qt Toolkit.
@@ -20,10 +21,9 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
@@ -56,7 +56,10 @@
#include <QtGui/private/qpixmap_raster_p.h>
#include <private/qvg_p.h>
#if !defined(QT_NO_EGL)
-#include <QtGui/private/qegl_p.h>
+#endif
+
+#if defined(Q_OS_SYMBIAN)
+class RSGImage;
#endif
QT_BEGIN_NAMESPACE
@@ -91,9 +94,18 @@ public:
QSize size() const { return QSize(w, h); }
+#if defined(Q_OS_SYMBIAN)
+ void* toNativeType(NativeType type);
+ void fromNativeType(void* pixmap, NativeType type);
+#endif
+
protected:
int metric(QPaintDevice::PaintDeviceMetric metric) const;
+#if defined(Q_OS_SYMBIAN)
+ void cleanup();
+#endif
+
private:
VGImage vgImage;
VGImage vgImageOpacity;
diff --git a/src/openvg/qpixmapfilter_vg.cpp b/src/openvg/qpixmapfilter_vg.cpp
index 7d26759..ca4db38 100644
--- a/src/openvg/qpixmapfilter_vg.cpp
+++ b/src/openvg/qpixmapfilter_vg.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtOpenVG module of the Qt Toolkit.
@@ -20,10 +21,9 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
diff --git a/src/openvg/qpixmapfilter_vg_p.h b/src/openvg/qpixmapfilter_vg_p.h
index 82cbd62..8bd4f7e 100644
--- a/src/openvg/qpixmapfilter_vg_p.h
+++ b/src/openvg/qpixmapfilter_vg_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtOpenVG module of the Qt Toolkit.
@@ -20,10 +21,9 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
diff --git a/src/openvg/qvg.h b/src/openvg/qvg.h
index e0dd754..ff5b04c 100644
--- a/src/openvg/qvg.h
+++ b/src/openvg/qvg.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtOpenVG module of the Qt Toolkit.
@@ -20,10 +21,9 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
diff --git a/src/openvg/qvg_p.h b/src/openvg/qvg_p.h
index d3583ed..04e2bab 100644
--- a/src/openvg/qvg_p.h
+++ b/src/openvg/qvg_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtOpenVG module of the Qt Toolkit.
@@ -20,10 +21,9 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
@@ -81,15 +81,6 @@ Q_OPENVG_EXPORT void qt_vg_destroy_context(QEglContext *context);
// destroy VGImage objects when there is no other surface available.
Q_OPENVG_EXPORT EGLSurface qt_vg_shared_surface(void);
-// Make a context current with a specific surface.
-Q_OPENVG_EXPORT void qt_vg_make_current(QEglContext *context, EGLSurface surface);
-
-// Make a context uncurrent.
-Q_OPENVG_EXPORT void qt_vg_done_current(QEglContext *context, bool force = false);
-
-// Destroy a surface that was previously associated with a context.
-Q_OPENVG_EXPORT void qt_vg_destroy_surface(QEglContext *context, EGLSurface surface);
-
// Convert the configuration format in a context to a VG or QImage format.
Q_OPENVG_EXPORT VGImageFormat qt_vg_config_to_vg_format(QEglContext *context);
Q_OPENVG_EXPORT QImage::Format qt_vg_config_to_image_format(QEglContext *context);
diff --git a/src/openvg/qvgcompositionhelper_p.h b/src/openvg/qvgcompositionhelper_p.h
index 59eaf66..6317c3f 100644
--- a/src/openvg/qvgcompositionhelper_p.h
+++ b/src/openvg/qvgcompositionhelper_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtOpenVG module of the Qt Toolkit.
@@ -20,10 +21,9 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
diff --git a/src/openvg/qwindowsurface_vg.cpp b/src/openvg/qwindowsurface_vg.cpp
index 08631f6..6cc2e27 100644
--- a/src/openvg/qwindowsurface_vg.cpp
+++ b/src/openvg/qwindowsurface_vg.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtOpenVG module of the Qt Toolkit.
@@ -20,10 +21,9 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
@@ -85,7 +85,6 @@ void QVGWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoin
void QVGWindowSurface::setGeometry(const QRect &rect)
{
QWindowSurface::setGeometry(rect);
- d_ptr->ensureContext(window());
}
bool QVGWindowSurface::scroll(const QRegion &area, int dx, int dy)
diff --git a/src/openvg/qwindowsurface_vg_p.h b/src/openvg/qwindowsurface_vg_p.h
index 4f0c272..b149625 100644
--- a/src/openvg/qwindowsurface_vg_p.h
+++ b/src/openvg/qwindowsurface_vg_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtOpenVG module of the Qt Toolkit.
@@ -20,10 +21,9 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
diff --git a/src/openvg/qwindowsurface_vgegl.cpp b/src/openvg/qwindowsurface_vgegl.cpp
index 0510bb9..3ae911f 100644
--- a/src/openvg/qwindowsurface_vgegl.cpp
+++ b/src/openvg/qwindowsurface_vgegl.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtOpenVG module of the Qt Toolkit.
@@ -20,10 +21,9 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
@@ -125,7 +125,6 @@ public:
int refCount;
QVGPaintEngine *engine;
EGLSurface surface;
- EGLSurface lastSurface;
};
QVGSharedContext::QVGSharedContext()
@@ -133,19 +132,22 @@ QVGSharedContext::QVGSharedContext()
, refCount(0)
, engine(0)
, surface(EGL_NO_SURFACE)
- , lastSurface(EGL_NO_SURFACE)
{
}
QVGSharedContext::~QVGSharedContext()
{
+ // Don't accidentally destroy the QEglContext if the reference
+ // count falls to zero while deleting the paint engine.
+ ++refCount;
+
if (context)
- qt_vg_make_current(context, qt_vg_shared_surface());
+ context->makeCurrent(qt_vg_shared_surface());
delete engine;
if (context)
- qt_vg_done_current(context, true);
- if (surface != EGL_NO_SURFACE)
- qt_vg_destroy_surface(context, surface);
+ context->doneCurrent();
+ if (context && surface != EGL_NO_SURFACE)
+ context->destroySurface(surface);
delete context;
}
@@ -261,12 +263,12 @@ void qt_vg_destroy_context(QEglContext *context)
// This is not the shared context. Shouldn't happen!
delete context;
} else if (--(shared->refCount) <= 0) {
- qt_vg_make_current(shared->context, qt_vg_shared_surface());
+ shared->context->makeCurrent(qt_vg_shared_surface());
delete shared->engine;
shared->engine = 0;
- qt_vg_done_current(shared->context, true);
+ shared->context->doneCurrent();
if (shared->surface != EGL_NO_SURFACE) {
- qt_vg_destroy_surface(shared->context, shared->surface);
+ eglDestroySurface(shared->context->display(), shared->surface);
shared->surface = EGL_NO_SURFACE;
}
delete shared->context;
@@ -299,50 +301,6 @@ EGLSurface qt_vg_shared_surface(void)
return shared->surface;
}
-void qt_vg_make_current(QEglContext *context, EGLSurface surface)
-{
- // Bail out if the context and surface are already current.
- if (context->isCurrent() && context->surface() == surface)
- return;
-
- // Are we setting the surface to the same as the last elided doneCurrent()?
- QVGSharedContext *shared = sharedContext();
- if (context->isCurrent() && shared->lastSurface == surface) {
- shared->lastSurface = EGL_NO_SURFACE;
- context->setSurface(surface);
- return;
- }
-
- // Switch to the new context and surface.
- shared->lastSurface = EGL_NO_SURFACE;
- context->setSurface(surface);
- context->makeCurrent();
-}
-
-void qt_vg_done_current(QEglContext *context, bool force)
-{
- QVGSharedContext *shared = sharedContext();
- if (force) {
- context->doneCurrent();
- shared->lastSurface = EGL_NO_SURFACE;
- } else {
- // Keep the context current for now just in case we immediately
- // reuse the same surface for the next frame.
- shared->lastSurface = context->surface();
- }
-}
-
-void qt_vg_destroy_surface(QEglContext *context, EGLSurface surface)
-{
- QVGSharedContext *shared = sharedContext();
- if (shared->lastSurface == surface) {
- shared->lastSurface = EGL_NO_SURFACE;
- context->doneCurrent();
- }
- context->setSurface(surface);
- context->destroySurface();
-}
-
#else
QEglContext *qt_vg_create_context(QPaintDevice *device)
@@ -360,24 +318,6 @@ EGLSurface qt_vg_shared_surface(void)
return EGL_NO_SURFACE;
}
-void qt_vg_make_current(QEglContext *context, EGLSurface surface)
-{
- context->setSurface(surface);
- context->makeCurrent();
-}
-
-void qt_vg_done_current(QEglContext *context, bool force)
-{
- Q_UNUSED(force);
- context->doneCurrent();
-}
-
-void qt_vg_destroy_surface(QEglContext *context, EGLSurface surface)
-{
- context->setSurface(surface);
- context->destroySurface();
-}
-
#endif
QVGEGLWindowSurfacePrivate::QVGEGLWindowSurfacePrivate(QWindowSurface *win)
@@ -466,13 +406,13 @@ QVGEGLWindowSurfaceVGImage::~QVGEGLWindowSurfaceVGImage()
// We need a current context to be able to destroy the image.
// We use the shared surface because the native window handle
// associated with "windowSurface" may have been destroyed already.
- qt_vg_make_current(context, qt_vg_shared_surface());
- qt_vg_destroy_surface(context, backBufferSurface);
+ context->makeCurrent(qt_vg_shared_surface());
+ context->destroySurface(backBufferSurface);
vgDestroyImage(backBuffer);
- qt_vg_done_current(context, true);
+ context->doneCurrent();
}
if (windowSurface != EGL_NO_SURFACE)
- qt_vg_destroy_surface(context, windowSurface);
+ context->destroySurface(windowSurface);
qt_vg_destroy_context(context);
}
}
@@ -485,7 +425,7 @@ QEglContext *QVGEGLWindowSurfaceVGImage::ensureContext(QWidget *widget)
// the back buffer. Keep the same context and paint engine.
size = newSize;
if (isPaintingActive)
- qt_vg_done_current(context, true);
+ context->doneCurrent();
isPaintingActive = false;
recreateBackBuffer = true;
}
@@ -508,7 +448,7 @@ void QVGEGLWindowSurfaceVGImage::beginPaint(QWidget *widget)
// Create a VGImage object to act as the back buffer
// for this window. We have to create the VGImage with a
// current context, so activate the main surface for the window.
- qt_vg_make_current(context, mainSurface());
+ context->makeCurrent(mainSurface());
recreateBackBuffer = false;
if (backBufferSurface != EGL_NO_SURFACE) {
eglDestroySurface(context->display(), backBufferSurface);
@@ -534,9 +474,9 @@ void QVGEGLWindowSurfaceVGImage::beginPaint(QWidget *widget)
}
}
if (backBufferSurface != EGL_NO_SURFACE)
- qt_vg_make_current(context, backBufferSurface);
+ context->makeCurrent(backBufferSurface);
else
- qt_vg_make_current(context, mainSurface());
+ context->makeCurrent(mainSurface());
isPaintingActive = true;
}
}
@@ -551,9 +491,8 @@ void QVGEGLWindowSurfaceVGImage::endPaint
if (backBufferSurface != EGL_NO_SURFACE) {
if (isPaintingActive)
vgFlush();
- qt_vg_done_current(context);
+ context->lazyDoneCurrent();
}
- context->setSurface(EGL_NO_SURFACE);
isPaintingActive = false;
}
}
@@ -588,7 +527,7 @@ void QVGEGLWindowSurfaceQImage::endPaint
if (backBufferSurface != EGL_NO_SURFACE) {
if (isPaintingActive)
vgFlush();
- qt_vg_make_current(context, mainSurface());
+ context->makeCurrent(mainSurface());
QRegion rgn = region.intersected
(QRect(0, 0, image->width(), image->height()));
if (rgn.numRects() == 1) {
@@ -598,9 +537,8 @@ void QVGEGLWindowSurfaceQImage::endPaint
for (int index = 0; index < rects.size(); ++index)
copySubImage(image, backBuffer, rects[index]);
}
- qt_vg_done_current(context);
+ context->lazyDoneCurrent();
}
- context->setSurface(EGL_NO_SURFACE);
isPaintingActive = false;
}
}
@@ -621,7 +559,7 @@ QVGEGLWindowSurfaceDirect::~QVGEGLWindowSurfaceDirect()
destroyPaintEngine();
if (context) {
if (windowSurface != EGL_NO_SURFACE)
- qt_vg_destroy_surface(context, windowSurface);
+ context->destroySurface(windowSurface);
qt_vg_destroy_context(context);
}
}
@@ -638,9 +576,8 @@ QEglContext *QVGEGLWindowSurfaceDirect::ensureContext(QWidget *widget)
// We can keep the same context and paint engine.
size = newSize;
if (isPaintingActive)
- qt_vg_done_current(context, true);
- context->setSurface(windowSurface);
- context->destroySurface();
+ context->doneCurrent();
+ context->destroySurface(windowSurface);
#if defined(EGL_VG_ALPHA_FORMAT_PRE_BIT)
if (isPremultipliedContext(context)) {
surfaceProps.setValue
@@ -649,9 +586,7 @@ QEglContext *QVGEGLWindowSurfaceDirect::ensureContext(QWidget *widget)
surfaceProps.removeValue(EGL_VG_ALPHA_FORMAT);
}
#endif
- context->createSurface(widget, &surfaceProps);
- windowSurface = context->surface();
- context->setSurface(EGL_NO_SURFACE);
+ windowSurface = context->createSurface(widget, &surfaceProps);
isPaintingActive = false;
}
#else
@@ -663,8 +598,7 @@ QEglContext *QVGEGLWindowSurfaceDirect::ensureContext(QWidget *widget)
// in the new context.
qt_vg_destroy_paint_engine(engine);
engine = 0;
- context->setSurface(windowSurface);
- context->destroySurface();
+ context->destroySurface(windowSurface);
qt_vg_destroy_context(context);
context = 0;
windowSurface = EGL_NO_SURFACE;
@@ -689,7 +623,8 @@ QEglContext *QVGEGLWindowSurfaceDirect::ensureContext(QWidget *widget)
surfaceProps.removeValue(EGL_VG_ALPHA_FORMAT);
}
#endif
- if (!context->createSurface(widget, &surfaceProps)) {
+ EGLSurface surface = context->createSurface(widget, &surfaceProps);
+ if (surface == EGL_NO_SURFACE) {
qt_vg_destroy_context(context);
context = 0;
return 0;
@@ -708,15 +643,14 @@ QEglContext *QVGEGLWindowSurfaceDirect::ensureContext(QWidget *widget)
// Try to force the surface back buffer to preserve its contents.
if (needToSwap) {
eglGetError(); // Clear error state first.
- eglSurfaceAttrib(context->display(), context->surface(),
+ eglSurfaceAttrib(context->display(), surface,
EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED);
if (eglGetError() != EGL_SUCCESS) {
qWarning("QVG: could not enable preserved swap");
}
}
#endif
- windowSurface = context->surface();
- context->setSurface(EGL_NO_SURFACE);
+ windowSurface = surface;
isPaintingActive = false;
}
return context;
@@ -726,7 +660,7 @@ void QVGEGLWindowSurfaceDirect::beginPaint(QWidget *widget)
{
QEglContext *context = ensureContext(widget);
if (context) {
- qt_vg_make_current(context, windowSurface);
+ context->makeCurrent(windowSurface);
isPaintingActive = true;
}
}
@@ -740,14 +674,13 @@ void QVGEGLWindowSurfaceDirect::endPaint
if (context) {
if (needToSwap) {
if (!isPaintingActive)
- qt_vg_make_current(context, windowSurface);
- context->swapBuffers();
- qt_vg_done_current(context);
+ context->makeCurrent(windowSurface);
+ context->swapBuffers(windowSurface);
+ context->lazyDoneCurrent();
} else if (isPaintingActive) {
vgFlush();
- qt_vg_done_current(context);
+ context->lazyDoneCurrent();
}
- context->setSurface(EGL_NO_SURFACE);
isPaintingActive = false;
}
}
diff --git a/src/openvg/qwindowsurface_vgegl_p.h b/src/openvg/qwindowsurface_vgegl_p.h
index 43f8e1e..fa36b94 100644
--- a/src/openvg/qwindowsurface_vgegl_p.h
+++ b/src/openvg/qwindowsurface_vgegl_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtOpenVG module of the Qt Toolkit.
@@ -20,10 +21,9 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.