QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskPaintedNode.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_PAINTED_NODE_H
7#define QSK_PAINTED_NODE_H
8
9#include "QskGlobal.h"
10#include <qsgnode.h>
11
12class QQuickWindow;
13class QPainter;
14class QImage;
15
16class QSK_EXPORT QskPaintedNode : public QSGNode
17{
18 public:
19 /*
20 Raster usually provides a better antialiasing and is less buggy,
21 while OpenGL might be faster - depending on the content that has
22 to be painted.
23
24 Since Qt 5.10 X11 is back and could be an interesting option
25 with good quality and hardware accelerated performance. TODO ...
26
27 OpenGL might be ignored depending on the backend used by the
28 application.
29 */
30 enum RenderHint
31 {
32 Raster,
33 OpenGL
34 };
35
37 ~QskPaintedNode() override;
38
39 void setRenderHint( RenderHint );
40 RenderHint renderHint() const;
41
42 void setMirrored( Qt::Orientations );
43 Qt::Orientations mirrored() const;
44
45 QRectF rect() const;
46 QSize textureSize() const;
47
48 virtual void paint( QPainter*, const QSize&, const void* nodeData ) = 0;
49
50 protected:
51 void update( QQuickWindow*, const QRectF&, const QSizeF&, const void* nodeData );
52
53 // a hash value of '0' always results in repainting
54 virtual QskHashValue hash( const void* nodeData ) const = 0;
55
56 private:
57 void updateTexture( QQuickWindow*, const QSize&, const void* nodeData );
58
59 QImage createImage( QQuickWindow*, const QSize&, const void* nodeData );
60 quint32 createTextureGL( QQuickWindow*, const QSize&, const void* nodeData );
61
62 RenderHint m_renderHint = OpenGL;
63 Qt::Orientations m_mirrored;
64 QskHashValue m_hash = 0;
65};
66
67#endif