qskinny/src/nodes/QskPaintedNode.h

66 lines
1.8 KiB
C
Raw Normal View History

/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/
#ifndef QSK_PAINTED_NODE_H
#define QSK_PAINTED_NODE_H
2022-06-01 16:57:57 +02:00
#include "QskGlobal.h"
#include <qsgnode.h>
2022-06-01 16:57:57 +02:00
class QQuickWindow;
class QPainter;
class QSK_EXPORT QskPaintedNode : public QSGNode
{
public:
2022-06-01 16:57:57 +02:00
/*
Raster usually provides a better antialiasing and is less buggy,
while OpenGL might be faster - depending on the content that has
to be painted.
Since Qt 5.10 X11 is back and could be an interesting option
with good quality and hardware accelerated performance. TODO ...
OpenGL might be ignored depending on the backend used by the
application.
*/
enum RenderHint
{
Raster,
OpenGL
};
QskPaintedNode();
~QskPaintedNode() override;
2022-06-01 16:57:57 +02:00
void setRenderHint( RenderHint );
RenderHint renderHint() const;
2022-06-01 18:27:05 +02:00
void setMirrored( Qt::Orientations );
Qt::Orientations mirrored() const;
2022-06-01 16:57:57 +02:00
QRectF rect() const;
protected:
2022-06-01 16:57:57 +02:00
void update( QQuickWindow*, const QRectF&, const void* nodeData );
virtual void paint( QPainter*, const QSizeF&, const void* nodeData ) = 0;
// a hash value of '0' always results in repainting
2022-06-01 16:57:57 +02:00
virtual QskHashValue hash( const void* nodeData ) const = 0;
private:
2022-06-01 16:57:57 +02:00
void updateImageNode( QQuickWindow*, const QRectF&, const void* nodeData );
void updateImageNodeGL( QQuickWindow*, const QRectF&, const void* nodeData );
2022-06-01 16:57:57 +02:00
uint32_t createTexture( QQuickWindow*, const QSize&, const void* nodeData );
2022-06-01 16:57:57 +02:00
RenderHint m_renderHint = OpenGL;
2022-06-01 18:27:05 +02:00
Qt::Orientations m_mirrored;
2022-06-01 16:57:57 +02:00
QskHashValue m_hash = 0;
};
#endif