Debian Codegraph @

src/imports/PerformanceMetrics/plugin/upmtexturefromimage.h

raw
1 /*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Florian Boucault <[email protected]>
17 */
18
19 #ifndef UPMTEXTUREFROMIMAGE_H
20 #define UPMTEXTUREFROMIMAGE_H
21
22 #include <QtQuick/QSGTextureProvider>
23 #include <QtQuick/QQuickItem>
24
25 class UPMTextureFromImageTextureProvider : public QSGTextureProvider
26 {
27 Q_OBJECT
28
29 public:
30 explicit UPMTextureFromImageTextureProvider();
31 virtual ~UPMTextureFromImageTextureProvider();
32 QSGTexture* texture() const override;
33 void setTexture(QSGTexture* texture);
34
35 private:
36 QSGTexture* m_texture;
37 };
38
39
40 class UPMTextureFromImage : public QQuickItem
41 {
42 Q_OBJECT
43
44 Q_PROPERTY(QImage image READ image WRITE setImage NOTIFY imageChanged)
45
46 public:
47 explicit UPMTextureFromImage(QQuickItem* parent = 0);
48 virtual ~UPMTextureFromImage();
49 bool isTextureProvider() const override;
50 QSGTextureProvider* textureProvider() const override;
51 QSGNode* updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData* updatePaintNodeData) override;
52
53 // getter
54 QImage image() const;
55
56 // setters
57 void setImage(QImage image);
58
59 Q_SIGNALS:
60 void imageChanged();
61
62 private:
63 UPMTextureFromImageTextureProvider* m_textureProvider;
64 QImage m_image;
65 bool m_textureNeedsUpdate;
66 };
67
68
69 #endif // UPMTEXTUREFROMIMAGE_H