1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4// W A R N I N G
5// -------------
6//
7// This file is not part of the Qt Chart API. It exists purely as an
8// implementation detail. This header file may change from version to
9// version without notice, or even be removed.
10//
11// We mean it.
12
13#ifndef DECLARATIVEOPENGLRENDERNODE_P_H
14#define DECLARATIVEOPENGLRENDERNODE_P_H
15
16#include <private/declarativeabstractrendernode_p.h>
17
18#include <QtCharts/QChartGlobal>
19#include <private/glxyseriesdata_p.h>
20#include <QtQuick/QSGImageNode>
21#include <QtQuick/QQuickWindow>
22#include <QtOpenGL/QOpenGLShaderProgram>
23#include <QtOpenGL/QOpenGLVertexArrayObject>
24#include <QtGui/QOpenGLFunctions>
25#include <QtOpenGL/QOpenGLFramebufferObject>
26#include <QtOpenGL/QOpenGLBuffer>
27
28QT_BEGIN_NAMESPACE
29
30class DeclarativeOpenGLRenderNode : public QObject, public DeclarativeAbstractRenderNode, QOpenGLFunctions
31{
32 Q_OBJECT
33public:
34 DeclarativeOpenGLRenderNode(QQuickWindow *window);
35 ~DeclarativeOpenGLRenderNode();
36
37 void initGL();
38 QSize textureSize() const override { return m_textureSize; }
39 void setTextureSize(const QSize &size) override;
40
41 void setSeriesData(bool mapDirty, const GLXYDataMap &dataMap) override;
42 void setRect(const QRectF &rect) override;
43 void setAntialiasing(bool enable) override;
44 void addMouseEvents(const QList<QMouseEvent *> &events) override;
45 void takeMouseEventResponses(QList<MouseEventResponse> &responses) override;
46
47public Q_SLOTS:
48 void render();
49
50private:
51 void renderGL(bool selection);
52 void renderSelection();
53 void renderVisual();
54 void recreateFBO();
55 void cleanXYSeriesResources(const QXYSeries *series);
56 void handleMouseEvents();
57 const QXYSeries *findSeriesAtEvent(QMouseEvent *event);
58
59 QSGTexture *m_texture;
60 QSGImageNode *m_imageNode;
61 QQuickWindow *m_window;
62 QQuickWindow::CreateTextureOptions m_textureOptions;
63 QSize m_textureSize;
64 bool m_recreateFbo;
65 GLXYDataMap m_xyDataMap;
66 QOpenGLFramebufferObject *m_fbo;
67 QOpenGLFramebufferObject *m_resolvedFbo;
68 QOpenGLFramebufferObject *m_selectionFbo;
69 QOpenGLShaderProgram *m_program;
70 int m_shaderAttribLoc;
71 int m_colorUniformLoc;
72 int m_minUniformLoc;
73 int m_deltaUniformLoc;
74 int m_pointSizeUniformLoc;
75 int m_matrixUniformLoc;
76 QOpenGLVertexArrayObject m_vao;
77 QHash<const QAbstractSeries *, QOpenGLBuffer *> m_seriesBufferMap;
78 bool m_renderNeeded;
79 QRectF m_rect;
80 bool m_antialiasing;
81 QList<QMouseEvent *> m_mouseEvents;
82 QList<MouseEventResponse> m_mouseEventResponses;
83 bool m_selectionRenderNeeded;
84 QList<const QXYSeries *> m_selectionList;
85 QPoint m_mousePressPos;
86 bool m_mousePressed;
87 const QXYSeries *m_lastPressSeries;
88 const QXYSeries *m_lastHoverSeries;
89};
90
91QT_END_NAMESPACE
92
93#endif // DECLARATIVEOPENGLRENDERNODE_P_H
94

source code of qtcharts/src/chartsqml2/declarativeopenglrendernode_p.h