From b664f8be580e252489d4db919ac660ecfe303e98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 10 Sep 2010 09:54:43 +0200 Subject: Don't waste memory on the share widget in the GL window surface. Reviewed-by: Trond --- src/opengl/qwindowsurface_gl.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index e84bc29..48c7deb 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -190,7 +190,10 @@ public: QGLWidget *shareWidget() { if (!initializing && !widget && !cleanedUp) { initializing = true; - widget = new QGLWidget; + + widget = new QGLWidget(QGLFormat(QGL::SingleBuffer | QGL::NoDepthBuffer | QGL::NoStencilBuffer)); + widget->resize(1, 1); + // We dont need this internal widget to appear in QApplication::topLevelWidgets() if (QWidgetPrivate::allWidgets) QWidgetPrivate::allWidgets->remove(widget); -- cgit v0.12 From 5768bab92310ee553822de8a752f94b9137b23df Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 10 Sep 2010 11:04:49 +0200 Subject: Fix crash when using unprintable chars in QStaticText The assumption that the output glyph array and input glyph array is of equal size is wrong when unprintable characters are used (and discarded in getGlyphPositions()) Task-number: QTBUG-12614 Reviewed-by: Jiang Jiang --- src/gui/text/qstatictext.cpp | 3 +-- tests/auto/qstatictext/tst_qstatictext.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp index b950b13..7a5dec4 100644 --- a/src/gui/text/qstatictext.cpp +++ b/src/gui/text/qstatictext.cpp @@ -448,7 +448,6 @@ namespace { currentItem.font = ti.font(); currentItem.charOffset = m_chars.size(); currentItem.numChars = ti.num_chars; - currentItem.numGlyphs = ti.glyphs.numGlyphs; currentItem.glyphOffset = m_glyphs.size(); // Store offset into glyph pool currentItem.positionOffset = m_glyphs.size(); // Offset into position pool currentItem.useBackendOptimizations = m_useBackendOptimizations; @@ -463,8 +462,8 @@ namespace { ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions); int size = glyphs.size(); - Q_ASSERT(size == ti.glyphs.numGlyphs); Q_ASSERT(size == positions.size()); + currentItem.numGlyphs = size; m_glyphs.resize(m_glyphs.size() + size); m_positions.resize(m_glyphs.size()); diff --git a/tests/auto/qstatictext/tst_qstatictext.cpp b/tests/auto/qstatictext/tst_qstatictext.cpp index 2a60e9e..68c3ea9 100644 --- a/tests/auto/qstatictext/tst_qstatictext.cpp +++ b/tests/auto/qstatictext/tst_qstatictext.cpp @@ -91,6 +91,8 @@ private slots: void drawStruckOutText(); void drawOverlinedText(); void drawUnderlinedText(); + + void unprintableCharacter_qtbug12614(); }; void tst_QStaticText::init() @@ -753,5 +755,14 @@ void tst_QStaticText::drawUnderlinedText() QCOMPARE(imageDrawText, imageDrawStaticText); } +void tst_QStaticText::unprintableCharacter_qtbug12614() +{ + QString s(QChar(0x200B)); // U+200B, ZERO WIDTH SPACE + + QStaticText staticText(s); + + QVERIFY(staticText.size().isValid()); // Force layout. Should not crash. +} + QTEST_MAIN(tst_QStaticText) #include "tst_qstatictext.moc" -- cgit v0.12 From a9bf68d69d30fc44264f09a75f5e33431bdf4616 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Wed, 25 Aug 2010 16:40:32 +0200 Subject: Fix cache_cost initialization of QFontEngineMultiWin Originally, QFontEngineMultiWin does not set its cache_cost according to the regular font engines it refers to, which makes cache management in QFontCache useless because cache_cost is always 0, and garbage collecting timerEvent can hardly be triggered. This patch solve part of the problem by using cache_cost of the first font engine for QFontEngineMultiWin. However, if a font engine is loaded by QFontEngineMulti::loadEngine, the cost is still not counted. Task-number: QTBUG-12562 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qfontengine_win.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp index 82de0d5..ef1b504 100644 --- a/src/gui/text/qfontengine_win.cpp +++ b/src/gui/text/qfontengine_win.cpp @@ -1296,6 +1296,7 @@ QFontEngineMultiWin::QFontEngineMultiWin(QFontEngineWin *first, const QStringLis engines[0] = first; first->ref.ref(); fontDef = engines[0]->fontDef; + cache_cost = first->cache_cost; } void QFontEngineMultiWin::loadEngine(int at) @@ -1317,6 +1318,8 @@ void QFontEngineMultiWin::loadEngine(int at) engines[at] = new QFontEngineWin(fam, hfont, stockFont, lf); engines[at]->ref.ref(); engines[at]->fontDef = fontDef; + + // TODO: increase cost in QFontCache for the font engine loaded here } QT_END_NAMESPACE -- cgit v0.12 From 1c109b9e504b4b51707c97f443be49c88720b386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 6 Sep 2010 08:58:18 +0200 Subject: Imported meego graphics system sources. From http://www.gitorious.com/meego-graphics/meego-graphics --- .../graphicssystems/meego/meegographicssystem.pro | 12 ++ src/plugins/graphicssystems/meego/mextensions.cpp | 102 ++++++++++ src/plugins/graphicssystems/meego/mextensions.h | 62 ++++++ .../graphicssystems/meego/mgraphicssystem.cpp | 221 +++++++++++++++++++++ .../graphicssystems/meego/mgraphicssystem.h | 58 ++++++ .../meego/mgraphicssystemplugin.cpp | 31 +++ .../graphicssystems/meego/mgraphicssystemplugin.h | 27 +++ src/plugins/graphicssystems/meego/mpixmapdata.cpp | 179 +++++++++++++++++ src/plugins/graphicssystems/meego/mpixmapdata.h | 46 +++++ 9 files changed, 738 insertions(+) create mode 100644 src/plugins/graphicssystems/meego/meegographicssystem.pro create mode 100644 src/plugins/graphicssystems/meego/mextensions.cpp create mode 100644 src/plugins/graphicssystems/meego/mextensions.h create mode 100644 src/plugins/graphicssystems/meego/mgraphicssystem.cpp create mode 100644 src/plugins/graphicssystems/meego/mgraphicssystem.h create mode 100644 src/plugins/graphicssystems/meego/mgraphicssystemplugin.cpp create mode 100644 src/plugins/graphicssystems/meego/mgraphicssystemplugin.h create mode 100644 src/plugins/graphicssystems/meego/mpixmapdata.cpp create mode 100644 src/plugins/graphicssystems/meego/mpixmapdata.h diff --git a/src/plugins/graphicssystems/meego/meegographicssystem.pro b/src/plugins/graphicssystems/meego/meegographicssystem.pro new file mode 100644 index 0000000..80a974e --- /dev/null +++ b/src/plugins/graphicssystems/meego/meegographicssystem.pro @@ -0,0 +1,12 @@ +TEMPLATE = lib +QT += gui opengl +INCLUDEPATH += '../' +HEADERS = mgraphicssystem.h mpixmapdata.h mextensions.h +SOURCES = mgraphicssystem.cpp mgraphicssystem.h mgraphicssystemplugin.h mgraphicssystemplugin.cpp mpixmapdata.h mpixmapdata.cpp mextensions.h mextensions.cpp +CONFIG += GLESv2 EGL X11 debug plugin +LIBS += -lGLESv2 +TARGET = meegographicssystem + +target.path = $$[QT_INSTALL_PLUGINS]/graphicssystems + +INSTALLS += target diff --git a/src/plugins/graphicssystems/meego/mextensions.cpp b/src/plugins/graphicssystems/meego/mextensions.cpp new file mode 100644 index 0000000..814532f --- /dev/null +++ b/src/plugins/graphicssystems/meego/mextensions.cpp @@ -0,0 +1,102 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include "mextensions.h" +#include "../private/qeglcontext_p.h" +#include "../private/qpixmapdata_gl_p.h" + +bool MExtensions::initialized = false; +bool MExtensions::hasImageShared = false; +bool MExtensions::hasSurfaceScaling = false; + +/* Extension funcs */ + +typedef EGLBoolean (EGLAPIENTRY *eglQueryImageNOKFunc)(EGLDisplay, EGLImageKHR, EGLint, EGLint*); +typedef EGLNativeSharedImageTypeNOK (EGLAPIENTRY *eglCreateSharedImageNOKFunc)(EGLDisplay, EGLImageKHR, EGLint*); +typedef EGLBoolean (EGLAPIENTRY *eglDestroySharedImageNOKFunc)(EGLDisplay, EGLNativeSharedImageTypeNOK); +typedef EGLBoolean (EGLAPIENTRY *eglSetSurfaceScalingNOKFunc)(EGLDisplay, EGLSurface, EGLint, EGLint, EGLint, EGLint); + +static eglQueryImageNOKFunc _eglQueryImageNOK = 0; +static eglCreateSharedImageNOKFunc _eglCreateSharedImageNOK = 0; +static eglDestroySharedImageNOKFunc _eglDestroySharedImageNOK = 0; +static eglSetSurfaceScalingNOKFunc _eglSetSurfaceScalingNOK = 0; + +/* Public */ + +void MExtensions::ensureInitialized() +{ + if (!initialized) + initialize(); + + initialized = true; +} + +EGLNativeSharedImageTypeNOK MExtensions::eglCreateSharedImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint *props) +{ + if (! hasImageShared) + qFatal("EGL_NOK_image_shared not found but trying to use capability!"); + + return _eglCreateSharedImageNOK(dpy, image, props); +} + +bool MExtensions::eglQueryImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint prop, EGLint *v) +{ + if (! hasImageShared) + qFatal("EGL_NOK_image_shared not found but trying to use capability!"); + + return _eglQueryImageNOK(dpy, image, prop, v); +} + +bool MExtensions::eglDestroySharedImageNOK(EGLDisplay dpy, EGLNativeSharedImageTypeNOK img) +{ + if (! hasImageShared) + qFatal("EGL_NOK_image_shared not found but trying to use capability!"); + + return _eglDestroySharedImageNOK(dpy, img); +} + +bool MExtensions::eglSetSurfaceScalingNOK(EGLDisplay dpy, EGLSurface surface, int x, int y, int width, int height) +{ + if (! hasSurfaceScaling) + qFatal("EGL_NOK_surface_scaling not found but trying to use capability!"); + + return _eglSetSurfaceScalingNOK(dpy, surface, x, y, width, height); +} + +/* Private */ + +void MExtensions::initialize() +{ + QGLContext *ctx = (QGLContext *) QGLContext::currentContext(); + qt_resolve_eglimage_gl_extensions(ctx); + + if (QEgl::hasExtension("EGL_NOK_image_shared")) { + qDebug("MeegoGraphics: found EGL_NOK_image_shared"); + _eglQueryImageNOK = (eglQueryImageNOKFunc) eglGetProcAddress("eglQueryImageNOK"); + _eglCreateSharedImageNOK = (eglCreateSharedImageNOKFunc) eglGetProcAddress("eglCreateSharedImageNOK"); + _eglDestroySharedImageNOK = (eglDestroySharedImageNOKFunc) eglGetProcAddress("eglDestroySharedImageNOK"); + + Q_ASSERT(_eglQueryImageNOK && _eglCreateSharedImageNOK && _eglDestroySharedImageNOK); + hasImageShared = true; + } + + if (QEgl::hasExtension("EGL_NOK_surface_scaling")) { + qDebug("MeegoGraphics: found EGL_NOK_surface_scaling"); + _eglSetSurfaceScalingNOK = (eglSetSurfaceScalingNOKFunc) eglGetProcAddress("eglSetSurfaceScalingNOK"); + + Q_ASSERT(_eglSetSurfaceScalingNOK); + hasSurfaceScaling = true; + } +} + diff --git a/src/plugins/graphicssystems/meego/mextensions.h b/src/plugins/graphicssystems/meego/mextensions.h new file mode 100644 index 0000000..9506c50 --- /dev/null +++ b/src/plugins/graphicssystems/meego/mextensions.h @@ -0,0 +1,62 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#ifndef MEXTENSIONS_H +#define MEXTENSIONS_H + +#include +#include +#include +#include +#include "../private/qgl_p.h" +#include "../private/qeglcontext_p.h" +#include "../private/qpixmapdata_gl_p.h" + +/* Extensions decls */ + +#ifndef EGL_SHARED_IMAGE_NOK +#define EGL_SHARED_IMAGE_NOK 0x30DA +typedef void* EGLNativeSharedImageTypeNOK; +#endif + +#ifndef EGL_GL_TEXTURE_2D_KHR +#define EGL_GL_TEXTURE_2D_KHR 0x30B1 +#endif + +#ifndef EGL_FIXED_WIDTH_NOK +#define EGL_FIXED_WIDTH_NOK 0x30DB +#define EGL_FIXED_HEIGHT_NOK 0x30DC +#endif + +/* Class */ + +class MExtensions +{ +public: + static void ensureInitialized(); + + static EGLNativeSharedImageTypeNOK eglCreateSharedImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint *props); + static bool eglQueryImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint prop, EGLint *v); + static bool eglDestroySharedImageNOK(EGLDisplay dpy, EGLNativeSharedImageTypeNOK img); + static bool eglSetSurfaceScalingNOK(EGLDisplay dpy, EGLSurface surface, int x, int y, int width, int height); + +private: + static void initialize(); + + static bool initialized; + static bool hasImageShared; + static bool hasSurfaceScaling; +}; + +#endif diff --git a/src/plugins/graphicssystems/meego/mgraphicssystem.cpp b/src/plugins/graphicssystems/meego/mgraphicssystem.cpp new file mode 100644 index 0000000..e4a8210 --- /dev/null +++ b/src/plugins/graphicssystems/meego/mgraphicssystem.cpp @@ -0,0 +1,221 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include +#include "../private/qpixmap_raster_p.h" +#include "../private/qwindowsurface_gl_p.h" +#include "../private/qegl_p.h" +#include "../private/qglextensions_p.h" +#include "../private/qgl_p.h" +#include "../private/qimagepixmapcleanuphooks_p.h" +#include "../private/qapplication_p.h" +#include "../private/qgraphicssystem_runtime_p.h" +#include "../private/qimage_p.h" +#include "../private/qeglproperties_p.h" +#include "../private/qeglcontext_p.h" + +#include "mpixmapdata.h" +#include "mgraphicssystem.h" +#include "mextensions.h" + +bool MGraphicsSystem::surfaceWasCreated = false; + +MGraphicsSystem::MGraphicsSystem() +{ + qDebug("Using the meego graphics system"); +} + +MGraphicsSystem::~MGraphicsSystem() +{ + qDebug("Meego graphics system destroyed"); + qt_destroy_gl_share_widget(); +} + +QWindowSurface* MGraphicsSystem::createWindowSurface(QWidget *widget) const +{ + MGraphicsSystem::surfaceWasCreated = true; + QWindowSurface *surface = new QGLWindowSurface(widget); + surface->window()->setAttribute(Qt::WA_NoSystemBackground); + return surface; +} + +QPixmapData *MGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const +{ + // Long story short: without this it's possible to hit an + // unitialized paintDevice due to a Qt bug too complex to even + // explain here... not to mention fix without going crazy. + // MDK + QGLShareContextScope ctx(qt_gl_share_widget()->context()); + + return new QRasterPixmapData(type); +} + +QPixmapData *MGraphicsSystem::createPixmapData(QPixmapData *origin) +{ + // If the pixmap is a raster type... + // and if the pixmap pointer matches our mapping... + // create a shared image instead with the given handle. + + if (origin->classId() == QPixmapData::RasterClass) { + QRasterPixmapData *rasterClass = static_cast (origin); + void *rawResource = static_cast (rasterClass->buffer()->data_ptr()->data); + + if (MPixmapData::sharedImagesMap.contains(rawResource)) + return new MPixmapData(); + } + + return new QRasterPixmapData(origin->pixelType()); +} + +QPixmapData* MGraphicsSystem::wrapPixmapData(QPixmapData *pmd) +{ + QString name = QApplicationPrivate::instance()->graphics_system_name; + if (name == "runtime") { + QRuntimeGraphicsSystem *rsystem = (QRuntimeGraphicsSystem *) QApplicationPrivate::instance()->graphics_system; + QRuntimePixmapData *rt = new QRuntimePixmapData(rsystem, pmd->pixelType());; + rt->m_data = pmd; + rt->readBackInfo(); + rsystem->m_pixmapDatas << rt; + return rt; + } else + return pmd; +} + +void MGraphicsSystem::setSurfaceFixedSize(int /*width*/, int /*height*/) +{ + if (MGraphicsSystem::surfaceWasCreated) + qWarning("Trying to set surface fixed size but surface already created!"); + +#ifdef QT_WAS_PATCHED + QEglProperties *properties = new QEglProperties(); + properties->setValue(EGL_FIXED_WIDTH_NOK, width); + properties->setValue(EGL_FIXED_HEIGHT_NOK, height); + QGLContextPrivate::setExtraWindowSurfaceCreationProps(properties); +#endif +} + +void MGraphicsSystem::setSurfaceScaling(int x, int y, int width, int height) +{ + MExtensions::ensureInitialized(); + MExtensions::eglSetSurfaceScalingNOK(QEgl::display(), QEglContext::currentContext(QEgl::OpenGL)->currentSurface, x, y, width, height); +} + +void MGraphicsSystem::setTranslucent(bool translucent) +{ + QGLWindowSurface::surfaceFormat.setSampleBuffers(false); + QGLWindowSurface::surfaceFormat.setSamples(0); + QGLWindowSurface::surfaceFormat.setAlpha(translucent); +} + +QPixmapData *MGraphicsSystem::pixmapDataFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage) +{ + if (softImage.format() != QImage::Format_ARGB32_Premultiplied && + softImage.format() != QImage::Format_ARGB32) { + qFatal("For egl shared images, the soft image has to be ARGB32 or ARGB32_Premultiplied"); + return NULL; + } + + if (MGraphicsSystem::meegoRunning()) { + MPixmapData *pmd = new MPixmapData; + pmd->fromEGLSharedImage(handle, softImage); + return MGraphicsSystem::wrapPixmapData(pmd); + } else { + QRasterPixmapData *pmd = new QRasterPixmapData(QPixmapData::PixmapType); + pmd->fromImage(softImage, Qt::NoOpaqueDetection); + + // Make sure that the image was not converted in any way + if (pmd->buffer()->data_ptr()->data != + const_cast(softImage).data_ptr()->data) + qFatal("Iternal misalignment of raster data detected. Prolly a QImage copy fail."); + + MPixmapData::registerSharedImage(handle, softImage); + return MGraphicsSystem::wrapPixmapData(pmd); + } +} + +void MGraphicsSystem::updateEGLSharedImagePixmap(QPixmap *pixmap) +{ + MPixmapData *pmd = (MPixmapData *) pixmap->pixmapData(); + + // Basic sanity check to make sure this is really a MPixmapData... + if (pmd->classId() != QPixmapData::OpenGLClass) + qFatal("Trying to updated EGLSharedImage pixmap but it's not really a shared image pixmap!"); + + pmd->updateFromSoftImage(); +} + +QPixmapData *MGraphicsSystem::pixmapDataWithGLTexture(int w, int h) +{ + QGLPixmapData *pmd = new QGLPixmapData(QPixmapData::PixmapType); + pmd->resize(w, h); + return MGraphicsSystem::wrapPixmapData(pmd); +} + +bool MGraphicsSystem::meegoRunning() +{ + if (! QApplicationPrivate::instance()) { + qWarning("Application not running just yet... hard to know what system running!"); + return false; + } + + QString name = QApplicationPrivate::instance()->graphics_system_name; + if (name == "runtime") { + QRuntimeGraphicsSystem *rsystem = (QRuntimeGraphicsSystem *) QApplicationPrivate::instance()->graphics_system; + name = rsystem->graphicsSystemName(); + } + + return (name == "meego"); +} + +/* C API */ + +int m_image_to_egl_shared_image(const QImage &image) +{ + return MPixmapData::imageToEGLSharedImage(image); +} + +QPixmapData* m_pixmapdata_from_egl_shared_image(Qt::HANDLE handle, const QImage &softImage) +{ + return MGraphicsSystem::pixmapDataFromEGLSharedImage(handle, softImage); +} + +QPixmapData* m_pixmapdata_with_gl_texture(int w, int h) +{ + return MGraphicsSystem::pixmapDataWithGLTexture(w, h); +} + +bool m_destroy_egl_shared_image(Qt::HANDLE handle) +{ + return MPixmapData::destroyEGLSharedImage(handle); +} + +void m_set_surface_fixed_size(int width, int height) +{ + MGraphicsSystem::setSurfaceFixedSize(width, height); +} + +void m_set_surface_scaling(int x, int y, int width, int height) +{ + MGraphicsSystem::setSurfaceScaling(x, y, width, height); +} + +void m_set_translucent(bool translucent) +{ + MGraphicsSystem::setTranslucent(translucent); +} + +void m_update_egl_shared_image_pixmap(QPixmap *pixmap) +{ + MGraphicsSystem::updateEGLSharedImagePixmap(pixmap); +} diff --git a/src/plugins/graphicssystems/meego/mgraphicssystem.h b/src/plugins/graphicssystems/meego/mgraphicssystem.h new file mode 100644 index 0000000..c95d7ae --- /dev/null +++ b/src/plugins/graphicssystems/meego/mgraphicssystem.h @@ -0,0 +1,58 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#ifndef MGRAPHICSSYSTEM_H +#define MGRAPHICSSYSTEM_H + +#include "../private/qgraphicssystem_p.h" + +class MGraphicsSystem : public QGraphicsSystem +{ +public: + MGraphicsSystem(); + ~MGraphicsSystem(); + + virtual QWindowSurface *createWindowSurface(QWidget *widget) const; + virtual QPixmapData *createPixmapData(QPixmapData::PixelType) const; + virtual QPixmapData *createPixmapData(QPixmapData *origin); + + static QPixmapData *wrapPixmapData(QPixmapData *pmd); + static void setSurfaceFixedSize(int width, int height); + static void setSurfaceScaling(int x, int y, int width, int height); + static void setTranslucent(bool translucent); + + static QPixmapData *pixmapDataFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage); + static QPixmapData *pixmapDataWithGLTexture(int w, int h); + static void updateEGLSharedImagePixmap(QPixmap *pixmap); + +private: + static bool meegoRunning(); + + static bool surfaceWasCreated; +}; + +/* C api */ + +extern "C" { + int m_image_to_egl_shared_image(const QImage &image); + QPixmapData* m_pixmapdata_from_egl_shared_image(Qt::HANDLE handle, const QImage &softImage); + QPixmapData* m_pixmapdata_with_gl_texture(int w, int h); + void m_update_egl_shared_image_pixmap(QPixmap *pixmap); + bool m_destroy_egl_shared_image(Qt::HANDLE handle); + void m_set_surface_fixed_size(int width, int height); + void m_set_surface_scaling(int x, int y, int width, int height); + void m_set_translucent(bool translucent); +} + +#endif diff --git a/src/plugins/graphicssystems/meego/mgraphicssystemplugin.cpp b/src/plugins/graphicssystems/meego/mgraphicssystemplugin.cpp new file mode 100644 index 0000000..3bb7ffb --- /dev/null +++ b/src/plugins/graphicssystems/meego/mgraphicssystemplugin.cpp @@ -0,0 +1,31 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include +#include "mgraphicssystemplugin.h" +#include "mgraphicssystem.h" + +QStringList MGraphicsSystemPlugin::keys() const +{ + QStringList list; + list << "meego"; + return list; +} + +QGraphicsSystem *MGraphicsSystemPlugin::create(const QString&) +{ + return new MGraphicsSystem; +} + +Q_EXPORT_PLUGIN2(meego, MGraphicsSystemPlugin) diff --git a/src/plugins/graphicssystems/meego/mgraphicssystemplugin.h b/src/plugins/graphicssystems/meego/mgraphicssystemplugin.h new file mode 100644 index 0000000..84d4427 --- /dev/null +++ b/src/plugins/graphicssystems/meego/mgraphicssystemplugin.h @@ -0,0 +1,27 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#ifndef MGRAPHICSSYSTEMPLUGIN_H +#define MGRAPHICSSYSTEMPLUGIN_H + +#include "../private/qgraphicssystemplugin_p.h" + +class MGraphicsSystemPlugin : public QGraphicsSystemPlugin +{ +public: + virtual QStringList keys() const; + virtual QGraphicsSystem *create(const QString&); +}; + +#endif diff --git a/src/plugins/graphicssystems/meego/mpixmapdata.cpp b/src/plugins/graphicssystems/meego/mpixmapdata.cpp new file mode 100644 index 0000000..b17adf3 --- /dev/null +++ b/src/plugins/graphicssystems/meego/mpixmapdata.cpp @@ -0,0 +1,179 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include "mpixmapdata.h" +#include "mextensions.h" +#include "../private/qimage_p.h" +#include "../private/qwindowsurface_gl_p.h" +#include "../private/qeglcontext_p.h" +#include "../private/qapplication_p.h" +#include "../private/qgraphicssystem_runtime_p.h" + +static EGLint preserved_image_attribs[] = { EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE }; + +QHash MPixmapData::sharedImagesMap; + +/* Public */ + +MPixmapData::MPixmapData() : QGLPixmapData(QPixmapData::PixmapType) +{ +} + +void MPixmapData::fromTexture(GLuint textureId, int w, int h, bool alpha) +{ + resize(w, h); + texture()->id = textureId; + m_hasAlpha = alpha; + softImage = QImage(); +} + +QImage MPixmapData::toImage() const +{ + return softImage; +} + +void MPixmapData::fromImage(const QImage &image, + Qt::ImageConversionFlags flags) +{ + void *rawResource = static_cast (((QImage &) image).data_ptr()->data); + + if (sharedImagesMap.contains(rawResource)) { + MImageInfo *info = sharedImagesMap.value(rawResource); + fromEGLSharedImage(info->handle, image); + } else { + // This should *never* happen since the graphics system should never + // create a MPixmapData for an origin that doesn't contain a raster + // image we know about. But... + qWarning("MPixmapData::fromImage called on non-know resource. Falling back..."); + QGLPixmapData::fromImage(image, flags); + } +} + +void MPixmapData::fromEGLSharedImage(Qt::HANDLE handle, const QImage &si) +{ + if (si.isNull()) + qFatal("Trying to build pixmap with an empty/null softimage!"); + + QGLShareContextScope ctx(qt_gl_share_widget()->context()); + + MExtensions::ensureInitialized(); + + bool textureIsBound = false; + GLuint newTextureId; + GLint newWidth, newHeight; + + glGenTextures(1, &newTextureId); + glBindTexture(GL_TEXTURE_2D, newTextureId); + + glFinish(); + EGLImageKHR image = QEgl::eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_SHARED_IMAGE_NOK, + (EGLClientBuffer)handle, preserved_image_attribs); + + if (image != EGL_NO_IMAGE_KHR) { + glFinish(); + glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image); + GLint err = glGetError(); + if (err == GL_NO_ERROR) + textureIsBound = true; + + MExtensions::eglQueryImageNOK(QEgl::display(), image, EGL_WIDTH, &newWidth); + MExtensions::eglQueryImageNOK(QEgl::display(), image, EGL_HEIGHT, &newHeight); + + QEgl::eglDestroyImageKHR(QEgl::display(), image); + glFinish(); + } + + if (textureIsBound) { + // FIXME Remove this ugly hasAlphaChannel check when Qt lands the NoOpaqueCheck flag fix + // for QGLPixmapData. + fromTexture(newTextureId, newWidth, newHeight, + (si.hasAlphaChannel() && const_cast(si).data_ptr()->checkForAlphaPixels())); + softImage = si; + MPixmapData::registerSharedImage(handle, softImage); + } else { + qWarning("Failed to create a texture from a shared image!"); + glDeleteTextures(1, &newTextureId); + } +} + +Qt::HANDLE MPixmapData::imageToEGLSharedImage(const QImage &image) +{ + QGLShareContextScope ctx(qt_gl_share_widget()->context()); + + MExtensions::ensureInitialized(); + + glFinish(); + QGLPixmapData pixmapData(QPixmapData::PixmapType); + pixmapData.fromImage(image, 0); + GLuint textureId = pixmapData.bind(); + + glFinish(); + EGLImageKHR eglimage = QEgl::eglCreateImageKHR(QEgl::display(), QEglContext::currentContext(QEgl::OpenGL)->context(), + EGL_GL_TEXTURE_2D_KHR, + (EGLClientBuffer) textureId, + preserved_image_attribs); + glFinish(); + + if (eglimage) { + EGLNativeSharedImageTypeNOK handle = MExtensions::eglCreateSharedImageNOK(QEgl::display(), eglimage, NULL); + QEgl::eglDestroyImageKHR(QEgl::display(), eglimage); + glFinish(); + return (Qt::HANDLE) handle; + } else { + qWarning("Failed to create shared image from pixmap/texture!"); + return 0; + } +} + +void MPixmapData::updateFromSoftImage() +{ + m_dirty = true; + m_source = softImage; + ensureCreated(); + + if (softImage.width() != w || softImage.height() != h) + qWarning("Ooops, looks like softImage changed dimensions since last updated! Corruption ahead?!"); +} + +bool MPixmapData::destroyEGLSharedImage(Qt::HANDLE h) +{ + QGLShareContextScope ctx(qt_gl_share_widget()->context()); + MExtensions::ensureInitialized(); + + QMutableHashIterator i(sharedImagesMap); + while (i.hasNext()) { + i.next(); + if (i.value()->handle == h) + i.remove(); + } + + return MExtensions::eglDestroySharedImageNOK(QEgl::display(), (EGLNativeSharedImageTypeNOK) h); +} + +void MPixmapData::registerSharedImage(Qt::HANDLE handle, const QImage &si) +{ + void *raw = static_cast (((QImage) si).data_ptr()->data); + MImageInfo *info; + + if (! sharedImagesMap.contains(raw)) { + info = new MImageInfo; + info->handle = handle; + info->rawFormat = si.format(); + sharedImagesMap.insert(raw, info); + } else { + info = sharedImagesMap.value(raw); + if (info->handle != handle || info->rawFormat != si.format()) + qWarning("Inconsistency detected: overwriting entry in sharedImagesMap but handle/format different"); + } +} diff --git a/src/plugins/graphicssystems/meego/mpixmapdata.h b/src/plugins/graphicssystems/meego/mpixmapdata.h new file mode 100644 index 0000000..ae4ed6b --- /dev/null +++ b/src/plugins/graphicssystems/meego/mpixmapdata.h @@ -0,0 +1,46 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#ifndef MPIXMAPDATA_H +#define MPIXMAPDATA_H + +#include "../private/qpixmapdata_gl_p.h" + +struct MImageInfo +{ + Qt::HANDLE handle; + QImage::Format rawFormat; +}; + +class MPixmapData : public QGLPixmapData +{ +public: + MPixmapData(); + void fromTexture(GLuint textureId, int w, int h, bool alpha); + + virtual void fromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage); + virtual void fromImage (const QImage &image, Qt::ImageConversionFlags flags); + virtual QImage toImage() const; + virtual void updateFromSoftImage(); + + QImage softImage; + + static QHash sharedImagesMap; + + static Qt::HANDLE imageToEGLSharedImage(const QImage &image); + static bool destroyEGLSharedImage(Qt::HANDLE h); + static void registerSharedImage(Qt::HANDLE handle, const QImage &si); +}; + +#endif -- cgit v0.12 From 5d6ceabf3aa9d07f31f0a06d20b76c122973d3b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 6 Sep 2010 09:54:02 +0200 Subject: Renamed meego graphics system files. --- src/plugins/graphicssystems/meego/meego.pro | 12 ++ .../graphicssystems/meego/meegographicssystem.pro | 12 -- src/plugins/graphicssystems/meego/mextensions.cpp | 102 ---------- src/plugins/graphicssystems/meego/mextensions.h | 62 ------ .../graphicssystems/meego/mgraphicssystem.cpp | 221 --------------------- .../graphicssystems/meego/mgraphicssystem.h | 58 ------ .../meego/mgraphicssystemplugin.cpp | 31 --- .../graphicssystems/meego/mgraphicssystemplugin.h | 27 --- src/plugins/graphicssystems/meego/mpixmapdata.cpp | 179 ----------------- src/plugins/graphicssystems/meego/mpixmapdata.h | 46 ----- .../graphicssystems/meego/qmeegoextensions.cpp | 102 ++++++++++ .../graphicssystems/meego/qmeegoextensions.h | 62 ++++++ .../graphicssystems/meego/qmeegographicssystem.cpp | 221 +++++++++++++++++++++ .../graphicssystems/meego/qmeegographicssystem.h | 58 ++++++ .../meego/qmeegographicssystemplugin.cpp | 31 +++ .../meego/qmeegographicssystemplugin.h | 27 +++ .../graphicssystems/meego/qmeegopixmapdata.cpp | 179 +++++++++++++++++ .../graphicssystems/meego/qmeegopixmapdata.h | 46 +++++ 18 files changed, 738 insertions(+), 738 deletions(-) create mode 100644 src/plugins/graphicssystems/meego/meego.pro delete mode 100644 src/plugins/graphicssystems/meego/meegographicssystem.pro delete mode 100644 src/plugins/graphicssystems/meego/mextensions.cpp delete mode 100644 src/plugins/graphicssystems/meego/mextensions.h delete mode 100644 src/plugins/graphicssystems/meego/mgraphicssystem.cpp delete mode 100644 src/plugins/graphicssystems/meego/mgraphicssystem.h delete mode 100644 src/plugins/graphicssystems/meego/mgraphicssystemplugin.cpp delete mode 100644 src/plugins/graphicssystems/meego/mgraphicssystemplugin.h delete mode 100644 src/plugins/graphicssystems/meego/mpixmapdata.cpp delete mode 100644 src/plugins/graphicssystems/meego/mpixmapdata.h create mode 100644 src/plugins/graphicssystems/meego/qmeegoextensions.cpp create mode 100644 src/plugins/graphicssystems/meego/qmeegoextensions.h create mode 100644 src/plugins/graphicssystems/meego/qmeegographicssystem.cpp create mode 100644 src/plugins/graphicssystems/meego/qmeegographicssystem.h create mode 100644 src/plugins/graphicssystems/meego/qmeegographicssystemplugin.cpp create mode 100644 src/plugins/graphicssystems/meego/qmeegographicssystemplugin.h create mode 100644 src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp create mode 100644 src/plugins/graphicssystems/meego/qmeegopixmapdata.h diff --git a/src/plugins/graphicssystems/meego/meego.pro b/src/plugins/graphicssystems/meego/meego.pro new file mode 100644 index 0000000..80a974e --- /dev/null +++ b/src/plugins/graphicssystems/meego/meego.pro @@ -0,0 +1,12 @@ +TEMPLATE = lib +QT += gui opengl +INCLUDEPATH += '../' +HEADERS = mgraphicssystem.h mpixmapdata.h mextensions.h +SOURCES = mgraphicssystem.cpp mgraphicssystem.h mgraphicssystemplugin.h mgraphicssystemplugin.cpp mpixmapdata.h mpixmapdata.cpp mextensions.h mextensions.cpp +CONFIG += GLESv2 EGL X11 debug plugin +LIBS += -lGLESv2 +TARGET = meegographicssystem + +target.path = $$[QT_INSTALL_PLUGINS]/graphicssystems + +INSTALLS += target diff --git a/src/plugins/graphicssystems/meego/meegographicssystem.pro b/src/plugins/graphicssystems/meego/meegographicssystem.pro deleted file mode 100644 index 80a974e..0000000 --- a/src/plugins/graphicssystems/meego/meegographicssystem.pro +++ /dev/null @@ -1,12 +0,0 @@ -TEMPLATE = lib -QT += gui opengl -INCLUDEPATH += '../' -HEADERS = mgraphicssystem.h mpixmapdata.h mextensions.h -SOURCES = mgraphicssystem.cpp mgraphicssystem.h mgraphicssystemplugin.h mgraphicssystemplugin.cpp mpixmapdata.h mpixmapdata.cpp mextensions.h mextensions.cpp -CONFIG += GLESv2 EGL X11 debug plugin -LIBS += -lGLESv2 -TARGET = meegographicssystem - -target.path = $$[QT_INSTALL_PLUGINS]/graphicssystems - -INSTALLS += target diff --git a/src/plugins/graphicssystems/meego/mextensions.cpp b/src/plugins/graphicssystems/meego/mextensions.cpp deleted file mode 100644 index 814532f..0000000 --- a/src/plugins/graphicssystems/meego/mextensions.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#include "mextensions.h" -#include "../private/qeglcontext_p.h" -#include "../private/qpixmapdata_gl_p.h" - -bool MExtensions::initialized = false; -bool MExtensions::hasImageShared = false; -bool MExtensions::hasSurfaceScaling = false; - -/* Extension funcs */ - -typedef EGLBoolean (EGLAPIENTRY *eglQueryImageNOKFunc)(EGLDisplay, EGLImageKHR, EGLint, EGLint*); -typedef EGLNativeSharedImageTypeNOK (EGLAPIENTRY *eglCreateSharedImageNOKFunc)(EGLDisplay, EGLImageKHR, EGLint*); -typedef EGLBoolean (EGLAPIENTRY *eglDestroySharedImageNOKFunc)(EGLDisplay, EGLNativeSharedImageTypeNOK); -typedef EGLBoolean (EGLAPIENTRY *eglSetSurfaceScalingNOKFunc)(EGLDisplay, EGLSurface, EGLint, EGLint, EGLint, EGLint); - -static eglQueryImageNOKFunc _eglQueryImageNOK = 0; -static eglCreateSharedImageNOKFunc _eglCreateSharedImageNOK = 0; -static eglDestroySharedImageNOKFunc _eglDestroySharedImageNOK = 0; -static eglSetSurfaceScalingNOKFunc _eglSetSurfaceScalingNOK = 0; - -/* Public */ - -void MExtensions::ensureInitialized() -{ - if (!initialized) - initialize(); - - initialized = true; -} - -EGLNativeSharedImageTypeNOK MExtensions::eglCreateSharedImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint *props) -{ - if (! hasImageShared) - qFatal("EGL_NOK_image_shared not found but trying to use capability!"); - - return _eglCreateSharedImageNOK(dpy, image, props); -} - -bool MExtensions::eglQueryImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint prop, EGLint *v) -{ - if (! hasImageShared) - qFatal("EGL_NOK_image_shared not found but trying to use capability!"); - - return _eglQueryImageNOK(dpy, image, prop, v); -} - -bool MExtensions::eglDestroySharedImageNOK(EGLDisplay dpy, EGLNativeSharedImageTypeNOK img) -{ - if (! hasImageShared) - qFatal("EGL_NOK_image_shared not found but trying to use capability!"); - - return _eglDestroySharedImageNOK(dpy, img); -} - -bool MExtensions::eglSetSurfaceScalingNOK(EGLDisplay dpy, EGLSurface surface, int x, int y, int width, int height) -{ - if (! hasSurfaceScaling) - qFatal("EGL_NOK_surface_scaling not found but trying to use capability!"); - - return _eglSetSurfaceScalingNOK(dpy, surface, x, y, width, height); -} - -/* Private */ - -void MExtensions::initialize() -{ - QGLContext *ctx = (QGLContext *) QGLContext::currentContext(); - qt_resolve_eglimage_gl_extensions(ctx); - - if (QEgl::hasExtension("EGL_NOK_image_shared")) { - qDebug("MeegoGraphics: found EGL_NOK_image_shared"); - _eglQueryImageNOK = (eglQueryImageNOKFunc) eglGetProcAddress("eglQueryImageNOK"); - _eglCreateSharedImageNOK = (eglCreateSharedImageNOKFunc) eglGetProcAddress("eglCreateSharedImageNOK"); - _eglDestroySharedImageNOK = (eglDestroySharedImageNOKFunc) eglGetProcAddress("eglDestroySharedImageNOK"); - - Q_ASSERT(_eglQueryImageNOK && _eglCreateSharedImageNOK && _eglDestroySharedImageNOK); - hasImageShared = true; - } - - if (QEgl::hasExtension("EGL_NOK_surface_scaling")) { - qDebug("MeegoGraphics: found EGL_NOK_surface_scaling"); - _eglSetSurfaceScalingNOK = (eglSetSurfaceScalingNOKFunc) eglGetProcAddress("eglSetSurfaceScalingNOK"); - - Q_ASSERT(_eglSetSurfaceScalingNOK); - hasSurfaceScaling = true; - } -} - diff --git a/src/plugins/graphicssystems/meego/mextensions.h b/src/plugins/graphicssystems/meego/mextensions.h deleted file mode 100644 index 9506c50..0000000 --- a/src/plugins/graphicssystems/meego/mextensions.h +++ /dev/null @@ -1,62 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#ifndef MEXTENSIONS_H -#define MEXTENSIONS_H - -#include -#include -#include -#include -#include "../private/qgl_p.h" -#include "../private/qeglcontext_p.h" -#include "../private/qpixmapdata_gl_p.h" - -/* Extensions decls */ - -#ifndef EGL_SHARED_IMAGE_NOK -#define EGL_SHARED_IMAGE_NOK 0x30DA -typedef void* EGLNativeSharedImageTypeNOK; -#endif - -#ifndef EGL_GL_TEXTURE_2D_KHR -#define EGL_GL_TEXTURE_2D_KHR 0x30B1 -#endif - -#ifndef EGL_FIXED_WIDTH_NOK -#define EGL_FIXED_WIDTH_NOK 0x30DB -#define EGL_FIXED_HEIGHT_NOK 0x30DC -#endif - -/* Class */ - -class MExtensions -{ -public: - static void ensureInitialized(); - - static EGLNativeSharedImageTypeNOK eglCreateSharedImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint *props); - static bool eglQueryImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint prop, EGLint *v); - static bool eglDestroySharedImageNOK(EGLDisplay dpy, EGLNativeSharedImageTypeNOK img); - static bool eglSetSurfaceScalingNOK(EGLDisplay dpy, EGLSurface surface, int x, int y, int width, int height); - -private: - static void initialize(); - - static bool initialized; - static bool hasImageShared; - static bool hasSurfaceScaling; -}; - -#endif diff --git a/src/plugins/graphicssystems/meego/mgraphicssystem.cpp b/src/plugins/graphicssystems/meego/mgraphicssystem.cpp deleted file mode 100644 index e4a8210..0000000 --- a/src/plugins/graphicssystems/meego/mgraphicssystem.cpp +++ /dev/null @@ -1,221 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#include -#include "../private/qpixmap_raster_p.h" -#include "../private/qwindowsurface_gl_p.h" -#include "../private/qegl_p.h" -#include "../private/qglextensions_p.h" -#include "../private/qgl_p.h" -#include "../private/qimagepixmapcleanuphooks_p.h" -#include "../private/qapplication_p.h" -#include "../private/qgraphicssystem_runtime_p.h" -#include "../private/qimage_p.h" -#include "../private/qeglproperties_p.h" -#include "../private/qeglcontext_p.h" - -#include "mpixmapdata.h" -#include "mgraphicssystem.h" -#include "mextensions.h" - -bool MGraphicsSystem::surfaceWasCreated = false; - -MGraphicsSystem::MGraphicsSystem() -{ - qDebug("Using the meego graphics system"); -} - -MGraphicsSystem::~MGraphicsSystem() -{ - qDebug("Meego graphics system destroyed"); - qt_destroy_gl_share_widget(); -} - -QWindowSurface* MGraphicsSystem::createWindowSurface(QWidget *widget) const -{ - MGraphicsSystem::surfaceWasCreated = true; - QWindowSurface *surface = new QGLWindowSurface(widget); - surface->window()->setAttribute(Qt::WA_NoSystemBackground); - return surface; -} - -QPixmapData *MGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const -{ - // Long story short: without this it's possible to hit an - // unitialized paintDevice due to a Qt bug too complex to even - // explain here... not to mention fix without going crazy. - // MDK - QGLShareContextScope ctx(qt_gl_share_widget()->context()); - - return new QRasterPixmapData(type); -} - -QPixmapData *MGraphicsSystem::createPixmapData(QPixmapData *origin) -{ - // If the pixmap is a raster type... - // and if the pixmap pointer matches our mapping... - // create a shared image instead with the given handle. - - if (origin->classId() == QPixmapData::RasterClass) { - QRasterPixmapData *rasterClass = static_cast (origin); - void *rawResource = static_cast (rasterClass->buffer()->data_ptr()->data); - - if (MPixmapData::sharedImagesMap.contains(rawResource)) - return new MPixmapData(); - } - - return new QRasterPixmapData(origin->pixelType()); -} - -QPixmapData* MGraphicsSystem::wrapPixmapData(QPixmapData *pmd) -{ - QString name = QApplicationPrivate::instance()->graphics_system_name; - if (name == "runtime") { - QRuntimeGraphicsSystem *rsystem = (QRuntimeGraphicsSystem *) QApplicationPrivate::instance()->graphics_system; - QRuntimePixmapData *rt = new QRuntimePixmapData(rsystem, pmd->pixelType());; - rt->m_data = pmd; - rt->readBackInfo(); - rsystem->m_pixmapDatas << rt; - return rt; - } else - return pmd; -} - -void MGraphicsSystem::setSurfaceFixedSize(int /*width*/, int /*height*/) -{ - if (MGraphicsSystem::surfaceWasCreated) - qWarning("Trying to set surface fixed size but surface already created!"); - -#ifdef QT_WAS_PATCHED - QEglProperties *properties = new QEglProperties(); - properties->setValue(EGL_FIXED_WIDTH_NOK, width); - properties->setValue(EGL_FIXED_HEIGHT_NOK, height); - QGLContextPrivate::setExtraWindowSurfaceCreationProps(properties); -#endif -} - -void MGraphicsSystem::setSurfaceScaling(int x, int y, int width, int height) -{ - MExtensions::ensureInitialized(); - MExtensions::eglSetSurfaceScalingNOK(QEgl::display(), QEglContext::currentContext(QEgl::OpenGL)->currentSurface, x, y, width, height); -} - -void MGraphicsSystem::setTranslucent(bool translucent) -{ - QGLWindowSurface::surfaceFormat.setSampleBuffers(false); - QGLWindowSurface::surfaceFormat.setSamples(0); - QGLWindowSurface::surfaceFormat.setAlpha(translucent); -} - -QPixmapData *MGraphicsSystem::pixmapDataFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage) -{ - if (softImage.format() != QImage::Format_ARGB32_Premultiplied && - softImage.format() != QImage::Format_ARGB32) { - qFatal("For egl shared images, the soft image has to be ARGB32 or ARGB32_Premultiplied"); - return NULL; - } - - if (MGraphicsSystem::meegoRunning()) { - MPixmapData *pmd = new MPixmapData; - pmd->fromEGLSharedImage(handle, softImage); - return MGraphicsSystem::wrapPixmapData(pmd); - } else { - QRasterPixmapData *pmd = new QRasterPixmapData(QPixmapData::PixmapType); - pmd->fromImage(softImage, Qt::NoOpaqueDetection); - - // Make sure that the image was not converted in any way - if (pmd->buffer()->data_ptr()->data != - const_cast(softImage).data_ptr()->data) - qFatal("Iternal misalignment of raster data detected. Prolly a QImage copy fail."); - - MPixmapData::registerSharedImage(handle, softImage); - return MGraphicsSystem::wrapPixmapData(pmd); - } -} - -void MGraphicsSystem::updateEGLSharedImagePixmap(QPixmap *pixmap) -{ - MPixmapData *pmd = (MPixmapData *) pixmap->pixmapData(); - - // Basic sanity check to make sure this is really a MPixmapData... - if (pmd->classId() != QPixmapData::OpenGLClass) - qFatal("Trying to updated EGLSharedImage pixmap but it's not really a shared image pixmap!"); - - pmd->updateFromSoftImage(); -} - -QPixmapData *MGraphicsSystem::pixmapDataWithGLTexture(int w, int h) -{ - QGLPixmapData *pmd = new QGLPixmapData(QPixmapData::PixmapType); - pmd->resize(w, h); - return MGraphicsSystem::wrapPixmapData(pmd); -} - -bool MGraphicsSystem::meegoRunning() -{ - if (! QApplicationPrivate::instance()) { - qWarning("Application not running just yet... hard to know what system running!"); - return false; - } - - QString name = QApplicationPrivate::instance()->graphics_system_name; - if (name == "runtime") { - QRuntimeGraphicsSystem *rsystem = (QRuntimeGraphicsSystem *) QApplicationPrivate::instance()->graphics_system; - name = rsystem->graphicsSystemName(); - } - - return (name == "meego"); -} - -/* C API */ - -int m_image_to_egl_shared_image(const QImage &image) -{ - return MPixmapData::imageToEGLSharedImage(image); -} - -QPixmapData* m_pixmapdata_from_egl_shared_image(Qt::HANDLE handle, const QImage &softImage) -{ - return MGraphicsSystem::pixmapDataFromEGLSharedImage(handle, softImage); -} - -QPixmapData* m_pixmapdata_with_gl_texture(int w, int h) -{ - return MGraphicsSystem::pixmapDataWithGLTexture(w, h); -} - -bool m_destroy_egl_shared_image(Qt::HANDLE handle) -{ - return MPixmapData::destroyEGLSharedImage(handle); -} - -void m_set_surface_fixed_size(int width, int height) -{ - MGraphicsSystem::setSurfaceFixedSize(width, height); -} - -void m_set_surface_scaling(int x, int y, int width, int height) -{ - MGraphicsSystem::setSurfaceScaling(x, y, width, height); -} - -void m_set_translucent(bool translucent) -{ - MGraphicsSystem::setTranslucent(translucent); -} - -void m_update_egl_shared_image_pixmap(QPixmap *pixmap) -{ - MGraphicsSystem::updateEGLSharedImagePixmap(pixmap); -} diff --git a/src/plugins/graphicssystems/meego/mgraphicssystem.h b/src/plugins/graphicssystems/meego/mgraphicssystem.h deleted file mode 100644 index c95d7ae..0000000 --- a/src/plugins/graphicssystems/meego/mgraphicssystem.h +++ /dev/null @@ -1,58 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#ifndef MGRAPHICSSYSTEM_H -#define MGRAPHICSSYSTEM_H - -#include "../private/qgraphicssystem_p.h" - -class MGraphicsSystem : public QGraphicsSystem -{ -public: - MGraphicsSystem(); - ~MGraphicsSystem(); - - virtual QWindowSurface *createWindowSurface(QWidget *widget) const; - virtual QPixmapData *createPixmapData(QPixmapData::PixelType) const; - virtual QPixmapData *createPixmapData(QPixmapData *origin); - - static QPixmapData *wrapPixmapData(QPixmapData *pmd); - static void setSurfaceFixedSize(int width, int height); - static void setSurfaceScaling(int x, int y, int width, int height); - static void setTranslucent(bool translucent); - - static QPixmapData *pixmapDataFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage); - static QPixmapData *pixmapDataWithGLTexture(int w, int h); - static void updateEGLSharedImagePixmap(QPixmap *pixmap); - -private: - static bool meegoRunning(); - - static bool surfaceWasCreated; -}; - -/* C api */ - -extern "C" { - int m_image_to_egl_shared_image(const QImage &image); - QPixmapData* m_pixmapdata_from_egl_shared_image(Qt::HANDLE handle, const QImage &softImage); - QPixmapData* m_pixmapdata_with_gl_texture(int w, int h); - void m_update_egl_shared_image_pixmap(QPixmap *pixmap); - bool m_destroy_egl_shared_image(Qt::HANDLE handle); - void m_set_surface_fixed_size(int width, int height); - void m_set_surface_scaling(int x, int y, int width, int height); - void m_set_translucent(bool translucent); -} - -#endif diff --git a/src/plugins/graphicssystems/meego/mgraphicssystemplugin.cpp b/src/plugins/graphicssystems/meego/mgraphicssystemplugin.cpp deleted file mode 100644 index 3bb7ffb..0000000 --- a/src/plugins/graphicssystems/meego/mgraphicssystemplugin.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#include -#include "mgraphicssystemplugin.h" -#include "mgraphicssystem.h" - -QStringList MGraphicsSystemPlugin::keys() const -{ - QStringList list; - list << "meego"; - return list; -} - -QGraphicsSystem *MGraphicsSystemPlugin::create(const QString&) -{ - return new MGraphicsSystem; -} - -Q_EXPORT_PLUGIN2(meego, MGraphicsSystemPlugin) diff --git a/src/plugins/graphicssystems/meego/mgraphicssystemplugin.h b/src/plugins/graphicssystems/meego/mgraphicssystemplugin.h deleted file mode 100644 index 84d4427..0000000 --- a/src/plugins/graphicssystems/meego/mgraphicssystemplugin.h +++ /dev/null @@ -1,27 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#ifndef MGRAPHICSSYSTEMPLUGIN_H -#define MGRAPHICSSYSTEMPLUGIN_H - -#include "../private/qgraphicssystemplugin_p.h" - -class MGraphicsSystemPlugin : public QGraphicsSystemPlugin -{ -public: - virtual QStringList keys() const; - virtual QGraphicsSystem *create(const QString&); -}; - -#endif diff --git a/src/plugins/graphicssystems/meego/mpixmapdata.cpp b/src/plugins/graphicssystems/meego/mpixmapdata.cpp deleted file mode 100644 index b17adf3..0000000 --- a/src/plugins/graphicssystems/meego/mpixmapdata.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#include "mpixmapdata.h" -#include "mextensions.h" -#include "../private/qimage_p.h" -#include "../private/qwindowsurface_gl_p.h" -#include "../private/qeglcontext_p.h" -#include "../private/qapplication_p.h" -#include "../private/qgraphicssystem_runtime_p.h" - -static EGLint preserved_image_attribs[] = { EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE }; - -QHash MPixmapData::sharedImagesMap; - -/* Public */ - -MPixmapData::MPixmapData() : QGLPixmapData(QPixmapData::PixmapType) -{ -} - -void MPixmapData::fromTexture(GLuint textureId, int w, int h, bool alpha) -{ - resize(w, h); - texture()->id = textureId; - m_hasAlpha = alpha; - softImage = QImage(); -} - -QImage MPixmapData::toImage() const -{ - return softImage; -} - -void MPixmapData::fromImage(const QImage &image, - Qt::ImageConversionFlags flags) -{ - void *rawResource = static_cast (((QImage &) image).data_ptr()->data); - - if (sharedImagesMap.contains(rawResource)) { - MImageInfo *info = sharedImagesMap.value(rawResource); - fromEGLSharedImage(info->handle, image); - } else { - // This should *never* happen since the graphics system should never - // create a MPixmapData for an origin that doesn't contain a raster - // image we know about. But... - qWarning("MPixmapData::fromImage called on non-know resource. Falling back..."); - QGLPixmapData::fromImage(image, flags); - } -} - -void MPixmapData::fromEGLSharedImage(Qt::HANDLE handle, const QImage &si) -{ - if (si.isNull()) - qFatal("Trying to build pixmap with an empty/null softimage!"); - - QGLShareContextScope ctx(qt_gl_share_widget()->context()); - - MExtensions::ensureInitialized(); - - bool textureIsBound = false; - GLuint newTextureId; - GLint newWidth, newHeight; - - glGenTextures(1, &newTextureId); - glBindTexture(GL_TEXTURE_2D, newTextureId); - - glFinish(); - EGLImageKHR image = QEgl::eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_SHARED_IMAGE_NOK, - (EGLClientBuffer)handle, preserved_image_attribs); - - if (image != EGL_NO_IMAGE_KHR) { - glFinish(); - glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image); - GLint err = glGetError(); - if (err == GL_NO_ERROR) - textureIsBound = true; - - MExtensions::eglQueryImageNOK(QEgl::display(), image, EGL_WIDTH, &newWidth); - MExtensions::eglQueryImageNOK(QEgl::display(), image, EGL_HEIGHT, &newHeight); - - QEgl::eglDestroyImageKHR(QEgl::display(), image); - glFinish(); - } - - if (textureIsBound) { - // FIXME Remove this ugly hasAlphaChannel check when Qt lands the NoOpaqueCheck flag fix - // for QGLPixmapData. - fromTexture(newTextureId, newWidth, newHeight, - (si.hasAlphaChannel() && const_cast(si).data_ptr()->checkForAlphaPixels())); - softImage = si; - MPixmapData::registerSharedImage(handle, softImage); - } else { - qWarning("Failed to create a texture from a shared image!"); - glDeleteTextures(1, &newTextureId); - } -} - -Qt::HANDLE MPixmapData::imageToEGLSharedImage(const QImage &image) -{ - QGLShareContextScope ctx(qt_gl_share_widget()->context()); - - MExtensions::ensureInitialized(); - - glFinish(); - QGLPixmapData pixmapData(QPixmapData::PixmapType); - pixmapData.fromImage(image, 0); - GLuint textureId = pixmapData.bind(); - - glFinish(); - EGLImageKHR eglimage = QEgl::eglCreateImageKHR(QEgl::display(), QEglContext::currentContext(QEgl::OpenGL)->context(), - EGL_GL_TEXTURE_2D_KHR, - (EGLClientBuffer) textureId, - preserved_image_attribs); - glFinish(); - - if (eglimage) { - EGLNativeSharedImageTypeNOK handle = MExtensions::eglCreateSharedImageNOK(QEgl::display(), eglimage, NULL); - QEgl::eglDestroyImageKHR(QEgl::display(), eglimage); - glFinish(); - return (Qt::HANDLE) handle; - } else { - qWarning("Failed to create shared image from pixmap/texture!"); - return 0; - } -} - -void MPixmapData::updateFromSoftImage() -{ - m_dirty = true; - m_source = softImage; - ensureCreated(); - - if (softImage.width() != w || softImage.height() != h) - qWarning("Ooops, looks like softImage changed dimensions since last updated! Corruption ahead?!"); -} - -bool MPixmapData::destroyEGLSharedImage(Qt::HANDLE h) -{ - QGLShareContextScope ctx(qt_gl_share_widget()->context()); - MExtensions::ensureInitialized(); - - QMutableHashIterator i(sharedImagesMap); - while (i.hasNext()) { - i.next(); - if (i.value()->handle == h) - i.remove(); - } - - return MExtensions::eglDestroySharedImageNOK(QEgl::display(), (EGLNativeSharedImageTypeNOK) h); -} - -void MPixmapData::registerSharedImage(Qt::HANDLE handle, const QImage &si) -{ - void *raw = static_cast (((QImage) si).data_ptr()->data); - MImageInfo *info; - - if (! sharedImagesMap.contains(raw)) { - info = new MImageInfo; - info->handle = handle; - info->rawFormat = si.format(); - sharedImagesMap.insert(raw, info); - } else { - info = sharedImagesMap.value(raw); - if (info->handle != handle || info->rawFormat != si.format()) - qWarning("Inconsistency detected: overwriting entry in sharedImagesMap but handle/format different"); - } -} diff --git a/src/plugins/graphicssystems/meego/mpixmapdata.h b/src/plugins/graphicssystems/meego/mpixmapdata.h deleted file mode 100644 index ae4ed6b..0000000 --- a/src/plugins/graphicssystems/meego/mpixmapdata.h +++ /dev/null @@ -1,46 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#ifndef MPIXMAPDATA_H -#define MPIXMAPDATA_H - -#include "../private/qpixmapdata_gl_p.h" - -struct MImageInfo -{ - Qt::HANDLE handle; - QImage::Format rawFormat; -}; - -class MPixmapData : public QGLPixmapData -{ -public: - MPixmapData(); - void fromTexture(GLuint textureId, int w, int h, bool alpha); - - virtual void fromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage); - virtual void fromImage (const QImage &image, Qt::ImageConversionFlags flags); - virtual QImage toImage() const; - virtual void updateFromSoftImage(); - - QImage softImage; - - static QHash sharedImagesMap; - - static Qt::HANDLE imageToEGLSharedImage(const QImage &image); - static bool destroyEGLSharedImage(Qt::HANDLE h); - static void registerSharedImage(Qt::HANDLE handle, const QImage &si); -}; - -#endif diff --git a/src/plugins/graphicssystems/meego/qmeegoextensions.cpp b/src/plugins/graphicssystems/meego/qmeegoextensions.cpp new file mode 100644 index 0000000..814532f --- /dev/null +++ b/src/plugins/graphicssystems/meego/qmeegoextensions.cpp @@ -0,0 +1,102 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include "mextensions.h" +#include "../private/qeglcontext_p.h" +#include "../private/qpixmapdata_gl_p.h" + +bool MExtensions::initialized = false; +bool MExtensions::hasImageShared = false; +bool MExtensions::hasSurfaceScaling = false; + +/* Extension funcs */ + +typedef EGLBoolean (EGLAPIENTRY *eglQueryImageNOKFunc)(EGLDisplay, EGLImageKHR, EGLint, EGLint*); +typedef EGLNativeSharedImageTypeNOK (EGLAPIENTRY *eglCreateSharedImageNOKFunc)(EGLDisplay, EGLImageKHR, EGLint*); +typedef EGLBoolean (EGLAPIENTRY *eglDestroySharedImageNOKFunc)(EGLDisplay, EGLNativeSharedImageTypeNOK); +typedef EGLBoolean (EGLAPIENTRY *eglSetSurfaceScalingNOKFunc)(EGLDisplay, EGLSurface, EGLint, EGLint, EGLint, EGLint); + +static eglQueryImageNOKFunc _eglQueryImageNOK = 0; +static eglCreateSharedImageNOKFunc _eglCreateSharedImageNOK = 0; +static eglDestroySharedImageNOKFunc _eglDestroySharedImageNOK = 0; +static eglSetSurfaceScalingNOKFunc _eglSetSurfaceScalingNOK = 0; + +/* Public */ + +void MExtensions::ensureInitialized() +{ + if (!initialized) + initialize(); + + initialized = true; +} + +EGLNativeSharedImageTypeNOK MExtensions::eglCreateSharedImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint *props) +{ + if (! hasImageShared) + qFatal("EGL_NOK_image_shared not found but trying to use capability!"); + + return _eglCreateSharedImageNOK(dpy, image, props); +} + +bool MExtensions::eglQueryImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint prop, EGLint *v) +{ + if (! hasImageShared) + qFatal("EGL_NOK_image_shared not found but trying to use capability!"); + + return _eglQueryImageNOK(dpy, image, prop, v); +} + +bool MExtensions::eglDestroySharedImageNOK(EGLDisplay dpy, EGLNativeSharedImageTypeNOK img) +{ + if (! hasImageShared) + qFatal("EGL_NOK_image_shared not found but trying to use capability!"); + + return _eglDestroySharedImageNOK(dpy, img); +} + +bool MExtensions::eglSetSurfaceScalingNOK(EGLDisplay dpy, EGLSurface surface, int x, int y, int width, int height) +{ + if (! hasSurfaceScaling) + qFatal("EGL_NOK_surface_scaling not found but trying to use capability!"); + + return _eglSetSurfaceScalingNOK(dpy, surface, x, y, width, height); +} + +/* Private */ + +void MExtensions::initialize() +{ + QGLContext *ctx = (QGLContext *) QGLContext::currentContext(); + qt_resolve_eglimage_gl_extensions(ctx); + + if (QEgl::hasExtension("EGL_NOK_image_shared")) { + qDebug("MeegoGraphics: found EGL_NOK_image_shared"); + _eglQueryImageNOK = (eglQueryImageNOKFunc) eglGetProcAddress("eglQueryImageNOK"); + _eglCreateSharedImageNOK = (eglCreateSharedImageNOKFunc) eglGetProcAddress("eglCreateSharedImageNOK"); + _eglDestroySharedImageNOK = (eglDestroySharedImageNOKFunc) eglGetProcAddress("eglDestroySharedImageNOK"); + + Q_ASSERT(_eglQueryImageNOK && _eglCreateSharedImageNOK && _eglDestroySharedImageNOK); + hasImageShared = true; + } + + if (QEgl::hasExtension("EGL_NOK_surface_scaling")) { + qDebug("MeegoGraphics: found EGL_NOK_surface_scaling"); + _eglSetSurfaceScalingNOK = (eglSetSurfaceScalingNOKFunc) eglGetProcAddress("eglSetSurfaceScalingNOK"); + + Q_ASSERT(_eglSetSurfaceScalingNOK); + hasSurfaceScaling = true; + } +} + diff --git a/src/plugins/graphicssystems/meego/qmeegoextensions.h b/src/plugins/graphicssystems/meego/qmeegoextensions.h new file mode 100644 index 0000000..9506c50 --- /dev/null +++ b/src/plugins/graphicssystems/meego/qmeegoextensions.h @@ -0,0 +1,62 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#ifndef MEXTENSIONS_H +#define MEXTENSIONS_H + +#include +#include +#include +#include +#include "../private/qgl_p.h" +#include "../private/qeglcontext_p.h" +#include "../private/qpixmapdata_gl_p.h" + +/* Extensions decls */ + +#ifndef EGL_SHARED_IMAGE_NOK +#define EGL_SHARED_IMAGE_NOK 0x30DA +typedef void* EGLNativeSharedImageTypeNOK; +#endif + +#ifndef EGL_GL_TEXTURE_2D_KHR +#define EGL_GL_TEXTURE_2D_KHR 0x30B1 +#endif + +#ifndef EGL_FIXED_WIDTH_NOK +#define EGL_FIXED_WIDTH_NOK 0x30DB +#define EGL_FIXED_HEIGHT_NOK 0x30DC +#endif + +/* Class */ + +class MExtensions +{ +public: + static void ensureInitialized(); + + static EGLNativeSharedImageTypeNOK eglCreateSharedImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint *props); + static bool eglQueryImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint prop, EGLint *v); + static bool eglDestroySharedImageNOK(EGLDisplay dpy, EGLNativeSharedImageTypeNOK img); + static bool eglSetSurfaceScalingNOK(EGLDisplay dpy, EGLSurface surface, int x, int y, int width, int height); + +private: + static void initialize(); + + static bool initialized; + static bool hasImageShared; + static bool hasSurfaceScaling; +}; + +#endif diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp new file mode 100644 index 0000000..e4a8210 --- /dev/null +++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp @@ -0,0 +1,221 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include +#include "../private/qpixmap_raster_p.h" +#include "../private/qwindowsurface_gl_p.h" +#include "../private/qegl_p.h" +#include "../private/qglextensions_p.h" +#include "../private/qgl_p.h" +#include "../private/qimagepixmapcleanuphooks_p.h" +#include "../private/qapplication_p.h" +#include "../private/qgraphicssystem_runtime_p.h" +#include "../private/qimage_p.h" +#include "../private/qeglproperties_p.h" +#include "../private/qeglcontext_p.h" + +#include "mpixmapdata.h" +#include "mgraphicssystem.h" +#include "mextensions.h" + +bool MGraphicsSystem::surfaceWasCreated = false; + +MGraphicsSystem::MGraphicsSystem() +{ + qDebug("Using the meego graphics system"); +} + +MGraphicsSystem::~MGraphicsSystem() +{ + qDebug("Meego graphics system destroyed"); + qt_destroy_gl_share_widget(); +} + +QWindowSurface* MGraphicsSystem::createWindowSurface(QWidget *widget) const +{ + MGraphicsSystem::surfaceWasCreated = true; + QWindowSurface *surface = new QGLWindowSurface(widget); + surface->window()->setAttribute(Qt::WA_NoSystemBackground); + return surface; +} + +QPixmapData *MGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const +{ + // Long story short: without this it's possible to hit an + // unitialized paintDevice due to a Qt bug too complex to even + // explain here... not to mention fix without going crazy. + // MDK + QGLShareContextScope ctx(qt_gl_share_widget()->context()); + + return new QRasterPixmapData(type); +} + +QPixmapData *MGraphicsSystem::createPixmapData(QPixmapData *origin) +{ + // If the pixmap is a raster type... + // and if the pixmap pointer matches our mapping... + // create a shared image instead with the given handle. + + if (origin->classId() == QPixmapData::RasterClass) { + QRasterPixmapData *rasterClass = static_cast (origin); + void *rawResource = static_cast (rasterClass->buffer()->data_ptr()->data); + + if (MPixmapData::sharedImagesMap.contains(rawResource)) + return new MPixmapData(); + } + + return new QRasterPixmapData(origin->pixelType()); +} + +QPixmapData* MGraphicsSystem::wrapPixmapData(QPixmapData *pmd) +{ + QString name = QApplicationPrivate::instance()->graphics_system_name; + if (name == "runtime") { + QRuntimeGraphicsSystem *rsystem = (QRuntimeGraphicsSystem *) QApplicationPrivate::instance()->graphics_system; + QRuntimePixmapData *rt = new QRuntimePixmapData(rsystem, pmd->pixelType());; + rt->m_data = pmd; + rt->readBackInfo(); + rsystem->m_pixmapDatas << rt; + return rt; + } else + return pmd; +} + +void MGraphicsSystem::setSurfaceFixedSize(int /*width*/, int /*height*/) +{ + if (MGraphicsSystem::surfaceWasCreated) + qWarning("Trying to set surface fixed size but surface already created!"); + +#ifdef QT_WAS_PATCHED + QEglProperties *properties = new QEglProperties(); + properties->setValue(EGL_FIXED_WIDTH_NOK, width); + properties->setValue(EGL_FIXED_HEIGHT_NOK, height); + QGLContextPrivate::setExtraWindowSurfaceCreationProps(properties); +#endif +} + +void MGraphicsSystem::setSurfaceScaling(int x, int y, int width, int height) +{ + MExtensions::ensureInitialized(); + MExtensions::eglSetSurfaceScalingNOK(QEgl::display(), QEglContext::currentContext(QEgl::OpenGL)->currentSurface, x, y, width, height); +} + +void MGraphicsSystem::setTranslucent(bool translucent) +{ + QGLWindowSurface::surfaceFormat.setSampleBuffers(false); + QGLWindowSurface::surfaceFormat.setSamples(0); + QGLWindowSurface::surfaceFormat.setAlpha(translucent); +} + +QPixmapData *MGraphicsSystem::pixmapDataFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage) +{ + if (softImage.format() != QImage::Format_ARGB32_Premultiplied && + softImage.format() != QImage::Format_ARGB32) { + qFatal("For egl shared images, the soft image has to be ARGB32 or ARGB32_Premultiplied"); + return NULL; + } + + if (MGraphicsSystem::meegoRunning()) { + MPixmapData *pmd = new MPixmapData; + pmd->fromEGLSharedImage(handle, softImage); + return MGraphicsSystem::wrapPixmapData(pmd); + } else { + QRasterPixmapData *pmd = new QRasterPixmapData(QPixmapData::PixmapType); + pmd->fromImage(softImage, Qt::NoOpaqueDetection); + + // Make sure that the image was not converted in any way + if (pmd->buffer()->data_ptr()->data != + const_cast(softImage).data_ptr()->data) + qFatal("Iternal misalignment of raster data detected. Prolly a QImage copy fail."); + + MPixmapData::registerSharedImage(handle, softImage); + return MGraphicsSystem::wrapPixmapData(pmd); + } +} + +void MGraphicsSystem::updateEGLSharedImagePixmap(QPixmap *pixmap) +{ + MPixmapData *pmd = (MPixmapData *) pixmap->pixmapData(); + + // Basic sanity check to make sure this is really a MPixmapData... + if (pmd->classId() != QPixmapData::OpenGLClass) + qFatal("Trying to updated EGLSharedImage pixmap but it's not really a shared image pixmap!"); + + pmd->updateFromSoftImage(); +} + +QPixmapData *MGraphicsSystem::pixmapDataWithGLTexture(int w, int h) +{ + QGLPixmapData *pmd = new QGLPixmapData(QPixmapData::PixmapType); + pmd->resize(w, h); + return MGraphicsSystem::wrapPixmapData(pmd); +} + +bool MGraphicsSystem::meegoRunning() +{ + if (! QApplicationPrivate::instance()) { + qWarning("Application not running just yet... hard to know what system running!"); + return false; + } + + QString name = QApplicationPrivate::instance()->graphics_system_name; + if (name == "runtime") { + QRuntimeGraphicsSystem *rsystem = (QRuntimeGraphicsSystem *) QApplicationPrivate::instance()->graphics_system; + name = rsystem->graphicsSystemName(); + } + + return (name == "meego"); +} + +/* C API */ + +int m_image_to_egl_shared_image(const QImage &image) +{ + return MPixmapData::imageToEGLSharedImage(image); +} + +QPixmapData* m_pixmapdata_from_egl_shared_image(Qt::HANDLE handle, const QImage &softImage) +{ + return MGraphicsSystem::pixmapDataFromEGLSharedImage(handle, softImage); +} + +QPixmapData* m_pixmapdata_with_gl_texture(int w, int h) +{ + return MGraphicsSystem::pixmapDataWithGLTexture(w, h); +} + +bool m_destroy_egl_shared_image(Qt::HANDLE handle) +{ + return MPixmapData::destroyEGLSharedImage(handle); +} + +void m_set_surface_fixed_size(int width, int height) +{ + MGraphicsSystem::setSurfaceFixedSize(width, height); +} + +void m_set_surface_scaling(int x, int y, int width, int height) +{ + MGraphicsSystem::setSurfaceScaling(x, y, width, height); +} + +void m_set_translucent(bool translucent) +{ + MGraphicsSystem::setTranslucent(translucent); +} + +void m_update_egl_shared_image_pixmap(QPixmap *pixmap) +{ + MGraphicsSystem::updateEGLSharedImagePixmap(pixmap); +} diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.h b/src/plugins/graphicssystems/meego/qmeegographicssystem.h new file mode 100644 index 0000000..c95d7ae --- /dev/null +++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.h @@ -0,0 +1,58 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#ifndef MGRAPHICSSYSTEM_H +#define MGRAPHICSSYSTEM_H + +#include "../private/qgraphicssystem_p.h" + +class MGraphicsSystem : public QGraphicsSystem +{ +public: + MGraphicsSystem(); + ~MGraphicsSystem(); + + virtual QWindowSurface *createWindowSurface(QWidget *widget) const; + virtual QPixmapData *createPixmapData(QPixmapData::PixelType) const; + virtual QPixmapData *createPixmapData(QPixmapData *origin); + + static QPixmapData *wrapPixmapData(QPixmapData *pmd); + static void setSurfaceFixedSize(int width, int height); + static void setSurfaceScaling(int x, int y, int width, int height); + static void setTranslucent(bool translucent); + + static QPixmapData *pixmapDataFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage); + static QPixmapData *pixmapDataWithGLTexture(int w, int h); + static void updateEGLSharedImagePixmap(QPixmap *pixmap); + +private: + static bool meegoRunning(); + + static bool surfaceWasCreated; +}; + +/* C api */ + +extern "C" { + int m_image_to_egl_shared_image(const QImage &image); + QPixmapData* m_pixmapdata_from_egl_shared_image(Qt::HANDLE handle, const QImage &softImage); + QPixmapData* m_pixmapdata_with_gl_texture(int w, int h); + void m_update_egl_shared_image_pixmap(QPixmap *pixmap); + bool m_destroy_egl_shared_image(Qt::HANDLE handle); + void m_set_surface_fixed_size(int width, int height); + void m_set_surface_scaling(int x, int y, int width, int height); + void m_set_translucent(bool translucent); +} + +#endif diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.cpp b/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.cpp new file mode 100644 index 0000000..3bb7ffb --- /dev/null +++ b/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.cpp @@ -0,0 +1,31 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include +#include "mgraphicssystemplugin.h" +#include "mgraphicssystem.h" + +QStringList MGraphicsSystemPlugin::keys() const +{ + QStringList list; + list << "meego"; + return list; +} + +QGraphicsSystem *MGraphicsSystemPlugin::create(const QString&) +{ + return new MGraphicsSystem; +} + +Q_EXPORT_PLUGIN2(meego, MGraphicsSystemPlugin) diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.h b/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.h new file mode 100644 index 0000000..84d4427 --- /dev/null +++ b/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.h @@ -0,0 +1,27 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#ifndef MGRAPHICSSYSTEMPLUGIN_H +#define MGRAPHICSSYSTEMPLUGIN_H + +#include "../private/qgraphicssystemplugin_p.h" + +class MGraphicsSystemPlugin : public QGraphicsSystemPlugin +{ +public: + virtual QStringList keys() const; + virtual QGraphicsSystem *create(const QString&); +}; + +#endif diff --git a/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp b/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp new file mode 100644 index 0000000..b17adf3 --- /dev/null +++ b/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp @@ -0,0 +1,179 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include "mpixmapdata.h" +#include "mextensions.h" +#include "../private/qimage_p.h" +#include "../private/qwindowsurface_gl_p.h" +#include "../private/qeglcontext_p.h" +#include "../private/qapplication_p.h" +#include "../private/qgraphicssystem_runtime_p.h" + +static EGLint preserved_image_attribs[] = { EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE }; + +QHash MPixmapData::sharedImagesMap; + +/* Public */ + +MPixmapData::MPixmapData() : QGLPixmapData(QPixmapData::PixmapType) +{ +} + +void MPixmapData::fromTexture(GLuint textureId, int w, int h, bool alpha) +{ + resize(w, h); + texture()->id = textureId; + m_hasAlpha = alpha; + softImage = QImage(); +} + +QImage MPixmapData::toImage() const +{ + return softImage; +} + +void MPixmapData::fromImage(const QImage &image, + Qt::ImageConversionFlags flags) +{ + void *rawResource = static_cast (((QImage &) image).data_ptr()->data); + + if (sharedImagesMap.contains(rawResource)) { + MImageInfo *info = sharedImagesMap.value(rawResource); + fromEGLSharedImage(info->handle, image); + } else { + // This should *never* happen since the graphics system should never + // create a MPixmapData for an origin that doesn't contain a raster + // image we know about. But... + qWarning("MPixmapData::fromImage called on non-know resource. Falling back..."); + QGLPixmapData::fromImage(image, flags); + } +} + +void MPixmapData::fromEGLSharedImage(Qt::HANDLE handle, const QImage &si) +{ + if (si.isNull()) + qFatal("Trying to build pixmap with an empty/null softimage!"); + + QGLShareContextScope ctx(qt_gl_share_widget()->context()); + + MExtensions::ensureInitialized(); + + bool textureIsBound = false; + GLuint newTextureId; + GLint newWidth, newHeight; + + glGenTextures(1, &newTextureId); + glBindTexture(GL_TEXTURE_2D, newTextureId); + + glFinish(); + EGLImageKHR image = QEgl::eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_SHARED_IMAGE_NOK, + (EGLClientBuffer)handle, preserved_image_attribs); + + if (image != EGL_NO_IMAGE_KHR) { + glFinish(); + glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image); + GLint err = glGetError(); + if (err == GL_NO_ERROR) + textureIsBound = true; + + MExtensions::eglQueryImageNOK(QEgl::display(), image, EGL_WIDTH, &newWidth); + MExtensions::eglQueryImageNOK(QEgl::display(), image, EGL_HEIGHT, &newHeight); + + QEgl::eglDestroyImageKHR(QEgl::display(), image); + glFinish(); + } + + if (textureIsBound) { + // FIXME Remove this ugly hasAlphaChannel check when Qt lands the NoOpaqueCheck flag fix + // for QGLPixmapData. + fromTexture(newTextureId, newWidth, newHeight, + (si.hasAlphaChannel() && const_cast(si).data_ptr()->checkForAlphaPixels())); + softImage = si; + MPixmapData::registerSharedImage(handle, softImage); + } else { + qWarning("Failed to create a texture from a shared image!"); + glDeleteTextures(1, &newTextureId); + } +} + +Qt::HANDLE MPixmapData::imageToEGLSharedImage(const QImage &image) +{ + QGLShareContextScope ctx(qt_gl_share_widget()->context()); + + MExtensions::ensureInitialized(); + + glFinish(); + QGLPixmapData pixmapData(QPixmapData::PixmapType); + pixmapData.fromImage(image, 0); + GLuint textureId = pixmapData.bind(); + + glFinish(); + EGLImageKHR eglimage = QEgl::eglCreateImageKHR(QEgl::display(), QEglContext::currentContext(QEgl::OpenGL)->context(), + EGL_GL_TEXTURE_2D_KHR, + (EGLClientBuffer) textureId, + preserved_image_attribs); + glFinish(); + + if (eglimage) { + EGLNativeSharedImageTypeNOK handle = MExtensions::eglCreateSharedImageNOK(QEgl::display(), eglimage, NULL); + QEgl::eglDestroyImageKHR(QEgl::display(), eglimage); + glFinish(); + return (Qt::HANDLE) handle; + } else { + qWarning("Failed to create shared image from pixmap/texture!"); + return 0; + } +} + +void MPixmapData::updateFromSoftImage() +{ + m_dirty = true; + m_source = softImage; + ensureCreated(); + + if (softImage.width() != w || softImage.height() != h) + qWarning("Ooops, looks like softImage changed dimensions since last updated! Corruption ahead?!"); +} + +bool MPixmapData::destroyEGLSharedImage(Qt::HANDLE h) +{ + QGLShareContextScope ctx(qt_gl_share_widget()->context()); + MExtensions::ensureInitialized(); + + QMutableHashIterator i(sharedImagesMap); + while (i.hasNext()) { + i.next(); + if (i.value()->handle == h) + i.remove(); + } + + return MExtensions::eglDestroySharedImageNOK(QEgl::display(), (EGLNativeSharedImageTypeNOK) h); +} + +void MPixmapData::registerSharedImage(Qt::HANDLE handle, const QImage &si) +{ + void *raw = static_cast (((QImage) si).data_ptr()->data); + MImageInfo *info; + + if (! sharedImagesMap.contains(raw)) { + info = new MImageInfo; + info->handle = handle; + info->rawFormat = si.format(); + sharedImagesMap.insert(raw, info); + } else { + info = sharedImagesMap.value(raw); + if (info->handle != handle || info->rawFormat != si.format()) + qWarning("Inconsistency detected: overwriting entry in sharedImagesMap but handle/format different"); + } +} diff --git a/src/plugins/graphicssystems/meego/qmeegopixmapdata.h b/src/plugins/graphicssystems/meego/qmeegopixmapdata.h new file mode 100644 index 0000000..ae4ed6b --- /dev/null +++ b/src/plugins/graphicssystems/meego/qmeegopixmapdata.h @@ -0,0 +1,46 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#ifndef MPIXMAPDATA_H +#define MPIXMAPDATA_H + +#include "../private/qpixmapdata_gl_p.h" + +struct MImageInfo +{ + Qt::HANDLE handle; + QImage::Format rawFormat; +}; + +class MPixmapData : public QGLPixmapData +{ +public: + MPixmapData(); + void fromTexture(GLuint textureId, int w, int h, bool alpha); + + virtual void fromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage); + virtual void fromImage (const QImage &image, Qt::ImageConversionFlags flags); + virtual QImage toImage() const; + virtual void updateFromSoftImage(); + + QImage softImage; + + static QHash sharedImagesMap; + + static Qt::HANDLE imageToEGLSharedImage(const QImage &image); + static bool destroyEGLSharedImage(Qt::HANDLE h); + static void registerSharedImage(Qt::HANDLE handle, const QImage &si); +}; + +#endif -- cgit v0.12 From dc61fc45601000626169409443fdeac6a3cd31af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 6 Sep 2010 09:54:59 +0200 Subject: Fixed compilation and API of meego graphics system. --- src/gui/egl/qeglcontext_p.h | 3 + src/gui/painting/qgraphicssystem_runtime_p.h | 1 + src/opengl/qpixmapdata_gl_p.h | 1 + src/plugins/graphicssystems/graphicssystems.pro | 4 + src/plugins/graphicssystems/meego/meego.pro | 19 ++-- .../graphicssystems/meego/qmeegoextensions.cpp | 24 ++-- .../graphicssystems/meego/qmeegoextensions.h | 8 +- .../graphicssystems/meego/qmeegographicssystem.cpp | 122 ++++++++++----------- .../graphicssystems/meego/qmeegographicssystem.h | 30 ++--- .../meego/qmeegographicssystemplugin.cpp | 12 +- .../meego/qmeegographicssystemplugin.h | 4 +- .../graphicssystems/meego/qmeegopixmapdata.cpp | 64 +++++------ .../graphicssystems/meego/qmeegopixmapdata.h | 14 +-- 13 files changed, 158 insertions(+), 148 deletions(-) diff --git a/src/gui/egl/qeglcontext_p.h b/src/gui/egl/qeglcontext_p.h index cae8164..5bc8f09 100644 --- a/src/gui/egl/qeglcontext_p.h +++ b/src/gui/egl/qeglcontext_p.h @@ -107,6 +107,9 @@ private: static QEglContext *currentContext(QEgl::API api); static void setCurrentContext(QEgl::API api, QEglContext *context); + + friend class QMeeGoGraphicsSystem; + friend class QMeeGoPixmapData; }; QT_END_NAMESPACE diff --git a/src/gui/painting/qgraphicssystem_runtime_p.h b/src/gui/painting/qgraphicssystem_runtime_p.h index 0232241..421fbeb 100644 --- a/src/gui/painting/qgraphicssystem_runtime_p.h +++ b/src/gui/painting/qgraphicssystem_runtime_p.h @@ -177,6 +177,7 @@ private: friend class QRuntimePixmapData; friend class QRuntimeWindowSurface; + friend class QMeeGoGraphicsSystem; }; QT_END_NAMESPACE diff --git a/src/opengl/qpixmapdata_gl_p.h b/src/opengl/qpixmapdata_gl_p.h index 4cb67b0..f000993 100644 --- a/src/opengl/qpixmapdata_gl_p.h +++ b/src/opengl/qpixmapdata_gl_p.h @@ -168,6 +168,7 @@ private: mutable QGLPixmapGLPaintDevice m_glDevice; friend class QGLPixmapGLPaintDevice; + friend class QMeeGoPixmapData; }; QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/graphicssystems.pro b/src/plugins/graphicssystems/graphicssystems.pro index 0788933..29a1f34 100644 --- a/src/plugins/graphicssystems/graphicssystems.pro +++ b/src/plugins/graphicssystems/graphicssystems.pro @@ -7,3 +7,7 @@ contains(QT_CONFIG, shivavg) { # Only works under X11 at present !win32:!embedded:!mac:SUBDIRS += shivavg } + +!win32:!embedded:!mac:!symbian:CONFIG += x11 + +x11:contains(QT_CONFIG, opengles2):contains(QT_CONFIG, egl):SUBDIRS += meego diff --git a/src/plugins/graphicssystems/meego/meego.pro b/src/plugins/graphicssystems/meego/meego.pro index 80a974e..d750d34 100644 --- a/src/plugins/graphicssystems/meego/meego.pro +++ b/src/plugins/graphicssystems/meego/meego.pro @@ -1,12 +1,13 @@ -TEMPLATE = lib +TARGET = qmeegographicssystem +include(../../qpluginbase.pri) + QT += gui opengl -INCLUDEPATH += '../' -HEADERS = mgraphicssystem.h mpixmapdata.h mextensions.h -SOURCES = mgraphicssystem.cpp mgraphicssystem.h mgraphicssystemplugin.h mgraphicssystemplugin.cpp mpixmapdata.h mpixmapdata.cpp mextensions.h mextensions.cpp -CONFIG += GLESv2 EGL X11 debug plugin -LIBS += -lGLESv2 -TARGET = meegographicssystem -target.path = $$[QT_INSTALL_PLUGINS]/graphicssystems +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems + +HEADERS = qmeegographicssystem.h qmeegopixmapdata.h qmeegoextensions.h +SOURCES = qmeegographicssystem.cpp qmeegographicssystem.h qmeegographicssystemplugin.h qmeegographicssystemplugin.cpp qmeegopixmapdata.h qmeegopixmapdata.cpp qmeegoextensions.h qmeegoextensions.cpp + +target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +INSTALLS += target -INSTALLS += target diff --git a/src/plugins/graphicssystems/meego/qmeegoextensions.cpp b/src/plugins/graphicssystems/meego/qmeegoextensions.cpp index 814532f..f40fc43 100644 --- a/src/plugins/graphicssystems/meego/qmeegoextensions.cpp +++ b/src/plugins/graphicssystems/meego/qmeegoextensions.cpp @@ -12,13 +12,13 @@ ** ****************************************************************************/ -#include "mextensions.h" -#include "../private/qeglcontext_p.h" -#include "../private/qpixmapdata_gl_p.h" +#include "qmeegoextensions.h" +#include +#include -bool MExtensions::initialized = false; -bool MExtensions::hasImageShared = false; -bool MExtensions::hasSurfaceScaling = false; +bool QMeeGoExtensions::initialized = false; +bool QMeeGoExtensions::hasImageShared = false; +bool QMeeGoExtensions::hasSurfaceScaling = false; /* Extension funcs */ @@ -34,7 +34,7 @@ static eglSetSurfaceScalingNOKFunc _eglSetSurfaceScalingNOK = 0; /* Public */ -void MExtensions::ensureInitialized() +void QMeeGoExtensions::ensureInitialized() { if (!initialized) initialize(); @@ -42,7 +42,7 @@ void MExtensions::ensureInitialized() initialized = true; } -EGLNativeSharedImageTypeNOK MExtensions::eglCreateSharedImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint *props) +EGLNativeSharedImageTypeNOK QMeeGoExtensions::eglCreateSharedImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint *props) { if (! hasImageShared) qFatal("EGL_NOK_image_shared not found but trying to use capability!"); @@ -50,7 +50,7 @@ EGLNativeSharedImageTypeNOK MExtensions::eglCreateSharedImageNOK(EGLDisplay dpy, return _eglCreateSharedImageNOK(dpy, image, props); } -bool MExtensions::eglQueryImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint prop, EGLint *v) +bool QMeeGoExtensions::eglQueryImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint prop, EGLint *v) { if (! hasImageShared) qFatal("EGL_NOK_image_shared not found but trying to use capability!"); @@ -58,7 +58,7 @@ bool MExtensions::eglQueryImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint pro return _eglQueryImageNOK(dpy, image, prop, v); } -bool MExtensions::eglDestroySharedImageNOK(EGLDisplay dpy, EGLNativeSharedImageTypeNOK img) +bool QMeeGoExtensions::eglDestroySharedImageNOK(EGLDisplay dpy, EGLNativeSharedImageTypeNOK img) { if (! hasImageShared) qFatal("EGL_NOK_image_shared not found but trying to use capability!"); @@ -66,7 +66,7 @@ bool MExtensions::eglDestroySharedImageNOK(EGLDisplay dpy, EGLNativeSharedImageT return _eglDestroySharedImageNOK(dpy, img); } -bool MExtensions::eglSetSurfaceScalingNOK(EGLDisplay dpy, EGLSurface surface, int x, int y, int width, int height) +bool QMeeGoExtensions::eglSetSurfaceScalingNOK(EGLDisplay dpy, EGLSurface surface, int x, int y, int width, int height) { if (! hasSurfaceScaling) qFatal("EGL_NOK_surface_scaling not found but trying to use capability!"); @@ -76,7 +76,7 @@ bool MExtensions::eglSetSurfaceScalingNOK(EGLDisplay dpy, EGLSurface surface, in /* Private */ -void MExtensions::initialize() +void QMeeGoExtensions::initialize() { QGLContext *ctx = (QGLContext *) QGLContext::currentContext(); qt_resolve_eglimage_gl_extensions(ctx); diff --git a/src/plugins/graphicssystems/meego/qmeegoextensions.h b/src/plugins/graphicssystems/meego/qmeegoextensions.h index 9506c50..b8e6195 100644 --- a/src/plugins/graphicssystems/meego/qmeegoextensions.h +++ b/src/plugins/graphicssystems/meego/qmeegoextensions.h @@ -19,9 +19,9 @@ #include #include #include -#include "../private/qgl_p.h" -#include "../private/qeglcontext_p.h" -#include "../private/qpixmapdata_gl_p.h" +#include +#include +#include /* Extensions decls */ @@ -41,7 +41,7 @@ typedef void* EGLNativeSharedImageTypeNOK; /* Class */ -class MExtensions +class QMeeGoExtensions { public: static void ensureInitialized(); diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp index e4a8210..e575cf3 100644 --- a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp +++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp @@ -13,44 +13,44 @@ ****************************************************************************/ #include -#include "../private/qpixmap_raster_p.h" -#include "../private/qwindowsurface_gl_p.h" -#include "../private/qegl_p.h" -#include "../private/qglextensions_p.h" -#include "../private/qgl_p.h" -#include "../private/qimagepixmapcleanuphooks_p.h" -#include "../private/qapplication_p.h" -#include "../private/qgraphicssystem_runtime_p.h" -#include "../private/qimage_p.h" -#include "../private/qeglproperties_p.h" -#include "../private/qeglcontext_p.h" - -#include "mpixmapdata.h" -#include "mgraphicssystem.h" -#include "mextensions.h" - -bool MGraphicsSystem::surfaceWasCreated = false; - -MGraphicsSystem::MGraphicsSystem() +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "qmeegopixmapdata.h" +#include "qmeegographicssystem.h" +#include "qmeegoextensions.h" + +bool QMeeGoGraphicsSystem::surfaceWasCreated = false; + +QMeeGoGraphicsSystem::QMeeGoGraphicsSystem() { qDebug("Using the meego graphics system"); } -MGraphicsSystem::~MGraphicsSystem() +QMeeGoGraphicsSystem::~QMeeGoGraphicsSystem() { qDebug("Meego graphics system destroyed"); qt_destroy_gl_share_widget(); } -QWindowSurface* MGraphicsSystem::createWindowSurface(QWidget *widget) const +QWindowSurface* QMeeGoGraphicsSystem::createWindowSurface(QWidget *widget) const { - MGraphicsSystem::surfaceWasCreated = true; + QMeeGoGraphicsSystem::surfaceWasCreated = true; QWindowSurface *surface = new QGLWindowSurface(widget); surface->window()->setAttribute(Qt::WA_NoSystemBackground); return surface; } -QPixmapData *MGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const +QPixmapData *QMeeGoGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const { // Long story short: without this it's possible to hit an // unitialized paintDevice due to a Qt bug too complex to even @@ -61,7 +61,7 @@ QPixmapData *MGraphicsSystem::createPixmapData(QPixmapData::PixelType type) cons return new QRasterPixmapData(type); } -QPixmapData *MGraphicsSystem::createPixmapData(QPixmapData *origin) +QPixmapData *QMeeGoGraphicsSystem::createPixmapData(QPixmapData *origin) { // If the pixmap is a raster type... // and if the pixmap pointer matches our mapping... @@ -71,14 +71,14 @@ QPixmapData *MGraphicsSystem::createPixmapData(QPixmapData *origin) QRasterPixmapData *rasterClass = static_cast (origin); void *rawResource = static_cast (rasterClass->buffer()->data_ptr()->data); - if (MPixmapData::sharedImagesMap.contains(rawResource)) - return new MPixmapData(); + if (QMeeGoPixmapData::sharedImagesMap.contains(rawResource)) + return new QMeeGoPixmapData(); } return new QRasterPixmapData(origin->pixelType()); } -QPixmapData* MGraphicsSystem::wrapPixmapData(QPixmapData *pmd) +QPixmapData* QMeeGoGraphicsSystem::wrapPixmapData(QPixmapData *pmd) { QString name = QApplicationPrivate::instance()->graphics_system_name; if (name == "runtime") { @@ -92,9 +92,9 @@ QPixmapData* MGraphicsSystem::wrapPixmapData(QPixmapData *pmd) return pmd; } -void MGraphicsSystem::setSurfaceFixedSize(int /*width*/, int /*height*/) +void QMeeGoGraphicsSystem::setSurfaceFixedSize(int /*width*/, int /*height*/) { - if (MGraphicsSystem::surfaceWasCreated) + if (QMeeGoGraphicsSystem::surfaceWasCreated) qWarning("Trying to set surface fixed size but surface already created!"); #ifdef QT_WAS_PATCHED @@ -105,20 +105,20 @@ void MGraphicsSystem::setSurfaceFixedSize(int /*width*/, int /*height*/) #endif } -void MGraphicsSystem::setSurfaceScaling(int x, int y, int width, int height) +void QMeeGoGraphicsSystem::setSurfaceScaling(int x, int y, int width, int height) { - MExtensions::ensureInitialized(); - MExtensions::eglSetSurfaceScalingNOK(QEgl::display(), QEglContext::currentContext(QEgl::OpenGL)->currentSurface, x, y, width, height); + QMeeGoExtensions::ensureInitialized(); + QMeeGoExtensions::eglSetSurfaceScalingNOK(QEgl::display(), QEglContext::currentContext(QEgl::OpenGL)->currentSurface, x, y, width, height); } -void MGraphicsSystem::setTranslucent(bool translucent) +void QMeeGoGraphicsSystem::setTranslucent(bool translucent) { QGLWindowSurface::surfaceFormat.setSampleBuffers(false); QGLWindowSurface::surfaceFormat.setSamples(0); QGLWindowSurface::surfaceFormat.setAlpha(translucent); } -QPixmapData *MGraphicsSystem::pixmapDataFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage) +QPixmapData *QMeeGoGraphicsSystem::pixmapDataFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage) { if (softImage.format() != QImage::Format_ARGB32_Premultiplied && softImage.format() != QImage::Format_ARGB32) { @@ -126,10 +126,10 @@ QPixmapData *MGraphicsSystem::pixmapDataFromEGLSharedImage(Qt::HANDLE handle, co return NULL; } - if (MGraphicsSystem::meegoRunning()) { - MPixmapData *pmd = new MPixmapData; + if (QMeeGoGraphicsSystem::meeGoRunning()) { + QMeeGoPixmapData *pmd = new QMeeGoPixmapData; pmd->fromEGLSharedImage(handle, softImage); - return MGraphicsSystem::wrapPixmapData(pmd); + return QMeeGoGraphicsSystem::wrapPixmapData(pmd); } else { QRasterPixmapData *pmd = new QRasterPixmapData(QPixmapData::PixmapType); pmd->fromImage(softImage, Qt::NoOpaqueDetection); @@ -139,30 +139,30 @@ QPixmapData *MGraphicsSystem::pixmapDataFromEGLSharedImage(Qt::HANDLE handle, co const_cast(softImage).data_ptr()->data) qFatal("Iternal misalignment of raster data detected. Prolly a QImage copy fail."); - MPixmapData::registerSharedImage(handle, softImage); - return MGraphicsSystem::wrapPixmapData(pmd); + QMeeGoPixmapData::registerSharedImage(handle, softImage); + return QMeeGoGraphicsSystem::wrapPixmapData(pmd); } } -void MGraphicsSystem::updateEGLSharedImagePixmap(QPixmap *pixmap) +void QMeeGoGraphicsSystem::updateEGLSharedImagePixmap(QPixmap *pixmap) { - MPixmapData *pmd = (MPixmapData *) pixmap->pixmapData(); + QMeeGoPixmapData *pmd = (QMeeGoPixmapData *) pixmap->pixmapData(); - // Basic sanity check to make sure this is really a MPixmapData... + // Basic sanity check to make sure this is really a QMeeGoPixmapData... if (pmd->classId() != QPixmapData::OpenGLClass) qFatal("Trying to updated EGLSharedImage pixmap but it's not really a shared image pixmap!"); pmd->updateFromSoftImage(); } -QPixmapData *MGraphicsSystem::pixmapDataWithGLTexture(int w, int h) +QPixmapData *QMeeGoGraphicsSystem::pixmapDataWithGLTexture(int w, int h) { QGLPixmapData *pmd = new QGLPixmapData(QPixmapData::PixmapType); pmd->resize(w, h); - return MGraphicsSystem::wrapPixmapData(pmd); + return QMeeGoGraphicsSystem::wrapPixmapData(pmd); } -bool MGraphicsSystem::meegoRunning() +bool QMeeGoGraphicsSystem::meeGoRunning() { if (! QApplicationPrivate::instance()) { qWarning("Application not running just yet... hard to know what system running!"); @@ -180,42 +180,42 @@ bool MGraphicsSystem::meegoRunning() /* C API */ -int m_image_to_egl_shared_image(const QImage &image) +int qt_meego_image_to_egl_shared_image(const QImage &image) { - return MPixmapData::imageToEGLSharedImage(image); + return QMeeGoPixmapData::imageToEGLSharedImage(image); } -QPixmapData* m_pixmapdata_from_egl_shared_image(Qt::HANDLE handle, const QImage &softImage) +QPixmapData* qt_meego_pixmapdata_from_egl_shared_image(Qt::HANDLE handle, const QImage &softImage) { - return MGraphicsSystem::pixmapDataFromEGLSharedImage(handle, softImage); + return QMeeGoGraphicsSystem::pixmapDataFromEGLSharedImage(handle, softImage); } -QPixmapData* m_pixmapdata_with_gl_texture(int w, int h) +QPixmapData* qt_meego_pixmapdata_with_gl_texture(int w, int h) { - return MGraphicsSystem::pixmapDataWithGLTexture(w, h); + return QMeeGoGraphicsSystem::pixmapDataWithGLTexture(w, h); } -bool m_destroy_egl_shared_image(Qt::HANDLE handle) +bool qt_meego_destroy_egl_shared_image(Qt::HANDLE handle) { - return MPixmapData::destroyEGLSharedImage(handle); + return QMeeGoPixmapData::destroyEGLSharedImage(handle); } -void m_set_surface_fixed_size(int width, int height) +void qt_meego_set_surface_fixed_size(int width, int height) { - MGraphicsSystem::setSurfaceFixedSize(width, height); + QMeeGoGraphicsSystem::setSurfaceFixedSize(width, height); } -void m_set_surface_scaling(int x, int y, int width, int height) +void qt_meego_set_surface_scaling(int x, int y, int width, int height) { - MGraphicsSystem::setSurfaceScaling(x, y, width, height); + QMeeGoGraphicsSystem::setSurfaceScaling(x, y, width, height); } -void m_set_translucent(bool translucent) +void qt_meego_set_translucent(bool translucent) { - MGraphicsSystem::setTranslucent(translucent); + QMeeGoGraphicsSystem::setTranslucent(translucent); } -void m_update_egl_shared_image_pixmap(QPixmap *pixmap) +void qt_meego_update_egl_shared_image_pixmap(QPixmap *pixmap) { - MGraphicsSystem::updateEGLSharedImagePixmap(pixmap); + QMeeGoGraphicsSystem::updateEGLSharedImagePixmap(pixmap); } diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.h b/src/plugins/graphicssystems/meego/qmeegographicssystem.h index c95d7ae..8dc4f23 100644 --- a/src/plugins/graphicssystems/meego/qmeegographicssystem.h +++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.h @@ -15,14 +15,14 @@ #ifndef MGRAPHICSSYSTEM_H #define MGRAPHICSSYSTEM_H -#include "../private/qgraphicssystem_p.h" +#include -class MGraphicsSystem : public QGraphicsSystem +class QMeeGoGraphicsSystem : public QGraphicsSystem { public: - MGraphicsSystem(); - ~MGraphicsSystem(); - + QMeeGoGraphicsSystem(); + ~QMeeGoGraphicsSystem(); + virtual QWindowSurface *createWindowSurface(QWidget *widget) const; virtual QPixmapData *createPixmapData(QPixmapData::PixelType) const; virtual QPixmapData *createPixmapData(QPixmapData *origin); @@ -37,22 +37,22 @@ public: static void updateEGLSharedImagePixmap(QPixmap *pixmap); private: - static bool meegoRunning(); - + static bool meeGoRunning(); + static bool surfaceWasCreated; }; /* C api */ extern "C" { - int m_image_to_egl_shared_image(const QImage &image); - QPixmapData* m_pixmapdata_from_egl_shared_image(Qt::HANDLE handle, const QImage &softImage); - QPixmapData* m_pixmapdata_with_gl_texture(int w, int h); - void m_update_egl_shared_image_pixmap(QPixmap *pixmap); - bool m_destroy_egl_shared_image(Qt::HANDLE handle); - void m_set_surface_fixed_size(int width, int height); - void m_set_surface_scaling(int x, int y, int width, int height); - void m_set_translucent(bool translucent); + int qt_meego_image_to_egl_shared_image(const QImage &image); + QPixmapData* qt_meego_pixmapdata_from_egl_shared_image(Qt::HANDLE handle, const QImage &softImage); + QPixmapData* qt_meego_pixmapdata_with_gl_texture(int w, int h); + void qt_meego_update_egl_shared_image_pixmap(QPixmap *pixmap); + bool qt_meego_destroy_egl_shared_image(Qt::HANDLE handle); + void qt_meego_set_surface_fixed_size(int width, int height); + void qt_meego_set_surface_scaling(int x, int y, int width, int height); + void qt_meego_set_translucent(bool translucent); } #endif diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.cpp b/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.cpp index 3bb7ffb..15c74a0 100644 --- a/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.cpp +++ b/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.cpp @@ -13,19 +13,19 @@ ****************************************************************************/ #include -#include "mgraphicssystemplugin.h" -#include "mgraphicssystem.h" +#include "qmeegographicssystemplugin.h" +#include "qmeegographicssystem.h" -QStringList MGraphicsSystemPlugin::keys() const +QStringList QMeeGoGraphicsSystemPlugin::keys() const { QStringList list; list << "meego"; return list; } -QGraphicsSystem *MGraphicsSystemPlugin::create(const QString&) +QGraphicsSystem *QMeeGoGraphicsSystemPlugin::create(const QString&) { - return new MGraphicsSystem; + return new QMeeGoGraphicsSystem; } -Q_EXPORT_PLUGIN2(meego, MGraphicsSystemPlugin) +Q_EXPORT_PLUGIN2(meego, QMeeGoGraphicsSystemPlugin) diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.h b/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.h index 84d4427..76e180a 100644 --- a/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.h +++ b/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.h @@ -15,9 +15,9 @@ #ifndef MGRAPHICSSYSTEMPLUGIN_H #define MGRAPHICSSYSTEMPLUGIN_H -#include "../private/qgraphicssystemplugin_p.h" +#include -class MGraphicsSystemPlugin : public QGraphicsSystemPlugin +class QMeeGoGraphicsSystemPlugin : public QGraphicsSystemPlugin { public: virtual QStringList keys() const; diff --git a/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp b/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp index b17adf3..b029761 100644 --- a/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp +++ b/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp @@ -12,25 +12,25 @@ ** ****************************************************************************/ -#include "mpixmapdata.h" -#include "mextensions.h" -#include "../private/qimage_p.h" -#include "../private/qwindowsurface_gl_p.h" -#include "../private/qeglcontext_p.h" -#include "../private/qapplication_p.h" -#include "../private/qgraphicssystem_runtime_p.h" +#include "qmeegopixmapdata.h" +#include "qmeegoextensions.h" +#include +#include +#include +#include +#include static EGLint preserved_image_attribs[] = { EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE }; -QHash MPixmapData::sharedImagesMap; +QHash QMeeGoPixmapData::sharedImagesMap; /* Public */ -MPixmapData::MPixmapData() : QGLPixmapData(QPixmapData::PixmapType) +QMeeGoPixmapData::QMeeGoPixmapData() : QGLPixmapData(QPixmapData::PixmapType) { } -void MPixmapData::fromTexture(GLuint textureId, int w, int h, bool alpha) +void QMeeGoPixmapData::fromTexture(GLuint textureId, int w, int h, bool alpha) { resize(w, h); texture()->id = textureId; @@ -38,36 +38,36 @@ void MPixmapData::fromTexture(GLuint textureId, int w, int h, bool alpha) softImage = QImage(); } -QImage MPixmapData::toImage() const +QImage QMeeGoPixmapData::toImage() const { return softImage; } -void MPixmapData::fromImage(const QImage &image, - Qt::ImageConversionFlags flags) +void QMeeGoPixmapData::fromImage(const QImage &image, + Qt::ImageConversionFlags flags) { void *rawResource = static_cast (((QImage &) image).data_ptr()->data); if (sharedImagesMap.contains(rawResource)) { - MImageInfo *info = sharedImagesMap.value(rawResource); + QMeeGoImageInfo *info = sharedImagesMap.value(rawResource); fromEGLSharedImage(info->handle, image); } else { // This should *never* happen since the graphics system should never - // create a MPixmapData for an origin that doesn't contain a raster + // create a QMeeGoPixmapData for an origin that doesn't contain a raster // image we know about. But... - qWarning("MPixmapData::fromImage called on non-know resource. Falling back..."); + qWarning("QMeeGoPixmapData::fromImage called on non-know resource. Falling back..."); QGLPixmapData::fromImage(image, flags); } } -void MPixmapData::fromEGLSharedImage(Qt::HANDLE handle, const QImage &si) +void QMeeGoPixmapData::fromEGLSharedImage(Qt::HANDLE handle, const QImage &si) { if (si.isNull()) qFatal("Trying to build pixmap with an empty/null softimage!"); QGLShareContextScope ctx(qt_gl_share_widget()->context()); - MExtensions::ensureInitialized(); + QMeeGoExtensions::ensureInitialized(); bool textureIsBound = false; GLuint newTextureId; @@ -87,8 +87,8 @@ void MPixmapData::fromEGLSharedImage(Qt::HANDLE handle, const QImage &si) if (err == GL_NO_ERROR) textureIsBound = true; - MExtensions::eglQueryImageNOK(QEgl::display(), image, EGL_WIDTH, &newWidth); - MExtensions::eglQueryImageNOK(QEgl::display(), image, EGL_HEIGHT, &newHeight); + QMeeGoExtensions::eglQueryImageNOK(QEgl::display(), image, EGL_WIDTH, &newWidth); + QMeeGoExtensions::eglQueryImageNOK(QEgl::display(), image, EGL_HEIGHT, &newHeight); QEgl::eglDestroyImageKHR(QEgl::display(), image); glFinish(); @@ -100,18 +100,18 @@ void MPixmapData::fromEGLSharedImage(Qt::HANDLE handle, const QImage &si) fromTexture(newTextureId, newWidth, newHeight, (si.hasAlphaChannel() && const_cast(si).data_ptr()->checkForAlphaPixels())); softImage = si; - MPixmapData::registerSharedImage(handle, softImage); + QMeeGoPixmapData::registerSharedImage(handle, softImage); } else { qWarning("Failed to create a texture from a shared image!"); glDeleteTextures(1, &newTextureId); } } -Qt::HANDLE MPixmapData::imageToEGLSharedImage(const QImage &image) +Qt::HANDLE QMeeGoPixmapData::imageToEGLSharedImage(const QImage &image) { QGLShareContextScope ctx(qt_gl_share_widget()->context()); - MExtensions::ensureInitialized(); + QMeeGoExtensions::ensureInitialized(); glFinish(); QGLPixmapData pixmapData(QPixmapData::PixmapType); @@ -126,7 +126,7 @@ Qt::HANDLE MPixmapData::imageToEGLSharedImage(const QImage &image) glFinish(); if (eglimage) { - EGLNativeSharedImageTypeNOK handle = MExtensions::eglCreateSharedImageNOK(QEgl::display(), eglimage, NULL); + EGLNativeSharedImageTypeNOK handle = QMeeGoExtensions::eglCreateSharedImageNOK(QEgl::display(), eglimage, NULL); QEgl::eglDestroyImageKHR(QEgl::display(), eglimage); glFinish(); return (Qt::HANDLE) handle; @@ -136,7 +136,7 @@ Qt::HANDLE MPixmapData::imageToEGLSharedImage(const QImage &image) } } -void MPixmapData::updateFromSoftImage() +void QMeeGoPixmapData::updateFromSoftImage() { m_dirty = true; m_source = softImage; @@ -146,28 +146,28 @@ void MPixmapData::updateFromSoftImage() qWarning("Ooops, looks like softImage changed dimensions since last updated! Corruption ahead?!"); } -bool MPixmapData::destroyEGLSharedImage(Qt::HANDLE h) +bool QMeeGoPixmapData::destroyEGLSharedImage(Qt::HANDLE h) { QGLShareContextScope ctx(qt_gl_share_widget()->context()); - MExtensions::ensureInitialized(); + QMeeGoExtensions::ensureInitialized(); - QMutableHashIterator i(sharedImagesMap); + QMutableHashIterator i(sharedImagesMap); while (i.hasNext()) { i.next(); if (i.value()->handle == h) i.remove(); } - return MExtensions::eglDestroySharedImageNOK(QEgl::display(), (EGLNativeSharedImageTypeNOK) h); + return QMeeGoExtensions::eglDestroySharedImageNOK(QEgl::display(), (EGLNativeSharedImageTypeNOK) h); } -void MPixmapData::registerSharedImage(Qt::HANDLE handle, const QImage &si) +void QMeeGoPixmapData::registerSharedImage(Qt::HANDLE handle, const QImage &si) { void *raw = static_cast (((QImage) si).data_ptr()->data); - MImageInfo *info; + QMeeGoImageInfo *info; if (! sharedImagesMap.contains(raw)) { - info = new MImageInfo; + info = new QMeeGoImageInfo; info->handle = handle; info->rawFormat = si.format(); sharedImagesMap.insert(raw, info); diff --git a/src/plugins/graphicssystems/meego/qmeegopixmapdata.h b/src/plugins/graphicssystems/meego/qmeegopixmapdata.h index ae4ed6b..5fb7f9f 100644 --- a/src/plugins/graphicssystems/meego/qmeegopixmapdata.h +++ b/src/plugins/graphicssystems/meego/qmeegopixmapdata.h @@ -15,18 +15,18 @@ #ifndef MPIXMAPDATA_H #define MPIXMAPDATA_H -#include "../private/qpixmapdata_gl_p.h" +#include -struct MImageInfo +struct QMeeGoImageInfo { Qt::HANDLE handle; QImage::Format rawFormat; }; -class MPixmapData : public QGLPixmapData +class QMeeGoPixmapData : public QGLPixmapData { public: - MPixmapData(); + QMeeGoPixmapData(); void fromTexture(GLuint textureId, int w, int h, bool alpha); virtual void fromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage); @@ -35,9 +35,9 @@ public: virtual void updateFromSoftImage(); QImage softImage; - - static QHash sharedImagesMap; - + + static QHash sharedImagesMap; + static Qt::HANDLE imageToEGLSharedImage(const QImage &image); static bool destroyEGLSharedImage(Qt::HANDLE h); static void registerSharedImage(Qt::HANDLE handle, const QImage &si); -- cgit v0.12 From 06159e2dbe169e05d9fd3f450d2993208e6dd21d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 6 Sep 2010 09:58:09 +0200 Subject: Updated license headers for meego graphics system. --- .../graphicssystems/meego/qmeegoextensions.cpp | 41 ++++++++++++++++++---- .../graphicssystems/meego/qmeegoextensions.h | 41 ++++++++++++++++++---- .../graphicssystems/meego/qmeegographicssystem.cpp | 41 ++++++++++++++++++---- .../graphicssystems/meego/qmeegographicssystem.h | 41 ++++++++++++++++++---- .../meego/qmeegographicssystemplugin.cpp | 41 ++++++++++++++++++---- .../meego/qmeegographicssystemplugin.h | 41 ++++++++++++++++++---- .../graphicssystems/meego/qmeegopixmapdata.cpp | 41 ++++++++++++++++++---- .../graphicssystems/meego/qmeegopixmapdata.h | 41 ++++++++++++++++++---- 8 files changed, 272 insertions(+), 56 deletions(-) diff --git a/src/plugins/graphicssystems/meego/qmeegoextensions.cpp b/src/plugins/graphicssystems/meego/qmeegoextensions.cpp index f40fc43..e7f6439 100644 --- a/src/plugins/graphicssystems/meego/qmeegoextensions.cpp +++ b/src/plugins/graphicssystems/meego/qmeegoextensions.cpp @@ -1,14 +1,41 @@ -/*************************************************************************** +/**************************************************************************** ** ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. -** Contact: Nokia Corporation +** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This library is free software; you can redistribute it and/or -** modify it 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. +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/plugins/graphicssystems/meego/qmeegoextensions.h b/src/plugins/graphicssystems/meego/qmeegoextensions.h index b8e6195..7f219de 100644 --- a/src/plugins/graphicssystems/meego/qmeegoextensions.h +++ b/src/plugins/graphicssystems/meego/qmeegoextensions.h @@ -1,14 +1,41 @@ -/*************************************************************************** +/**************************************************************************** ** ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. -** Contact: Nokia Corporation +** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This library is free software; you can redistribute it and/or -** modify it 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. +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp index e575cf3..e2c8425 100644 --- a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp +++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp @@ -1,14 +1,41 @@ -/*************************************************************************** +/**************************************************************************** ** ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. -** Contact: Nokia Corporation +** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This library is free software; you can redistribute it and/or -** modify it 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. +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.h b/src/plugins/graphicssystems/meego/qmeegographicssystem.h index 8dc4f23..59392ad 100644 --- a/src/plugins/graphicssystems/meego/qmeegographicssystem.h +++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.h @@ -1,14 +1,41 @@ -/*************************************************************************** +/**************************************************************************** ** ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. -** Contact: Nokia Corporation +** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This library is free software; you can redistribute it and/or -** modify it 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. +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.cpp b/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.cpp index 15c74a0..7c142eb 100644 --- a/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.cpp +++ b/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.cpp @@ -1,14 +1,41 @@ -/*************************************************************************** +/**************************************************************************** ** ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. -** Contact: Nokia Corporation +** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This library is free software; you can redistribute it and/or -** modify it 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. +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.h b/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.h index 76e180a..336458f 100644 --- a/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.h +++ b/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.h @@ -1,14 +1,41 @@ -/*************************************************************************** +/**************************************************************************** ** ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. -** Contact: Nokia Corporation +** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This library is free software; you can redistribute it and/or -** modify it 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. +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp b/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp index b029761..33611dc 100644 --- a/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp +++ b/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp @@ -1,14 +1,41 @@ -/*************************************************************************** +/**************************************************************************** ** ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. -** Contact: Nokia Corporation +** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This library is free software; you can redistribute it and/or -** modify it 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. +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/plugins/graphicssystems/meego/qmeegopixmapdata.h b/src/plugins/graphicssystems/meego/qmeegopixmapdata.h index 5fb7f9f..8af33bd 100644 --- a/src/plugins/graphicssystems/meego/qmeegopixmapdata.h +++ b/src/plugins/graphicssystems/meego/qmeegopixmapdata.h @@ -1,14 +1,41 @@ -/*************************************************************************** +/**************************************************************************** ** ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. -** Contact: Nokia Corporation +** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This library is free software; you can redistribute it and/or -** modify it 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. +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ ** ****************************************************************************/ -- cgit v0.12 From 34c08ff7048419713464b28679ac15a250bd7dd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 6 Sep 2010 13:14:30 +0200 Subject: Imported meego graphics system helper sources. From http://www.gitorious.com/meego-graphics/meego-graphics --- .../meegographicssystemhelper.pro | 19 +++ .../mgraphicssystemhelper.cpp | 106 +++++++++++++++ .../mgraphicssystemhelper.h | 148 +++++++++++++++++++++ tools/qmeegographicssystemhelper/mliveimage.cpp | 88 ++++++++++++ tools/qmeegographicssystemhelper/mliveimage.h | 79 +++++++++++ tools/qmeegographicssystemhelper/mliveimage_p.h | 36 +++++ tools/qmeegographicssystemhelper/mlivepixmap.cpp | 136 +++++++++++++++++++ tools/qmeegographicssystemhelper/mlivepixmap.h | 71 ++++++++++ tools/qmeegographicssystemhelper/mlivepixmap_p.h | 39 ++++++ .../qmeegographicssystemhelper/moverlaywidget.cpp | 72 ++++++++++ tools/qmeegographicssystemhelper/moverlaywidget.h | 59 ++++++++ tools/qmeegographicssystemhelper/mruntime.cpp | 112 ++++++++++++++++ tools/qmeegographicssystemhelper/mruntime.h | 36 +++++ 13 files changed, 1001 insertions(+) create mode 100644 tools/qmeegographicssystemhelper/meegographicssystemhelper.pro create mode 100644 tools/qmeegographicssystemhelper/mgraphicssystemhelper.cpp create mode 100644 tools/qmeegographicssystemhelper/mgraphicssystemhelper.h create mode 100644 tools/qmeegographicssystemhelper/mliveimage.cpp create mode 100644 tools/qmeegographicssystemhelper/mliveimage.h create mode 100644 tools/qmeegographicssystemhelper/mliveimage_p.h create mode 100644 tools/qmeegographicssystemhelper/mlivepixmap.cpp create mode 100644 tools/qmeegographicssystemhelper/mlivepixmap.h create mode 100644 tools/qmeegographicssystemhelper/mlivepixmap_p.h create mode 100644 tools/qmeegographicssystemhelper/moverlaywidget.cpp create mode 100644 tools/qmeegographicssystemhelper/moverlaywidget.h create mode 100644 tools/qmeegographicssystemhelper/mruntime.cpp create mode 100644 tools/qmeegographicssystemhelper/mruntime.h diff --git a/tools/qmeegographicssystemhelper/meegographicssystemhelper.pro b/tools/qmeegographicssystemhelper/meegographicssystemhelper.pro new file mode 100644 index 0000000..cab096e --- /dev/null +++ b/tools/qmeegographicssystemhelper/meegographicssystemhelper.pro @@ -0,0 +1,19 @@ +TEMPLATE = lib +TARGET = meegographicssystemhelper +QT += gui +INCLUDEPATH += '../' +LIBS += -L../plugin +CONFIG += debug +VERSION = 0.1.9 +HEADERS = mgraphicssystemhelper.h moverlaywidget.h mlivepixmap.h mliveimage.h mruntime.h mliveimage_p.h mlivepixmap_p.h +SOURCES = mgraphicssystemhelper.cpp mgraphicssystemhelper.h moverlaywidget.h moverlaywidget.cpp mruntime.cpp mruntime.h mlivepixmap.cpp mlivepixmap.h mliveimage.h mliveimage.cpp mliveimage_p.h mlivepixmap_p.h + +target.path = /usr/lib/ + +headers.files = mgraphicssystemhelper.h moverlaywidget.h mlivepixmap.h mliveimage.h +headers.path = /usr/include/meegographicssystemhelper/ + +pkg.files = meegographicssystemhelper.pc +pkg.path = /usr/lib/pkgconfig/ + +INSTALLS += target headers pkg diff --git a/tools/qmeegographicssystemhelper/mgraphicssystemhelper.cpp b/tools/qmeegographicssystemhelper/mgraphicssystemhelper.cpp new file mode 100644 index 0000000..ff921fd --- /dev/null +++ b/tools/qmeegographicssystemhelper/mgraphicssystemhelper.cpp @@ -0,0 +1,106 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#define ENSURE_RUNNING_MEEGO {if (! MGraphicsSystemHelper::isRunningMeeGo()) { qFatal("Using meego functionality but not running meego graphics system!"); }} + +#include "mgraphicssystemhelper.h" +#include "../private/qapplication_p.h" +#include "../private/qgraphicssystem_runtime_p.h" +#include "../private/qpixmap_raster_p.h" +#include "mruntime.h" + +QString MGraphicsSystemHelper::runningGraphicsSystemName() +{ + if (! QApplicationPrivate::instance()) { + qWarning("Querying graphics system but application not running yet!"); + return ""; + } + + QString name = QApplicationPrivate::instance()->graphics_system_name; + if (name == "runtime") { + QRuntimeGraphicsSystem *rsystem = (QRuntimeGraphicsSystem *) QApplicationPrivate::instance()->graphics_system; + name = rsystem->graphicsSystemName(); + } + + return name; +} + +bool MGraphicsSystemHelper::isRunningMeeGo() +{ + return (runningGraphicsSystemName() == "meego"); +} + +void MGraphicsSystemHelper::switchToMeeGo() +{ + if (runningGraphicsSystemName() == "meego") + return; + + if (QApplicationPrivate::instance()->graphics_system_name != "runtime") + qWarning("Can't switch to meego - switching only supported with 'runtime' graphics system."); + else { + QApplication *app = static_cast(QCoreApplication::instance()); + app->setGraphicsSystem("meego"); + } +} + +void MGraphicsSystemHelper::switchToRaster() +{ + if (runningGraphicsSystemName() == "raster") + return; + + if (QApplicationPrivate::instance()->graphics_system_name != "runtime") + qWarning("Can't switch to raster - switching only supported with 'runtime' graphics system."); + else { + QApplication *app = static_cast(QCoreApplication::instance()); + app->setGraphicsSystem("raster"); + } +} + +Qt::HANDLE MGraphicsSystemHelper::imageToEGLSharedImage(const QImage &image) +{ + ENSURE_RUNNING_MEEGO; + return MRuntime::imageToEGLSharedImage(image); +} + +QPixmap MGraphicsSystemHelper::pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage) +{ + // This function is supported when not running meego too. A raster-backed + // pixmap will be created... but when you switch back to 'meego', it'll + // be replaced with a EGL shared image backing. + return MRuntime::pixmapFromEGLSharedImage(handle, softImage); +} + +QPixmap MGraphicsSystemHelper::pixmapWithGLTexture(int w, int h) +{ + ENSURE_RUNNING_MEEGO; + return MRuntime::pixmapWithGLTexture(w, h); +} + +bool MGraphicsSystemHelper::destroyEGLSharedImage(Qt::HANDLE handle) +{ + ENSURE_RUNNING_MEEGO; + return MRuntime::destroyEGLSharedImage(handle); +} + +void MGraphicsSystemHelper::updateEGLSharedImagePixmap(QPixmap *p) +{ + ENSURE_RUNNING_MEEGO; + return MRuntime::updateEGLSharedImagePixmap(p); +} + +void MGraphicsSystemHelper::setTranslucent(bool translucent) +{ + ENSURE_RUNNING_MEEGO; + MRuntime::setTranslucent(translucent); +} diff --git a/tools/qmeegographicssystemhelper/mgraphicssystemhelper.h b/tools/qmeegographicssystemhelper/mgraphicssystemhelper.h new file mode 100644 index 0000000..1966648 --- /dev/null +++ b/tools/qmeegographicssystemhelper/mgraphicssystemhelper.h @@ -0,0 +1,148 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#ifndef MGRAPHICSSYSTEMHELPER_H +#define MGRAPHICSSYSTEMHELPER_H + +#include +#include +#include "mlivepixmap.h" + +class QLibrary; + +//! The base class for accressing special meego graphics system features. +/*! + This class is a helper class with static-only methods for accessing various + meego graphics system functionalities. The way it works is that the helper + dynamically calls-in to the loaded graphicssystem plugin... therefore, you're + expected to make sure that you're indeed running with 'meego' before using any + of the specialized methods. + + In example: + + \code + QPixmap p; + if (MGraphicsSystemHelper::isRunningMeeGo()) { + p = MGraphicsSystemHelper::pixmapWithGLTexture(64, 64); + } else { + p = QPixmap(64, 64); + } + \endcode + + Calling any of the meego-specific features while not running meego might + give unpredictable results. The only functions safe to call at all times are: + + \code + MGraphicsSystemHelper::isRunningMeeGo(); + MGraphicsSystemHelper::runningGraphicsSystemName(); + MGraphicsSystemHelper::switchToMeeGo(); + MGraphicsSystemHelper::switchToRaster(); + \endcode +*/ + +class MGraphicsSystemHelper +{ +public: + //! Returns true if running meego. + /*! + Returns true if the currently active (running) system is 'meego' with OpenGL. + This returns both true if the app was started with 'meego' or was started with + 'runtime' graphics system and the currently active system through the runtime + switching is 'meego'. + */ + static bool isRunningMeeGo(); + + //! Switches to meego graphics system. + /*! + When running with the 'runtime' graphics system, sets the currently active + system to 'meego'. The window surface and all the resources are automatically + migrated to OpenGL. Will fail if the active graphics system is not 'runtime'. + */ + static void switchToMeeGo(); + + //! Switches to raster graphics system + /*! + When running with the 'runtime' graphics system, sets the currently active + system to 'raster'. The window surface and the graphics resources (including the + EGL shared image resources) are automatically migrated back to the CPU. All OpenGL + resources (surface, context, cache, font cache) are automaticall anihilated. + */ + static void switchToRaster(); + + //! Returns the name of the active graphics system + /*! + Returns the name of the currently active system. If running with 'runtime' graphics + system, returns the name of the active system inside the runtime graphics system + */ + static QString runningGraphicsSystemName(); + + //! Creates a new EGL shared image. + /*! + Creates a new EGL shared image from the given image. The EGL shared image wraps + a GL texture in the native format and can be easily accessed from other processes. + */ + static Qt::HANDLE imageToEGLSharedImage(const QImage &image); + + //! Creates a QPixmap from an EGL shared image + /*! + Creates a new QPixmap from the given EGL shared image handle. The QPixmap can be + used for painting like any other pixmap. The softImage should point to an alternative, + software version of the graphical resource -- ie. obtained from theme daemon. The + softImage can be allocated on a QSharedMemory slice for easy sharing across processes + too. When the application is migrated ToRaster, this softImage will replace the + contents of the sharedImage. + + It's ok to call this function too when not running 'meego' graphics system. In this + case it'll create a QPixmap backed with a raster data (from softImage)... but when + the system is switched back to 'meego', the QPixmap will be migrated to a EGL-shared image + backed storage (handle). + */ + static QPixmap pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage); + + //! Destroys an EGL shared image. + /*! + Destroys an EGLSharedImage previously created with an ::imageToEGLSharedImage call. + Returns true if the image was found and the destruction was successfull. Notice that + this destroys the image for all processes using it. + */ + static bool destroyEGLSharedImage(Qt::HANDLE handle); + + //! Updates the QPixmap backed with an EGLShared image. + /*! + This function re-reads the softImage that was specified when creating the pixmap with + ::pixmapFromEGLSharedImage and updates the EGL Shared image contents. It can be used + to share cross-proccess mutable EGLShared images. + */ + static void updateEGLSharedImagePixmap(QPixmap *p); + + //! Create a new QPixmap with a GL texture. + /*! + Creates a new QPixmap which is backed by an OpenGL local texture. Drawing to this + QPixmap will be accelerated by hardware -- unlike the normal (new QPixmap()) pixmaps, + which are backed by a software engine and only migrated to GPU when used. Migrating those + GL-backed pixmaps when going ToRaster is expsensive (they need to be downloaded from + GPU to CPU) so use wisely. + */ + static QPixmap pixmapWithGLTexture(int w, int h); + + //! Sets translucency (alpha) on the base window surface. + /*! + This function needs to be called *before* any widget/content is created. + When called with true, the base window surface will be translucent and initialized + with QGLFormat.alpha == true. + */ + static void setTranslucent(bool translucent); +}; + +#endif diff --git a/tools/qmeegographicssystemhelper/mliveimage.cpp b/tools/qmeegographicssystemhelper/mliveimage.cpp new file mode 100644 index 0000000..37ead21 --- /dev/null +++ b/tools/qmeegographicssystemhelper/mliveimage.cpp @@ -0,0 +1,88 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include "mliveimage.h" +#include "mliveimage_p.h" +#include "mlivepixmap.h" +#include "mlivepixmap_p.h" + +/* MLiveImagePrivate */ + +MLiveImagePrivate::MLiveImagePrivate() +{ +} + +MLiveImagePrivate::~MLiveImagePrivate() +{ + if (attachedPixmaps.length() > 0) + qWarning("Destroying MLiveImage but it still has MLivePixmaps attached!"); +} + +void MLiveImagePrivate::attachPixmap(MLivePixmap* pixmap) +{ + attachedPixmaps << pixmap; +} + +void MLiveImagePrivate::detachPixmap(MLivePixmap* pixmap) +{ + attachedPixmaps.removeAll(pixmap); +} + +/* MLiveImage */ + +MLiveImage* MLiveImage::liveImageWithSize(int w, int h, Format format, int buffers) +{ + if (format != Format_ARGB32_Premultiplied) { + qWarning("Only _ARGB32_Premultiplied format is supported for live images now!"); + return 0; + } + + if (buffers != 1) { + qWarning("Only single-buffer streams are supported at the moment"); + return 0; + } + + MLiveImage *liveImage = new MLiveImage(w, h); + return liveImage; +} + +MLiveImage::MLiveImage(int w, int h) : QImage(w, h, QImage::Format_ARGB32_Premultiplied), d_ptr(new MLiveImagePrivate()) +{ + Q_D(MLiveImage); + d->q_ptr = this; +} + +MLiveImage::~MLiveImage() +{ +} + +void MLiveImage::lock(int buffer) +{ + if (buffer != 0) + qWarning("Only locking 0 buffer is supported at the moment!"); +} + +void MLiveImage::release(int buffer) +{ + Q_D(MLiveImage); + + if (buffer != 0) { + qWarning("Only locking 0 buffer is supported at the moment!"); + return; + } + + // We need to copy the update image to all the client MLivePixmap's + foreach (MLivePixmap* livePixmap, d->attachedPixmaps) + livePixmap->d_ptr->copyBackFrom((const void *) bits()); +} \ No newline at end of file diff --git a/tools/qmeegographicssystemhelper/mliveimage.h b/tools/qmeegographicssystemhelper/mliveimage.h new file mode 100644 index 0000000..f945b34 --- /dev/null +++ b/tools/qmeegographicssystemhelper/mliveimage.h @@ -0,0 +1,79 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#ifndef MLIVEIMAGE_H +#define MLIVEIMAGE_H + +#include + +class MLivePixmap; +class MLiveImagePrivate; + +//! A streamable QImage subclass. +/*! +*/ + +class MLiveImage : public QImage +{ +public: + //! Format specifier. + /*! + Used to specify the format of the underlying image data for MLiveImage. + */ + enum Format { + Format_ARGB32_Premultiplied //! 32bit, AARRGGBB format. The typical Qt format. + }; + + //! Locks the access to the image. + /*! + All drawing/access to the underlying image data needs to happen between + ::lock() and ::unlock() pairs. + */ + void lock(int buffer = 0); + + //! Unlocks the access to the image. + /*! + All drawing/access to the underlying image data needs to happen between + ::lock() and ::unlock() pairs. + */ + void release(int buffer = 0); + + //! Destroys the image. + /*! + It's a mistake to destroy an image before destroying all the MLivePixmaps + built on top of it. You should first destroy all the MLivePixmaps. + */ + virtual ~MLiveImage(); + + //! Creates and returns a new live image with the given parameters. + /*! + The new image is created with the given width w and the given height h. + The format specifies the color format used by the image. Optionally, a + number of buffers can be specfied for a stream-like behavior. + */ + static MLiveImage* liveImageWithSize(int w, int h, Format format, int buffers = 1); + +private: + MLiveImage(int w, int h); //! Private bits. + Q_DISABLE_COPY(MLiveImage) + Q_DECLARE_PRIVATE(MLiveImage) + +protected: + QScopedPointer d_ptr; + + friend class MLivePixmap; + friend class MLivePixmapPrivate; +}; + +#endif diff --git a/tools/qmeegographicssystemhelper/mliveimage_p.h b/tools/qmeegographicssystemhelper/mliveimage_p.h new file mode 100644 index 0000000..0789b93 --- /dev/null +++ b/tools/qmeegographicssystemhelper/mliveimage_p.h @@ -0,0 +1,36 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include "mliveimage.h" + +#ifndef MLIVEIMAGE_P_H +#define MLIVEIMAGE_P_H + +class MLiveImagePrivate +{ +public: + Q_DECLARE_PUBLIC(MLiveImage); + MLiveImagePrivate(); + virtual ~MLiveImagePrivate(); + void attachPixmap(MLivePixmap* pixmap); + void detachPixmap(MLivePixmap* pixmap); + + QList attachedPixmaps; + MLiveImage *q_ptr; + + friend class MLivePixmap; + friend class MLivePixmapPrivate; +}; + +#endif \ No newline at end of file diff --git a/tools/qmeegographicssystemhelper/mlivepixmap.cpp b/tools/qmeegographicssystemhelper/mlivepixmap.cpp new file mode 100644 index 0000000..2f7abd7 --- /dev/null +++ b/tools/qmeegographicssystemhelper/mlivepixmap.cpp @@ -0,0 +1,136 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include "mlivepixmap.h" +#include "../private/qimage_p.h" +#include "../private/qpixmap_raster_p.h" +#include "mlivepixmap_p.h" +#include "mliveimage_p.h" +#include + +/* MLivePixmapPrivate */ + +MLivePixmapPrivate::MLivePixmapPrivate() : shm(0), shmSerial(0), owns(true), parentImage(0) +{ +} + +void MLivePixmapPrivate::copyBackFrom(const void *raw) +{ + Q_Q(MLivePixmap); + + q->detach(); + shm->lock(); + uchar *dest = ((uchar *) shm->data()) + (2 * sizeof(int)); + memcpy(dest, raw, q->width() * q->height() * 4); + shm->unlock(); +} + +MLivePixmapPrivate::~MLivePixmapPrivate() +{ + Q_Q(MLivePixmap); + + if (parentImage) + parentImage->d_ptr->detachPixmap(q); + + if (shm) + shm->detach(); + + if (owns) + delete shm; +} + +/* MLivePixmap */ + +MLivePixmap::MLivePixmap(QPixmapData *p) : QPixmap(p), d_ptr(new MLivePixmapPrivate()) +{ + Q_D(MLivePixmap); + d->q_ptr = this; +} + +MLivePixmap* MLivePixmap::fromLiveImage(MLiveImage *liveImage) +{ + static int counter = 100; + QSharedMemory *shm = NULL; + uchar* imgData = NULL; + int *header = NULL; + int w = liveImage->width(); + int h = liveImage->height(); + + counter++; + shm = new QSharedMemory(QString("MLivePixmap%1").arg(counter)); + shm->create((w * h * 4) + 2 * sizeof(int)); // +2 to store width & height + shm->attach(); + + imgData = ((uchar *) shm->data()) + (2 * sizeof(int)); + header = (int *) shm->data(); + + header[0] = w; + header[1] = h; + + QImage img(imgData, w, h, QImage::Format_ARGB32_Premultiplied); + + QPixmapData *pmd = new QRasterPixmapData(QPixmapData::PixmapType); + pmd->fromImage(img, Qt::NoOpaqueDetection); + + MLivePixmap *livePixmap = new MLivePixmap(pmd); + livePixmap->d_ptr->shm = shm; + livePixmap->d_ptr->owns = true; + livePixmap->d_ptr->shmSerial = counter; + livePixmap->d_ptr->parentImage = liveImage; + + liveImage->d_ptr->attachPixmap(livePixmap); + + return livePixmap; +} + +MLivePixmap* MLivePixmap::fromHandle(Qt::HANDLE handle) +{ + QSharedMemory *shm = NULL; + int *header; + int width; + int height; + uchar* imgData; + + shm = new QSharedMemory(QString("MLivePixmap%1").arg(handle)); + shm->attach(); + + shm->lock(); + header = (int *) shm->data(); + width = header[0]; + height = header[1]; + shm->unlock(); + + imgData = ((uchar *) shm->data()) + (2 * sizeof(int)); + QImage img(imgData, width, height, QImage::Format_ARGB32_Premultiplied); + + QPixmapData *pmd = new QRasterPixmapData(QPixmapData::PixmapType); + pmd->fromImage(img, Qt::NoOpaqueDetection); + + MLivePixmap *livePixmap = new MLivePixmap(pmd); + livePixmap->d_ptr->shm = shm; + livePixmap->d_ptr->owns = false; + livePixmap->d_ptr->shmSerial = handle; + + return livePixmap; +} + +MLivePixmap::~MLivePixmap() +{ +} + +Qt::HANDLE MLivePixmap::handle() +{ + Q_D(MLivePixmap); + return d->shmSerial; +} diff --git a/tools/qmeegographicssystemhelper/mlivepixmap.h b/tools/qmeegographicssystemhelper/mlivepixmap.h new file mode 100644 index 0000000..dee4d2a --- /dev/null +++ b/tools/qmeegographicssystemhelper/mlivepixmap.h @@ -0,0 +1,71 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#ifndef MLIVEPIXMAP_H +#define MLIVEPIXMAP_H + +#include +#include "mliveimage.h" + +class MLivePixmapPrivate; +class QSharedMemory; +class QImage; + +//! A pixmap representing streamed content. +/*! +*/ + +class MLivePixmap : public QPixmap +{ +public: + //! Creates new pixmap from the given MLiveImage. + /*! + The created MLivePixmap will be attached to the given MLiveImage. + Updates to the MLiveImage will be represented on this newly created + MLivePixmap. + */ + static MLivePixmap* fromLiveImage(MLiveImage *liveImage); + + //! Creates a new MLivePixmap from the specified handle. + /*! + The handle can be used to share MLivePixmap cross-process. + */ + static MLivePixmap* fromHandle(Qt::HANDLE handle); + + //! Returns the handle for this MLivePixmap. + /*! + The handle can be used to share MLivePixmap cross-process. + */ + Qt::HANDLE handle(); + + //! Destroys the MLivePixmap. + /*! + All MLivePixmaps attached to a given MLiveImage have to be destroyed + before the MLiveImage itself is destroyed. + */ + virtual ~MLivePixmap(); + +private: + MLivePixmap(QPixmapData *p); + Q_DISABLE_COPY(MLivePixmap) + Q_DECLARE_PRIVATE(MLivePixmap) + +protected: + QScopedPointer d_ptr; //! Private bits. + + friend class MLiveImage; + friend class MLiveImagePrivate; +}; + +#endif diff --git a/tools/qmeegographicssystemhelper/mlivepixmap_p.h b/tools/qmeegographicssystemhelper/mlivepixmap_p.h new file mode 100644 index 0000000..4ff64de --- /dev/null +++ b/tools/qmeegographicssystemhelper/mlivepixmap_p.h @@ -0,0 +1,39 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include "mlivepixmap.h" + +#ifndef MLIVEPIXMAP_P_H +#define MLIVEPIXMAP_P_H + +class MLivePixmapPrivate +{ +public: + Q_DECLARE_PUBLIC(MLivePixmap); + MLivePixmapPrivate(); + void copyBackFrom(const void *raw); + virtual ~MLivePixmapPrivate(); + + QSharedMemory *shm; + int shmSerial; + bool owns; + MLiveImage *parentImage; + + MLivePixmap *q_ptr; + + friend class MLiveImage; + friend class MLiveImagePrivate; +}; + +#endif \ No newline at end of file diff --git a/tools/qmeegographicssystemhelper/moverlaywidget.cpp b/tools/qmeegographicssystemhelper/moverlaywidget.cpp new file mode 100644 index 0000000..8f64b3f --- /dev/null +++ b/tools/qmeegographicssystemhelper/moverlaywidget.cpp @@ -0,0 +1,72 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include +#include +#include +#include +#include "moverlaywidget.h" +#include "mgraphicssystemhelper.h" +#include "mruntime.h" + +MOverlayWidget::MOverlayWidget(int surfaceWidth, int surfaceHeight, QWidget *parent) : QWidget(parent, 0), + sw(surfaceWidth), + sh(surfaceHeight) +{ + if (! MGraphicsSystemHelper::isRunningMeeGo()) + qFatal("MOverlayWidget can only be used when running with 'meego' graphics system!"); + + MRuntime::setSurfaceFixedSize(surfaceWidth, surfaceHeight); + + scaleW = sw / 864.0; + scaleH = sh / 480.0; + installEventFilter(this); +} + +QPoint MOverlayWidget::convertPoint(const QPoint &p) +{ + int x = p.x() * scaleW; + int y = p.y() * scaleH; + return QPoint(x, y); +} + +void MOverlayWidget::showEvent(QShowEvent *event) +{ + MRuntime::setSurfaceScaling(0, 0, width(), height()); +} + +bool MOverlayWidget::eventFilter(QObject *obj, QEvent *event) +{ + if (event->spontaneous() == false) + return false; + + switch(event->type()) { + case QEvent::MouseButtonPress: + case QEvent::MouseButtonRelease: + { + QMouseEvent *e = static_cast (event); + QMouseEvent newEvent = QMouseEvent(e->type(), + convertPoint(e->pos()), + convertPoint(e->globalPos()), + e->button(), + e->buttons(), + e->modifiers()); + QCoreApplication::sendEvent(this, &newEvent); + return true; + } + + default: + return false; + } +} diff --git a/tools/qmeegographicssystemhelper/moverlaywidget.h b/tools/qmeegographicssystemhelper/moverlaywidget.h new file mode 100644 index 0000000..f45a673 --- /dev/null +++ b/tools/qmeegographicssystemhelper/moverlaywidget.h @@ -0,0 +1,59 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#ifndef MOVERLAYWIDGET_H +#define MOVERLAYWIDGET_H + +#include + +//! A widget automatically scaling it's content. +/*! +*/ + +class MOverlayWidget : public QWidget +{ +public: + //! Constructs a new scaling widget. + /*! + The real surface used for this widget will have the specified + width and height. + */ + MOverlayWidget(int surfaceWidth, int surfaceHeight, QWidget *parent = 0); + + + //! Event filtering function. + /*! + Converts coordinates for mouse/touch event. Do not + call manually. + */ + bool eventFilter(QObject *obj, QEvent *event); + + //! Standard override. + /*! + The surface scaling on the target paint device is being + set when the widget is displayed for the first time. + */ + virtual void showEvent(QShowEvent *event); + +private: + //! Converts coordinates between real & virtual area of the widget. + QPoint convertPoint(const QPoint &p); + + int sw; /// Surface real width. + int sh; /// Surface real height. + float scaleW; /// Width scaling factor. + float scaleH; /// Height scaling factor. +}; + +#endif diff --git a/tools/qmeegographicssystemhelper/mruntime.cpp b/tools/qmeegographicssystemhelper/mruntime.cpp new file mode 100644 index 0000000..b1b0874 --- /dev/null +++ b/tools/qmeegographicssystemhelper/mruntime.cpp @@ -0,0 +1,112 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include "mruntime.h" + +#define ENSURE_INITIALIZED {if (!initialized) initialize();} + +QLibrary* MRuntime::library = NULL; +bool MRuntime::initialized = false; + +typedef int (*MImageToEglSharedImageFunc) (const QImage&); +typedef QPixmapData* (*MPixmapDataFromEglSharedImageFunc) (Qt::HANDLE handle, const QImage&); +typedef QPixmapData* (*MPixmapDataWithGLTextureFunc) (int w, int h); +typedef bool (*MDestroyEGLSharedImageFunc) (Qt::HANDLE handle); +typedef void (*MUpdateEglSharedImagePixmapFunc) (QPixmap*); +typedef void (*MSetSurfaceFixedSizeFunc) (int w, int h); +typedef void (*MSetSurfaceScalingFunc) (int x, int y, int w, int h); +typedef void (*MSetTranslucentFunc) (bool translucent); + +static MImageToEglSharedImageFunc m_image_to_egl_shared_image = NULL; +static MPixmapDataFromEglSharedImageFunc m_pixmapdata_from_egl_shared_image = NULL; +static MPixmapDataWithGLTextureFunc m_pixmapdata_with_gl_texture = NULL; +static MDestroyEGLSharedImageFunc m_destroy_egl_shared_image = NULL; +static MUpdateEglSharedImagePixmapFunc m_update_egl_shared_image_pixmap = NULL; +static MSetSurfaceFixedSizeFunc m_set_surface_fixed_size = NULL; +static MSetSurfaceScalingFunc m_set_surface_scaling = NULL; +static MSetTranslucentFunc m_set_translucent = NULL; + +void MRuntime::initialize() +{ + library = new QLibrary("/usr/lib/qt4/plugins/graphicssystems/libmeegographicssystem.so"); + Q_ASSERT(library); + + m_image_to_egl_shared_image = (MImageToEglSharedImageFunc) library->resolve("m_image_to_egl_shared_image"); + m_pixmapdata_from_egl_shared_image = (MPixmapDataFromEglSharedImageFunc) library->resolve("m_pixmapdata_from_egl_shared_image"); + m_pixmapdata_with_gl_texture = (MPixmapDataWithGLTextureFunc) library->resolve("m_pixmapdata_with_gl_texture"); + m_destroy_egl_shared_image = (MDestroyEGLSharedImageFunc) library->resolve("m_destroy_egl_shared_image"); + m_update_egl_shared_image_pixmap = (MUpdateEglSharedImagePixmapFunc) library->resolve("m_update_egl_shared_image_pixmap"); + m_set_surface_fixed_size = (MSetSurfaceFixedSizeFunc) library->resolve("m_set_surface_fixed_size"); + m_set_surface_scaling = (MSetSurfaceScalingFunc) library->resolve("m_set_surface_scaling"); + m_set_translucent = (MSetTranslucentFunc) library->resolve("m_set_translucent"); + + + initialized = true; +} + +Qt::HANDLE MRuntime::imageToEGLSharedImage(const QImage &image) +{ + ENSURE_INITIALIZED; + Q_ASSERT(m_image_to_egl_shared_image); + return m_image_to_egl_shared_image(image); +} + +QPixmap MRuntime::pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage) +{ + ENSURE_INITIALIZED; + Q_ASSERT(m_pixmapdata_from_egl_shared_image); + return QPixmap(m_pixmapdata_from_egl_shared_image(handle, softImage)); +} + +QPixmap MRuntime::pixmapWithGLTexture(int w, int h) +{ + ENSURE_INITIALIZED; + Q_ASSERT(m_pixmapdata_with_gl_texture); + return QPixmap(m_pixmapdata_with_gl_texture(w, h)); +} + +bool MRuntime::destroyEGLSharedImage(Qt::HANDLE handle) +{ + ENSURE_INITIALIZED; + Q_ASSERT(m_destroy_egl_shared_image); + return m_destroy_egl_shared_image(handle); +} + +void MRuntime::updateEGLSharedImagePixmap(QPixmap *p) +{ + ENSURE_INITIALIZED; + Q_ASSERT(m_update_egl_shared_image_pixmap); + return m_update_egl_shared_image_pixmap(p); +} + +void MRuntime::setSurfaceFixedSize(int w, int h) +{ + ENSURE_INITIALIZED; + Q_ASSERT(m_set_surface_fixed_size); + m_set_surface_fixed_size(w, h); +} + +void MRuntime::setSurfaceScaling(int x, int y, int w, int h) +{ + ENSURE_INITIALIZED; + Q_ASSERT(m_set_surface_scaling); + m_set_surface_scaling(x, y, w, h); +} + +void MRuntime::setTranslucent(bool translucent) +{ + ENSURE_INITIALIZED; + Q_ASSERT(m_set_translucent); + m_set_translucent(translucent); +} diff --git a/tools/qmeegographicssystemhelper/mruntime.h b/tools/qmeegographicssystemhelper/mruntime.h new file mode 100644 index 0000000..34474cc --- /dev/null +++ b/tools/qmeegographicssystemhelper/mruntime.h @@ -0,0 +1,36 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include +#include +#include + +class MRuntime +{ +public: + static void initialize(); + + static Qt::HANDLE imageToEGLSharedImage(const QImage &image); + static QPixmap pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage); + static QPixmap pixmapWithGLTexture(int w, int h); + static bool destroyEGLSharedImage(Qt::HANDLE handle); + static void updateEGLSharedImagePixmap(QPixmap *p); + static void setSurfaceFixedSize(int w, int h); + static void setSurfaceScaling(int x, int y, int w, int h); + static void setTranslucent(bool translucent); + +private: + static bool initialized; + static QLibrary *library; +}; \ No newline at end of file -- cgit v0.12 From ca1a8a7f4ad1fb249f47085e6ad0cf133122c0f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 6 Sep 2010 13:19:30 +0200 Subject: Renamed meego graphics system helper files. --- .../meegographicssystemhelper.pro | 19 --- .../mgraphicssystemhelper.cpp | 106 --------------- .../mgraphicssystemhelper.h | 148 --------------------- tools/qmeegographicssystemhelper/mliveimage.cpp | 88 ------------ tools/qmeegographicssystemhelper/mliveimage.h | 79 ----------- tools/qmeegographicssystemhelper/mliveimage_p.h | 36 ----- tools/qmeegographicssystemhelper/mlivepixmap.cpp | 136 ------------------- tools/qmeegographicssystemhelper/mlivepixmap.h | 71 ---------- tools/qmeegographicssystemhelper/mlivepixmap_p.h | 39 ------ .../qmeegographicssystemhelper/moverlaywidget.cpp | 72 ---------- tools/qmeegographicssystemhelper/moverlaywidget.h | 59 -------- tools/qmeegographicssystemhelper/mruntime.cpp | 112 ---------------- tools/qmeegographicssystemhelper/mruntime.h | 36 ----- .../qmeegographicssystemhelper.cpp | 106 +++++++++++++++ .../qmeegographicssystemhelper.h | 148 +++++++++++++++++++++ .../qmeegographicssystemhelper.pro | 19 +++ .../qmeegographicssystemhelper/qmeegoliveimage.cpp | 88 ++++++++++++ tools/qmeegographicssystemhelper/qmeegoliveimage.h | 79 +++++++++++ .../qmeegographicssystemhelper/qmeegoliveimage_p.h | 36 +++++ .../qmeegolivepixmap.cpp | 136 +++++++++++++++++++ .../qmeegographicssystemhelper/qmeegolivepixmap.h | 71 ++++++++++ .../qmeegolivepixmap_p.h | 39 ++++++ .../qmeegooverlaywidget.cpp | 72 ++++++++++ .../qmeegooverlaywidget.h | 59 ++++++++ tools/qmeegographicssystemhelper/qmeegoruntime.cpp | 112 ++++++++++++++++ tools/qmeegographicssystemhelper/qmeegoruntime.h | 36 +++++ 26 files changed, 1001 insertions(+), 1001 deletions(-) delete mode 100644 tools/qmeegographicssystemhelper/meegographicssystemhelper.pro delete mode 100644 tools/qmeegographicssystemhelper/mgraphicssystemhelper.cpp delete mode 100644 tools/qmeegographicssystemhelper/mgraphicssystemhelper.h delete mode 100644 tools/qmeegographicssystemhelper/mliveimage.cpp delete mode 100644 tools/qmeegographicssystemhelper/mliveimage.h delete mode 100644 tools/qmeegographicssystemhelper/mliveimage_p.h delete mode 100644 tools/qmeegographicssystemhelper/mlivepixmap.cpp delete mode 100644 tools/qmeegographicssystemhelper/mlivepixmap.h delete mode 100644 tools/qmeegographicssystemhelper/mlivepixmap_p.h delete mode 100644 tools/qmeegographicssystemhelper/moverlaywidget.cpp delete mode 100644 tools/qmeegographicssystemhelper/moverlaywidget.h delete mode 100644 tools/qmeegographicssystemhelper/mruntime.cpp delete mode 100644 tools/qmeegographicssystemhelper/mruntime.h create mode 100644 tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp create mode 100644 tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h create mode 100644 tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro create mode 100644 tools/qmeegographicssystemhelper/qmeegoliveimage.cpp create mode 100644 tools/qmeegographicssystemhelper/qmeegoliveimage.h create mode 100644 tools/qmeegographicssystemhelper/qmeegoliveimage_p.h create mode 100644 tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp create mode 100644 tools/qmeegographicssystemhelper/qmeegolivepixmap.h create mode 100644 tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h create mode 100644 tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp create mode 100644 tools/qmeegographicssystemhelper/qmeegooverlaywidget.h create mode 100644 tools/qmeegographicssystemhelper/qmeegoruntime.cpp create mode 100644 tools/qmeegographicssystemhelper/qmeegoruntime.h diff --git a/tools/qmeegographicssystemhelper/meegographicssystemhelper.pro b/tools/qmeegographicssystemhelper/meegographicssystemhelper.pro deleted file mode 100644 index cab096e..0000000 --- a/tools/qmeegographicssystemhelper/meegographicssystemhelper.pro +++ /dev/null @@ -1,19 +0,0 @@ -TEMPLATE = lib -TARGET = meegographicssystemhelper -QT += gui -INCLUDEPATH += '../' -LIBS += -L../plugin -CONFIG += debug -VERSION = 0.1.9 -HEADERS = mgraphicssystemhelper.h moverlaywidget.h mlivepixmap.h mliveimage.h mruntime.h mliveimage_p.h mlivepixmap_p.h -SOURCES = mgraphicssystemhelper.cpp mgraphicssystemhelper.h moverlaywidget.h moverlaywidget.cpp mruntime.cpp mruntime.h mlivepixmap.cpp mlivepixmap.h mliveimage.h mliveimage.cpp mliveimage_p.h mlivepixmap_p.h - -target.path = /usr/lib/ - -headers.files = mgraphicssystemhelper.h moverlaywidget.h mlivepixmap.h mliveimage.h -headers.path = /usr/include/meegographicssystemhelper/ - -pkg.files = meegographicssystemhelper.pc -pkg.path = /usr/lib/pkgconfig/ - -INSTALLS += target headers pkg diff --git a/tools/qmeegographicssystemhelper/mgraphicssystemhelper.cpp b/tools/qmeegographicssystemhelper/mgraphicssystemhelper.cpp deleted file mode 100644 index ff921fd..0000000 --- a/tools/qmeegographicssystemhelper/mgraphicssystemhelper.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#define ENSURE_RUNNING_MEEGO {if (! MGraphicsSystemHelper::isRunningMeeGo()) { qFatal("Using meego functionality but not running meego graphics system!"); }} - -#include "mgraphicssystemhelper.h" -#include "../private/qapplication_p.h" -#include "../private/qgraphicssystem_runtime_p.h" -#include "../private/qpixmap_raster_p.h" -#include "mruntime.h" - -QString MGraphicsSystemHelper::runningGraphicsSystemName() -{ - if (! QApplicationPrivate::instance()) { - qWarning("Querying graphics system but application not running yet!"); - return ""; - } - - QString name = QApplicationPrivate::instance()->graphics_system_name; - if (name == "runtime") { - QRuntimeGraphicsSystem *rsystem = (QRuntimeGraphicsSystem *) QApplicationPrivate::instance()->graphics_system; - name = rsystem->graphicsSystemName(); - } - - return name; -} - -bool MGraphicsSystemHelper::isRunningMeeGo() -{ - return (runningGraphicsSystemName() == "meego"); -} - -void MGraphicsSystemHelper::switchToMeeGo() -{ - if (runningGraphicsSystemName() == "meego") - return; - - if (QApplicationPrivate::instance()->graphics_system_name != "runtime") - qWarning("Can't switch to meego - switching only supported with 'runtime' graphics system."); - else { - QApplication *app = static_cast(QCoreApplication::instance()); - app->setGraphicsSystem("meego"); - } -} - -void MGraphicsSystemHelper::switchToRaster() -{ - if (runningGraphicsSystemName() == "raster") - return; - - if (QApplicationPrivate::instance()->graphics_system_name != "runtime") - qWarning("Can't switch to raster - switching only supported with 'runtime' graphics system."); - else { - QApplication *app = static_cast(QCoreApplication::instance()); - app->setGraphicsSystem("raster"); - } -} - -Qt::HANDLE MGraphicsSystemHelper::imageToEGLSharedImage(const QImage &image) -{ - ENSURE_RUNNING_MEEGO; - return MRuntime::imageToEGLSharedImage(image); -} - -QPixmap MGraphicsSystemHelper::pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage) -{ - // This function is supported when not running meego too. A raster-backed - // pixmap will be created... but when you switch back to 'meego', it'll - // be replaced with a EGL shared image backing. - return MRuntime::pixmapFromEGLSharedImage(handle, softImage); -} - -QPixmap MGraphicsSystemHelper::pixmapWithGLTexture(int w, int h) -{ - ENSURE_RUNNING_MEEGO; - return MRuntime::pixmapWithGLTexture(w, h); -} - -bool MGraphicsSystemHelper::destroyEGLSharedImage(Qt::HANDLE handle) -{ - ENSURE_RUNNING_MEEGO; - return MRuntime::destroyEGLSharedImage(handle); -} - -void MGraphicsSystemHelper::updateEGLSharedImagePixmap(QPixmap *p) -{ - ENSURE_RUNNING_MEEGO; - return MRuntime::updateEGLSharedImagePixmap(p); -} - -void MGraphicsSystemHelper::setTranslucent(bool translucent) -{ - ENSURE_RUNNING_MEEGO; - MRuntime::setTranslucent(translucent); -} diff --git a/tools/qmeegographicssystemhelper/mgraphicssystemhelper.h b/tools/qmeegographicssystemhelper/mgraphicssystemhelper.h deleted file mode 100644 index 1966648..0000000 --- a/tools/qmeegographicssystemhelper/mgraphicssystemhelper.h +++ /dev/null @@ -1,148 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#ifndef MGRAPHICSSYSTEMHELPER_H -#define MGRAPHICSSYSTEMHELPER_H - -#include -#include -#include "mlivepixmap.h" - -class QLibrary; - -//! The base class for accressing special meego graphics system features. -/*! - This class is a helper class with static-only methods for accessing various - meego graphics system functionalities. The way it works is that the helper - dynamically calls-in to the loaded graphicssystem plugin... therefore, you're - expected to make sure that you're indeed running with 'meego' before using any - of the specialized methods. - - In example: - - \code - QPixmap p; - if (MGraphicsSystemHelper::isRunningMeeGo()) { - p = MGraphicsSystemHelper::pixmapWithGLTexture(64, 64); - } else { - p = QPixmap(64, 64); - } - \endcode - - Calling any of the meego-specific features while not running meego might - give unpredictable results. The only functions safe to call at all times are: - - \code - MGraphicsSystemHelper::isRunningMeeGo(); - MGraphicsSystemHelper::runningGraphicsSystemName(); - MGraphicsSystemHelper::switchToMeeGo(); - MGraphicsSystemHelper::switchToRaster(); - \endcode -*/ - -class MGraphicsSystemHelper -{ -public: - //! Returns true if running meego. - /*! - Returns true if the currently active (running) system is 'meego' with OpenGL. - This returns both true if the app was started with 'meego' or was started with - 'runtime' graphics system and the currently active system through the runtime - switching is 'meego'. - */ - static bool isRunningMeeGo(); - - //! Switches to meego graphics system. - /*! - When running with the 'runtime' graphics system, sets the currently active - system to 'meego'. The window surface and all the resources are automatically - migrated to OpenGL. Will fail if the active graphics system is not 'runtime'. - */ - static void switchToMeeGo(); - - //! Switches to raster graphics system - /*! - When running with the 'runtime' graphics system, sets the currently active - system to 'raster'. The window surface and the graphics resources (including the - EGL shared image resources) are automatically migrated back to the CPU. All OpenGL - resources (surface, context, cache, font cache) are automaticall anihilated. - */ - static void switchToRaster(); - - //! Returns the name of the active graphics system - /*! - Returns the name of the currently active system. If running with 'runtime' graphics - system, returns the name of the active system inside the runtime graphics system - */ - static QString runningGraphicsSystemName(); - - //! Creates a new EGL shared image. - /*! - Creates a new EGL shared image from the given image. The EGL shared image wraps - a GL texture in the native format and can be easily accessed from other processes. - */ - static Qt::HANDLE imageToEGLSharedImage(const QImage &image); - - //! Creates a QPixmap from an EGL shared image - /*! - Creates a new QPixmap from the given EGL shared image handle. The QPixmap can be - used for painting like any other pixmap. The softImage should point to an alternative, - software version of the graphical resource -- ie. obtained from theme daemon. The - softImage can be allocated on a QSharedMemory slice for easy sharing across processes - too. When the application is migrated ToRaster, this softImage will replace the - contents of the sharedImage. - - It's ok to call this function too when not running 'meego' graphics system. In this - case it'll create a QPixmap backed with a raster data (from softImage)... but when - the system is switched back to 'meego', the QPixmap will be migrated to a EGL-shared image - backed storage (handle). - */ - static QPixmap pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage); - - //! Destroys an EGL shared image. - /*! - Destroys an EGLSharedImage previously created with an ::imageToEGLSharedImage call. - Returns true if the image was found and the destruction was successfull. Notice that - this destroys the image for all processes using it. - */ - static bool destroyEGLSharedImage(Qt::HANDLE handle); - - //! Updates the QPixmap backed with an EGLShared image. - /*! - This function re-reads the softImage that was specified when creating the pixmap with - ::pixmapFromEGLSharedImage and updates the EGL Shared image contents. It can be used - to share cross-proccess mutable EGLShared images. - */ - static void updateEGLSharedImagePixmap(QPixmap *p); - - //! Create a new QPixmap with a GL texture. - /*! - Creates a new QPixmap which is backed by an OpenGL local texture. Drawing to this - QPixmap will be accelerated by hardware -- unlike the normal (new QPixmap()) pixmaps, - which are backed by a software engine and only migrated to GPU when used. Migrating those - GL-backed pixmaps when going ToRaster is expsensive (they need to be downloaded from - GPU to CPU) so use wisely. - */ - static QPixmap pixmapWithGLTexture(int w, int h); - - //! Sets translucency (alpha) on the base window surface. - /*! - This function needs to be called *before* any widget/content is created. - When called with true, the base window surface will be translucent and initialized - with QGLFormat.alpha == true. - */ - static void setTranslucent(bool translucent); -}; - -#endif diff --git a/tools/qmeegographicssystemhelper/mliveimage.cpp b/tools/qmeegographicssystemhelper/mliveimage.cpp deleted file mode 100644 index 37ead21..0000000 --- a/tools/qmeegographicssystemhelper/mliveimage.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#include "mliveimage.h" -#include "mliveimage_p.h" -#include "mlivepixmap.h" -#include "mlivepixmap_p.h" - -/* MLiveImagePrivate */ - -MLiveImagePrivate::MLiveImagePrivate() -{ -} - -MLiveImagePrivate::~MLiveImagePrivate() -{ - if (attachedPixmaps.length() > 0) - qWarning("Destroying MLiveImage but it still has MLivePixmaps attached!"); -} - -void MLiveImagePrivate::attachPixmap(MLivePixmap* pixmap) -{ - attachedPixmaps << pixmap; -} - -void MLiveImagePrivate::detachPixmap(MLivePixmap* pixmap) -{ - attachedPixmaps.removeAll(pixmap); -} - -/* MLiveImage */ - -MLiveImage* MLiveImage::liveImageWithSize(int w, int h, Format format, int buffers) -{ - if (format != Format_ARGB32_Premultiplied) { - qWarning("Only _ARGB32_Premultiplied format is supported for live images now!"); - return 0; - } - - if (buffers != 1) { - qWarning("Only single-buffer streams are supported at the moment"); - return 0; - } - - MLiveImage *liveImage = new MLiveImage(w, h); - return liveImage; -} - -MLiveImage::MLiveImage(int w, int h) : QImage(w, h, QImage::Format_ARGB32_Premultiplied), d_ptr(new MLiveImagePrivate()) -{ - Q_D(MLiveImage); - d->q_ptr = this; -} - -MLiveImage::~MLiveImage() -{ -} - -void MLiveImage::lock(int buffer) -{ - if (buffer != 0) - qWarning("Only locking 0 buffer is supported at the moment!"); -} - -void MLiveImage::release(int buffer) -{ - Q_D(MLiveImage); - - if (buffer != 0) { - qWarning("Only locking 0 buffer is supported at the moment!"); - return; - } - - // We need to copy the update image to all the client MLivePixmap's - foreach (MLivePixmap* livePixmap, d->attachedPixmaps) - livePixmap->d_ptr->copyBackFrom((const void *) bits()); -} \ No newline at end of file diff --git a/tools/qmeegographicssystemhelper/mliveimage.h b/tools/qmeegographicssystemhelper/mliveimage.h deleted file mode 100644 index f945b34..0000000 --- a/tools/qmeegographicssystemhelper/mliveimage.h +++ /dev/null @@ -1,79 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#ifndef MLIVEIMAGE_H -#define MLIVEIMAGE_H - -#include - -class MLivePixmap; -class MLiveImagePrivate; - -//! A streamable QImage subclass. -/*! -*/ - -class MLiveImage : public QImage -{ -public: - //! Format specifier. - /*! - Used to specify the format of the underlying image data for MLiveImage. - */ - enum Format { - Format_ARGB32_Premultiplied //! 32bit, AARRGGBB format. The typical Qt format. - }; - - //! Locks the access to the image. - /*! - All drawing/access to the underlying image data needs to happen between - ::lock() and ::unlock() pairs. - */ - void lock(int buffer = 0); - - //! Unlocks the access to the image. - /*! - All drawing/access to the underlying image data needs to happen between - ::lock() and ::unlock() pairs. - */ - void release(int buffer = 0); - - //! Destroys the image. - /*! - It's a mistake to destroy an image before destroying all the MLivePixmaps - built on top of it. You should first destroy all the MLivePixmaps. - */ - virtual ~MLiveImage(); - - //! Creates and returns a new live image with the given parameters. - /*! - The new image is created with the given width w and the given height h. - The format specifies the color format used by the image. Optionally, a - number of buffers can be specfied for a stream-like behavior. - */ - static MLiveImage* liveImageWithSize(int w, int h, Format format, int buffers = 1); - -private: - MLiveImage(int w, int h); //! Private bits. - Q_DISABLE_COPY(MLiveImage) - Q_DECLARE_PRIVATE(MLiveImage) - -protected: - QScopedPointer d_ptr; - - friend class MLivePixmap; - friend class MLivePixmapPrivate; -}; - -#endif diff --git a/tools/qmeegographicssystemhelper/mliveimage_p.h b/tools/qmeegographicssystemhelper/mliveimage_p.h deleted file mode 100644 index 0789b93..0000000 --- a/tools/qmeegographicssystemhelper/mliveimage_p.h +++ /dev/null @@ -1,36 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#include "mliveimage.h" - -#ifndef MLIVEIMAGE_P_H -#define MLIVEIMAGE_P_H - -class MLiveImagePrivate -{ -public: - Q_DECLARE_PUBLIC(MLiveImage); - MLiveImagePrivate(); - virtual ~MLiveImagePrivate(); - void attachPixmap(MLivePixmap* pixmap); - void detachPixmap(MLivePixmap* pixmap); - - QList attachedPixmaps; - MLiveImage *q_ptr; - - friend class MLivePixmap; - friend class MLivePixmapPrivate; -}; - -#endif \ No newline at end of file diff --git a/tools/qmeegographicssystemhelper/mlivepixmap.cpp b/tools/qmeegographicssystemhelper/mlivepixmap.cpp deleted file mode 100644 index 2f7abd7..0000000 --- a/tools/qmeegographicssystemhelper/mlivepixmap.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#include "mlivepixmap.h" -#include "../private/qimage_p.h" -#include "../private/qpixmap_raster_p.h" -#include "mlivepixmap_p.h" -#include "mliveimage_p.h" -#include - -/* MLivePixmapPrivate */ - -MLivePixmapPrivate::MLivePixmapPrivate() : shm(0), shmSerial(0), owns(true), parentImage(0) -{ -} - -void MLivePixmapPrivate::copyBackFrom(const void *raw) -{ - Q_Q(MLivePixmap); - - q->detach(); - shm->lock(); - uchar *dest = ((uchar *) shm->data()) + (2 * sizeof(int)); - memcpy(dest, raw, q->width() * q->height() * 4); - shm->unlock(); -} - -MLivePixmapPrivate::~MLivePixmapPrivate() -{ - Q_Q(MLivePixmap); - - if (parentImage) - parentImage->d_ptr->detachPixmap(q); - - if (shm) - shm->detach(); - - if (owns) - delete shm; -} - -/* MLivePixmap */ - -MLivePixmap::MLivePixmap(QPixmapData *p) : QPixmap(p), d_ptr(new MLivePixmapPrivate()) -{ - Q_D(MLivePixmap); - d->q_ptr = this; -} - -MLivePixmap* MLivePixmap::fromLiveImage(MLiveImage *liveImage) -{ - static int counter = 100; - QSharedMemory *shm = NULL; - uchar* imgData = NULL; - int *header = NULL; - int w = liveImage->width(); - int h = liveImage->height(); - - counter++; - shm = new QSharedMemory(QString("MLivePixmap%1").arg(counter)); - shm->create((w * h * 4) + 2 * sizeof(int)); // +2 to store width & height - shm->attach(); - - imgData = ((uchar *) shm->data()) + (2 * sizeof(int)); - header = (int *) shm->data(); - - header[0] = w; - header[1] = h; - - QImage img(imgData, w, h, QImage::Format_ARGB32_Premultiplied); - - QPixmapData *pmd = new QRasterPixmapData(QPixmapData::PixmapType); - pmd->fromImage(img, Qt::NoOpaqueDetection); - - MLivePixmap *livePixmap = new MLivePixmap(pmd); - livePixmap->d_ptr->shm = shm; - livePixmap->d_ptr->owns = true; - livePixmap->d_ptr->shmSerial = counter; - livePixmap->d_ptr->parentImage = liveImage; - - liveImage->d_ptr->attachPixmap(livePixmap); - - return livePixmap; -} - -MLivePixmap* MLivePixmap::fromHandle(Qt::HANDLE handle) -{ - QSharedMemory *shm = NULL; - int *header; - int width; - int height; - uchar* imgData; - - shm = new QSharedMemory(QString("MLivePixmap%1").arg(handle)); - shm->attach(); - - shm->lock(); - header = (int *) shm->data(); - width = header[0]; - height = header[1]; - shm->unlock(); - - imgData = ((uchar *) shm->data()) + (2 * sizeof(int)); - QImage img(imgData, width, height, QImage::Format_ARGB32_Premultiplied); - - QPixmapData *pmd = new QRasterPixmapData(QPixmapData::PixmapType); - pmd->fromImage(img, Qt::NoOpaqueDetection); - - MLivePixmap *livePixmap = new MLivePixmap(pmd); - livePixmap->d_ptr->shm = shm; - livePixmap->d_ptr->owns = false; - livePixmap->d_ptr->shmSerial = handle; - - return livePixmap; -} - -MLivePixmap::~MLivePixmap() -{ -} - -Qt::HANDLE MLivePixmap::handle() -{ - Q_D(MLivePixmap); - return d->shmSerial; -} diff --git a/tools/qmeegographicssystemhelper/mlivepixmap.h b/tools/qmeegographicssystemhelper/mlivepixmap.h deleted file mode 100644 index dee4d2a..0000000 --- a/tools/qmeegographicssystemhelper/mlivepixmap.h +++ /dev/null @@ -1,71 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#ifndef MLIVEPIXMAP_H -#define MLIVEPIXMAP_H - -#include -#include "mliveimage.h" - -class MLivePixmapPrivate; -class QSharedMemory; -class QImage; - -//! A pixmap representing streamed content. -/*! -*/ - -class MLivePixmap : public QPixmap -{ -public: - //! Creates new pixmap from the given MLiveImage. - /*! - The created MLivePixmap will be attached to the given MLiveImage. - Updates to the MLiveImage will be represented on this newly created - MLivePixmap. - */ - static MLivePixmap* fromLiveImage(MLiveImage *liveImage); - - //! Creates a new MLivePixmap from the specified handle. - /*! - The handle can be used to share MLivePixmap cross-process. - */ - static MLivePixmap* fromHandle(Qt::HANDLE handle); - - //! Returns the handle for this MLivePixmap. - /*! - The handle can be used to share MLivePixmap cross-process. - */ - Qt::HANDLE handle(); - - //! Destroys the MLivePixmap. - /*! - All MLivePixmaps attached to a given MLiveImage have to be destroyed - before the MLiveImage itself is destroyed. - */ - virtual ~MLivePixmap(); - -private: - MLivePixmap(QPixmapData *p); - Q_DISABLE_COPY(MLivePixmap) - Q_DECLARE_PRIVATE(MLivePixmap) - -protected: - QScopedPointer d_ptr; //! Private bits. - - friend class MLiveImage; - friend class MLiveImagePrivate; -}; - -#endif diff --git a/tools/qmeegographicssystemhelper/mlivepixmap_p.h b/tools/qmeegographicssystemhelper/mlivepixmap_p.h deleted file mode 100644 index 4ff64de..0000000 --- a/tools/qmeegographicssystemhelper/mlivepixmap_p.h +++ /dev/null @@ -1,39 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#include "mlivepixmap.h" - -#ifndef MLIVEPIXMAP_P_H -#define MLIVEPIXMAP_P_H - -class MLivePixmapPrivate -{ -public: - Q_DECLARE_PUBLIC(MLivePixmap); - MLivePixmapPrivate(); - void copyBackFrom(const void *raw); - virtual ~MLivePixmapPrivate(); - - QSharedMemory *shm; - int shmSerial; - bool owns; - MLiveImage *parentImage; - - MLivePixmap *q_ptr; - - friend class MLiveImage; - friend class MLiveImagePrivate; -}; - -#endif \ No newline at end of file diff --git a/tools/qmeegographicssystemhelper/moverlaywidget.cpp b/tools/qmeegographicssystemhelper/moverlaywidget.cpp deleted file mode 100644 index 8f64b3f..0000000 --- a/tools/qmeegographicssystemhelper/moverlaywidget.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#include -#include -#include -#include -#include "moverlaywidget.h" -#include "mgraphicssystemhelper.h" -#include "mruntime.h" - -MOverlayWidget::MOverlayWidget(int surfaceWidth, int surfaceHeight, QWidget *parent) : QWidget(parent, 0), - sw(surfaceWidth), - sh(surfaceHeight) -{ - if (! MGraphicsSystemHelper::isRunningMeeGo()) - qFatal("MOverlayWidget can only be used when running with 'meego' graphics system!"); - - MRuntime::setSurfaceFixedSize(surfaceWidth, surfaceHeight); - - scaleW = sw / 864.0; - scaleH = sh / 480.0; - installEventFilter(this); -} - -QPoint MOverlayWidget::convertPoint(const QPoint &p) -{ - int x = p.x() * scaleW; - int y = p.y() * scaleH; - return QPoint(x, y); -} - -void MOverlayWidget::showEvent(QShowEvent *event) -{ - MRuntime::setSurfaceScaling(0, 0, width(), height()); -} - -bool MOverlayWidget::eventFilter(QObject *obj, QEvent *event) -{ - if (event->spontaneous() == false) - return false; - - switch(event->type()) { - case QEvent::MouseButtonPress: - case QEvent::MouseButtonRelease: - { - QMouseEvent *e = static_cast (event); - QMouseEvent newEvent = QMouseEvent(e->type(), - convertPoint(e->pos()), - convertPoint(e->globalPos()), - e->button(), - e->buttons(), - e->modifiers()); - QCoreApplication::sendEvent(this, &newEvent); - return true; - } - - default: - return false; - } -} diff --git a/tools/qmeegographicssystemhelper/moverlaywidget.h b/tools/qmeegographicssystemhelper/moverlaywidget.h deleted file mode 100644 index f45a673..0000000 --- a/tools/qmeegographicssystemhelper/moverlaywidget.h +++ /dev/null @@ -1,59 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#ifndef MOVERLAYWIDGET_H -#define MOVERLAYWIDGET_H - -#include - -//! A widget automatically scaling it's content. -/*! -*/ - -class MOverlayWidget : public QWidget -{ -public: - //! Constructs a new scaling widget. - /*! - The real surface used for this widget will have the specified - width and height. - */ - MOverlayWidget(int surfaceWidth, int surfaceHeight, QWidget *parent = 0); - - - //! Event filtering function. - /*! - Converts coordinates for mouse/touch event. Do not - call manually. - */ - bool eventFilter(QObject *obj, QEvent *event); - - //! Standard override. - /*! - The surface scaling on the target paint device is being - set when the widget is displayed for the first time. - */ - virtual void showEvent(QShowEvent *event); - -private: - //! Converts coordinates between real & virtual area of the widget. - QPoint convertPoint(const QPoint &p); - - int sw; /// Surface real width. - int sh; /// Surface real height. - float scaleW; /// Width scaling factor. - float scaleH; /// Height scaling factor. -}; - -#endif diff --git a/tools/qmeegographicssystemhelper/mruntime.cpp b/tools/qmeegographicssystemhelper/mruntime.cpp deleted file mode 100644 index b1b0874..0000000 --- a/tools/qmeegographicssystemhelper/mruntime.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#include "mruntime.h" - -#define ENSURE_INITIALIZED {if (!initialized) initialize();} - -QLibrary* MRuntime::library = NULL; -bool MRuntime::initialized = false; - -typedef int (*MImageToEglSharedImageFunc) (const QImage&); -typedef QPixmapData* (*MPixmapDataFromEglSharedImageFunc) (Qt::HANDLE handle, const QImage&); -typedef QPixmapData* (*MPixmapDataWithGLTextureFunc) (int w, int h); -typedef bool (*MDestroyEGLSharedImageFunc) (Qt::HANDLE handle); -typedef void (*MUpdateEglSharedImagePixmapFunc) (QPixmap*); -typedef void (*MSetSurfaceFixedSizeFunc) (int w, int h); -typedef void (*MSetSurfaceScalingFunc) (int x, int y, int w, int h); -typedef void (*MSetTranslucentFunc) (bool translucent); - -static MImageToEglSharedImageFunc m_image_to_egl_shared_image = NULL; -static MPixmapDataFromEglSharedImageFunc m_pixmapdata_from_egl_shared_image = NULL; -static MPixmapDataWithGLTextureFunc m_pixmapdata_with_gl_texture = NULL; -static MDestroyEGLSharedImageFunc m_destroy_egl_shared_image = NULL; -static MUpdateEglSharedImagePixmapFunc m_update_egl_shared_image_pixmap = NULL; -static MSetSurfaceFixedSizeFunc m_set_surface_fixed_size = NULL; -static MSetSurfaceScalingFunc m_set_surface_scaling = NULL; -static MSetTranslucentFunc m_set_translucent = NULL; - -void MRuntime::initialize() -{ - library = new QLibrary("/usr/lib/qt4/plugins/graphicssystems/libmeegographicssystem.so"); - Q_ASSERT(library); - - m_image_to_egl_shared_image = (MImageToEglSharedImageFunc) library->resolve("m_image_to_egl_shared_image"); - m_pixmapdata_from_egl_shared_image = (MPixmapDataFromEglSharedImageFunc) library->resolve("m_pixmapdata_from_egl_shared_image"); - m_pixmapdata_with_gl_texture = (MPixmapDataWithGLTextureFunc) library->resolve("m_pixmapdata_with_gl_texture"); - m_destroy_egl_shared_image = (MDestroyEGLSharedImageFunc) library->resolve("m_destroy_egl_shared_image"); - m_update_egl_shared_image_pixmap = (MUpdateEglSharedImagePixmapFunc) library->resolve("m_update_egl_shared_image_pixmap"); - m_set_surface_fixed_size = (MSetSurfaceFixedSizeFunc) library->resolve("m_set_surface_fixed_size"); - m_set_surface_scaling = (MSetSurfaceScalingFunc) library->resolve("m_set_surface_scaling"); - m_set_translucent = (MSetTranslucentFunc) library->resolve("m_set_translucent"); - - - initialized = true; -} - -Qt::HANDLE MRuntime::imageToEGLSharedImage(const QImage &image) -{ - ENSURE_INITIALIZED; - Q_ASSERT(m_image_to_egl_shared_image); - return m_image_to_egl_shared_image(image); -} - -QPixmap MRuntime::pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage) -{ - ENSURE_INITIALIZED; - Q_ASSERT(m_pixmapdata_from_egl_shared_image); - return QPixmap(m_pixmapdata_from_egl_shared_image(handle, softImage)); -} - -QPixmap MRuntime::pixmapWithGLTexture(int w, int h) -{ - ENSURE_INITIALIZED; - Q_ASSERT(m_pixmapdata_with_gl_texture); - return QPixmap(m_pixmapdata_with_gl_texture(w, h)); -} - -bool MRuntime::destroyEGLSharedImage(Qt::HANDLE handle) -{ - ENSURE_INITIALIZED; - Q_ASSERT(m_destroy_egl_shared_image); - return m_destroy_egl_shared_image(handle); -} - -void MRuntime::updateEGLSharedImagePixmap(QPixmap *p) -{ - ENSURE_INITIALIZED; - Q_ASSERT(m_update_egl_shared_image_pixmap); - return m_update_egl_shared_image_pixmap(p); -} - -void MRuntime::setSurfaceFixedSize(int w, int h) -{ - ENSURE_INITIALIZED; - Q_ASSERT(m_set_surface_fixed_size); - m_set_surface_fixed_size(w, h); -} - -void MRuntime::setSurfaceScaling(int x, int y, int w, int h) -{ - ENSURE_INITIALIZED; - Q_ASSERT(m_set_surface_scaling); - m_set_surface_scaling(x, y, w, h); -} - -void MRuntime::setTranslucent(bool translucent) -{ - ENSURE_INITIALIZED; - Q_ASSERT(m_set_translucent); - m_set_translucent(translucent); -} diff --git a/tools/qmeegographicssystemhelper/mruntime.h b/tools/qmeegographicssystemhelper/mruntime.h deleted file mode 100644 index 34474cc..0000000 --- a/tools/qmeegographicssystemhelper/mruntime.h +++ /dev/null @@ -1,36 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#include -#include -#include - -class MRuntime -{ -public: - static void initialize(); - - static Qt::HANDLE imageToEGLSharedImage(const QImage &image); - static QPixmap pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage); - static QPixmap pixmapWithGLTexture(int w, int h); - static bool destroyEGLSharedImage(Qt::HANDLE handle); - static void updateEGLSharedImagePixmap(QPixmap *p); - static void setSurfaceFixedSize(int w, int h); - static void setSurfaceScaling(int x, int y, int w, int h); - static void setTranslucent(bool translucent); - -private: - static bool initialized; - static QLibrary *library; -}; \ No newline at end of file diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp new file mode 100644 index 0000000..ff921fd --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp @@ -0,0 +1,106 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#define ENSURE_RUNNING_MEEGO {if (! MGraphicsSystemHelper::isRunningMeeGo()) { qFatal("Using meego functionality but not running meego graphics system!"); }} + +#include "mgraphicssystemhelper.h" +#include "../private/qapplication_p.h" +#include "../private/qgraphicssystem_runtime_p.h" +#include "../private/qpixmap_raster_p.h" +#include "mruntime.h" + +QString MGraphicsSystemHelper::runningGraphicsSystemName() +{ + if (! QApplicationPrivate::instance()) { + qWarning("Querying graphics system but application not running yet!"); + return ""; + } + + QString name = QApplicationPrivate::instance()->graphics_system_name; + if (name == "runtime") { + QRuntimeGraphicsSystem *rsystem = (QRuntimeGraphicsSystem *) QApplicationPrivate::instance()->graphics_system; + name = rsystem->graphicsSystemName(); + } + + return name; +} + +bool MGraphicsSystemHelper::isRunningMeeGo() +{ + return (runningGraphicsSystemName() == "meego"); +} + +void MGraphicsSystemHelper::switchToMeeGo() +{ + if (runningGraphicsSystemName() == "meego") + return; + + if (QApplicationPrivate::instance()->graphics_system_name != "runtime") + qWarning("Can't switch to meego - switching only supported with 'runtime' graphics system."); + else { + QApplication *app = static_cast(QCoreApplication::instance()); + app->setGraphicsSystem("meego"); + } +} + +void MGraphicsSystemHelper::switchToRaster() +{ + if (runningGraphicsSystemName() == "raster") + return; + + if (QApplicationPrivate::instance()->graphics_system_name != "runtime") + qWarning("Can't switch to raster - switching only supported with 'runtime' graphics system."); + else { + QApplication *app = static_cast(QCoreApplication::instance()); + app->setGraphicsSystem("raster"); + } +} + +Qt::HANDLE MGraphicsSystemHelper::imageToEGLSharedImage(const QImage &image) +{ + ENSURE_RUNNING_MEEGO; + return MRuntime::imageToEGLSharedImage(image); +} + +QPixmap MGraphicsSystemHelper::pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage) +{ + // This function is supported when not running meego too. A raster-backed + // pixmap will be created... but when you switch back to 'meego', it'll + // be replaced with a EGL shared image backing. + return MRuntime::pixmapFromEGLSharedImage(handle, softImage); +} + +QPixmap MGraphicsSystemHelper::pixmapWithGLTexture(int w, int h) +{ + ENSURE_RUNNING_MEEGO; + return MRuntime::pixmapWithGLTexture(w, h); +} + +bool MGraphicsSystemHelper::destroyEGLSharedImage(Qt::HANDLE handle) +{ + ENSURE_RUNNING_MEEGO; + return MRuntime::destroyEGLSharedImage(handle); +} + +void MGraphicsSystemHelper::updateEGLSharedImagePixmap(QPixmap *p) +{ + ENSURE_RUNNING_MEEGO; + return MRuntime::updateEGLSharedImagePixmap(p); +} + +void MGraphicsSystemHelper::setTranslucent(bool translucent) +{ + ENSURE_RUNNING_MEEGO; + MRuntime::setTranslucent(translucent); +} diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h new file mode 100644 index 0000000..1966648 --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h @@ -0,0 +1,148 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#ifndef MGRAPHICSSYSTEMHELPER_H +#define MGRAPHICSSYSTEMHELPER_H + +#include +#include +#include "mlivepixmap.h" + +class QLibrary; + +//! The base class for accressing special meego graphics system features. +/*! + This class is a helper class with static-only methods for accessing various + meego graphics system functionalities. The way it works is that the helper + dynamically calls-in to the loaded graphicssystem plugin... therefore, you're + expected to make sure that you're indeed running with 'meego' before using any + of the specialized methods. + + In example: + + \code + QPixmap p; + if (MGraphicsSystemHelper::isRunningMeeGo()) { + p = MGraphicsSystemHelper::pixmapWithGLTexture(64, 64); + } else { + p = QPixmap(64, 64); + } + \endcode + + Calling any of the meego-specific features while not running meego might + give unpredictable results. The only functions safe to call at all times are: + + \code + MGraphicsSystemHelper::isRunningMeeGo(); + MGraphicsSystemHelper::runningGraphicsSystemName(); + MGraphicsSystemHelper::switchToMeeGo(); + MGraphicsSystemHelper::switchToRaster(); + \endcode +*/ + +class MGraphicsSystemHelper +{ +public: + //! Returns true if running meego. + /*! + Returns true if the currently active (running) system is 'meego' with OpenGL. + This returns both true if the app was started with 'meego' or was started with + 'runtime' graphics system and the currently active system through the runtime + switching is 'meego'. + */ + static bool isRunningMeeGo(); + + //! Switches to meego graphics system. + /*! + When running with the 'runtime' graphics system, sets the currently active + system to 'meego'. The window surface and all the resources are automatically + migrated to OpenGL. Will fail if the active graphics system is not 'runtime'. + */ + static void switchToMeeGo(); + + //! Switches to raster graphics system + /*! + When running with the 'runtime' graphics system, sets the currently active + system to 'raster'. The window surface and the graphics resources (including the + EGL shared image resources) are automatically migrated back to the CPU. All OpenGL + resources (surface, context, cache, font cache) are automaticall anihilated. + */ + static void switchToRaster(); + + //! Returns the name of the active graphics system + /*! + Returns the name of the currently active system. If running with 'runtime' graphics + system, returns the name of the active system inside the runtime graphics system + */ + static QString runningGraphicsSystemName(); + + //! Creates a new EGL shared image. + /*! + Creates a new EGL shared image from the given image. The EGL shared image wraps + a GL texture in the native format and can be easily accessed from other processes. + */ + static Qt::HANDLE imageToEGLSharedImage(const QImage &image); + + //! Creates a QPixmap from an EGL shared image + /*! + Creates a new QPixmap from the given EGL shared image handle. The QPixmap can be + used for painting like any other pixmap. The softImage should point to an alternative, + software version of the graphical resource -- ie. obtained from theme daemon. The + softImage can be allocated on a QSharedMemory slice for easy sharing across processes + too. When the application is migrated ToRaster, this softImage will replace the + contents of the sharedImage. + + It's ok to call this function too when not running 'meego' graphics system. In this + case it'll create a QPixmap backed with a raster data (from softImage)... but when + the system is switched back to 'meego', the QPixmap will be migrated to a EGL-shared image + backed storage (handle). + */ + static QPixmap pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage); + + //! Destroys an EGL shared image. + /*! + Destroys an EGLSharedImage previously created with an ::imageToEGLSharedImage call. + Returns true if the image was found and the destruction was successfull. Notice that + this destroys the image for all processes using it. + */ + static bool destroyEGLSharedImage(Qt::HANDLE handle); + + //! Updates the QPixmap backed with an EGLShared image. + /*! + This function re-reads the softImage that was specified when creating the pixmap with + ::pixmapFromEGLSharedImage and updates the EGL Shared image contents. It can be used + to share cross-proccess mutable EGLShared images. + */ + static void updateEGLSharedImagePixmap(QPixmap *p); + + //! Create a new QPixmap with a GL texture. + /*! + Creates a new QPixmap which is backed by an OpenGL local texture. Drawing to this + QPixmap will be accelerated by hardware -- unlike the normal (new QPixmap()) pixmaps, + which are backed by a software engine and only migrated to GPU when used. Migrating those + GL-backed pixmaps when going ToRaster is expsensive (they need to be downloaded from + GPU to CPU) so use wisely. + */ + static QPixmap pixmapWithGLTexture(int w, int h); + + //! Sets translucency (alpha) on the base window surface. + /*! + This function needs to be called *before* any widget/content is created. + When called with true, the base window surface will be translucent and initialized + with QGLFormat.alpha == true. + */ + static void setTranslucent(bool translucent); +}; + +#endif diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro new file mode 100644 index 0000000..cab096e --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro @@ -0,0 +1,19 @@ +TEMPLATE = lib +TARGET = meegographicssystemhelper +QT += gui +INCLUDEPATH += '../' +LIBS += -L../plugin +CONFIG += debug +VERSION = 0.1.9 +HEADERS = mgraphicssystemhelper.h moverlaywidget.h mlivepixmap.h mliveimage.h mruntime.h mliveimage_p.h mlivepixmap_p.h +SOURCES = mgraphicssystemhelper.cpp mgraphicssystemhelper.h moverlaywidget.h moverlaywidget.cpp mruntime.cpp mruntime.h mlivepixmap.cpp mlivepixmap.h mliveimage.h mliveimage.cpp mliveimage_p.h mlivepixmap_p.h + +target.path = /usr/lib/ + +headers.files = mgraphicssystemhelper.h moverlaywidget.h mlivepixmap.h mliveimage.h +headers.path = /usr/include/meegographicssystemhelper/ + +pkg.files = meegographicssystemhelper.pc +pkg.path = /usr/lib/pkgconfig/ + +INSTALLS += target headers pkg diff --git a/tools/qmeegographicssystemhelper/qmeegoliveimage.cpp b/tools/qmeegographicssystemhelper/qmeegoliveimage.cpp new file mode 100644 index 0000000..37ead21 --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegoliveimage.cpp @@ -0,0 +1,88 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include "mliveimage.h" +#include "mliveimage_p.h" +#include "mlivepixmap.h" +#include "mlivepixmap_p.h" + +/* MLiveImagePrivate */ + +MLiveImagePrivate::MLiveImagePrivate() +{ +} + +MLiveImagePrivate::~MLiveImagePrivate() +{ + if (attachedPixmaps.length() > 0) + qWarning("Destroying MLiveImage but it still has MLivePixmaps attached!"); +} + +void MLiveImagePrivate::attachPixmap(MLivePixmap* pixmap) +{ + attachedPixmaps << pixmap; +} + +void MLiveImagePrivate::detachPixmap(MLivePixmap* pixmap) +{ + attachedPixmaps.removeAll(pixmap); +} + +/* MLiveImage */ + +MLiveImage* MLiveImage::liveImageWithSize(int w, int h, Format format, int buffers) +{ + if (format != Format_ARGB32_Premultiplied) { + qWarning("Only _ARGB32_Premultiplied format is supported for live images now!"); + return 0; + } + + if (buffers != 1) { + qWarning("Only single-buffer streams are supported at the moment"); + return 0; + } + + MLiveImage *liveImage = new MLiveImage(w, h); + return liveImage; +} + +MLiveImage::MLiveImage(int w, int h) : QImage(w, h, QImage::Format_ARGB32_Premultiplied), d_ptr(new MLiveImagePrivate()) +{ + Q_D(MLiveImage); + d->q_ptr = this; +} + +MLiveImage::~MLiveImage() +{ +} + +void MLiveImage::lock(int buffer) +{ + if (buffer != 0) + qWarning("Only locking 0 buffer is supported at the moment!"); +} + +void MLiveImage::release(int buffer) +{ + Q_D(MLiveImage); + + if (buffer != 0) { + qWarning("Only locking 0 buffer is supported at the moment!"); + return; + } + + // We need to copy the update image to all the client MLivePixmap's + foreach (MLivePixmap* livePixmap, d->attachedPixmaps) + livePixmap->d_ptr->copyBackFrom((const void *) bits()); +} \ No newline at end of file diff --git a/tools/qmeegographicssystemhelper/qmeegoliveimage.h b/tools/qmeegographicssystemhelper/qmeegoliveimage.h new file mode 100644 index 0000000..f945b34 --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegoliveimage.h @@ -0,0 +1,79 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#ifndef MLIVEIMAGE_H +#define MLIVEIMAGE_H + +#include + +class MLivePixmap; +class MLiveImagePrivate; + +//! A streamable QImage subclass. +/*! +*/ + +class MLiveImage : public QImage +{ +public: + //! Format specifier. + /*! + Used to specify the format of the underlying image data for MLiveImage. + */ + enum Format { + Format_ARGB32_Premultiplied //! 32bit, AARRGGBB format. The typical Qt format. + }; + + //! Locks the access to the image. + /*! + All drawing/access to the underlying image data needs to happen between + ::lock() and ::unlock() pairs. + */ + void lock(int buffer = 0); + + //! Unlocks the access to the image. + /*! + All drawing/access to the underlying image data needs to happen between + ::lock() and ::unlock() pairs. + */ + void release(int buffer = 0); + + //! Destroys the image. + /*! + It's a mistake to destroy an image before destroying all the MLivePixmaps + built on top of it. You should first destroy all the MLivePixmaps. + */ + virtual ~MLiveImage(); + + //! Creates and returns a new live image with the given parameters. + /*! + The new image is created with the given width w and the given height h. + The format specifies the color format used by the image. Optionally, a + number of buffers can be specfied for a stream-like behavior. + */ + static MLiveImage* liveImageWithSize(int w, int h, Format format, int buffers = 1); + +private: + MLiveImage(int w, int h); //! Private bits. + Q_DISABLE_COPY(MLiveImage) + Q_DECLARE_PRIVATE(MLiveImage) + +protected: + QScopedPointer d_ptr; + + friend class MLivePixmap; + friend class MLivePixmapPrivate; +}; + +#endif diff --git a/tools/qmeegographicssystemhelper/qmeegoliveimage_p.h b/tools/qmeegographicssystemhelper/qmeegoliveimage_p.h new file mode 100644 index 0000000..0789b93 --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegoliveimage_p.h @@ -0,0 +1,36 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include "mliveimage.h" + +#ifndef MLIVEIMAGE_P_H +#define MLIVEIMAGE_P_H + +class MLiveImagePrivate +{ +public: + Q_DECLARE_PUBLIC(MLiveImage); + MLiveImagePrivate(); + virtual ~MLiveImagePrivate(); + void attachPixmap(MLivePixmap* pixmap); + void detachPixmap(MLivePixmap* pixmap); + + QList attachedPixmaps; + MLiveImage *q_ptr; + + friend class MLivePixmap; + friend class MLivePixmapPrivate; +}; + +#endif \ No newline at end of file diff --git a/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp b/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp new file mode 100644 index 0000000..2f7abd7 --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp @@ -0,0 +1,136 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include "mlivepixmap.h" +#include "../private/qimage_p.h" +#include "../private/qpixmap_raster_p.h" +#include "mlivepixmap_p.h" +#include "mliveimage_p.h" +#include + +/* MLivePixmapPrivate */ + +MLivePixmapPrivate::MLivePixmapPrivate() : shm(0), shmSerial(0), owns(true), parentImage(0) +{ +} + +void MLivePixmapPrivate::copyBackFrom(const void *raw) +{ + Q_Q(MLivePixmap); + + q->detach(); + shm->lock(); + uchar *dest = ((uchar *) shm->data()) + (2 * sizeof(int)); + memcpy(dest, raw, q->width() * q->height() * 4); + shm->unlock(); +} + +MLivePixmapPrivate::~MLivePixmapPrivate() +{ + Q_Q(MLivePixmap); + + if (parentImage) + parentImage->d_ptr->detachPixmap(q); + + if (shm) + shm->detach(); + + if (owns) + delete shm; +} + +/* MLivePixmap */ + +MLivePixmap::MLivePixmap(QPixmapData *p) : QPixmap(p), d_ptr(new MLivePixmapPrivate()) +{ + Q_D(MLivePixmap); + d->q_ptr = this; +} + +MLivePixmap* MLivePixmap::fromLiveImage(MLiveImage *liveImage) +{ + static int counter = 100; + QSharedMemory *shm = NULL; + uchar* imgData = NULL; + int *header = NULL; + int w = liveImage->width(); + int h = liveImage->height(); + + counter++; + shm = new QSharedMemory(QString("MLivePixmap%1").arg(counter)); + shm->create((w * h * 4) + 2 * sizeof(int)); // +2 to store width & height + shm->attach(); + + imgData = ((uchar *) shm->data()) + (2 * sizeof(int)); + header = (int *) shm->data(); + + header[0] = w; + header[1] = h; + + QImage img(imgData, w, h, QImage::Format_ARGB32_Premultiplied); + + QPixmapData *pmd = new QRasterPixmapData(QPixmapData::PixmapType); + pmd->fromImage(img, Qt::NoOpaqueDetection); + + MLivePixmap *livePixmap = new MLivePixmap(pmd); + livePixmap->d_ptr->shm = shm; + livePixmap->d_ptr->owns = true; + livePixmap->d_ptr->shmSerial = counter; + livePixmap->d_ptr->parentImage = liveImage; + + liveImage->d_ptr->attachPixmap(livePixmap); + + return livePixmap; +} + +MLivePixmap* MLivePixmap::fromHandle(Qt::HANDLE handle) +{ + QSharedMemory *shm = NULL; + int *header; + int width; + int height; + uchar* imgData; + + shm = new QSharedMemory(QString("MLivePixmap%1").arg(handle)); + shm->attach(); + + shm->lock(); + header = (int *) shm->data(); + width = header[0]; + height = header[1]; + shm->unlock(); + + imgData = ((uchar *) shm->data()) + (2 * sizeof(int)); + QImage img(imgData, width, height, QImage::Format_ARGB32_Premultiplied); + + QPixmapData *pmd = new QRasterPixmapData(QPixmapData::PixmapType); + pmd->fromImage(img, Qt::NoOpaqueDetection); + + MLivePixmap *livePixmap = new MLivePixmap(pmd); + livePixmap->d_ptr->shm = shm; + livePixmap->d_ptr->owns = false; + livePixmap->d_ptr->shmSerial = handle; + + return livePixmap; +} + +MLivePixmap::~MLivePixmap() +{ +} + +Qt::HANDLE MLivePixmap::handle() +{ + Q_D(MLivePixmap); + return d->shmSerial; +} diff --git a/tools/qmeegographicssystemhelper/qmeegolivepixmap.h b/tools/qmeegographicssystemhelper/qmeegolivepixmap.h new file mode 100644 index 0000000..dee4d2a --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegolivepixmap.h @@ -0,0 +1,71 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#ifndef MLIVEPIXMAP_H +#define MLIVEPIXMAP_H + +#include +#include "mliveimage.h" + +class MLivePixmapPrivate; +class QSharedMemory; +class QImage; + +//! A pixmap representing streamed content. +/*! +*/ + +class MLivePixmap : public QPixmap +{ +public: + //! Creates new pixmap from the given MLiveImage. + /*! + The created MLivePixmap will be attached to the given MLiveImage. + Updates to the MLiveImage will be represented on this newly created + MLivePixmap. + */ + static MLivePixmap* fromLiveImage(MLiveImage *liveImage); + + //! Creates a new MLivePixmap from the specified handle. + /*! + The handle can be used to share MLivePixmap cross-process. + */ + static MLivePixmap* fromHandle(Qt::HANDLE handle); + + //! Returns the handle for this MLivePixmap. + /*! + The handle can be used to share MLivePixmap cross-process. + */ + Qt::HANDLE handle(); + + //! Destroys the MLivePixmap. + /*! + All MLivePixmaps attached to a given MLiveImage have to be destroyed + before the MLiveImage itself is destroyed. + */ + virtual ~MLivePixmap(); + +private: + MLivePixmap(QPixmapData *p); + Q_DISABLE_COPY(MLivePixmap) + Q_DECLARE_PRIVATE(MLivePixmap) + +protected: + QScopedPointer d_ptr; //! Private bits. + + friend class MLiveImage; + friend class MLiveImagePrivate; +}; + +#endif diff --git a/tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h b/tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h new file mode 100644 index 0000000..4ff64de --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h @@ -0,0 +1,39 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include "mlivepixmap.h" + +#ifndef MLIVEPIXMAP_P_H +#define MLIVEPIXMAP_P_H + +class MLivePixmapPrivate +{ +public: + Q_DECLARE_PUBLIC(MLivePixmap); + MLivePixmapPrivate(); + void copyBackFrom(const void *raw); + virtual ~MLivePixmapPrivate(); + + QSharedMemory *shm; + int shmSerial; + bool owns; + MLiveImage *parentImage; + + MLivePixmap *q_ptr; + + friend class MLiveImage; + friend class MLiveImagePrivate; +}; + +#endif \ No newline at end of file diff --git a/tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp b/tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp new file mode 100644 index 0000000..8f64b3f --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp @@ -0,0 +1,72 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include +#include +#include +#include +#include "moverlaywidget.h" +#include "mgraphicssystemhelper.h" +#include "mruntime.h" + +MOverlayWidget::MOverlayWidget(int surfaceWidth, int surfaceHeight, QWidget *parent) : QWidget(parent, 0), + sw(surfaceWidth), + sh(surfaceHeight) +{ + if (! MGraphicsSystemHelper::isRunningMeeGo()) + qFatal("MOverlayWidget can only be used when running with 'meego' graphics system!"); + + MRuntime::setSurfaceFixedSize(surfaceWidth, surfaceHeight); + + scaleW = sw / 864.0; + scaleH = sh / 480.0; + installEventFilter(this); +} + +QPoint MOverlayWidget::convertPoint(const QPoint &p) +{ + int x = p.x() * scaleW; + int y = p.y() * scaleH; + return QPoint(x, y); +} + +void MOverlayWidget::showEvent(QShowEvent *event) +{ + MRuntime::setSurfaceScaling(0, 0, width(), height()); +} + +bool MOverlayWidget::eventFilter(QObject *obj, QEvent *event) +{ + if (event->spontaneous() == false) + return false; + + switch(event->type()) { + case QEvent::MouseButtonPress: + case QEvent::MouseButtonRelease: + { + QMouseEvent *e = static_cast (event); + QMouseEvent newEvent = QMouseEvent(e->type(), + convertPoint(e->pos()), + convertPoint(e->globalPos()), + e->button(), + e->buttons(), + e->modifiers()); + QCoreApplication::sendEvent(this, &newEvent); + return true; + } + + default: + return false; + } +} diff --git a/tools/qmeegographicssystemhelper/qmeegooverlaywidget.h b/tools/qmeegographicssystemhelper/qmeegooverlaywidget.h new file mode 100644 index 0000000..f45a673 --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegooverlaywidget.h @@ -0,0 +1,59 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#ifndef MOVERLAYWIDGET_H +#define MOVERLAYWIDGET_H + +#include + +//! A widget automatically scaling it's content. +/*! +*/ + +class MOverlayWidget : public QWidget +{ +public: + //! Constructs a new scaling widget. + /*! + The real surface used for this widget will have the specified + width and height. + */ + MOverlayWidget(int surfaceWidth, int surfaceHeight, QWidget *parent = 0); + + + //! Event filtering function. + /*! + Converts coordinates for mouse/touch event. Do not + call manually. + */ + bool eventFilter(QObject *obj, QEvent *event); + + //! Standard override. + /*! + The surface scaling on the target paint device is being + set when the widget is displayed for the first time. + */ + virtual void showEvent(QShowEvent *event); + +private: + //! Converts coordinates between real & virtual area of the widget. + QPoint convertPoint(const QPoint &p); + + int sw; /// Surface real width. + int sh; /// Surface real height. + float scaleW; /// Width scaling factor. + float scaleH; /// Height scaling factor. +}; + +#endif diff --git a/tools/qmeegographicssystemhelper/qmeegoruntime.cpp b/tools/qmeegographicssystemhelper/qmeegoruntime.cpp new file mode 100644 index 0000000..b1b0874 --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegoruntime.cpp @@ -0,0 +1,112 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include "mruntime.h" + +#define ENSURE_INITIALIZED {if (!initialized) initialize();} + +QLibrary* MRuntime::library = NULL; +bool MRuntime::initialized = false; + +typedef int (*MImageToEglSharedImageFunc) (const QImage&); +typedef QPixmapData* (*MPixmapDataFromEglSharedImageFunc) (Qt::HANDLE handle, const QImage&); +typedef QPixmapData* (*MPixmapDataWithGLTextureFunc) (int w, int h); +typedef bool (*MDestroyEGLSharedImageFunc) (Qt::HANDLE handle); +typedef void (*MUpdateEglSharedImagePixmapFunc) (QPixmap*); +typedef void (*MSetSurfaceFixedSizeFunc) (int w, int h); +typedef void (*MSetSurfaceScalingFunc) (int x, int y, int w, int h); +typedef void (*MSetTranslucentFunc) (bool translucent); + +static MImageToEglSharedImageFunc m_image_to_egl_shared_image = NULL; +static MPixmapDataFromEglSharedImageFunc m_pixmapdata_from_egl_shared_image = NULL; +static MPixmapDataWithGLTextureFunc m_pixmapdata_with_gl_texture = NULL; +static MDestroyEGLSharedImageFunc m_destroy_egl_shared_image = NULL; +static MUpdateEglSharedImagePixmapFunc m_update_egl_shared_image_pixmap = NULL; +static MSetSurfaceFixedSizeFunc m_set_surface_fixed_size = NULL; +static MSetSurfaceScalingFunc m_set_surface_scaling = NULL; +static MSetTranslucentFunc m_set_translucent = NULL; + +void MRuntime::initialize() +{ + library = new QLibrary("/usr/lib/qt4/plugins/graphicssystems/libmeegographicssystem.so"); + Q_ASSERT(library); + + m_image_to_egl_shared_image = (MImageToEglSharedImageFunc) library->resolve("m_image_to_egl_shared_image"); + m_pixmapdata_from_egl_shared_image = (MPixmapDataFromEglSharedImageFunc) library->resolve("m_pixmapdata_from_egl_shared_image"); + m_pixmapdata_with_gl_texture = (MPixmapDataWithGLTextureFunc) library->resolve("m_pixmapdata_with_gl_texture"); + m_destroy_egl_shared_image = (MDestroyEGLSharedImageFunc) library->resolve("m_destroy_egl_shared_image"); + m_update_egl_shared_image_pixmap = (MUpdateEglSharedImagePixmapFunc) library->resolve("m_update_egl_shared_image_pixmap"); + m_set_surface_fixed_size = (MSetSurfaceFixedSizeFunc) library->resolve("m_set_surface_fixed_size"); + m_set_surface_scaling = (MSetSurfaceScalingFunc) library->resolve("m_set_surface_scaling"); + m_set_translucent = (MSetTranslucentFunc) library->resolve("m_set_translucent"); + + + initialized = true; +} + +Qt::HANDLE MRuntime::imageToEGLSharedImage(const QImage &image) +{ + ENSURE_INITIALIZED; + Q_ASSERT(m_image_to_egl_shared_image); + return m_image_to_egl_shared_image(image); +} + +QPixmap MRuntime::pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage) +{ + ENSURE_INITIALIZED; + Q_ASSERT(m_pixmapdata_from_egl_shared_image); + return QPixmap(m_pixmapdata_from_egl_shared_image(handle, softImage)); +} + +QPixmap MRuntime::pixmapWithGLTexture(int w, int h) +{ + ENSURE_INITIALIZED; + Q_ASSERT(m_pixmapdata_with_gl_texture); + return QPixmap(m_pixmapdata_with_gl_texture(w, h)); +} + +bool MRuntime::destroyEGLSharedImage(Qt::HANDLE handle) +{ + ENSURE_INITIALIZED; + Q_ASSERT(m_destroy_egl_shared_image); + return m_destroy_egl_shared_image(handle); +} + +void MRuntime::updateEGLSharedImagePixmap(QPixmap *p) +{ + ENSURE_INITIALIZED; + Q_ASSERT(m_update_egl_shared_image_pixmap); + return m_update_egl_shared_image_pixmap(p); +} + +void MRuntime::setSurfaceFixedSize(int w, int h) +{ + ENSURE_INITIALIZED; + Q_ASSERT(m_set_surface_fixed_size); + m_set_surface_fixed_size(w, h); +} + +void MRuntime::setSurfaceScaling(int x, int y, int w, int h) +{ + ENSURE_INITIALIZED; + Q_ASSERT(m_set_surface_scaling); + m_set_surface_scaling(x, y, w, h); +} + +void MRuntime::setTranslucent(bool translucent) +{ + ENSURE_INITIALIZED; + Q_ASSERT(m_set_translucent); + m_set_translucent(translucent); +} diff --git a/tools/qmeegographicssystemhelper/qmeegoruntime.h b/tools/qmeegographicssystemhelper/qmeegoruntime.h new file mode 100644 index 0000000..34474cc --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegoruntime.h @@ -0,0 +1,36 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include +#include +#include + +class MRuntime +{ +public: + static void initialize(); + + static Qt::HANDLE imageToEGLSharedImage(const QImage &image); + static QPixmap pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage); + static QPixmap pixmapWithGLTexture(int w, int h); + static bool destroyEGLSharedImage(Qt::HANDLE handle); + static void updateEGLSharedImagePixmap(QPixmap *p); + static void setSurfaceFixedSize(int w, int h); + static void setSurfaceScaling(int x, int y, int w, int h); + static void setTranslucent(bool translucent); + +private: + static bool initialized; + static QLibrary *library; +}; \ No newline at end of file -- cgit v0.12 From 2c7a0fef42993dbaeceab9a72de65591bbedd1c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 6 Sep 2010 15:06:07 +0200 Subject: Fixed compilation and API of meego graphics system helper. --- .../qmeegographicssystemhelper.cpp | 44 ++++----- .../qmeegographicssystemhelper.h | 20 ++-- .../qmeegographicssystemhelper.pro | 22 ++--- .../qmeegographicssystemhelper/qmeegoliveimage.cpp | 44 ++++----- tools/qmeegographicssystemhelper/qmeegoliveimage.h | 32 +++---- .../qmeegographicssystemhelper/qmeegoliveimage_p.h | 28 +++--- .../qmeegolivepixmap.cpp | 46 ++++----- .../qmeegographicssystemhelper/qmeegolivepixmap.h | 50 +++++----- .../qmeegolivepixmap_p.h | 24 ++--- .../qmeegooverlaywidget.cpp | 22 ++--- .../qmeegooverlaywidget.h | 8 +- tools/qmeegographicssystemhelper/qmeegoruntime.cpp | 104 ++++++++++----------- tools/qmeegographicssystemhelper/qmeegoruntime.h | 4 +- tools/tools.pro | 4 + 14 files changed, 224 insertions(+), 228 deletions(-) diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp index ff921fd..38ba82d 100644 --- a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp +++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp @@ -12,15 +12,15 @@ ** ****************************************************************************/ -#define ENSURE_RUNNING_MEEGO {if (! MGraphicsSystemHelper::isRunningMeeGo()) { qFatal("Using meego functionality but not running meego graphics system!"); }} +#define ENSURE_RUNNING_MEEGO {if (! QMeeGoGraphicsSystemHelper::isRunningMeeGo()) { qFatal("Using meego functionality but not running meego graphics system!"); }} -#include "mgraphicssystemhelper.h" -#include "../private/qapplication_p.h" -#include "../private/qgraphicssystem_runtime_p.h" -#include "../private/qpixmap_raster_p.h" -#include "mruntime.h" +#include "qmeegographicssystemhelper.h" +#include +#include +#include +#include "qmeegoruntime.h" -QString MGraphicsSystemHelper::runningGraphicsSystemName() +QString QMeeGoGraphicsSystemHelper::runningGraphicsSystemName() { if (! QApplicationPrivate::instance()) { qWarning("Querying graphics system but application not running yet!"); @@ -36,12 +36,12 @@ QString MGraphicsSystemHelper::runningGraphicsSystemName() return name; } -bool MGraphicsSystemHelper::isRunningMeeGo() +bool QMeeGoGraphicsSystemHelper::isRunningMeeGo() { return (runningGraphicsSystemName() == "meego"); } -void MGraphicsSystemHelper::switchToMeeGo() +void QMeeGoGraphicsSystemHelper::switchToMeeGo() { if (runningGraphicsSystemName() == "meego") return; @@ -54,7 +54,7 @@ void MGraphicsSystemHelper::switchToMeeGo() } } -void MGraphicsSystemHelper::switchToRaster() +void QMeeGoGraphicsSystemHelper::switchToRaster() { if (runningGraphicsSystemName() == "raster") return; @@ -67,40 +67,40 @@ void MGraphicsSystemHelper::switchToRaster() } } -Qt::HANDLE MGraphicsSystemHelper::imageToEGLSharedImage(const QImage &image) +Qt::HANDLE QMeeGoGraphicsSystemHelper::imageToEGLSharedImage(const QImage &image) { ENSURE_RUNNING_MEEGO; - return MRuntime::imageToEGLSharedImage(image); + return QMeeGoRuntime::imageToEGLSharedImage(image); } -QPixmap MGraphicsSystemHelper::pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage) +QPixmap QMeeGoGraphicsSystemHelper::pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage) { // This function is supported when not running meego too. A raster-backed // pixmap will be created... but when you switch back to 'meego', it'll // be replaced with a EGL shared image backing. - return MRuntime::pixmapFromEGLSharedImage(handle, softImage); + return QMeeGoRuntime::pixmapFromEGLSharedImage(handle, softImage); } -QPixmap MGraphicsSystemHelper::pixmapWithGLTexture(int w, int h) +QPixmap QMeeGoGraphicsSystemHelper::pixmapWithGLTexture(int w, int h) { ENSURE_RUNNING_MEEGO; - return MRuntime::pixmapWithGLTexture(w, h); + return QMeeGoRuntime::pixmapWithGLTexture(w, h); } -bool MGraphicsSystemHelper::destroyEGLSharedImage(Qt::HANDLE handle) +bool QMeeGoGraphicsSystemHelper::destroyEGLSharedImage(Qt::HANDLE handle) { ENSURE_RUNNING_MEEGO; - return MRuntime::destroyEGLSharedImage(handle); + return QMeeGoRuntime::destroyEGLSharedImage(handle); } -void MGraphicsSystemHelper::updateEGLSharedImagePixmap(QPixmap *p) +void QMeeGoGraphicsSystemHelper::updateEGLSharedImagePixmap(QPixmap *p) { ENSURE_RUNNING_MEEGO; - return MRuntime::updateEGLSharedImagePixmap(p); + return QMeeGoRuntime::updateEGLSharedImagePixmap(p); } -void MGraphicsSystemHelper::setTranslucent(bool translucent) +void QMeeGoGraphicsSystemHelper::setTranslucent(bool translucent) { ENSURE_RUNNING_MEEGO; - MRuntime::setTranslucent(translucent); + QMeeGoRuntime::setTranslucent(translucent); } diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h index 1966648..069a27c 100644 --- a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h +++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h @@ -12,12 +12,12 @@ ** ****************************************************************************/ -#ifndef MGRAPHICSSYSTEMHELPER_H -#define MGRAPHICSSYSTEMHELPER_H +#ifndef QMEEGOGRAPHICSSYSTEMHELPER_H +#define QMEEGOGRAPHICSSYSTEMHELPER_H #include #include -#include "mlivepixmap.h" +#include "qmeegolivepixmap.h" class QLibrary; @@ -33,8 +33,8 @@ class QLibrary; \code QPixmap p; - if (MGraphicsSystemHelper::isRunningMeeGo()) { - p = MGraphicsSystemHelper::pixmapWithGLTexture(64, 64); + if (QMeeGoGraphicsSystemHelper::isRunningMeeGo()) { + p = QMeeGoGraphicsSystemHelper::pixmapWithGLTexture(64, 64); } else { p = QPixmap(64, 64); } @@ -44,14 +44,14 @@ class QLibrary; give unpredictable results. The only functions safe to call at all times are: \code - MGraphicsSystemHelper::isRunningMeeGo(); - MGraphicsSystemHelper::runningGraphicsSystemName(); - MGraphicsSystemHelper::switchToMeeGo(); - MGraphicsSystemHelper::switchToRaster(); + QMeeGoGraphicsSystemHelper::isRunningMeeGo(); + QMeeGoGraphicsSystemHelper::runningGraphicsSystemName(); + QMeeGoGraphicsSystemHelper::switchToMeeGo(); + QMeeGoGraphicsSystemHelper::switchToRaster(); \endcode */ -class MGraphicsSystemHelper +class QMeeGoGraphicsSystemHelper { public: //! Returns true if running meego. diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro index cab096e..eba6da4 100644 --- a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro +++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro @@ -1,19 +1,11 @@ TEMPLATE = lib -TARGET = meegographicssystemhelper -QT += gui -INCLUDEPATH += '../' -LIBS += -L../plugin -CONFIG += debug -VERSION = 0.1.9 -HEADERS = mgraphicssystemhelper.h moverlaywidget.h mlivepixmap.h mliveimage.h mruntime.h mliveimage_p.h mlivepixmap_p.h -SOURCES = mgraphicssystemhelper.cpp mgraphicssystemhelper.h moverlaywidget.h moverlaywidget.cpp mruntime.cpp mruntime.h mlivepixmap.cpp mlivepixmap.h mliveimage.h mliveimage.cpp mliveimage_p.h mlivepixmap_p.h - -target.path = /usr/lib/ +TARGET = qmeegographicssystemhelper -headers.files = mgraphicssystemhelper.h moverlaywidget.h mlivepixmap.h mliveimage.h -headers.path = /usr/include/meegographicssystemhelper/ +include(../../src/qbase.pri) -pkg.files = meegographicssystemhelper.pc -pkg.path = /usr/lib/pkgconfig/ +QT += gui +INCLUDEPATH += '../../src/plugins/graphicssystems/meego' -INSTALLS += target headers pkg +VERSION = 0.1.9 +HEADERS = qmeegographicssystemhelper.h qmeegooverlaywidget.h qmeegolivepixmap.h qmeegoliveimage.h qmeegoruntime.h qmeegoliveimage_p.h qmeegolivepixmap_p.h +SOURCES = qmeegographicssystemhelper.cpp qmeegooverlaywidget.cpp qmeegoruntime.cpp qmeegolivepixmap.cpp qmeegoliveimage.cpp diff --git a/tools/qmeegographicssystemhelper/qmeegoliveimage.cpp b/tools/qmeegographicssystemhelper/qmeegoliveimage.cpp index 37ead21..f92caf7 100644 --- a/tools/qmeegographicssystemhelper/qmeegoliveimage.cpp +++ b/tools/qmeegographicssystemhelper/qmeegoliveimage.cpp @@ -12,36 +12,36 @@ ** ****************************************************************************/ -#include "mliveimage.h" -#include "mliveimage_p.h" -#include "mlivepixmap.h" -#include "mlivepixmap_p.h" +#include "qmeegoliveimage.h" +#include "qmeegoliveimage_p.h" +#include "qmeegolivepixmap.h" +#include "qmeegolivepixmap_p.h" -/* MLiveImagePrivate */ +/* QMeeGoLiveImagePrivate */ -MLiveImagePrivate::MLiveImagePrivate() +QMeeGoLiveImagePrivate::QMeeGoLiveImagePrivate() { } -MLiveImagePrivate::~MLiveImagePrivate() +QMeeGoLiveImagePrivate::~QMeeGoLiveImagePrivate() { if (attachedPixmaps.length() > 0) - qWarning("Destroying MLiveImage but it still has MLivePixmaps attached!"); + qWarning("Destroying QMeeGoLiveImage but it still has QMeeGoLivePixmaps attached!"); } -void MLiveImagePrivate::attachPixmap(MLivePixmap* pixmap) +void QMeeGoLiveImagePrivate::attachPixmap(QMeeGoLivePixmap* pixmap) { attachedPixmaps << pixmap; } -void MLiveImagePrivate::detachPixmap(MLivePixmap* pixmap) +void QMeeGoLiveImagePrivate::detachPixmap(QMeeGoLivePixmap* pixmap) { attachedPixmaps.removeAll(pixmap); } -/* MLiveImage */ +/* QMeeGoLiveImage */ -MLiveImage* MLiveImage::liveImageWithSize(int w, int h, Format format, int buffers) +QMeeGoLiveImage* QMeeGoLiveImage::liveImageWithSize(int w, int h, Format format, int buffers) { if (format != Format_ARGB32_Premultiplied) { qWarning("Only _ARGB32_Premultiplied format is supported for live images now!"); @@ -53,36 +53,36 @@ MLiveImage* MLiveImage::liveImageWithSize(int w, int h, Format format, int buffe return 0; } - MLiveImage *liveImage = new MLiveImage(w, h); + QMeeGoLiveImage *liveImage = new QMeeGoLiveImage(w, h); return liveImage; } -MLiveImage::MLiveImage(int w, int h) : QImage(w, h, QImage::Format_ARGB32_Premultiplied), d_ptr(new MLiveImagePrivate()) +QMeeGoLiveImage::QMeeGoLiveImage(int w, int h) : QImage(w, h, QImage::Format_ARGB32_Premultiplied), d_ptr(new QMeeGoLiveImagePrivate()) { - Q_D(MLiveImage); + Q_D(QMeeGoLiveImage); d->q_ptr = this; } -MLiveImage::~MLiveImage() +QMeeGoLiveImage::~QMeeGoLiveImage() { } -void MLiveImage::lock(int buffer) +void QMeeGoLiveImage::lock(int buffer) { if (buffer != 0) qWarning("Only locking 0 buffer is supported at the moment!"); } -void MLiveImage::release(int buffer) +void QMeeGoLiveImage::release(int buffer) { - Q_D(MLiveImage); + Q_D(QMeeGoLiveImage); if (buffer != 0) { qWarning("Only locking 0 buffer is supported at the moment!"); return; } - // We need to copy the update image to all the client MLivePixmap's - foreach (MLivePixmap* livePixmap, d->attachedPixmaps) + // We need to copy the update image to all the client QMeeGoLivePixmap's + foreach (QMeeGoLivePixmap* livePixmap, d->attachedPixmaps) livePixmap->d_ptr->copyBackFrom((const void *) bits()); -} \ No newline at end of file +} diff --git a/tools/qmeegographicssystemhelper/qmeegoliveimage.h b/tools/qmeegographicssystemhelper/qmeegoliveimage.h index f945b34..1a998a3 100644 --- a/tools/qmeegographicssystemhelper/qmeegoliveimage.h +++ b/tools/qmeegographicssystemhelper/qmeegoliveimage.h @@ -12,24 +12,24 @@ ** ****************************************************************************/ -#ifndef MLIVEIMAGE_H -#define MLIVEIMAGE_H +#ifndef QMEEGOLIVEIMAGE_H +#define QMEEGOLIVEIMAGE_H #include -class MLivePixmap; -class MLiveImagePrivate; +class QMeeGoLivePixmap; +class QMeeGoLiveImagePrivate; //! A streamable QImage subclass. /*! */ -class MLiveImage : public QImage +class QMeeGoLiveImage : public QImage { public: //! Format specifier. /*! - Used to specify the format of the underlying image data for MLiveImage. + Used to specify the format of the underlying image data for QMeeGoLiveImage. */ enum Format { Format_ARGB32_Premultiplied //! 32bit, AARRGGBB format. The typical Qt format. @@ -51,10 +51,10 @@ public: //! Destroys the image. /*! - It's a mistake to destroy an image before destroying all the MLivePixmaps - built on top of it. You should first destroy all the MLivePixmaps. + It's a mistake to destroy an image before destroying all the QMeeGoLivePixmaps + built on top of it. You should first destroy all the QMeeGoLivePixmaps. */ - virtual ~MLiveImage(); + virtual ~QMeeGoLiveImage(); //! Creates and returns a new live image with the given parameters. /*! @@ -62,18 +62,18 @@ public: The format specifies the color format used by the image. Optionally, a number of buffers can be specfied for a stream-like behavior. */ - static MLiveImage* liveImageWithSize(int w, int h, Format format, int buffers = 1); + static QMeeGoLiveImage* liveImageWithSize(int w, int h, Format format, int buffers = 1); private: - MLiveImage(int w, int h); //! Private bits. - Q_DISABLE_COPY(MLiveImage) - Q_DECLARE_PRIVATE(MLiveImage) + QMeeGoLiveImage(int w, int h); //! Private bits. + Q_DISABLE_COPY(QMeeGoLiveImage) + Q_DECLARE_PRIVATE(QMeeGoLiveImage) protected: - QScopedPointer d_ptr; + QScopedPointer d_ptr; - friend class MLivePixmap; - friend class MLivePixmapPrivate; + friend class QMeeGoLivePixmap; + friend class QMeeGoLivePixmapPrivate; }; #endif diff --git a/tools/qmeegographicssystemhelper/qmeegoliveimage_p.h b/tools/qmeegographicssystemhelper/qmeegoliveimage_p.h index 0789b93..aae97da 100644 --- a/tools/qmeegographicssystemhelper/qmeegoliveimage_p.h +++ b/tools/qmeegographicssystemhelper/qmeegoliveimage_p.h @@ -12,25 +12,25 @@ ** ****************************************************************************/ -#include "mliveimage.h" +#include "qmeegoliveimage.h" -#ifndef MLIVEIMAGE_P_H -#define MLIVEIMAGE_P_H +#ifndef QMEEGOLIVEIMAGE_P_H +#define QMEEGOLIVEIMAGE_P_H -class MLiveImagePrivate +class QMeeGoLiveImagePrivate { public: - Q_DECLARE_PUBLIC(MLiveImage); - MLiveImagePrivate(); - virtual ~MLiveImagePrivate(); - void attachPixmap(MLivePixmap* pixmap); - void detachPixmap(MLivePixmap* pixmap); + Q_DECLARE_PUBLIC(QMeeGoLiveImage); + QMeeGoLiveImagePrivate(); + virtual ~QMeeGoLiveImagePrivate(); + void attachPixmap(QMeeGoLivePixmap* pixmap); + void detachPixmap(QMeeGoLivePixmap* pixmap); - QList attachedPixmaps; - MLiveImage *q_ptr; + QList attachedPixmaps; + QMeeGoLiveImage *q_ptr; - friend class MLivePixmap; - friend class MLivePixmapPrivate; + friend class QMeeGoLivePixmap; + friend class QMeeGoLivePixmapPrivate; }; -#endif \ No newline at end of file +#endif diff --git a/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp b/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp index 2f7abd7..743f4b9 100644 --- a/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp +++ b/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp @@ -12,22 +12,22 @@ ** ****************************************************************************/ -#include "mlivepixmap.h" -#include "../private/qimage_p.h" -#include "../private/qpixmap_raster_p.h" -#include "mlivepixmap_p.h" -#include "mliveimage_p.h" +#include "qmeegolivepixmap.h" +#include +#include +#include "qmeegolivepixmap_p.h" +#include "qmeegoliveimage_p.h" #include -/* MLivePixmapPrivate */ +/* QMeeGoLivePixmapPrivate */ -MLivePixmapPrivate::MLivePixmapPrivate() : shm(0), shmSerial(0), owns(true), parentImage(0) +QMeeGoLivePixmapPrivate::QMeeGoLivePixmapPrivate() : shm(0), shmSerial(0), owns(true), parentImage(0) { } -void MLivePixmapPrivate::copyBackFrom(const void *raw) +void QMeeGoLivePixmapPrivate::copyBackFrom(const void *raw) { - Q_Q(MLivePixmap); + Q_Q(QMeeGoLivePixmap); q->detach(); shm->lock(); @@ -36,9 +36,9 @@ void MLivePixmapPrivate::copyBackFrom(const void *raw) shm->unlock(); } -MLivePixmapPrivate::~MLivePixmapPrivate() +QMeeGoLivePixmapPrivate::~QMeeGoLivePixmapPrivate() { - Q_Q(MLivePixmap); + Q_Q(QMeeGoLivePixmap); if (parentImage) parentImage->d_ptr->detachPixmap(q); @@ -50,15 +50,15 @@ MLivePixmapPrivate::~MLivePixmapPrivate() delete shm; } -/* MLivePixmap */ +/* QMeeGoLivePixmap */ -MLivePixmap::MLivePixmap(QPixmapData *p) : QPixmap(p), d_ptr(new MLivePixmapPrivate()) +QMeeGoLivePixmap::QMeeGoLivePixmap(QPixmapData *p) : QPixmap(p), d_ptr(new QMeeGoLivePixmapPrivate()) { - Q_D(MLivePixmap); + Q_D(QMeeGoLivePixmap); d->q_ptr = this; } -MLivePixmap* MLivePixmap::fromLiveImage(MLiveImage *liveImage) +QMeeGoLivePixmap* QMeeGoLivePixmap::fromLiveImage(QMeeGoLiveImage *liveImage) { static int counter = 100; QSharedMemory *shm = NULL; @@ -68,7 +68,7 @@ MLivePixmap* MLivePixmap::fromLiveImage(MLiveImage *liveImage) int h = liveImage->height(); counter++; - shm = new QSharedMemory(QString("MLivePixmap%1").arg(counter)); + shm = new QSharedMemory(QString("QMeeGoLivePixmap%1").arg(counter)); shm->create((w * h * 4) + 2 * sizeof(int)); // +2 to store width & height shm->attach(); @@ -83,7 +83,7 @@ MLivePixmap* MLivePixmap::fromLiveImage(MLiveImage *liveImage) QPixmapData *pmd = new QRasterPixmapData(QPixmapData::PixmapType); pmd->fromImage(img, Qt::NoOpaqueDetection); - MLivePixmap *livePixmap = new MLivePixmap(pmd); + QMeeGoLivePixmap *livePixmap = new QMeeGoLivePixmap(pmd); livePixmap->d_ptr->shm = shm; livePixmap->d_ptr->owns = true; livePixmap->d_ptr->shmSerial = counter; @@ -94,7 +94,7 @@ MLivePixmap* MLivePixmap::fromLiveImage(MLiveImage *liveImage) return livePixmap; } -MLivePixmap* MLivePixmap::fromHandle(Qt::HANDLE handle) +QMeeGoLivePixmap* QMeeGoLivePixmap::fromHandle(Qt::HANDLE handle) { QSharedMemory *shm = NULL; int *header; @@ -102,7 +102,7 @@ MLivePixmap* MLivePixmap::fromHandle(Qt::HANDLE handle) int height; uchar* imgData; - shm = new QSharedMemory(QString("MLivePixmap%1").arg(handle)); + shm = new QSharedMemory(QString("QMeeGoLivePixmap%1").arg(handle)); shm->attach(); shm->lock(); @@ -117,7 +117,7 @@ MLivePixmap* MLivePixmap::fromHandle(Qt::HANDLE handle) QPixmapData *pmd = new QRasterPixmapData(QPixmapData::PixmapType); pmd->fromImage(img, Qt::NoOpaqueDetection); - MLivePixmap *livePixmap = new MLivePixmap(pmd); + QMeeGoLivePixmap *livePixmap = new QMeeGoLivePixmap(pmd); livePixmap->d_ptr->shm = shm; livePixmap->d_ptr->owns = false; livePixmap->d_ptr->shmSerial = handle; @@ -125,12 +125,12 @@ MLivePixmap* MLivePixmap::fromHandle(Qt::HANDLE handle) return livePixmap; } -MLivePixmap::~MLivePixmap() +QMeeGoLivePixmap::~QMeeGoLivePixmap() { } -Qt::HANDLE MLivePixmap::handle() +Qt::HANDLE QMeeGoLivePixmap::handle() { - Q_D(MLivePixmap); + Q_D(QMeeGoLivePixmap); return d->shmSerial; } diff --git a/tools/qmeegographicssystemhelper/qmeegolivepixmap.h b/tools/qmeegographicssystemhelper/qmeegolivepixmap.h index dee4d2a..123b64f 100644 --- a/tools/qmeegographicssystemhelper/qmeegolivepixmap.h +++ b/tools/qmeegographicssystemhelper/qmeegolivepixmap.h @@ -12,13 +12,13 @@ ** ****************************************************************************/ -#ifndef MLIVEPIXMAP_H -#define MLIVEPIXMAP_H +#ifndef QMEEGOLIVEPIXMAP_H +#define QMEEGOLIVEPIXMAP_H #include -#include "mliveimage.h" +#include "qmeegoliveimage.h" -class MLivePixmapPrivate; +class QMeeGoLivePixmapPrivate; class QSharedMemory; class QImage; @@ -26,46 +26,46 @@ class QImage; /*! */ -class MLivePixmap : public QPixmap +class QMeeGoLivePixmap : public QPixmap { public: - //! Creates new pixmap from the given MLiveImage. + //! Creates new pixmap from the given QMeeGoLiveImage. /*! - The created MLivePixmap will be attached to the given MLiveImage. - Updates to the MLiveImage will be represented on this newly created - MLivePixmap. + The created QMeeGoLivePixmap will be attached to the given QMeeGoLiveImage. + Updates to the QMeeGoLiveImage will be represented on this newly created + QMeeGoLivePixmap. */ - static MLivePixmap* fromLiveImage(MLiveImage *liveImage); + static QMeeGoLivePixmap* fromLiveImage(QMeeGoLiveImage *liveImage); - //! Creates a new MLivePixmap from the specified handle. + //! Creates a new QMeeGoLivePixmap from the specified handle. /*! - The handle can be used to share MLivePixmap cross-process. + The handle can be used to share QMeeGoLivePixmap cross-process. */ - static MLivePixmap* fromHandle(Qt::HANDLE handle); + static QMeeGoLivePixmap* fromHandle(Qt::HANDLE handle); - //! Returns the handle for this MLivePixmap. + //! Returns the handle for this QMeeGoLivePixmap. /*! - The handle can be used to share MLivePixmap cross-process. + The handle can be used to share QMeeGoLivePixmap cross-process. */ Qt::HANDLE handle(); - //! Destroys the MLivePixmap. + //! Destroys the QMeeGoLivePixmap. /*! - All MLivePixmaps attached to a given MLiveImage have to be destroyed - before the MLiveImage itself is destroyed. + All QMeeGoLivePixmaps attached to a given QMeeGoLiveImage have to be destroyed + before the QMeeGoLiveImage itself is destroyed. */ - virtual ~MLivePixmap(); + virtual ~QMeeGoLivePixmap(); private: - MLivePixmap(QPixmapData *p); - Q_DISABLE_COPY(MLivePixmap) - Q_DECLARE_PRIVATE(MLivePixmap) + QMeeGoLivePixmap(QPixmapData *p); + Q_DISABLE_COPY(QMeeGoLivePixmap) + Q_DECLARE_PRIVATE(QMeeGoLivePixmap) protected: - QScopedPointer d_ptr; //! Private bits. + QScopedPointer d_ptr; //! Private bits. - friend class MLiveImage; - friend class MLiveImagePrivate; + friend class QMeeGoLiveImage; + friend class QMeeGoLiveImagePrivate; }; #endif diff --git a/tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h b/tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h index 4ff64de..20158d6 100644 --- a/tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h +++ b/tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h @@ -12,28 +12,28 @@ ** ****************************************************************************/ -#include "mlivepixmap.h" +#include "qmeegolivepixmap.h" -#ifndef MLIVEPIXMAP_P_H -#define MLIVEPIXMAP_P_H +#ifndef QMEEGOLIVEPIXMAP_P_H +#define QMEEGOLIVEPIXMAP_P_H -class MLivePixmapPrivate +class QMeeGoLivePixmapPrivate { public: - Q_DECLARE_PUBLIC(MLivePixmap); - MLivePixmapPrivate(); + Q_DECLARE_PUBLIC(QMeeGoLivePixmap); + QMeeGoLivePixmapPrivate(); void copyBackFrom(const void *raw); - virtual ~MLivePixmapPrivate(); + virtual ~QMeeGoLivePixmapPrivate(); QSharedMemory *shm; int shmSerial; bool owns; - MLiveImage *parentImage; + QMeeGoLiveImage *parentImage; - MLivePixmap *q_ptr; + QMeeGoLivePixmap *q_ptr; - friend class MLiveImage; - friend class MLiveImagePrivate; + friend class QMeeGoLiveImage; + friend class QMeeGoLiveImagePrivate; }; -#endif \ No newline at end of file +#endif diff --git a/tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp b/tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp index 8f64b3f..e44ad0c 100644 --- a/tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp +++ b/tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp @@ -16,37 +16,37 @@ #include #include #include -#include "moverlaywidget.h" -#include "mgraphicssystemhelper.h" -#include "mruntime.h" +#include "qmeegooverlaywidget.h" +#include "qmeegographicssystemhelper.h" +#include "qmeegoruntime.h" -MOverlayWidget::MOverlayWidget(int surfaceWidth, int surfaceHeight, QWidget *parent) : QWidget(parent, 0), +QMeeGoOverlayWidget::QMeeGoOverlayWidget(int surfaceWidth, int surfaceHeight, QWidget *parent) : QWidget(parent, 0), sw(surfaceWidth), sh(surfaceHeight) { - if (! MGraphicsSystemHelper::isRunningMeeGo()) - qFatal("MOverlayWidget can only be used when running with 'meego' graphics system!"); + if (! QMeeGoGraphicsSystemHelper::isRunningMeeGo()) + qFatal("QMeeGoOverlayWidget can only be used when running with 'meego' graphics system!"); - MRuntime::setSurfaceFixedSize(surfaceWidth, surfaceHeight); + QMeeGoRuntime::setSurfaceFixedSize(surfaceWidth, surfaceHeight); scaleW = sw / 864.0; scaleH = sh / 480.0; installEventFilter(this); } -QPoint MOverlayWidget::convertPoint(const QPoint &p) +QPoint QMeeGoOverlayWidget::convertPoint(const QPoint &p) { int x = p.x() * scaleW; int y = p.y() * scaleH; return QPoint(x, y); } -void MOverlayWidget::showEvent(QShowEvent *event) +void QMeeGoOverlayWidget::showEvent(QShowEvent *event) { - MRuntime::setSurfaceScaling(0, 0, width(), height()); + QMeeGoRuntime::setSurfaceScaling(0, 0, width(), height()); } -bool MOverlayWidget::eventFilter(QObject *obj, QEvent *event) +bool QMeeGoOverlayWidget::eventFilter(QObject *obj, QEvent *event) { if (event->spontaneous() == false) return false; diff --git a/tools/qmeegographicssystemhelper/qmeegooverlaywidget.h b/tools/qmeegographicssystemhelper/qmeegooverlaywidget.h index f45a673..f36f407 100644 --- a/tools/qmeegographicssystemhelper/qmeegooverlaywidget.h +++ b/tools/qmeegographicssystemhelper/qmeegooverlaywidget.h @@ -12,8 +12,8 @@ ** ****************************************************************************/ -#ifndef MOVERLAYWIDGET_H -#define MOVERLAYWIDGET_H +#ifndef QMEEGOOVERLAYWIDGET_H +#define QMEEGOOVERLAYWIDGET_H #include @@ -21,7 +21,7 @@ /*! */ -class MOverlayWidget : public QWidget +class QMeeGoOverlayWidget : public QWidget { public: //! Constructs a new scaling widget. @@ -29,7 +29,7 @@ public: The real surface used for this widget will have the specified width and height. */ - MOverlayWidget(int surfaceWidth, int surfaceHeight, QWidget *parent = 0); + QMeeGoOverlayWidget(int surfaceWidth, int surfaceHeight, QWidget *parent = 0); //! Event filtering function. diff --git a/tools/qmeegographicssystemhelper/qmeegoruntime.cpp b/tools/qmeegographicssystemhelper/qmeegoruntime.cpp index b1b0874..1953483 100644 --- a/tools/qmeegographicssystemhelper/qmeegoruntime.cpp +++ b/tools/qmeegographicssystemhelper/qmeegoruntime.cpp @@ -12,101 +12,101 @@ ** ****************************************************************************/ -#include "mruntime.h" +#include "qmeegoruntime.h" #define ENSURE_INITIALIZED {if (!initialized) initialize();} -QLibrary* MRuntime::library = NULL; -bool MRuntime::initialized = false; +QLibrary* QMeeGoRuntime::library = NULL; +bool QMeeGoRuntime::initialized = false; -typedef int (*MImageToEglSharedImageFunc) (const QImage&); -typedef QPixmapData* (*MPixmapDataFromEglSharedImageFunc) (Qt::HANDLE handle, const QImage&); -typedef QPixmapData* (*MPixmapDataWithGLTextureFunc) (int w, int h); -typedef bool (*MDestroyEGLSharedImageFunc) (Qt::HANDLE handle); -typedef void (*MUpdateEglSharedImagePixmapFunc) (QPixmap*); -typedef void (*MSetSurfaceFixedSizeFunc) (int w, int h); -typedef void (*MSetSurfaceScalingFunc) (int x, int y, int w, int h); -typedef void (*MSetTranslucentFunc) (bool translucent); +typedef int (*QMeeGoImageToEglSharedImageFunc) (const QImage&); +typedef QPixmapData* (*QMeeGoPixmapDataFromEglSharedImageFunc) (Qt::HANDLE handle, const QImage&); +typedef QPixmapData* (*QMeeGoPixmapDataWithGLTextureFunc) (int w, int h); +typedef bool (*QMeeGoDestroyEGLSharedImageFunc) (Qt::HANDLE handle); +typedef void (*QMeeGoUpdateEglSharedImagePixmapFunc) (QPixmap*); +typedef void (*QMeeGoSetSurfaceFixedSizeFunc) (int w, int h); +typedef void (*QMeeGoSetSurfaceScalingFunc) (int x, int y, int w, int h); +typedef void (*QMeeGoSetTranslucentFunc) (bool translucent); -static MImageToEglSharedImageFunc m_image_to_egl_shared_image = NULL; -static MPixmapDataFromEglSharedImageFunc m_pixmapdata_from_egl_shared_image = NULL; -static MPixmapDataWithGLTextureFunc m_pixmapdata_with_gl_texture = NULL; -static MDestroyEGLSharedImageFunc m_destroy_egl_shared_image = NULL; -static MUpdateEglSharedImagePixmapFunc m_update_egl_shared_image_pixmap = NULL; -static MSetSurfaceFixedSizeFunc m_set_surface_fixed_size = NULL; -static MSetSurfaceScalingFunc m_set_surface_scaling = NULL; -static MSetTranslucentFunc m_set_translucent = NULL; +static QMeeGoImageToEglSharedImageFunc qt_meego_image_to_egl_shared_image = NULL; +static QMeeGoPixmapDataFromEglSharedImageFunc qt_meego_pixmapdata_from_egl_shared_image = NULL; +static QMeeGoPixmapDataWithGLTextureFunc qt_meego_pixmapdata_with_gl_texture = NULL; +static QMeeGoDestroyEGLSharedImageFunc qt_meego_destroy_egl_shared_image = NULL; +static QMeeGoUpdateEglSharedImagePixmapFunc qt_meego_update_egl_shared_image_pixmap = NULL; +static QMeeGoSetSurfaceFixedSizeFunc qt_meego_set_surface_fixed_size = NULL; +static QMeeGoSetSurfaceScalingFunc qt_meego_set_surface_scaling = NULL; +static QMeeGoSetTranslucentFunc qt_meego_set_translucent = NULL; -void MRuntime::initialize() +void QMeeGoRuntime::initialize() { library = new QLibrary("/usr/lib/qt4/plugins/graphicssystems/libmeegographicssystem.so"); Q_ASSERT(library); - m_image_to_egl_shared_image = (MImageToEglSharedImageFunc) library->resolve("m_image_to_egl_shared_image"); - m_pixmapdata_from_egl_shared_image = (MPixmapDataFromEglSharedImageFunc) library->resolve("m_pixmapdata_from_egl_shared_image"); - m_pixmapdata_with_gl_texture = (MPixmapDataWithGLTextureFunc) library->resolve("m_pixmapdata_with_gl_texture"); - m_destroy_egl_shared_image = (MDestroyEGLSharedImageFunc) library->resolve("m_destroy_egl_shared_image"); - m_update_egl_shared_image_pixmap = (MUpdateEglSharedImagePixmapFunc) library->resolve("m_update_egl_shared_image_pixmap"); - m_set_surface_fixed_size = (MSetSurfaceFixedSizeFunc) library->resolve("m_set_surface_fixed_size"); - m_set_surface_scaling = (MSetSurfaceScalingFunc) library->resolve("m_set_surface_scaling"); - m_set_translucent = (MSetTranslucentFunc) library->resolve("m_set_translucent"); + qt_meego_image_to_egl_shared_image = (QMeeGoImageToEglSharedImageFunc) library->resolve("qt_meego_image_to_egl_shared_image"); + qt_meego_pixmapdata_from_egl_shared_image = (QMeeGoPixmapDataFromEglSharedImageFunc) library->resolve("qt_meego_pixmapdata_from_egl_shared_image"); + qt_meego_pixmapdata_with_gl_texture = (QMeeGoPixmapDataWithGLTextureFunc) library->resolve("qt_meego_pixmapdata_with_gl_texture"); + qt_meego_destroy_egl_shared_image = (QMeeGoDestroyEGLSharedImageFunc) library->resolve("qt_meego_destroy_egl_shared_image"); + qt_meego_update_egl_shared_image_pixmap = (QMeeGoUpdateEglSharedImagePixmapFunc) library->resolve("qt_meego_update_egl_shared_image_pixmap"); + qt_meego_set_surface_fixed_size = (QMeeGoSetSurfaceFixedSizeFunc) library->resolve("qt_meego_set_surface_fixed_size"); + qt_meego_set_surface_scaling = (QMeeGoSetSurfaceScalingFunc) library->resolve("qt_meego_set_surface_scaling"); + qt_meego_set_translucent = (QMeeGoSetTranslucentFunc) library->resolve("qt_meego_set_translucent"); initialized = true; } -Qt::HANDLE MRuntime::imageToEGLSharedImage(const QImage &image) +Qt::HANDLE QMeeGoRuntime::imageToEGLSharedImage(const QImage &image) { ENSURE_INITIALIZED; - Q_ASSERT(m_image_to_egl_shared_image); - return m_image_to_egl_shared_image(image); + Q_ASSERT(qt_meego_image_to_egl_shared_image); + return qt_meego_image_to_egl_shared_image(image); } -QPixmap MRuntime::pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage) +QPixmap QMeeGoRuntime::pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage) { ENSURE_INITIALIZED; - Q_ASSERT(m_pixmapdata_from_egl_shared_image); - return QPixmap(m_pixmapdata_from_egl_shared_image(handle, softImage)); + Q_ASSERT(qt_meego_pixmapdata_from_egl_shared_image); + return QPixmap(qt_meego_pixmapdata_from_egl_shared_image(handle, softImage)); } -QPixmap MRuntime::pixmapWithGLTexture(int w, int h) +QPixmap QMeeGoRuntime::pixmapWithGLTexture(int w, int h) { ENSURE_INITIALIZED; - Q_ASSERT(m_pixmapdata_with_gl_texture); - return QPixmap(m_pixmapdata_with_gl_texture(w, h)); + Q_ASSERT(qt_meego_pixmapdata_with_gl_texture); + return QPixmap(qt_meego_pixmapdata_with_gl_texture(w, h)); } -bool MRuntime::destroyEGLSharedImage(Qt::HANDLE handle) +bool QMeeGoRuntime::destroyEGLSharedImage(Qt::HANDLE handle) { ENSURE_INITIALIZED; - Q_ASSERT(m_destroy_egl_shared_image); - return m_destroy_egl_shared_image(handle); + Q_ASSERT(qt_meego_destroy_egl_shared_image); + return qt_meego_destroy_egl_shared_image(handle); } -void MRuntime::updateEGLSharedImagePixmap(QPixmap *p) +void QMeeGoRuntime::updateEGLSharedImagePixmap(QPixmap *p) { ENSURE_INITIALIZED; - Q_ASSERT(m_update_egl_shared_image_pixmap); - return m_update_egl_shared_image_pixmap(p); + Q_ASSERT(qt_meego_update_egl_shared_image_pixmap); + return qt_meego_update_egl_shared_image_pixmap(p); } -void MRuntime::setSurfaceFixedSize(int w, int h) +void QMeeGoRuntime::setSurfaceFixedSize(int w, int h) { ENSURE_INITIALIZED; - Q_ASSERT(m_set_surface_fixed_size); - m_set_surface_fixed_size(w, h); + Q_ASSERT(qt_meego_set_surface_fixed_size); + qt_meego_set_surface_fixed_size(w, h); } -void MRuntime::setSurfaceScaling(int x, int y, int w, int h) +void QMeeGoRuntime::setSurfaceScaling(int x, int y, int w, int h) { ENSURE_INITIALIZED; - Q_ASSERT(m_set_surface_scaling); - m_set_surface_scaling(x, y, w, h); + Q_ASSERT(qt_meego_set_surface_scaling); + qt_meego_set_surface_scaling(x, y, w, h); } -void MRuntime::setTranslucent(bool translucent) +void QMeeGoRuntime::setTranslucent(bool translucent) { ENSURE_INITIALIZED; - Q_ASSERT(m_set_translucent); - m_set_translucent(translucent); + Q_ASSERT(qt_meego_set_translucent); + qt_meego_set_translucent(translucent); } diff --git a/tools/qmeegographicssystemhelper/qmeegoruntime.h b/tools/qmeegographicssystemhelper/qmeegoruntime.h index 34474cc..7840626 100644 --- a/tools/qmeegographicssystemhelper/qmeegoruntime.h +++ b/tools/qmeegographicssystemhelper/qmeegoruntime.h @@ -16,7 +16,7 @@ #include #include -class MRuntime +class QMeeGoRuntime { public: static void initialize(); @@ -33,4 +33,4 @@ public: private: static bool initialized; static QLibrary *library; -}; \ No newline at end of file +}; diff --git a/tools/tools.pro b/tools/tools.pro index f254230..8f23fe4 100644 --- a/tools/tools.pro +++ b/tools/tools.pro @@ -43,3 +43,7 @@ embedded: SUBDIRS += makeqpf CONFIG+=ordered QTDIR_build:REQUIRES = "contains(QT_CONFIG, full-config)" + +!win32:!embedded:!mac:!symbian:CONFIG += x11 + +x11:contains(QT_CONFIG, opengles2):contains(QT_CONFIG, egl):SUBDIRS += qmeegographicssystemhelper -- cgit v0.12 From 0d9c5bc460c66a96edc9416e5d7e5a56983562a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 7 Sep 2010 14:03:45 +0200 Subject: Updated license headers for meego graphics system helper. --- .../qmeegographicssystemhelper.cpp | 41 ++++++++++++++++++---- .../qmeegographicssystemhelper.h | 41 ++++++++++++++++++---- .../qmeegographicssystemhelper/qmeegoliveimage.cpp | 41 ++++++++++++++++++---- tools/qmeegographicssystemhelper/qmeegoliveimage.h | 41 ++++++++++++++++++---- .../qmeegographicssystemhelper/qmeegoliveimage_p.h | 41 ++++++++++++++++++---- .../qmeegolivepixmap.cpp | 41 ++++++++++++++++++---- .../qmeegographicssystemhelper/qmeegolivepixmap.h | 41 ++++++++++++++++++---- .../qmeegolivepixmap_p.h | 41 ++++++++++++++++++---- .../qmeegooverlaywidget.cpp | 41 ++++++++++++++++++---- .../qmeegooverlaywidget.h | 41 ++++++++++++++++++---- tools/qmeegographicssystemhelper/qmeegoruntime.cpp | 41 ++++++++++++++++++---- tools/qmeegographicssystemhelper/qmeegoruntime.h | 41 ++++++++++++++++++---- 12 files changed, 408 insertions(+), 84 deletions(-) diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp index 38ba82d..22b8d5f 100644 --- a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp +++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp @@ -1,14 +1,41 @@ -/*************************************************************************** +/**************************************************************************** ** ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. -** Contact: Nokia Corporation +** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This library is free software; you can redistribute it and/or -** modify it 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. +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h index 069a27c..aa301b1 100644 --- a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h +++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h @@ -1,14 +1,41 @@ -/*************************************************************************** +/**************************************************************************** ** ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. -** Contact: Nokia Corporation +** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This library is free software; you can redistribute it and/or -** modify it 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. +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tools/qmeegographicssystemhelper/qmeegoliveimage.cpp b/tools/qmeegographicssystemhelper/qmeegoliveimage.cpp index f92caf7..83a1e28 100644 --- a/tools/qmeegographicssystemhelper/qmeegoliveimage.cpp +++ b/tools/qmeegographicssystemhelper/qmeegoliveimage.cpp @@ -1,14 +1,41 @@ -/*************************************************************************** +/**************************************************************************** ** ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. -** Contact: Nokia Corporation +** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This library is free software; you can redistribute it and/or -** modify it 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. +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tools/qmeegographicssystemhelper/qmeegoliveimage.h b/tools/qmeegographicssystemhelper/qmeegoliveimage.h index 1a998a3..1e21e7b 100644 --- a/tools/qmeegographicssystemhelper/qmeegoliveimage.h +++ b/tools/qmeegographicssystemhelper/qmeegoliveimage.h @@ -1,14 +1,41 @@ -/*************************************************************************** +/**************************************************************************** ** ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. -** Contact: Nokia Corporation +** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This library is free software; you can redistribute it and/or -** modify it 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. +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tools/qmeegographicssystemhelper/qmeegoliveimage_p.h b/tools/qmeegographicssystemhelper/qmeegoliveimage_p.h index aae97da..085fed4 100644 --- a/tools/qmeegographicssystemhelper/qmeegoliveimage_p.h +++ b/tools/qmeegographicssystemhelper/qmeegoliveimage_p.h @@ -1,14 +1,41 @@ -/*************************************************************************** +/**************************************************************************** ** ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. -** Contact: Nokia Corporation +** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This library is free software; you can redistribute it and/or -** modify it 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. +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp b/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp index 743f4b9..f159b58 100644 --- a/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp +++ b/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp @@ -1,14 +1,41 @@ -/*************************************************************************** +/**************************************************************************** ** ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. -** Contact: Nokia Corporation +** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This library is free software; you can redistribute it and/or -** modify it 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. +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tools/qmeegographicssystemhelper/qmeegolivepixmap.h b/tools/qmeegographicssystemhelper/qmeegolivepixmap.h index 123b64f..2fa9db2 100644 --- a/tools/qmeegographicssystemhelper/qmeegolivepixmap.h +++ b/tools/qmeegographicssystemhelper/qmeegolivepixmap.h @@ -1,14 +1,41 @@ -/*************************************************************************** +/**************************************************************************** ** ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. -** Contact: Nokia Corporation +** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This library is free software; you can redistribute it and/or -** modify it 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. +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h b/tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h index 20158d6..c2591dc 100644 --- a/tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h +++ b/tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h @@ -1,14 +1,41 @@ -/*************************************************************************** +/**************************************************************************** ** ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. -** Contact: Nokia Corporation +** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This library is free software; you can redistribute it and/or -** modify it 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. +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp b/tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp index e44ad0c..90991e7 100644 --- a/tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp +++ b/tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp @@ -1,14 +1,41 @@ -/*************************************************************************** +/**************************************************************************** ** ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. -** Contact: Nokia Corporation +** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This library is free software; you can redistribute it and/or -** modify it 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. +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tools/qmeegographicssystemhelper/qmeegooverlaywidget.h b/tools/qmeegographicssystemhelper/qmeegooverlaywidget.h index f36f407..c2c08b4 100644 --- a/tools/qmeegographicssystemhelper/qmeegooverlaywidget.h +++ b/tools/qmeegographicssystemhelper/qmeegooverlaywidget.h @@ -1,14 +1,41 @@ -/*************************************************************************** +/**************************************************************************** ** ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. -** Contact: Nokia Corporation +** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This library is free software; you can redistribute it and/or -** modify it 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. +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tools/qmeegographicssystemhelper/qmeegoruntime.cpp b/tools/qmeegographicssystemhelper/qmeegoruntime.cpp index 1953483..66bae1d 100644 --- a/tools/qmeegographicssystemhelper/qmeegoruntime.cpp +++ b/tools/qmeegographicssystemhelper/qmeegoruntime.cpp @@ -1,14 +1,41 @@ -/*************************************************************************** +/**************************************************************************** ** ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. -** Contact: Nokia Corporation +** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This library is free software; you can redistribute it and/or -** modify it 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. +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tools/qmeegographicssystemhelper/qmeegoruntime.h b/tools/qmeegographicssystemhelper/qmeegoruntime.h index 7840626..98bf5b0 100644 --- a/tools/qmeegographicssystemhelper/qmeegoruntime.h +++ b/tools/qmeegographicssystemhelper/qmeegoruntime.h @@ -1,14 +1,41 @@ -/*************************************************************************** +/**************************************************************************** ** ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. -** Contact: Nokia Corporation +** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This library is free software; you can redistribute it and/or -** modify it 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. +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ ** ****************************************************************************/ -- cgit v0.12 From b2ef75097e608afc717604884c4b6e4b22e78dee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 7 Sep 2010 11:49:34 +0200 Subject: Use QFactoryLoader to ensure we get the correct graphics system plugin. Also, this prevents hard-coding the path to the meego plugin. --- src/corelib/plugin/qfactoryloader.cpp | 8 ++++ src/corelib/plugin/qfactoryloader_p.h | 4 ++ .../graphicssystems/meego/qmeegographicssystem.h | 16 ++++---- .../qmeegographicssystemhelper.h | 2 +- tools/qmeegographicssystemhelper/qmeegoruntime.cpp | 47 +++++++++++++++------- tools/qmeegographicssystemhelper/qmeegoruntime.h | 4 +- 6 files changed, 55 insertions(+), 26 deletions(-) diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp index 62d565a..a26dcd8 100644 --- a/src/corelib/plugin/qfactoryloader.cpp +++ b/src/corelib/plugin/qfactoryloader.cpp @@ -244,6 +244,14 @@ QObject *QFactoryLoader::instance(const QString &key) const return 0; } +#ifdef Q_WS_X11 +QLibraryPrivate *QFactoryLoader::library(const QString &key) const +{ + Q_D(const QFactoryLoader); + return d->keyMap.value(d->cs ? key : key.toLower()); +} +#endif + void QFactoryLoader::refreshAll() { QMutexLocker locker(qt_factoryloader_mutex()); diff --git a/src/corelib/plugin/qfactoryloader_p.h b/src/corelib/plugin/qfactoryloader_p.h index 10e6e2a..068c6c7 100644 --- a/src/corelib/plugin/qfactoryloader_p.h +++ b/src/corelib/plugin/qfactoryloader_p.h @@ -77,6 +77,10 @@ public: QStringList keys() const; QObject *instance(const QString &key) const; +#ifdef Q_WS_X11 + QLibraryPrivate *library(const QString &key) const; +#endif + void update(); static void refreshAll(); diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.h b/src/plugins/graphicssystems/meego/qmeegographicssystem.h index 59392ad..905f0c3 100644 --- a/src/plugins/graphicssystems/meego/qmeegographicssystem.h +++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.h @@ -72,14 +72,14 @@ private: /* C api */ extern "C" { - int qt_meego_image_to_egl_shared_image(const QImage &image); - QPixmapData* qt_meego_pixmapdata_from_egl_shared_image(Qt::HANDLE handle, const QImage &softImage); - QPixmapData* qt_meego_pixmapdata_with_gl_texture(int w, int h); - void qt_meego_update_egl_shared_image_pixmap(QPixmap *pixmap); - bool qt_meego_destroy_egl_shared_image(Qt::HANDLE handle); - void qt_meego_set_surface_fixed_size(int width, int height); - void qt_meego_set_surface_scaling(int x, int y, int width, int height); - void qt_meego_set_translucent(bool translucent); + Q_DECL_EXPORT int qt_meego_image_to_egl_shared_image(const QImage &image); + Q_DECL_EXPORT QPixmapData* qt_meego_pixmapdata_from_egl_shared_image(Qt::HANDLE handle, const QImage &softImage); + Q_DECL_EXPORT QPixmapData* qt_meego_pixmapdata_with_gl_texture(int w, int h); + Q_DECL_EXPORT void qt_meego_update_egl_shared_image_pixmap(QPixmap *pixmap); + Q_DECL_EXPORT bool qt_meego_destroy_egl_shared_image(Qt::HANDLE handle); + Q_DECL_EXPORT void qt_meego_set_surface_fixed_size(int width, int height); + Q_DECL_EXPORT void qt_meego_set_surface_scaling(int x, int y, int width, int height); + Q_DECL_EXPORT void qt_meego_set_translucent(bool translucent); } #endif diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h index aa301b1..02f2fa2 100644 --- a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h +++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h @@ -78,7 +78,7 @@ class QLibrary; \endcode */ -class QMeeGoGraphicsSystemHelper +class Q_DECL_EXPORT QMeeGoGraphicsSystemHelper { public: //! Returns true if running meego. diff --git a/tools/qmeegographicssystemhelper/qmeegoruntime.cpp b/tools/qmeegographicssystemhelper/qmeegoruntime.cpp index 66bae1d..70b5dc1 100644 --- a/tools/qmeegographicssystemhelper/qmeegoruntime.cpp +++ b/tools/qmeegographicssystemhelper/qmeegoruntime.cpp @@ -41,9 +41,12 @@ #include "qmeegoruntime.h" +#include +#include +#include + #define ENSURE_INITIALIZED {if (!initialized) initialize();} -QLibrary* QMeeGoRuntime::library = NULL; bool QMeeGoRuntime::initialized = false; typedef int (*QMeeGoImageToEglSharedImageFunc) (const QImage&); @@ -66,19 +69,35 @@ static QMeeGoSetTranslucentFunc qt_meego_set_translucent = NULL; void QMeeGoRuntime::initialize() { - library = new QLibrary("/usr/lib/qt4/plugins/graphicssystems/libmeegographicssystem.so"); - Q_ASSERT(library); - - qt_meego_image_to_egl_shared_image = (QMeeGoImageToEglSharedImageFunc) library->resolve("qt_meego_image_to_egl_shared_image"); - qt_meego_pixmapdata_from_egl_shared_image = (QMeeGoPixmapDataFromEglSharedImageFunc) library->resolve("qt_meego_pixmapdata_from_egl_shared_image"); - qt_meego_pixmapdata_with_gl_texture = (QMeeGoPixmapDataWithGLTextureFunc) library->resolve("qt_meego_pixmapdata_with_gl_texture"); - qt_meego_destroy_egl_shared_image = (QMeeGoDestroyEGLSharedImageFunc) library->resolve("qt_meego_destroy_egl_shared_image"); - qt_meego_update_egl_shared_image_pixmap = (QMeeGoUpdateEglSharedImagePixmapFunc) library->resolve("qt_meego_update_egl_shared_image_pixmap"); - qt_meego_set_surface_fixed_size = (QMeeGoSetSurfaceFixedSizeFunc) library->resolve("qt_meego_set_surface_fixed_size"); - qt_meego_set_surface_scaling = (QMeeGoSetSurfaceScalingFunc) library->resolve("qt_meego_set_surface_scaling"); - qt_meego_set_translucent = (QMeeGoSetTranslucentFunc) library->resolve("qt_meego_set_translucent"); - - + QFactoryLoader loader(QGraphicsSystemFactoryInterface_iid, QLatin1String("/graphicssystems"), Qt::CaseInsensitive); + + QLibraryPrivate *libraryPrivate = loader.library(QLatin1String("meego")); + Q_ASSERT(libraryPrivate); + + QLibrary library(libraryPrivate->fileName, libraryPrivate->fullVersion); + + bool success = library.load(); + + if (success) { + qt_meego_image_to_egl_shared_image = (QMeeGoImageToEglSharedImageFunc) library.resolve("qt_meego_image_to_egl_shared_image"); + qt_meego_pixmapdata_from_egl_shared_image = (QMeeGoPixmapDataFromEglSharedImageFunc) library.resolve("qt_meego_pixmapdata_from_egl_shared_image"); + qt_meego_pixmapdata_with_gl_texture = (QMeeGoPixmapDataWithGLTextureFunc) library.resolve("qt_meego_pixmapdata_with_gl_texture"); + qt_meego_destroy_egl_shared_image = (QMeeGoDestroyEGLSharedImageFunc) library.resolve("qt_meego_destroy_egl_shared_image"); + qt_meego_update_egl_shared_image_pixmap = (QMeeGoUpdateEglSharedImagePixmapFunc) library.resolve("qt_meego_update_egl_shared_image_pixmap"); + qt_meego_set_surface_fixed_size = (QMeeGoSetSurfaceFixedSizeFunc) library.resolve("qt_meego_set_surface_fixed_size"); + qt_meego_set_surface_scaling = (QMeeGoSetSurfaceScalingFunc) library.resolve("qt_meego_set_surface_scaling"); + qt_meego_set_translucent = (QMeeGoSetTranslucentFunc) library.resolve("qt_meego_set_translucent"); + + if (qt_meego_image_to_egl_shared_image && qt_meego_pixmapdata_from_egl_shared_image && qt_meego_pixmapdata_with_gl_texture + && qt_meego_destroy_egl_shared_image && qt_meego_update_egl_shared_image_pixmap && qt_meego_set_surface_fixed_size + && qt_meego_set_surface_scaling && qt_meego_set_translucent) + { + qDebug("Successfully resolved MeeGo graphics system: %s %s\n", qPrintable(libraryPrivate->fileName), qPrintable(libraryPrivate->fullVersion)); + } + } else { + Q_ASSERT(false); + } + initialized = true; } diff --git a/tools/qmeegographicssystemhelper/qmeegoruntime.h b/tools/qmeegographicssystemhelper/qmeegoruntime.h index 98bf5b0..82fdb52 100644 --- a/tools/qmeegographicssystemhelper/qmeegoruntime.h +++ b/tools/qmeegographicssystemhelper/qmeegoruntime.h @@ -39,7 +39,6 @@ ** ****************************************************************************/ -#include #include #include @@ -47,7 +46,7 @@ class QMeeGoRuntime { public: static void initialize(); - + static Qt::HANDLE imageToEGLSharedImage(const QImage &image); static QPixmap pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage); static QPixmap pixmapWithGLTexture(int w, int h); @@ -59,5 +58,4 @@ public: private: static bool initialized; - static QLibrary *library; }; -- cgit v0.12 From 39e16d89dc759fc5aafe883476a163759d2ad6cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 7 Sep 2010 13:58:06 +0200 Subject: Added meego graphics system helper to features/qt.prf and syncqt. MeeGo graphics system helper headers are now synced and the correct include path and libraries are added to an application by doing QT += meegographicssystem helper in the .pro file. --- bin/syncqt | 1 + mkspecs/features/qt.prf | 3 ++- tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro | 3 +-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/syncqt b/bin/syncqt index 907869d..c73d119 100755 --- a/bin/syncqt +++ b/bin/syncqt @@ -51,6 +51,7 @@ my %modules = ( # path to module name map "QtWebKit" => "$basedir/src/3rdparty/webkit/WebCore", "phonon" => "$basedir/src/phonon", "QtMultimedia" => "$basedir/src/multimedia", + "QtMeeGoGraphicsSystemHelper" => "$basedir/tools/qmeegographicssystemhelper", ); my %moduleheaders = ( # restrict the module headers to those found in relative path "QtWebKit" => "../WebKit/qt/Api", diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf index 4fd804d..e59319f 100644 --- a/mkspecs/features/qt.prf +++ b/mkspecs/features/qt.prf @@ -36,7 +36,7 @@ INCLUDEPATH = $$QMAKE_INCDIR_QT $$INCLUDEPATH #prepending prevents us from picki win32:INCLUDEPATH += $$QMAKE_INCDIR_QT/ActiveQt # As order does matter for static libs, we reorder the QT variable here -TMPLIBS = declarative webkit phonon multimedia dbus testlib script scripttools svg qt3support sql xmlpatterns xml egl opengl openvg gui network core +TMPLIBS = declarative webkit phonon multimedia dbus testlib script scripttools svg qt3support sql xmlpatterns xml egl opengl openvg gui network core meegographicssystemhelper for(QTLIB, $$list($$TMPLIBS)) { contains(QT, $$QTLIB): QT_ORDERED += $$QTLIB } @@ -175,6 +175,7 @@ for(QTLIB, $$list($$lower($$unique(QT)))) { } } else:isEqual(QTLIB, declarative):qlib = QtDeclarative else:isEqual(QTLIB, multimedia):qlib = QtMultimedia + else:isEqual(QTLIB, meegographicssystemhelper):qlib = QtMeeGoGraphicsSystemHelper else:message("Unknown QT: $$QTLIB"):qlib = !isEmpty(qlib) { target_qt:isEqual(TARGET, qlib) { diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro index eba6da4..1e6e233 100644 --- a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro +++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro @@ -1,11 +1,10 @@ TEMPLATE = lib -TARGET = qmeegographicssystemhelper +TARGET = QtMeeGoGraphicsSystemHelper include(../../src/qbase.pri) QT += gui INCLUDEPATH += '../../src/plugins/graphicssystems/meego' -VERSION = 0.1.9 HEADERS = qmeegographicssystemhelper.h qmeegooverlaywidget.h qmeegolivepixmap.h qmeegoliveimage.h qmeegoruntime.h qmeegoliveimage_p.h qmeegolivepixmap_p.h SOURCES = qmeegographicssystemhelper.cpp qmeegooverlaywidget.cpp qmeegoruntime.cpp qmeegolivepixmap.cpp qmeegoliveimage.cpp -- cgit v0.12 From eb8efdd8a38ca2304634155bdab60b973aa44c17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 7 Sep 2010 14:07:37 +0200 Subject: Fixed compiler warnings in meego graphics system helper. --- .../qmeegographicssystemhelper.cpp | 18 +++++++++--------- tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp | 4 ++-- .../qmeegographicssystemhelper/qmeegooverlaywidget.cpp | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp index 22b8d5f..0670ac4 100644 --- a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp +++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp @@ -51,11 +51,11 @@ QString QMeeGoGraphicsSystemHelper::runningGraphicsSystemName() { if (! QApplicationPrivate::instance()) { qWarning("Querying graphics system but application not running yet!"); - return ""; + return QString(); } QString name = QApplicationPrivate::instance()->graphics_system_name; - if (name == "runtime") { + if (name == QLatin1String("runtime")) { QRuntimeGraphicsSystem *rsystem = (QRuntimeGraphicsSystem *) QApplicationPrivate::instance()->graphics_system; name = rsystem->graphicsSystemName(); } @@ -65,32 +65,32 @@ QString QMeeGoGraphicsSystemHelper::runningGraphicsSystemName() bool QMeeGoGraphicsSystemHelper::isRunningMeeGo() { - return (runningGraphicsSystemName() == "meego"); + return (runningGraphicsSystemName() == QLatin1String("meego")); } void QMeeGoGraphicsSystemHelper::switchToMeeGo() { - if (runningGraphicsSystemName() == "meego") + if (isRunningMeeGo()) return; - if (QApplicationPrivate::instance()->graphics_system_name != "runtime") + if (QApplicationPrivate::instance()->graphics_system_name != QLatin1String("runtime")) qWarning("Can't switch to meego - switching only supported with 'runtime' graphics system."); else { QApplication *app = static_cast(QCoreApplication::instance()); - app->setGraphicsSystem("meego"); + app->setGraphicsSystem(QLatin1String("meego")); } } void QMeeGoGraphicsSystemHelper::switchToRaster() { - if (runningGraphicsSystemName() == "raster") + if (runningGraphicsSystemName() == QLatin1String("raster")) return; - if (QApplicationPrivate::instance()->graphics_system_name != "runtime") + if (QApplicationPrivate::instance()->graphics_system_name != QLatin1String("runtime")) qWarning("Can't switch to raster - switching only supported with 'runtime' graphics system."); else { QApplication *app = static_cast(QCoreApplication::instance()); - app->setGraphicsSystem("raster"); + app->setGraphicsSystem(QLatin1String("raster")); } } diff --git a/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp b/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp index f159b58..2a1c04b 100644 --- a/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp +++ b/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp @@ -95,7 +95,7 @@ QMeeGoLivePixmap* QMeeGoLivePixmap::fromLiveImage(QMeeGoLiveImage *liveImage) int h = liveImage->height(); counter++; - shm = new QSharedMemory(QString("QMeeGoLivePixmap%1").arg(counter)); + shm = new QSharedMemory(QString(QLatin1String("QMeeGoLivePixmap%1")).arg(counter)); shm->create((w * h * 4) + 2 * sizeof(int)); // +2 to store width & height shm->attach(); @@ -129,7 +129,7 @@ QMeeGoLivePixmap* QMeeGoLivePixmap::fromHandle(Qt::HANDLE handle) int height; uchar* imgData; - shm = new QSharedMemory(QString("QMeeGoLivePixmap%1").arg(handle)); + shm = new QSharedMemory(QString(QLatin1String("QMeeGoLivePixmap%1")).arg(handle)); shm->attach(); shm->lock(); diff --git a/tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp b/tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp index 90991e7..f9f14ae 100644 --- a/tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp +++ b/tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp @@ -68,12 +68,12 @@ QPoint QMeeGoOverlayWidget::convertPoint(const QPoint &p) return QPoint(x, y); } -void QMeeGoOverlayWidget::showEvent(QShowEvent *event) +void QMeeGoOverlayWidget::showEvent(QShowEvent *) { QMeeGoRuntime::setSurfaceScaling(0, 0, width(), height()); } -bool QMeeGoOverlayWidget::eventFilter(QObject *obj, QEvent *event) +bool QMeeGoOverlayWidget::eventFilter(QObject *, QEvent *event) { if (event->spontaneous() == false) return false; -- cgit v0.12 From 0472a8d312f2040f42ee817d05dd6e765260de88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 8 Sep 2010 10:00:21 +0200 Subject: Force MeeGo touch to use native graphics system for now. MeeGo touch doesn't yet work with other graphics systems since it assumes that QPixmaps are XPixmap based. If MeeGo touch doesn't link against the graphics system helper we'll force it to use the native graphics system. --- src/gui/kernel/qapplication.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 82dd83a..e99f6ca 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -94,6 +94,10 @@ #include +#if defined(Q_WS_X11) && !defined(QT_NO_EGL) +#include +#endif + #include "qapplication_p.h" #include "qevent_p.h" #include "qwidget_p.h" @@ -768,6 +772,13 @@ QApplication::QApplication(int &argc, char **argv, Type type , int _internal) : QCoreApplication(*new QApplicationPrivate(argc, argv, type)) { Q_D(QApplication); d->construct(); QApplicationPrivate::app_compile_version = _internal;} +#if defined(Q_WS_X11) && !defined(QT_NO_EGL) +static int qt_matchLibraryName(dl_phdr_info *info, size_t, void *data) +{ + const char *name = static_cast(data); + return strstr(info->dlpi_name, name) != 0; +} +#endif /*! \internal @@ -785,6 +796,19 @@ void QApplicationPrivate::construct( // the environment variable has the lowest precedence of runtime graphicssystem switches if (graphics_system_name.isEmpty()) graphics_system_name = QString::fromLocal8Bit(qgetenv("QT_GRAPHICSSYSTEM")); + +#if defined(Q_WS_X11) && !defined(QT_NO_EGL) + if (graphics_system_name.isEmpty()) { + bool linksWithMeeGoTouch = dl_iterate_phdr(qt_matchLibraryName, const_cast("libmeegotouchcore")); + bool linksWithMeeGoGraphicsSystemHelper = dl_iterate_phdr(qt_matchLibraryName, const_cast("libQtMeeGoGraphicsSystemHelper")); + + if (linksWithMeeGoTouch && !linksWithMeeGoGraphicsSystemHelper) { + qWarning("Running non-meego graphics system enabled MeeGo touch, forcing native graphicssystem\n"); + graphics_system_name = QLatin1String("native"); + } + } +#endif + // Must be called before initialize() qt_init(this, qt_appType #ifdef Q_WS_X11 -- cgit v0.12 From 8a43ccdaf3bbd1e77045cbb63231e201ea23896f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Fri, 10 Sep 2010 13:25:41 +0200 Subject: Fix a regression where setPreferredSize(QSize(100, -1)) did not work. Regressed by change 515991426832a6333f2fd9e639bd4c83e2b27cef Reviewed-by: Frederik Gladhorn --- src/gui/graphicsview/qgraphicslayoutitem.cpp | 2 +- tests/auto/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicslayoutitem.cpp b/src/gui/graphicsview/qgraphicslayoutitem.cpp index 3707591..634f68c 100644 --- a/src/gui/graphicsview/qgraphicslayoutitem.cpp +++ b/src/gui/graphicsview/qgraphicslayoutitem.cpp @@ -234,7 +234,7 @@ void QGraphicsLayoutItemPrivate::setSize(Qt::SizeHint which, const QSizeF &size) if (userSizeHints) { if (size == userSizeHints[which]) return; - } else if (!size.isValid()) { + } else if (size.width() < 0 && size.height() < 0) { return; } diff --git a/tests/auto/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp b/tests/auto/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp index 879e12b..dbffa6e 100644 --- a/tests/auto/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp +++ b/tests/auto/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp @@ -75,6 +75,7 @@ private slots: void setPreferredSize_data(); void setPreferredSize(); void setSizePolicy_data(); + void setPreferredSize2(); void setSizePolicy(); }; @@ -343,6 +344,13 @@ void tst_QGraphicsLayoutItem::setPreferredSize() } } +void tst_QGraphicsLayoutItem::setPreferredSize2() +{ + SubQGraphicsLayoutItem layoutItem; + layoutItem.setPreferredSize(QSizeF(30, -1)); + QCOMPARE(layoutItem.preferredWidth(), qreal(30)); +} + void tst_QGraphicsLayoutItem::setSizePolicy_data() { QTest::addColumn("policy"); -- cgit v0.12 From e78274d5f8c0eb5c10b9b58e069b90b6475c6f71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 10 Sep 2010 15:35:34 +0200 Subject: Prevented crash in GL window surface when deleting native child widgets. We should only destroy the FBO if it's the actual window that's deleted. Reviewed-by: Trond --- src/opengl/qwindowsurface_gl.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index 48c7deb..f98dcff 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -345,12 +345,14 @@ QGLWindowSurface::~QGLWindowSurface() void QGLWindowSurface::deleted(QObject *object) { - // Make sure that the fbo is destroyed before destroying its context. - delete d_ptr->fbo; - d_ptr->fbo = 0; - QWidget *widget = qobject_cast(object); if (widget) { + if (widget == window()) { + // Make sure that the fbo is destroyed before destroying its context. + delete d_ptr->fbo; + d_ptr->fbo = 0; + } + QWidgetPrivate *widgetPrivate = widget->d_func(); if (widgetPrivate->extraData()) { union { QGLContext **ctxPtr; void **voidPtr; }; @@ -422,6 +424,8 @@ QPaintDevice *QGLWindowSurface::paintDevice() QGLContext *ctx = reinterpret_cast(window()->d_func()->extraData()->glContext); ctx->makeCurrent(); + + Q_ASSERT(d_ptr->fbo); return d_ptr->fbo; } -- cgit v0.12