From d55aa14630bbb4130017f38177b20c850d556371 Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Mon, 7 Mar 2011 11:39:02 +0100 Subject: Invalidate the EGL surface of QMeeGoLivePixmapData when switching to Raster MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QMeeGoLivePixmap fails to lock the EGL surface and texture after switch to raster graphics system. The EGL surface is invalid after eglTerminate call in switch. But QMeeGoLivePixmapData doesn't know about the switch. Marking EGL surfaces and texture invalid after switch makes live pixmap automatically recreate the surface when next time requiring live pixmap. Signed-off-by: Pauli Nieminen Merge-request: 2571 Reviewed-by: Samuel Rødal --- .../graphicssystems/meego/qmeegographicssystem.cpp | 5 +++++ .../graphicssystems/meego/qmeegographicssystem.h | 1 + .../graphicssystems/meego/qmeegolivepixmapdata.cpp | 21 +++++++++++++++++++++ .../graphicssystems/meego/qmeegolivepixmapdata.h | 7 +++++++ 4 files changed, 34 insertions(+) (limited to 'src/plugins/graphicssystems') diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp index 6b8d2b368d..13eab7f88f 100644 --- a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp +++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp @@ -335,3 +335,8 @@ void qt_meego_destroy_fence_sync(void* fs) { return QMeeGoGraphicsSystem::destroyFenceSync(fs); } + +void qt_meego_invalidate_live_surfaces(void) +{ + return QMeeGoLivePixmapData::invalidateSurfaces(); +} diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.h b/src/plugins/graphicssystems/meego/qmeegographicssystem.h index 323ce1fcb9..27a4e7a8c6 100644 --- a/src/plugins/graphicssystems/meego/qmeegographicssystem.h +++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.h @@ -103,6 +103,7 @@ extern "C" { Q_DECL_EXPORT Qt::HANDLE qt_meego_live_texture_get_handle(QPixmap *pixmap); Q_DECL_EXPORT void* qt_meego_create_fence_sync(void); Q_DECL_EXPORT void qt_meego_destroy_fence_sync(void* fs); + Q_DECL_EXPORT void qt_meego_invalidate_live_surfaces(void); } #endif diff --git a/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.cpp b/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.cpp index e4f1900566..2a2a0989e4 100644 --- a/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.cpp +++ b/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.cpp @@ -49,6 +49,8 @@ #include #include +static QMeeGoLivePixmapDataList all_live_pixmaps; + static EGLint lock_attribs[] = { EGL_MAP_PRESERVE_PIXELS_KHR, EGL_TRUE, EGL_LOCK_USAGE_HINT_KHR, EGL_READ_SURFACE_BIT_KHR | EGL_WRITE_SURFACE_BIT_KHR, @@ -118,21 +120,29 @@ QMeeGoLivePixmapData::QMeeGoLivePixmapData(int w, int h, QImage::Format format) backingX11Pixmap = new QPixmap(pmd); initializeThroughEGLImage(); + + pos = all_live_pixmaps.insert(all_live_pixmaps.begin(), this); } QMeeGoLivePixmapData::QMeeGoLivePixmapData(Qt::HANDLE h) : QGLPixmapData(QPixmapData::PixmapType) { backingX11Pixmap = new QPixmap(QPixmap::fromX11Pixmap(h)); initializeThroughEGLImage(); + + pos = all_live_pixmaps.insert(all_live_pixmaps.begin(), this); } QMeeGoLivePixmapData::~QMeeGoLivePixmapData() { delete backingX11Pixmap; + all_live_pixmaps.erase(pos); } void QMeeGoLivePixmapData::initializeThroughEGLImage() { + if (texture()->id != 0) + return; + QGLShareContextScope ctx(qt_gl_share_widget()->context()); QMeeGoExtensions::ensureInitialized(); @@ -245,6 +255,8 @@ bool QMeeGoLivePixmapData::scroll(int dx, int dy, const QRect &rect) EGLSurface QMeeGoLivePixmapData::getSurfaceForBackingPixmap() { + initializeThroughEGLImage(); + // This code is a crative remix of the stuff that can be found in the // Qt's TFP implementation in /src/opengl/qgl_x11egl.cpp ::bindiTextureFromNativePixmap QX11PixmapData *pixmapData = static_cast(backingX11Pixmap->data_ptr().data()); @@ -290,3 +302,12 @@ void QMeeGoLivePixmapData::destroySurfaceForPixmapData(QPixmapData* pmd) pixmapData->gl_surface = 0; } } + +void QMeeGoLivePixmapData::invalidateSurfaces() +{ + foreach (QMeeGoLivePixmapData *data, all_live_pixmaps) { + QX11PixmapData *pixmapData = static_cast(data->backingX11Pixmap->data_ptr().data()); + *data->texture() = QGLTexture(); + pixmapData->gl_surface = 0; + } +} diff --git a/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.h b/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.h index 484028e61d..616b33cc95 100644 --- a/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.h +++ b/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.h @@ -42,9 +42,13 @@ #ifndef MLIVEPIXMAPDATA_H #define MLIVEPIXMAPDATA_H +#include #include #include "qmeegoextensions.h" +class QMeeGoLivePixmapData; +typedef QLinkedList QMeeGoLivePixmapDataList; + class QMeeGoLivePixmapData : public QGLPixmapData { public: @@ -66,6 +70,9 @@ public: QPixmap *backingX11Pixmap; QImage lockedImage; + QMeeGoLivePixmapDataList::Iterator pos; + + static void invalidateSurfaces(); }; #endif -- cgit v1.2.1