1/*
2 SPDX-FileCopyrightText: 2014 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
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
13class QImage;
14class QSGTexture;
15class ImageTexturesCachePrivate;
16
17/*
18 * 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. Keeps track of all the created textures in a map between the
22 * QImage::cacheKey() and the cached texture until it gets de-referenced.
23 *
24 * \sa ManagedTextureNode
25 */
26class ImageTexturesCache
27{
28public:
29 ImageTexturesCache();
30 ~ImageTexturesCache();
31
32 /*!
33 * Returns the texture for a given window and image.
34 *
35 * If image id is the same as one already provided before, we will not
36 * create a new texture, and will instead return a shared pointer to the existing texture.
37 */
38 QSharedPointer<QSGTexture> loadTexture(QQuickWindow *window, const QImage &image, QQuickWindow::CreateTextureOptions options);
39
40 QSharedPointer<QSGTexture> loadTexture(QQuickWindow *window, const QImage &image);
41
42private:
43 QScopedPointer<ImageTexturesCachePrivate> d;
44};
45
46#endif // IMAGETEXTURESCACHE_H
47

source code of ksvg/src/declarativeimports/imagetexturescache.h