summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKimmo Hämäläinen <kimmo.hamalainen@nokia.com>2010-10-04 16:50:08 +0300
committerKimmo Hämäläinen <kimmo.hamalainen@nokia.com>2010-10-04 16:50:08 +0300
commit485277ebf58de88f908f2a4103f3c5c2b79bd3de (patch)
treed18a95b6c8fb41faac12a00a0d0bc846c2a0f623
parent7ff699a944f10f60dc779fdb32028245bfc0f034 (diff)
Find out QGLWidget in MTexturePixmapPrivate::installPixelShader if it's not done
- installPixelShader depends on static variables glresource and glwidget, so make glwidget static too
-rw-r--r--src/mcompositemanager.cpp5
-rw-r--r--src/mcompositemanager.h3
-rw-r--r--src/mtexturepixmapitem_egl.cpp2
-rw-r--r--src/mtexturepixmapitem_p.cpp24
-rw-r--r--src/mtexturepixmapitem_p.h6
5 files changed, 32 insertions, 8 deletions
diff --git a/src/mcompositemanager.cpp b/src/mcompositemanager.cpp
index aa85f39..fb3c405 100644
--- a/src/mcompositemanager.cpp
+++ b/src/mcompositemanager.cpp
@@ -3395,6 +3395,11 @@ void MCompositeManager::setGLWidget(QGLWidget *glw)
d->glwidget = glw;
}
+QGLWidget *MCompositeManager::glWidget() const
+{
+ return d->glwidget;
+}
+
QGraphicsScene *MCompositeManager::scene()
{
return d->scene();
diff --git a/src/mcompositemanager.h b/src/mcompositemanager.h
index 66371df..b08ac61 100644
--- a/src/mcompositemanager.h
+++ b/src/mcompositemanager.h
@@ -69,6 +69,9 @@ public:
*/
void setGLWidget(QGLWidget *glw);
+ /*! QGLWidget accessor for static initialisations. */
+ QGLWidget *glWidget() const;
+
/*!
* Reimplemented from QApplication::x11EventFilter() to catch X11 events
*/
diff --git a/src/mtexturepixmapitem_egl.cpp b/src/mtexturepixmapitem_egl.cpp
index ac900b8..7b718e7 100644
--- a/src/mtexturepixmapitem_egl.cpp
+++ b/src/mtexturepixmapitem_egl.cpp
@@ -167,7 +167,7 @@ MTexturePixmapItem::MTexturePixmapItem(Window window, MWindowPropertyCache *mpc,
QGLWidget *glwidget,
QGraphicsItem* parent)
: MCompositeWindow(window, mpc, parent),
- d(new MTexturePixmapPrivate(window, glwidget, this))
+ d(new MTexturePixmapPrivate(window, this))
{
if (!d->ctx)
d->ctx = const_cast<QGLContext *>(glwidget->context());
diff --git a/src/mtexturepixmapitem_p.cpp b/src/mtexturepixmapitem_p.cpp
index 112a78a..47f1086 100644
--- a/src/mtexturepixmapitem_p.cpp
+++ b/src/mtexturepixmapitem_p.cpp
@@ -23,6 +23,7 @@
#include "mtexturepixmapitem.h"
#include "texturepixmapshaders.h"
#include "mcompositewindowshadereffect.h"
+#include "mcompositemanager.h"
#include <QX11Info>
#include <QRect>
@@ -42,6 +43,8 @@
#include "mtexturepixmapitem_p.h"
bool MTexturePixmapPrivate::inverted_texture = true;
+QGLWidget *MTexturePixmapPrivate::glwidget = 0;
+QGLContext *MTexturePixmapPrivate::ctx = 0;
MGLResourceManager *MTexturePixmapPrivate::glresource = 0;
static const GLuint D_VERTEX_COORDS = 0;
@@ -295,6 +298,14 @@ void MTexturePixmapPrivate::removeEffect()
GLuint MTexturePixmapPrivate::installPixelShader(const QByteArray& code)
{
+ if (!glwidget) {
+ MCompositeManager *m = (MCompositeManager*)qApp;
+ glwidget = m->glWidget();
+ }
+ if (!glresource) {
+ glresource = new MGLResourceManager(glwidget);
+ glresource->initVertices(glwidget);
+ }
if (glresource)
return glresource->installPixelShader(code);
@@ -325,10 +336,9 @@ void MTexturePixmapPrivate::init()
item->propertyCache()->realGeometry().y());
}
-MTexturePixmapPrivate::MTexturePixmapPrivate(Qt::HANDLE window, QGLWidget *w, MTexturePixmapItem *p)
- : ctx(0),
- glwidget(w),
- window(window),
+MTexturePixmapPrivate::MTexturePixmapPrivate(Qt::HANDLE window,
+ MTexturePixmapItem *p)
+ : window(window),
windowp(0),
#ifdef DESKTOP_VERSION
glpixmap(0),
@@ -340,6 +350,12 @@ MTexturePixmapPrivate::MTexturePixmapPrivate(Qt::HANDLE window, QGLWidget *w, MT
angle(0),
item(p)
{
+ if (!glwidget) {
+ MCompositeManager *m = (MCompositeManager*)qApp;
+ glwidget = m->glWidget();
+ }
+ if (!ctx)
+ ctx = const_cast<QGLContext *>(glwidget->context());
if (item->propertyCache())
item->propertyCache()->damageTracking(true);
init();
diff --git a/src/mtexturepixmapitem_p.h b/src/mtexturepixmapitem_p.h
index 75bf3b2..a3c9dfe 100644
--- a/src/mtexturepixmapitem_p.h
+++ b/src/mtexturepixmapitem_p.h
@@ -51,7 +51,7 @@ class MTexturePixmapPrivate: QObject
{
Q_OBJECT
public:
- MTexturePixmapPrivate(Window window, QGLWidget *w, MTexturePixmapItem *item);
+ MTexturePixmapPrivate(Window window, MTexturePixmapItem *item);
~MTexturePixmapPrivate();
void init();
void updateWindowPixmap(XRectangle *rects = 0, int num = 0);
@@ -66,8 +66,8 @@ public:
void installEffect(MCompositeWindowShaderEffect* effect);
static GLuint installPixelShader(const QByteArray& code);
- QGLContext *ctx;
- QGLWidget *glwidget;
+ static QGLContext *ctx;
+ static QGLWidget *glwidget;
Window window;
Pixmap windowp;
#ifdef GLES2_VERSION