From 25f0082455efe5b101d5219d7e7ca5008f9de709 Mon Sep 17 00:00:00 2001 From: Martin Zielinski Date: Wed, 8 Jun 2011 16:02:45 +0200 Subject: [PATCH] enable alpha-channel for wayland-windows --- src/qt-compositor/compositor_api/waylandsurfaceitem.cpp | 12 ++++++++++-- src/qt-compositor/compositor_api/waylandsurfaceitem.h | 4 ++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/qt-compositor/compositor_api/waylandsurfaceitem.cpp b/src/qt-compositor/compositor_api/waylandsurfaceitem.cpp index 9281831..cf930e1 100644 --- a/src/qt-compositor/compositor_api/waylandsurfaceitem.cpp +++ b/src/qt-compositor/compositor_api/waylandsurfaceitem.cpp @@ -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(); +} diff --git a/src/qt-compositor/compositor_api/waylandsurfaceitem.h b/src/qt-compositor/compositor_api/waylandsurfaceitem.h index 10f771b..5786fef 100644 --- a/src/qt-compositor/compositor_api/waylandsurfaceitem.h +++ b/src/qt-compositor/compositor_api/waylandsurfaceitem.h @@ -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 -- 2.7.4