Debian Codegraph @

src/qmlcontrols/imagetexturescache.h

raw
1 /*
2 SPDX-FileCopyrightText: 2014 Aleix Pol Gonzalez <[email protected]>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7 #ifndef IMAGETEXTURESCACHE_H
8 #define IMAGETEXTURESCACHE_H
9
10 #include <QQuickWindow>
11 #include <QSharedPointer>
12
13 class QImage;
14 class QSGTexture;
15 struct ImageTexturesCachePrivate;
16
17 /**
18 * @short Helps to manage textures by creating images and reference counts them.
19 *
20 * Use this class as a factory for textures, when creating them from a QImage
21 * instance.
22 * Keeps track of all the created textures in a map between the QImage::cacheKey() and
23 * the cached texture until it gets de-referenced.
24 *
25 * @see ManagedTextureNode
26 */
27 class ImageTexturesCache
28 {
29 public:
30 ImageTexturesCache();
31 ~ImageTexturesCache();
32
33 /**
34 * @returns the texture for a given @p window and @p image.
35 *
36 * If an @p image id is the same as one already provided before, we won't create
37 * a new texture and return a shared pointer to the existing texture.
38 */
39 QSharedPointer<QSGTexture> loadTexture(QQuickWindow *window, const QImage &image, QQuickWindow::CreateTextureOptions options);
40
41 QSharedPointer<QSGTexture> loadTexture(QQuickWindow *window, const QImage &image);
42
43 private:
44 QScopedPointer<ImageTexturesCachePrivate> d;
45 };
46
47 #endif // IMAGETEXTURESCACHE_H