m_surface = 0;
}
+void WaylandSurfaceItem::setDamagedFlag(bool on)
+{
+ m_damaged = on;
+}
+
+
void WaylandSurfaceItem::surfaceDamaged(const QRect &)
{
m_damaged = true;
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) {
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;
}
#include <QtQuick/qsgtextureprovider.h>
class WaylandSurfaceTextureProvider;
+class WaylandSurfaceNode;
Q_DECLARE_METATYPE(WaylandSurface*)
void setClientRenderingEnabled(bool enabled);
void setTouchEventsEnabled(bool enabled);
+ void setDamagedFlag(bool on);
+
protected:
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *);
private:
+ friend class WaylandSurfaceNode;
+ void updateNodeTexture(WaylandSurfaceNode *newNode);
QPoint toSurface(const QPointF &pos) const;
void init(WaylandSurface *);
#include "wlsurface.h"
#include "waylandsurface.h"
+#include "waylandsurfaceitem.h"
#include "wlcompositor.h"
#include "wlshmbuffer.h"
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();