enable alpha-channel for wayland-windows
authorMartin Zielinski <martin.zielinski@nokia.com>
Wed, 8 Jun 2011 14:02:45 +0000 (16:02 +0200)
committerMartin Zielinski <martin.zielinski@nokia.com>
Fri, 10 Jun 2011 14:50:40 +0000 (16:50 +0200)
src/qt-compositor/compositor_api/waylandsurfaceitem.cpp
src/qt-compositor/compositor_api/waylandsurfaceitem.h

index 9281831..cf930e1 100644 (file)
@@ -54,8 +54,11 @@ void WaylandSurfaceItem::surfaceDamaged(const QRect &)
     QSGTexture *oldTexture = m_texture;
 
     if (m_surface->type() == WaylandSurface::Texture) {
+        QSGEngine::TextureOption opt = useTextureAlpha() ? QSGEngine::TextureHasAlphaChannel : QSGEngine::TextureOption(0);
+
         m_texture = canvas()->sceneGraphEngine()->createTextureFromId(m_surface->texture(),
-                                                                      m_surface->geometry().size());
+                                                                      m_surface->geometry().size(),
+                                                                      opt);
     } else {
         m_texture = canvas()->sceneGraphEngine()->createTextureFromImage(m_surface->image());
     }
@@ -208,8 +211,13 @@ QSGNode *WaylandSurfaceItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDa
     }
 
     node->setTexture(m_texture);
-
     node->setFiltering(smooth() ? QSGTexture::Linear : QSGTexture::Nearest);
 
     return node;
 }
+
+void WaylandSurfaceItem::setUseTextureAlpha(bool useTextureAlpha)
+{
+    m_useTextureAlpha = useTextureAlpha;
+    update();
+}
index 10f771b..5786fef 100644 (file)
@@ -55,6 +55,7 @@ class WaylandSurfaceItem : public QSGItem, public QSGTextureProvider
     Q_INTERFACES(QSGTextureProvider)
     Q_PROPERTY(WaylandSurface* surface READ surface WRITE setSurface)
     Q_PROPERTY(bool paintEnabled READ paintEnabled WRITE setPaintEnabled)
+    Q_PROPERTY(bool useTextureAlpha READ useTextureAlpha WRITE setUseTextureAlpha)
 
 public:
     WaylandSurfaceItem(QSGItem *parent = 0);
@@ -70,6 +71,7 @@ public:
     const char *textureChangedSignal() const { return SIGNAL(textureChanged()); }
 
     bool paintEnabled() const;
+    bool useTextureAlpha() const  { return m_useTextureAlpha; }
 
 protected:
     void mousePressEvent(QGraphicsSceneMouseEvent *event);
@@ -82,6 +84,7 @@ protected:
 public slots:
     void takeFocus();
     void setPaintEnabled(bool paintEnabled);
+    void setUseTextureAlpha(bool useTextureAlpha);
 
 private slots:
     void surfaceMapped(const QRect &rect);
@@ -101,6 +104,7 @@ private:
     WaylandSurface *m_surface;
     QSGTexture *m_texture;
     bool m_paintEnabled;
+    bool m_useTextureAlpha;
 };
 
 #endif