diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri index a2bf90ce39..3ccfb04fcc 100644 --- a/src/gui/image/image.pri +++ b/src/gui/image/image.pri @@ -24,8 +24,7 @@ HEADERS += \ image/qplatformpixmap_qpa.h \ image/qimagepixmapcleanuphooks_p.h \ image/qvolatileimage_p.h \ - image/qvolatileimagedata_p.h \ - image/qnativeimagehandleprovider_p.h + image/qvolatileimagedata_p.h SOURCES += \ image/qbitmap.cpp \ diff --git a/src/gui/image/qnativeimagehandleprovider_p.h b/src/gui/image/qnativeimagehandleprovider_p.h deleted file mode 100644 index b3b3e487d1..0000000000 --- a/src/gui/image/qnativeimagehandleprovider_p.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QNATIVEIMAGEHANDLEPROVIDER_P_H -#define QNATIVEIMAGEHANDLEPROVIDER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -QT_BEGIN_NAMESPACE - -class QNativeImageHandleProvider -{ -public: - virtual void get(void **handle, QString *type) = 0; - virtual void release(void *handle, const QString &type) = 0; -}; - -QT_END_NAMESPACE - -#endif // QNATIVEIMAGEHANDLEPROVIDER_P_H diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index 636823ac75..7c1c0ce5fd 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -19,7 +19,7 @@ load(qt_module_config) HEADERS += $$QT_SOURCE_TREE/src/opengl/qtopenglversion.h -!win32:!embedded:!mac:!symbian:!qpa:CONFIG += x11 +!win32:!embedded:!mac:!qpa:CONFIG += x11 contains(QT_CONFIG, opengl):CONFIG += opengl contains(QT_CONFIG, opengles1):CONFIG += opengles1 contains(QT_CONFIG, opengles2):CONFIG += opengles2 @@ -138,22 +138,4 @@ wince*: { HEADERS += qgl_egl_p.h } -symbian { - DEFINES += QGL_NO_PRESERVED_SWAP - SOURCES += qgl_symbian.cpp \ - qglpixelbuffer_egl.cpp \ - qgl_egl.cpp - - HEADERS += qgl_egl_p.h - - contains(QT_CONFIG, freetype) { - DEFINES += QT_NO_FONTCONFIG - INCLUDEPATH += \ - ../3rdparty/freetype/src \ - ../3rdparty/freetype/include - } - - symbian:TARGET.UID3 = 0x2002131A -} - INCLUDEPATH += ../3rdparty/harfbuzz/src diff --git a/src/opengl/qgl_symbian.cpp b/src/opengl/qgl_symbian.cpp deleted file mode 100644 index de44607bb5..0000000000 --- a/src/opengl/qgl_symbian.cpp +++ /dev/null @@ -1,472 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenGL module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include "qgl.h" -#include -#include -#include -#include -#include -#include -#include // to access QWExtra -#include -#include "qgl_egl_p.h" -#include "qplatformpixmap_gl_p.h" -#include "qgltexturepool_p.h" -#include "qcolormap.h" -#include - -QT_BEGIN_NAMESPACE - -// Turn off "direct to window" rendering if EGL cannot support it. -#if !defined(EGL_RENDER_BUFFER) || !defined(EGL_SINGLE_BUFFER) -#if defined(QGL_DIRECT_TO_WINDOW) -#undef QGL_DIRECT_TO_WINDOW -#endif -#endif - -// Determine if preserved window contents should be used. -#if !defined(EGL_SWAP_BEHAVIOR) || !defined(EGL_BUFFER_PRESERVED) -#if !defined(QGL_NO_PRESERVED_SWAP) -#define QGL_NO_PRESERVED_SWAP 1 -#endif -#endif - -extern int qt_gl_pixmap_serial; - -/* - QGLTemporaryContext implementation -*/ - - -class QGLTemporaryContextPrivate -{ -public: - bool initialized; - RWindow *window; - EGLContext context; - EGLSurface surface; - EGLDisplay display; -}; - -QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *) - : d(new QGLTemporaryContextPrivate) -{ - d->initialized = false; - d->window = 0; - d->context = 0; - d->surface = 0; - - d->display = d->display = QEgl::display(); - - EGLConfig config; - int numConfigs = 0; - EGLint attribs[] = { - EGL_SURFACE_TYPE, EGL_WINDOW_BIT, -#ifdef QT_OPENGL_ES_2 - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, -#endif - EGL_NONE - }; - - eglChooseConfig(d->display, attribs, &config, 1, &numConfigs); - if (!numConfigs) { - qWarning("QGLTemporaryContext: No EGL configurations available."); - return; - } - - d->window = new RWindow(CCoeEnv::Static()->WsSession()); - d->window->Construct(CCoeEnv::Static()->RootWin(),(uint)this); - - d->surface = eglCreateWindowSurface(d->display, config, (EGLNativeWindowType) d->window, NULL); - - if (d->surface == EGL_NO_SURFACE) { - qWarning("QGLTemporaryContext: Error creating EGL surface."); - delete d->window; - d->window = 0; - return; - } - - EGLint contextAttribs[] = { -#ifdef QT_OPENGL_ES_2 - EGL_CONTEXT_CLIENT_VERSION, 2, -#endif - EGL_NONE - }; - d->context = eglCreateContext(d->display, config, 0, contextAttribs); - if (d->context != EGL_NO_CONTEXT - && eglMakeCurrent(d->display, d->surface, d->surface, d->context)) - { - d->initialized = true; - } else { - qWarning("QGLTemporaryContext: Error creating EGL context."); - d->window = 0; - return; - } -} - -QGLTemporaryContext::~QGLTemporaryContext() -{ - if (d->initialized) { - eglMakeCurrent(d->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); - eglDestroyContext(d->display, d->context); - eglDestroySurface(d->display, d->surface); - delete d->window; - } -} - -bool QGLFormat::hasOpenGLOverlays() -{ - return false; -} - -// Chooses the EGL config and creates the EGL context -bool QGLContext::chooseContext(const QGLContext* shareContext) // almost same as in qgl_x11egl.cpp -{ - Q_D(QGLContext); - - if (!device()) - return false; - - int devType = device()->devType(); - - if ((devType != QInternal::Widget) && (devType != QInternal::Pbuffer)) { - qWarning("WARNING: Creating a QGLContext not supported on device type %d", devType); - return false; - } - - // Get the display and initialize it. - if (d->eglContext == 0) { - d->eglContext = new QEglContext(); - d->ownsEglContext = true; - d->eglContext->setApi(QEgl::OpenGL); - - // If the device is a widget with WA_TranslucentBackground set, make sure the glFormat - // has the alpha channel option set: - if (devType == QInternal::Widget) { - QWidget* widget = static_cast(device()); - if (widget->testAttribute(Qt::WA_TranslucentBackground)) - d->glFormat.setAlpha(true); - } - - // Construct the configuration we need for this surface. - QEglProperties configProps; - configProps.setDeviceType(devType); - configProps.setPaintDeviceFormat(device()); - configProps.setRenderableType(QEgl::OpenGL); - configProps.setValue(EGL_SURFACE_TYPE, EGL_WINDOW_BIT|EGL_SWAP_BEHAVIOR_PRESERVED_BIT); - - qt_eglproperties_set_glformat(configProps, d->glFormat); - - if (!d->eglContext->chooseConfig(configProps, QEgl::BestPixelFormat)) { - delete d->eglContext; - d->eglContext = 0; - return false; - } - - // Create a new context for the configuration. - QEglContext* eglSharedContext = shareContext ? shareContext->d_func()->eglContext : 0; - if (!d->eglContext->createContext(eglSharedContext)) { - delete d->eglContext; - d->eglContext = 0; - return false; - } - d->sharing = d->eglContext->isSharing(); - if (d->sharing && shareContext) - const_cast(shareContext)->d_func()->sharing = true; - } - - // Inform the higher layers about the actual format properties - qt_glformat_from_eglconfig(d->glFormat, d->eglContext->config()); - - // Do don't create the EGLSurface for everything. - // QWidget - yes, create the EGLSurface and store it in QGLContextPrivate::eglSurface - // QGLWidget - yes, create the EGLSurface and store it in QGLContextPrivate::eglSurface - // QGLPixelBuffer - no, it creates the surface itself and stores it in QGLPixelBufferPrivate::pbuf - - if (devType == QInternal::Widget) { - if (d->eglSurface != EGL_NO_SURFACE) - eglDestroySurface(d->eglContext->display(), d->eglSurface); - - d->eglSurface = QEgl::createSurface(device(), d->eglContext->config()); - - eglGetError(); // Clear error state first. - -#ifdef QGL_NO_PRESERVED_SWAP - eglSurfaceAttrib(QEgl::display(), d->eglSurface, - EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED); - - if (eglGetError() != EGL_SUCCESS) - qWarning("QGLContext: could not enable destroyed swap behaviour"); -#else - eglSurfaceAttrib(QEgl::display(), d->eglSurface, - EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED); - - if (eglGetError() != EGL_SUCCESS) - qWarning("QGLContext: could not enable preserved swap behaviour"); -#endif - - setWindowCreated(true); - } - - return true; -} - -void QGLWidget::resizeEvent(QResizeEvent *) -{ - Q_D(QGLWidget); - if (!isValid()) - return; - - if (QGLContext::currentContext()) - doneCurrent(); - - // Symbian needs to recreate the surface on resize. - d->recreateEglSurface(); - - makeCurrent(); - if (!d->glcx->initialized()) - glInit(); - resizeGL(width(), height()); - //handle overlay -} - -const QGLContext* QGLWidget::overlayContext() const -{ - return 0; -} - -void QGLWidget::makeOverlayCurrent() -{ - //handle overlay -} - -void QGLWidget::updateOverlayGL() -{ - //handle overlay -} - -void QGLWidget::setContext(QGLContext *context, const QGLContext* shareContext, bool deleteOldContext) -{ - Q_D(QGLWidget); - if (context == 0) { - qWarning("QGLWidget::setContext: Cannot set null context"); - return; - } - if (!context->deviceIsPixmap() && context->device() != this) { - qWarning("QGLWidget::setContext: Context must refer to this widget"); - return; - } - - if (d->glcx) - d->glcx->doneCurrent(); - QGLContext* oldcx = d->glcx; - d->glcx = context; - - bool createFailed = false; - if (!d->glcx->isValid()) { - // Create the QGLContext here, which in turn chooses the EGL config - // and creates the EGL context: - if (!d->glcx->create(shareContext ? shareContext : oldcx)) - createFailed = true; - } - if (createFailed) { - if (deleteOldContext) - delete oldcx; - return; - } - - d->eglSurfaceWindowId = winId(); // Remember the window id we created the surface for -} - -void QGLWidgetPrivate::init(QGLContext *context, const QGLWidget* shareWidget) -{ - Q_Q(QGLWidget); - - initContext(context, shareWidget); - - if(q->isValid() && glcx->format().hasOverlay()) { - //no overlay - qWarning("QtOpenGL ES doesn't currently support overlays"); - } -} - -void QGLWidgetPrivate::cleanupColormaps() -{ -} - -const QGLColormap & QGLWidget::colormap() const -{ - return d_func()->cmap; -} - -void QGLWidget::setColormap(const QGLColormap &) -{ -} - -void QGLWidgetPrivate::recreateEglSurface() -{ - Q_Q(QGLWidget); - - WId currentId = q->winId(); - - if (glcx->d_func()->eglSurface != EGL_NO_SURFACE) { - eglDestroySurface(glcx->d_func()->eglContext->display(), - glcx->d_func()->eglSurface); - } - - glcx->d_func()->eglSurface = QEgl::createSurface(glcx->device(), - glcx->d_func()->eglContext->config()); - -#if !defined(QGL_NO_PRESERVED_SWAP) - eglGetError(); // Clear error state first. - eglSurfaceAttrib(QEgl::display(), glcx->d_func()->eglSurface, - EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED); - if (eglGetError() != EGL_SUCCESS) { - qWarning("QGLContext: could not enable preserved swap"); - } -#endif - - eglSurfaceWindowId = currentId; -} - -static inline bool knownGoodFormat(QImage::Format format) -{ - switch (format) { - case QImage::Format_RGB16: // EColor64K - case QImage::Format_RGB32: // EColor16MU - case QImage::Format_ARGB32_Premultiplied: // EColor16MAP - return true; - default: - return false; - } -} - -void QGLPlatformPixmap::fromNativeType(void* pixmap, NativeType type) -{ - if (type == QPlatformPixmap::FbsBitmap) { - CFbsBitmap *bitmap = reinterpret_cast(pixmap); - QSize size(bitmap->SizeInPixels().iWidth, bitmap->SizeInPixels().iHeight); - if (size.width() == w && size.height() == h) - setSerialNumber(++qt_gl_pixmap_serial); - resize(size.width(), size.height()); - m_source = QVolatileImage(bitmap); - if (pixelType() == BitmapType) { - m_source.ensureFormat(QImage::Format_MonoLSB); - } else if (!knownGoodFormat(m_source.format())) { - m_source.beginDataAccess(); - QImage::Format format = idealFormat(m_source.imageRef(), Qt::AutoColor); - m_source.endDataAccess(true); - m_source.ensureFormat(format); - } - m_hasAlpha = m_source.hasAlphaChannel(); - m_hasFillColor = false; - m_dirty = true; - - } else if (type == QPlatformPixmap::VolatileImage && pixmap) { - // Support QS60Style in more efficient skin graphics retrieval. - QVolatileImage *img = static_cast(pixmap); - if (img->width() == w && img->height() == h) - setSerialNumber(++qt_gl_pixmap_serial); - resize(img->width(), img->height()); - m_source = *img; - m_hasAlpha = m_source.hasAlphaChannel(); - m_hasFillColor = false; - m_dirty = true; - } else if (type == QPlatformPixmap::NativeImageHandleProvider && pixmap) { - destroyTexture(); - nativeImageHandleProvider = static_cast(pixmap); - // Cannot defer the retrieval, we need at least the size right away. - createFromNativeImageHandleProvider(); - } -} - -void* QGLPlatformPixmap::toNativeType(NativeType type) -{ - if (type == QPlatformPixmap::FbsBitmap) { - if (m_source.isNull()) - m_source = QVolatileImage(w, h, QImage::Format_ARGB32_Premultiplied); - return m_source.duplicateNativeImage(); - } - - return 0; -} - -bool QGLPlatformPixmap::initFromNativeImageHandle(void *handle, const QString &type) -{ - if (type == QLatin1String("RSgImage")) { - fromNativeType(handle, QPlatformPixmap::SgImage); - return true; - } else if (type == QLatin1String("CFbsBitmap")) { - fromNativeType(handle, QPlatformPixmap::FbsBitmap); - return true; - } - return false; -} - -void QGLPlatformPixmap::createFromNativeImageHandleProvider() -{ - void *handle = 0; - QString type; - nativeImageHandleProvider->get(&handle, &type); - if (handle) { - if (initFromNativeImageHandle(handle, type)) { - nativeImageHandle = handle; - nativeImageType = type; - } else { - qWarning("QGLPlatformPixmap: Unknown native image type '%s'", qPrintable(type)); - } - } else { - qWarning("QGLPlatformPixmap: Native handle is null"); - } -} - -void QGLPlatformPixmap::releaseNativeImageHandle() -{ - if (nativeImageHandleProvider && nativeImageHandle) { - nativeImageHandleProvider->release(nativeImageHandle, nativeImageType); - nativeImageHandle = 0; - nativeImageType = QString(); - } -} - -QT_END_NAMESPACE diff --git a/tests/auto/nativeimagehandleprovider/nativeimagehandleprovider.pro b/tests/auto/nativeimagehandleprovider/nativeimagehandleprovider.pro deleted file mode 100644 index 25a052b5f0..0000000000 --- a/tests/auto/nativeimagehandleprovider/nativeimagehandleprovider.pro +++ /dev/null @@ -1,8 +0,0 @@ -load(qttest_p4) - -QT += gui-private - -SOURCES += tst_nativeimagehandleprovider.cpp -symbian { - LIBS += -lfbscli -lbitgdi -} diff --git a/tests/auto/nativeimagehandleprovider/tst_nativeimagehandleprovider.cpp b/tests/auto/nativeimagehandleprovider/tst_nativeimagehandleprovider.cpp deleted file mode 100644 index d58e9fd8bc..0000000000 --- a/tests/auto/nativeimagehandleprovider/tst_nativeimagehandleprovider.cpp +++ /dev/null @@ -1,237 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include -#include -#include -#include -#include -#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_OPENVG) -#include -#include -#include -#endif - -QPixmap pixmapFromNativeImageHandleProvider(QNativeImageHandleProvider *source) -{ -#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_OPENVG) - if (!source) - return QPixmap(); - QScopedPointer pd(QPlatformPixmap::create(0, 0, QPlatformPixmap::PixmapType)); - pd->fromNativeType(source, QPlatformPixmap::NativeImageHandleProvider); - return QPixmap(pd.take()); -#else - Q_UNUSED(source); - return QPixmap(); -#endif -} - -class DummyProvider : public QNativeImageHandleProvider -{ -public: - void get(void **handle, QString *type); - void release(void *handle, const QString &type); -}; - -void DummyProvider::get(void **handle, QString *type) -{ - *handle = (void *) 0x12345678; - *type = "some dummy type"; -} - -void DummyProvider::release(void *handle, const QString &type) -{ - Q_UNUSED(handle); - Q_UNUSED(type); -} - -#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_OPENVG) -class BitmapProvider : public QNativeImageHandleProvider -{ -public: - BitmapProvider() : bmp(0), refCount(0), w(50), h(60) { } - void get(void **handle, QString *type); - void release(void *handle, const QString &type); - - CFbsBitmap *bmp; - int refCount, w, h; - void *returnedHandle; - QString returnedType; -}; - -void BitmapProvider::get(void **handle, QString *type) -{ - // There may not be a release() if the get() fails so don't bother with - // refcounting in such cases. - if (bmp) - ++refCount; - returnedType = QLatin1String("CFbsBitmap"); - returnedHandle = bmp; - *handle = returnedHandle; - *type = returnedType; -} - -void BitmapProvider::release(void *handle, const QString &type) -{ - if (handle == returnedHandle && type == returnedType && returnedHandle) { - --refCount; - } -} -#endif // symbian & openvg - -class tst_NativeImageHandleProvider : public QObject -{ - Q_OBJECT - -public: - tst_NativeImageHandleProvider() { } - -private slots: - void create(); - void bitmap(); - void hibernate(); -}; - -void tst_NativeImageHandleProvider::create() -{ - QPixmap pm = pixmapFromNativeImageHandleProvider(0); - QVERIFY(pm.isNull()); - QPixmap tmp(10, 20); - if (tmp.handle()->classId() == QPlatformPixmap::OpenVGClass) { - // Verify that null pixmap is properly returned when get() provides bogus results. - DummyProvider prov; - pm = pixmapFromNativeImageHandleProvider(&prov); - QVERIFY(pm.isNull()); - pm = QPixmap(); - } else { - QSKIP("Not openvg, skipping non-trivial tests", SkipSingle); - } -} - -void tst_NativeImageHandleProvider::bitmap() -{ -#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_OPENVG) - QPixmap tmp(10, 20); - if (tmp.handle()->classId() == QPlatformPixmap::OpenVGClass) { - BitmapProvider prov; - - // This should fail because of null ptr. - QPixmap pm = pixmapFromNativeImageHandleProvider(&prov); - QVERIFY(pm.isNull()); - pm = QPixmap(); - QCOMPARE(prov.refCount, 0); - - prov.bmp = new CFbsBitmap; - QCOMPARE(prov.bmp->Create(TSize(prov.w, prov.h), EColor16MAP), KErrNone); - CFbsBitmapDevice *bitmapDevice = CFbsBitmapDevice::NewL(prov.bmp); - CBitmapContext *bitmapContext = 0; - QCOMPARE(bitmapDevice->CreateBitmapContext(bitmapContext), KErrNone); - TRgb symbianColor = TRgb(255, 200, 100); - bitmapContext->SetBrushColor(symbianColor); - bitmapContext->Clear(); - delete bitmapContext; - delete bitmapDevice; - - pm = pixmapFromNativeImageHandleProvider(&prov); - QVERIFY(!pm.isNull()); - QCOMPARE(pm.width(), prov.w); - QCOMPARE(pm.height(), prov.h); - QVERIFY(prov.refCount == 1); - QImage img = pm.toImage(); - QVERIFY(prov.refCount == 1); - QRgb pix = img.pixel(QPoint(1, 2)); - QCOMPARE(qRed(pix), symbianColor.Red()); - QCOMPARE(qGreen(pix), symbianColor.Green()); - QCOMPARE(qBlue(pix), symbianColor.Blue()); - - pm = QPixmap(); // should result in calling release - QCOMPARE(prov.refCount, 0); - delete prov.bmp; - } else { - QSKIP("Not openvg", SkipSingle); - } -#else - QSKIP("Not applicable", SkipSingle); -#endif -} - -void tst_NativeImageHandleProvider::hibernate() -{ -#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_OPENVG) - QPixmap tmp(10, 20); - if (tmp.handle()->classId() == QPlatformPixmap::OpenVGClass) { - BitmapProvider prov; - prov.bmp = new CFbsBitmap; - QCOMPARE(prov.bmp->Create(TSize(prov.w, prov.h), EColor16MAP), KErrNone); - - QPixmap pm = pixmapFromNativeImageHandleProvider(&prov); - QCOMPARE(prov.refCount, 1); - - QVGPlatformPixmap *vgpd = static_cast(pm.handle()); - vgpd->hibernate(); - QCOMPARE(prov.refCount, 0); - - // Calling toVGImage() may cause some warnings as we don't have a gui initialized, - // but the only thing we care about here is get() being called. - vgpd->toVGImage(); - QCOMPARE(prov.refCount, 1); - - pm = QPixmap(); - QCOMPARE(prov.refCount, 0); - delete prov.bmp; - } else { - QSKIP("Not openvg", SkipSingle); - } -#else - QSKIP("Not applicable", SkipSingle); -#endif -} - -int main(int argc, char *argv[]) -{ - QApplication::setGraphicsSystem("openvg"); - QApplication app(argc, argv); - tst_NativeImageHandleProvider tc; - return QTest::qExec(&tc, argc, argv); -} - -#include "tst_nativeimagehandleprovider.moc" diff --git a/tests/auto/other.pro b/tests/auto/other.pro index c4ddc83cdf..b942920563 100644 --- a/tests/auto/other.pro +++ b/tests/auto/other.pro @@ -32,8 +32,7 @@ SUBDIRS=\ qvariant \ qwidget \ qworkspace \ - windowsmobile \ - nativeimagehandleprovider + windowsmobile contains(QT_CONFIG, accessibility):SUBDIRS += qaccessibility