Changeset View
Changeset View
Standalone View
Standalone View
plugins/dockers/smallcolorselector/KisGLImageWidget.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright (c) 2019 Dmitry Kazakov <dimula73@gmail.com> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or modify | ||||
5 | * it under the terms of the GNU General Public License as published by | ||||
6 | * the Free Software Foundation; either version 2 of the License, or | ||||
7 | * (at your option) any later version. | ||||
8 | * | ||||
9 | * This program is distributed in the hope that it will be useful, | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
12 | * GNU General Public License for more details. | ||||
13 | * | ||||
14 | * You should have received a copy of the GNU General Public License | ||||
15 | * along with this program; if not, write to the Free Software | ||||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
17 | */ | ||||
18 | | ||||
19 | #ifndef KISGLIMAGEWIDGET_H | ||||
20 | #define KISGLIMAGEWIDGET_H | ||||
21 | | ||||
22 | #include <QOpenGLWidget> | ||||
23 | #include <QOpenGLFunctions> | ||||
24 | #include <QOpenGLTexture> | ||||
25 | #include <QOpenGLShaderProgram> | ||||
26 | #include <QOpenGLVertexArrayObject> | ||||
27 | #include <QOpenGLBuffer> | ||||
28 | #include <QTransform> | ||||
29 | #include <KisGLImageF16.h> | ||||
30 | | ||||
31 | | ||||
32 | class KisGLImageWidget : public QOpenGLWidget, protected QOpenGLFunctions | ||||
33 | { | ||||
34 | Q_OBJECT | ||||
35 | public: | ||||
36 | KisGLImageWidget(QWidget *parent = nullptr); | ||||
37 | KisGLImageWidget(QSurfaceFormat::ColorSpace colorSpace, | ||||
38 | QWidget *parent = nullptr); | ||||
39 | | ||||
40 | void initializeGL(); | ||||
41 | void paintGL(); | ||||
42 | | ||||
43 | void loadImage(const KisGLImageF16 &image); | ||||
44 | | ||||
45 | void paintEvent(QPaintEvent *event) override; | ||||
46 | void resizeEvent(QResizeEvent *event) override; | ||||
47 | | ||||
48 | QSize sizeHint() const; | ||||
49 | | ||||
50 | public Q_SLOTS: | ||||
51 | | ||||
52 | private Q_SLOTS: | ||||
53 | void slotOpenGLContextDestroyed(); | ||||
54 | | ||||
55 | private: | ||||
56 | void updateVerticesBuffer(const QRect &rect); | ||||
57 | | ||||
58 | private: | ||||
59 | KisGLImageF16 m_sourceImage; | ||||
60 | | ||||
61 | QScopedPointer<QOpenGLShaderProgram> m_shader; | ||||
62 | QOpenGLVertexArrayObject m_vao; | ||||
63 | QOpenGLBuffer m_verticesBuffer; | ||||
64 | QOpenGLBuffer m_textureVerticesBuffer; | ||||
65 | QOpenGLTexture m_texture; | ||||
66 | | ||||
67 | bool m_havePendingTextureUpdate = false; | ||||
68 | }; | ||||
69 | | ||||
70 | #endif // KISGLIMAGEWIDGET_H |