summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@nokia.com>2012-03-02 10:12:29 +0100
committerAndy Nichols <andy.nichols@nokia.com>2012-03-02 12:39:52 +0100
commitc5163c53337b72e0c28aebe89580d2ef5986d339 (patch)
tree4836e96b72b2ee0adf7c0dae0a79389447562f57 /src
parent6fa64420f8a0d58ce5774f34b6df4f5502044fbc (diff)
Avoid flicker when switching back to composited mode
The surface item needs to create a new texture when the compositor switches from direct render to composited mode. Change-Id: Ic2d65929617f1941ea290645ac28b8e986c414bc Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/compositor/compositor_api/waylandsurfaceitem.cpp43
-rw-r--r--src/compositor/compositor_api/waylandsurfaceitem.h5
-rw-r--r--src/compositor/wayland_wrapper/wlsurface.cpp4
3 files changed, 42 insertions, 10 deletions
diff --git a/src/compositor/compositor_api/waylandsurfaceitem.cpp b/src/compositor/compositor_api/waylandsurfaceitem.cpp
index 471e5ca46..aff24cd54 100644
--- a/src/compositor/compositor_api/waylandsurfaceitem.cpp
+++ b/src/compositor/compositor_api/waylandsurfaceitem.cpp
@@ -248,6 +248,12 @@ void WaylandSurfaceItem::surfaceDestroyed(QObject *)
m_surface = 0;
}
+void WaylandSurfaceItem::setDamagedFlag(bool on)
+{
+ m_damaged = on;
+}
+
+
void WaylandSurfaceItem::surfaceDamaged(const QRect &)
{
m_damaged = true;
@@ -298,13 +304,23 @@ void WaylandSurfaceItem::setPaintEnabled(bool enabled)
update();
}
-QSGNode *WaylandSurfaceItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
+class WaylandSurfaceNode : public QSGSimpleTextureNode
{
- if (!m_surface) {
- delete oldNode;
- return 0;
+public:
+ WaylandSurfaceNode(WaylandSurfaceItem *item) : m_item(item) {
+ setFlag(UsePreprocess,true);
+ }
+ void preprocess() {
+ if (m_item->m_damaged)
+ m_item->updateNodeTexture(this);
}
+private:
+ WaylandSurfaceItem *m_item;
+};
+
+void WaylandSurfaceItem::updateNodeTexture(WaylandSurfaceNode *node)
+{
if (m_damaged) {
QSGTexture *oldTexture = m_texture;
if (m_surface->type() == WaylandSurface::Texture) {
@@ -327,25 +343,32 @@ QSGNode *WaylandSurfaceItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDa
m_provider->smooth = smooth();
}
- QSGSimpleTextureNode *node = static_cast<QSGSimpleTextureNode *>(oldNode);
- if (!m_texture || !m_paintEnabled) {
+ node->setTexture(m_texture);
+ node->setFiltering(smooth() ? QSGTexture::Linear : QSGTexture::Nearest);
+}
+
+
+QSGNode *WaylandSurfaceItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
+{
+ if (!m_surface || !m_paintEnabled) {
delete oldNode;
return 0;
}
+ WaylandSurfaceNode *node = static_cast<WaylandSurfaceNode *>(oldNode);
+
if (!node) {
- node = new QSGSimpleTextureNode();
+ node = new WaylandSurfaceNode(this);
}
+ updateNodeTexture(node);
+
if (surface()->isYInverted()) {
node->setRect(0, height(), width(), -height());
} else {
node->setRect(0, 0, width(), height());
}
- node->setTexture(m_texture);
- node->setFiltering(smooth() ? QSGTexture::Linear : QSGTexture::Nearest);
-
return node;
}
diff --git a/src/compositor/compositor_api/waylandsurfaceitem.h b/src/compositor/compositor_api/waylandsurfaceitem.h
index 0114f127c..b59ce8e53 100644
--- a/src/compositor/compositor_api/waylandsurfaceitem.h
+++ b/src/compositor/compositor_api/waylandsurfaceitem.h
@@ -50,6 +50,7 @@
#include <QtQuick/qsgtextureprovider.h>
class WaylandSurfaceTextureProvider;
+class WaylandSurfaceNode;
Q_DECLARE_METATYPE(WaylandSurface*)
@@ -85,6 +86,8 @@ public:
void setClientRenderingEnabled(bool enabled);
void setTouchEventsEnabled(bool enabled);
+ void setDamagedFlag(bool on);
+
protected:
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
@@ -120,6 +123,8 @@ protected:
QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *);
private:
+ friend class WaylandSurfaceNode;
+ void updateNodeTexture(WaylandSurfaceNode *newNode);
QPoint toSurface(const QPointF &pos) const;
void init(WaylandSurface *);
diff --git a/src/compositor/wayland_wrapper/wlsurface.cpp b/src/compositor/wayland_wrapper/wlsurface.cpp
index 7aa75160c..92ee0e7c3 100644
--- a/src/compositor/wayland_wrapper/wlsurface.cpp
+++ b/src/compositor/wayland_wrapper/wlsurface.cpp
@@ -41,6 +41,7 @@
#include "wlsurface.h"
#include "waylandsurface.h"
+#include "waylandsurfaceitem.h"
#include "wlcompositor.h"
#include "wlshmbuffer.h"
@@ -319,6 +320,9 @@ bool Surface::advanceBufferQueue()
void Surface::doUpdate() {
if (postBuffer()) {
+ WaylandSurfaceItem *surfaceItem = waylandSurface()->surfaceItem();
+ if (surfaceItem)
+ surfaceItem->setDamagedFlag(true); // avoid flicker when we switch back to composited mode
sendFrameCallback();
} else {
SurfaceBuffer *surfaceBuffer = currentSurfaceBuffer();