summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorA-Team <ateam@pad.test.qt.nokia.com>2010-09-10 22:00:11 (GMT)
committerA-Team <ateam@pad.test.qt.nokia.com>2010-09-10 22:00:11 (GMT)
commitfd570dca1319cd92daf0f73b10ea4e090ea15c23 (patch)
tree9de1035b83cd857340e30e82e781f80cd1abc6ef /src
parent99e4ba7cb0700eb1a68d6db9fa8d058ddb59f233 (diff)
parent3dc18b19ee2a02b93cc509a9162bf0a3900c6fd0 (diff)
downloadQt-fd570dca1319cd92daf0f73b10ea4e090ea15c23.zip
Qt-fd570dca1319cd92daf0f73b10ea4e090ea15c23.tar.gz
Qt-fd570dca1319cd92daf0f73b10ea4e090ea15c23.tar.bz2
Merge branch '4.7-upstream' into 4.7-doc
Diffstat (limited to 'src')
-rw-r--r--src/activeqt/control/qaxserverbase.cpp13
-rw-r--r--src/corelib/plugin/qfactoryloader.cpp8
-rw-r--r--src/corelib/plugin/qfactoryloader_p.h4
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimagebase.cpp23
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimagebase_p.h3
-rw-r--r--src/gui/egl/qeglcontext_p.h3
-rw-r--r--src/gui/graphicsview/qgraphicslayoutitem.cpp2
-rw-r--r--src/gui/inputmethod/qcoefepinputcontext_s60.cpp11
-rw-r--r--src/gui/kernel/qapplication.cpp24
-rw-r--r--src/gui/painting/qgraphicssystem_runtime_p.h1
-rw-r--r--src/gui/text/qfontengine_win.cpp3
-rw-r--r--src/gui/text/qstatictext.cpp3
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp6
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h2
-rw-r--r--src/opengl/qpixmapdata_gl.cpp40
-rw-r--r--src/opengl/qpixmapdata_gl_p.h3
-rw-r--r--src/opengl/qwindowsurface_gl.cpp23
-rw-r--r--src/plugins/graphicssystems/graphicssystems.pro4
-rw-r--r--src/plugins/graphicssystems/meego/meego.pro13
-rw-r--r--src/plugins/graphicssystems/meego/qmeegoextensions.cpp129
-rw-r--r--src/plugins/graphicssystems/meego/qmeegoextensions.h89
-rw-r--r--src/plugins/graphicssystems/meego/qmeegographicssystem.cpp248
-rw-r--r--src/plugins/graphicssystems/meego/qmeegographicssystem.h85
-rw-r--r--src/plugins/graphicssystems/meego/qmeegographicssystemplugin.cpp58
-rw-r--r--src/plugins/graphicssystems/meego/qmeegographicssystemplugin.h54
-rw-r--r--src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp206
-rw-r--r--src/plugins/graphicssystems/meego/qmeegopixmapdata.h73
27 files changed, 1100 insertions, 31 deletions
diff --git a/src/activeqt/control/qaxserverbase.cpp b/src/activeqt/control/qaxserverbase.cpp
index ca16b39..d8e7ea3 100644
--- a/src/activeqt/control/qaxserverbase.cpp
+++ b/src/activeqt/control/qaxserverbase.cpp
@@ -2730,6 +2730,19 @@ HRESULT WINAPI QAxServerBase::Load(IStream *pStm)
qtarray.resize(stat.cbSize.LowPart);
ULONG read;
pStm->Read(qtarray.data(), stat.cbSize.LowPart, &read);
+ } else if (hres == E_NOTIMPL) {
+ ULONG read = 0;
+ while (hres != S_FALSE) {
+ QByteArray arrayRead;
+ arrayRead.resize(4098);
+ hres = pStm->Read(arrayRead.data(), arrayRead.size(), &read);
+ if (hres != S_OK && hres != S_FALSE) {
+ qtarray.resize(0);
+ break;
+ } else if (read == 0)
+ break;
+ qtarray.append(arrayRead);
+ }
}
const QMetaObject *mo = qt.object->metaObject();
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/declarative/graphicsitems/qdeclarativeimagebase.cpp b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
index f0293d6..02b4807 100644
--- a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
@@ -129,27 +129,25 @@ QSize QDeclarativeImageBase::sourceSize() const
void QDeclarativeImageBase::load()
{
Q_D(QDeclarativeImageBase);
- if (d->progress != 0.0) {
- d->progress = 0.0;
- emit progressChanged(d->progress);
- }
if (d->url.isEmpty()) {
d->pix.clear();
d->status = Null;
+ d->progress = 0.0;
setImplicitWidth(0);
setImplicitHeight(0);
+ emit progressChanged(d->progress);
emit statusChanged(d->status);
pixmapChange();
update();
} else {
-
- d->status = Loading;
- emit statusChanged(d->status);
-
d->pix.load(qmlEngine(this), d->url, d->sourcesize, d->async);
if (d->pix.isLoading()) {
+ d->progress = 0.0;
+ d->status = Loading;
+ emit progressChanged(d->progress);
+ emit statusChanged(d->status);
static int thisRequestProgress = -1;
static int thisRequestFinished = -1;
@@ -173,6 +171,9 @@ void QDeclarativeImageBase::requestFinished()
{
Q_D(QDeclarativeImageBase);
+ QDeclarativeImageBase::Status oldStatus = d->status;
+ qreal oldProgress = d->progress;
+
if (d->pix.isError()) {
d->status = Error;
qmlInfo(this) << d->pix.error();
@@ -191,8 +192,10 @@ void QDeclarativeImageBase::requestFinished()
emit sourceSizeChanged();
}
- emit statusChanged(d->status);
- emit progressChanged(d->progress);
+ if (d->status != oldStatus)
+ emit statusChanged(d->status);
+ if (d->progress != oldProgress)
+ emit progressChanged(d->progress);
pixmapChange();
update();
}
diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase_p.h b/src/declarative/graphicsitems/qdeclarativeimagebase_p.h
index f5896b1..68eb8d0 100644
--- a/src/declarative/graphicsitems/qdeclarativeimagebase_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeimagebase_p.h
@@ -58,7 +58,6 @@ class Q_AUTOTEST_EXPORT QDeclarativeImageBase : public QDeclarativeItem
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
Q_PROPERTY(bool asynchronous READ asynchronous WRITE setAsynchronous NOTIFY asynchronousChanged)
-
Q_PROPERTY(QSize sourceSize READ sourceSize WRITE setSourceSize NOTIFY sourceSizeChanged)
public:
@@ -79,7 +78,7 @@ public:
Q_SIGNALS:
void sourceChanged(const QUrl &);
void sourceSizeChanged();
- void statusChanged(Status);
+ void statusChanged(QDeclarativeImageBase::Status);
void progressChanged(qreal progress);
void asynchronousChanged();
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/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/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
index b08b9a9..af86d77 100644
--- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
+++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
@@ -382,6 +382,9 @@ void QCoeFepInputContext::applyHints(Qt::InputMethodHints hints)
const bool anytextmodes = hints & (ImhUppercaseOnly | ImhLowercaseOnly | ImhEmailCharactersOnly | ImhUrlCharactersOnly);
const bool numbersOnly = anynumbermodes && !anytextmodes;
const bool noOnlys = !(hints & ImhExclusiveInputMask);
+ // if alphanumeric input, or if multiple incompatible number modes are selected;
+ // then make all symbols available in numeric mode too.
+ const bool needsCharMap= !numbersOnly || ((hints & ImhFormattedNumbersOnly) && (hints & ImhDialableCharactersOnly));
TInt flags;
Qt::InputMethodHints oldHints = hints;
@@ -481,9 +484,7 @@ void QCoeFepInputContext::applyHints(Qt::InputMethodHints hints)
if (hints & ImhNoPredictiveText || hints & ImhHiddenText) {
flags |= EAknEditorFlagNoT9;
}
- // if alphanumeric input, or if multiple incompatible number modes are selected;
- // then make all symbols available in numeric mode too.
- if (!numbersOnly || ((hints & ImhFormattedNumbersOnly) && (hints & ImhDialableCharactersOnly)))
+ if (needsCharMap)
flags |= EAknEditorFlagUseSCTNumericCharmap;
m_fepState->SetFlags(flags);
ReportAknEdStateEvent(MAknEdStateObserver::EAknEdwinStateFlagsUpdate);
@@ -508,8 +509,10 @@ void QCoeFepInputContext::applyHints(Qt::InputMethodHints hints)
m_fepState->SetSpecialCharacterTableResourceId(R_AVKON_URL_SPECIAL_CHARACTER_TABLE_DIALOG);
} else if (hints & ImhEmailCharactersOnly) {
m_fepState->SetSpecialCharacterTableResourceId(R_AVKON_EMAIL_ADDR_SPECIAL_CHARACTER_TABLE_DIALOG);
- } else {
+ } else if (needsCharMap) {
m_fepState->SetSpecialCharacterTableResourceId(R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG);
+ } else {
+ m_fepState->SetSpecialCharacterTableResourceId(0);
}
if (hints & ImhHiddenText) {
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 <stdlib.h>
+#if defined(Q_WS_X11) && !defined(QT_NO_EGL)
+#include <link.h>
+#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<const char *>(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<char *>("libmeegotouchcore"));
+ bool linksWithMeeGoGraphicsSystemHelper = dl_iterate_phdr(qt_matchLibraryName, const_cast<char *>("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
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/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
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/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index 18192e3..aa217f6 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -591,6 +591,12 @@ void QGL2PaintEngineEx::endNativePainting()
d->nativePaintingActive = false;
}
+void QGL2PaintEngineEx::invalidateState()
+{
+ Q_D(QGL2PaintEngineEx);
+ d->needsSync = true;
+}
+
bool QGL2PaintEngineEx::isNativePaintingActive() const {
Q_D(const QGL2PaintEngineEx);
return d->nativePaintingActive;
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
index 59b90d8..b255e75 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
@@ -151,6 +151,8 @@ public:
void beginNativePainting();
void endNativePainting();
+ void invalidateState();
+
QPixmapFilter *pixmapFilter(int type, const QPixmapFilter *prototype);
void setRenderTextActive(bool);
diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp
index 1efd398..89000bb 100644
--- a/src/opengl/qpixmapdata_gl.cpp
+++ b/src/opengl/qpixmapdata_gl.cpp
@@ -472,13 +472,42 @@ bool QGLPixmapData::scroll(int dx, int dy, const QRect &rect)
void QGLPixmapData::copy(const QPixmapData *data, const QRect &rect)
{
- if (data->classId() != QPixmapData::OpenGLClass) {
+ if (data->classId() != QPixmapData::OpenGLClass || !static_cast<const QGLPixmapData *>(data)->useFramebufferObjects()) {
QPixmapData::copy(data, rect);
return;
}
- // can be optimized to do a framebuffer blit or similar ...
- QPixmapData::copy(data, rect);
+ const QGLPixmapData *other = static_cast<const QGLPixmapData *>(data);
+ if (other->m_renderFbo) {
+ QGLShareContextScope ctx(qt_gl_share_widget()->context());
+
+ resize(rect.width(), rect.height());
+ m_hasAlpha = other->m_hasAlpha;
+ ensureCreated();
+
+ if (!ctx->d_ptr->fbo)
+ glGenFramebuffers(1, &ctx->d_ptr->fbo);
+
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, ctx->d_ptr->fbo);
+ glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
+ GL_TEXTURE_2D, m_texture.id, 0);
+
+ if (!other->m_renderFbo->isBound())
+ glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, other->m_renderFbo->handle());
+
+ glDisable(GL_SCISSOR_TEST);
+ if (ctx->d_ptr->active_engine && ctx->d_ptr->active_engine->type() == QPaintEngine::OpenGL2)
+ static_cast<QGL2PaintEngineEx *>(ctx->d_ptr->active_engine)->invalidateState();
+
+ glBlitFramebufferEXT(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height(),
+ 0, 0, w, h,
+ GL_COLOR_BUFFER_BIT,
+ GL_NEAREST);
+
+ glBindFramebuffer(GL_FRAMEBUFFER_EXT, ctx->d_ptr->current_fbo);
+ } else {
+ QPixmapData::copy(data, rect);
+ }
}
void QGLPixmapData::fill(const QColor &color)
@@ -623,11 +652,12 @@ void QGLPixmapData::copyBackFromRenderFbo(bool keepCurrentFboBound) const
}
}
-bool QGLPixmapData::useFramebufferObjects()
+bool QGLPixmapData::useFramebufferObjects() const
{
return QGLFramebufferObject::hasOpenGLFramebufferObjects()
&& QGLFramebufferObject::hasOpenGLFramebufferBlit()
- && qt_gl_preferGL2Engine();
+ && qt_gl_preferGL2Engine()
+ && (w * h > 32*32); // avoid overhead of FBOs for small pixmaps
}
QPaintEngine* QGLPixmapData::paintEngine() const
diff --git a/src/opengl/qpixmapdata_gl_p.h b/src/opengl/qpixmapdata_gl_p.h
index 736a28e..f000993 100644
--- a/src/opengl/qpixmapdata_gl_p.h
+++ b/src/opengl/qpixmapdata_gl_p.h
@@ -145,7 +145,7 @@ private:
void copyBackFromRenderFbo(bool keepCurrentFboBound) const;
QSize size() const { return QSize(w, h); }
- static bool useFramebufferObjects();
+ bool useFramebufferObjects() const;
QImage fillImage(const QColor &color) const;
@@ -168,6 +168,7 @@ private:
mutable QGLPixmapGLPaintDevice m_glDevice;
friend class QGLPixmapGLPaintDevice;
+ friend class QMeeGoPixmapData;
};
QT_END_NAMESPACE
diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp
index d602000..f98dcff 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);
@@ -342,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<QWidget *>(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; };
@@ -419,6 +424,8 @@ QPaintDevice *QGLWindowSurface::paintDevice()
QGLContext *ctx = reinterpret_cast<QGLContext *>(window()->d_func()->extraData()->glContext);
ctx->makeCurrent();
+
+ Q_ASSERT(d_ptr->fbo);
return d_ptr->fbo;
}
@@ -574,7 +581,9 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &
const int ty1 = parent->height() - rect.top();
if (window() == parent || d_ptr->fbo->format().samples() <= 1) {
- // glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, 0);
+ if (ctx->d_ptr->current_fbo != 0)
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, 0);
+
glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, d_ptr->fbo->handle());
glBlitFramebufferEXT(sx0, sy0, sx1, sy1,
@@ -607,6 +616,8 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &
qgl_fbo_pool()->release(temp);
}
+
+ ctx->d_ptr->current_fbo = 0;
}
#if !defined(QT_OPENGL_ES_2)
else {
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
new file mode 100644
index 0000000..d750d34
--- /dev/null
+++ b/src/plugins/graphicssystems/meego/meego.pro
@@ -0,0 +1,13 @@
+TARGET = qmeegographicssystem
+include(../../qpluginbase.pri)
+
+QT += gui opengl
+
+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
+
diff --git a/src/plugins/graphicssystems/meego/qmeegoextensions.cpp b/src/plugins/graphicssystems/meego/qmeegoextensions.cpp
new file mode 100644
index 0000000..e7f6439
--- /dev/null
+++ b/src/plugins/graphicssystems/meego/qmeegoextensions.cpp
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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$
+**
+****************************************************************************/
+
+#include "qmeegoextensions.h"
+#include <private/qeglcontext_p.h>
+#include <private/qpixmapdata_gl_p.h>
+
+bool QMeeGoExtensions::initialized = false;
+bool QMeeGoExtensions::hasImageShared = false;
+bool QMeeGoExtensions::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 QMeeGoExtensions::ensureInitialized()
+{
+ if (!initialized)
+ initialize();
+
+ initialized = true;
+}
+
+EGLNativeSharedImageTypeNOK QMeeGoExtensions::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 QMeeGoExtensions::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 QMeeGoExtensions::eglDestroySharedImageNOK(EGLDisplay dpy, EGLNativeSharedImageTypeNOK img)
+{
+ if (! hasImageShared)
+ qFatal("EGL_NOK_image_shared not found but trying to use capability!");
+
+ return _eglDestroySharedImageNOK(dpy, img);
+}
+
+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!");
+
+ return _eglSetSurfaceScalingNOK(dpy, surface, x, y, width, height);
+}
+
+/* Private */
+
+void QMeeGoExtensions::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..7f219de
--- /dev/null
+++ b/src/plugins/graphicssystems/meego/qmeegoextensions.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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$
+**
+****************************************************************************/
+
+#ifndef MEXTENSIONS_H
+#define MEXTENSIONS_H
+
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#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 QMeeGoExtensions
+{
+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..e2c8425
--- /dev/null
+++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp
@@ -0,0 +1,248 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QDebug>
+#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 "qmeegopixmapdata.h"
+#include "qmeegographicssystem.h"
+#include "qmeegoextensions.h"
+
+bool QMeeGoGraphicsSystem::surfaceWasCreated = false;
+
+QMeeGoGraphicsSystem::QMeeGoGraphicsSystem()
+{
+ qDebug("Using the meego graphics system");
+}
+
+QMeeGoGraphicsSystem::~QMeeGoGraphicsSystem()
+{
+ qDebug("Meego graphics system destroyed");
+ qt_destroy_gl_share_widget();
+}
+
+QWindowSurface* QMeeGoGraphicsSystem::createWindowSurface(QWidget *widget) const
+{
+ QMeeGoGraphicsSystem::surfaceWasCreated = true;
+ QWindowSurface *surface = new QGLWindowSurface(widget);
+ surface->window()->setAttribute(Qt::WA_NoSystemBackground);
+ return surface;
+}
+
+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
+ // explain here... not to mention fix without going crazy.
+ // MDK
+ QGLShareContextScope ctx(qt_gl_share_widget()->context());
+
+ return new QRasterPixmapData(type);
+}
+
+QPixmapData *QMeeGoGraphicsSystem::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 <QRasterPixmapData *> (origin);
+ void *rawResource = static_cast <void *> (rasterClass->buffer()->data_ptr()->data);
+
+ if (QMeeGoPixmapData::sharedImagesMap.contains(rawResource))
+ return new QMeeGoPixmapData();
+ }
+
+ return new QRasterPixmapData(origin->pixelType());
+}
+
+QPixmapData* QMeeGoGraphicsSystem::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 QMeeGoGraphicsSystem::setSurfaceFixedSize(int /*width*/, int /*height*/)
+{
+ if (QMeeGoGraphicsSystem::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 QMeeGoGraphicsSystem::setSurfaceScaling(int x, int y, int width, int height)
+{
+ QMeeGoExtensions::ensureInitialized();
+ QMeeGoExtensions::eglSetSurfaceScalingNOK(QEgl::display(), QEglContext::currentContext(QEgl::OpenGL)->currentSurface, x, y, width, height);
+}
+
+void QMeeGoGraphicsSystem::setTranslucent(bool translucent)
+{
+ QGLWindowSurface::surfaceFormat.setSampleBuffers(false);
+ QGLWindowSurface::surfaceFormat.setSamples(0);
+ QGLWindowSurface::surfaceFormat.setAlpha(translucent);
+}
+
+QPixmapData *QMeeGoGraphicsSystem::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 (QMeeGoGraphicsSystem::meeGoRunning()) {
+ QMeeGoPixmapData *pmd = new QMeeGoPixmapData;
+ pmd->fromEGLSharedImage(handle, softImage);
+ return QMeeGoGraphicsSystem::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<QImage &>(softImage).data_ptr()->data)
+ qFatal("Iternal misalignment of raster data detected. Prolly a QImage copy fail.");
+
+ QMeeGoPixmapData::registerSharedImage(handle, softImage);
+ return QMeeGoGraphicsSystem::wrapPixmapData(pmd);
+ }
+}
+
+void QMeeGoGraphicsSystem::updateEGLSharedImagePixmap(QPixmap *pixmap)
+{
+ QMeeGoPixmapData *pmd = (QMeeGoPixmapData *) pixmap->pixmapData();
+
+ // 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 *QMeeGoGraphicsSystem::pixmapDataWithGLTexture(int w, int h)
+{
+ QGLPixmapData *pmd = new QGLPixmapData(QPixmapData::PixmapType);
+ pmd->resize(w, h);
+ return QMeeGoGraphicsSystem::wrapPixmapData(pmd);
+}
+
+bool QMeeGoGraphicsSystem::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 qt_meego_image_to_egl_shared_image(const QImage &image)
+{
+ return QMeeGoPixmapData::imageToEGLSharedImage(image);
+}
+
+QPixmapData* qt_meego_pixmapdata_from_egl_shared_image(Qt::HANDLE handle, const QImage &softImage)
+{
+ return QMeeGoGraphicsSystem::pixmapDataFromEGLSharedImage(handle, softImage);
+}
+
+QPixmapData* qt_meego_pixmapdata_with_gl_texture(int w, int h)
+{
+ return QMeeGoGraphicsSystem::pixmapDataWithGLTexture(w, h);
+}
+
+bool qt_meego_destroy_egl_shared_image(Qt::HANDLE handle)
+{
+ return QMeeGoPixmapData::destroyEGLSharedImage(handle);
+}
+
+void qt_meego_set_surface_fixed_size(int width, int height)
+{
+ QMeeGoGraphicsSystem::setSurfaceFixedSize(width, height);
+}
+
+void qt_meego_set_surface_scaling(int x, int y, int width, int height)
+{
+ QMeeGoGraphicsSystem::setSurfaceScaling(x, y, width, height);
+}
+
+void qt_meego_set_translucent(bool translucent)
+{
+ QMeeGoGraphicsSystem::setTranslucent(translucent);
+}
+
+void qt_meego_update_egl_shared_image_pixmap(QPixmap *pixmap)
+{
+ QMeeGoGraphicsSystem::updateEGLSharedImagePixmap(pixmap);
+}
diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.h b/src/plugins/graphicssystems/meego/qmeegographicssystem.h
new file mode 100644
index 0000000..905f0c3
--- /dev/null
+++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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$
+**
+****************************************************************************/
+
+#ifndef MGRAPHICSSYSTEM_H
+#define MGRAPHICSSYSTEM_H
+
+#include <private/qgraphicssystem_p.h>
+
+class QMeeGoGraphicsSystem : public QGraphicsSystem
+{
+public:
+ QMeeGoGraphicsSystem();
+ ~QMeeGoGraphicsSystem();
+
+ 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" {
+ 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/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.cpp b/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.cpp
new file mode 100644
index 0000000..7c142eb
--- /dev/null
+++ b/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QDebug>
+#include "qmeegographicssystemplugin.h"
+#include "qmeegographicssystem.h"
+
+QStringList QMeeGoGraphicsSystemPlugin::keys() const
+{
+ QStringList list;
+ list << "meego";
+ return list;
+}
+
+QGraphicsSystem *QMeeGoGraphicsSystemPlugin::create(const QString&)
+{
+ return new QMeeGoGraphicsSystem;
+}
+
+Q_EXPORT_PLUGIN2(meego, QMeeGoGraphicsSystemPlugin)
diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.h b/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.h
new file mode 100644
index 0000000..336458f
--- /dev/null
+++ b/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.h
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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$
+**
+****************************************************************************/
+
+#ifndef MGRAPHICSSYSTEMPLUGIN_H
+#define MGRAPHICSSYSTEMPLUGIN_H
+
+#include <private/qgraphicssystemplugin_p.h>
+
+class QMeeGoGraphicsSystemPlugin : 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..33611dc
--- /dev/null
+++ b/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp
@@ -0,0 +1,206 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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$
+**
+****************************************************************************/
+
+#include "qmeegopixmapdata.h"
+#include "qmeegoextensions.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 <void*, QMeeGoImageInfo*> QMeeGoPixmapData::sharedImagesMap;
+
+/* Public */
+
+QMeeGoPixmapData::QMeeGoPixmapData() : QGLPixmapData(QPixmapData::PixmapType)
+{
+}
+
+void QMeeGoPixmapData::fromTexture(GLuint textureId, int w, int h, bool alpha)
+{
+ resize(w, h);
+ texture()->id = textureId;
+ m_hasAlpha = alpha;
+ softImage = QImage();
+}
+
+QImage QMeeGoPixmapData::toImage() const
+{
+ return softImage;
+}
+
+void QMeeGoPixmapData::fromImage(const QImage &image,
+ Qt::ImageConversionFlags flags)
+{
+ void *rawResource = static_cast <void *> (((QImage &) image).data_ptr()->data);
+
+ if (sharedImagesMap.contains(rawResource)) {
+ QMeeGoImageInfo *info = sharedImagesMap.value(rawResource);
+ fromEGLSharedImage(info->handle, image);
+ } else {
+ // This should *never* happen since the graphics system should never
+ // create a QMeeGoPixmapData for an origin that doesn't contain a raster
+ // image we know about. But...
+ qWarning("QMeeGoPixmapData::fromImage called on non-know resource. Falling back...");
+ QGLPixmapData::fromImage(image, flags);
+ }
+}
+
+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());
+
+ QMeeGoExtensions::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;
+
+ QMeeGoExtensions::eglQueryImageNOK(QEgl::display(), image, EGL_WIDTH, &newWidth);
+ QMeeGoExtensions::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<QImage &>(si).data_ptr()->checkForAlphaPixels()));
+ softImage = si;
+ QMeeGoPixmapData::registerSharedImage(handle, softImage);
+ } else {
+ qWarning("Failed to create a texture from a shared image!");
+ glDeleteTextures(1, &newTextureId);
+ }
+}
+
+Qt::HANDLE QMeeGoPixmapData::imageToEGLSharedImage(const QImage &image)
+{
+ QGLShareContextScope ctx(qt_gl_share_widget()->context());
+
+ QMeeGoExtensions::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 = QMeeGoExtensions::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 QMeeGoPixmapData::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 QMeeGoPixmapData::destroyEGLSharedImage(Qt::HANDLE h)
+{
+ QGLShareContextScope ctx(qt_gl_share_widget()->context());
+ QMeeGoExtensions::ensureInitialized();
+
+ QMutableHashIterator <void*, QMeeGoImageInfo*> i(sharedImagesMap);
+ while (i.hasNext()) {
+ i.next();
+ if (i.value()->handle == h)
+ i.remove();
+ }
+
+ return QMeeGoExtensions::eglDestroySharedImageNOK(QEgl::display(), (EGLNativeSharedImageTypeNOK) h);
+}
+
+void QMeeGoPixmapData::registerSharedImage(Qt::HANDLE handle, const QImage &si)
+{
+ void *raw = static_cast <void *> (((QImage) si).data_ptr()->data);
+ QMeeGoImageInfo *info;
+
+ if (! sharedImagesMap.contains(raw)) {
+ info = new QMeeGoImageInfo;
+ 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..8af33bd
--- /dev/null
+++ b/src/plugins/graphicssystems/meego/qmeegopixmapdata.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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$
+**
+****************************************************************************/
+
+#ifndef MPIXMAPDATA_H
+#define MPIXMAPDATA_H
+
+#include <private/qpixmapdata_gl_p.h>
+
+struct QMeeGoImageInfo
+{
+ Qt::HANDLE handle;
+ QImage::Format rawFormat;
+};
+
+class QMeeGoPixmapData : public QGLPixmapData
+{
+public:
+ QMeeGoPixmapData();
+ 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 <void*, QMeeGoImageInfo*> sharedImagesMap;
+
+ static Qt::HANDLE imageToEGLSharedImage(const QImage &image);
+ static bool destroyEGLSharedImage(Qt::HANDLE h);
+ static void registerSharedImage(Qt::HANDLE handle, const QImage &si);
+};
+
+#endif