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 * @class ImageTexturesCache imagetexturescache.h KQuickAddons/ImageTexturesCache
19 *
20 * @short Helps to manage textures by creating images and reference counts them.
21 *
22 * Use this class as a factory for textures, when creating them from a QImage
23 * instance. Keeps track of all the created textures in a map between the
24 * QImage::cacheKey() and the cached texture until it gets de-referenced.
25 *
26 * @see ManagedTextureNode
27 */
28class ImageTexturesCache
29{
30public:
31 ImageTexturesCache();
32 ~ImageTexturesCache();
33
34 /**
35 * @returns the texture for a given @p window and @p image.
36 *
37 * If @p image id is the same as one already provided before, we will not
38 * create a new texture, and will instead return a shared pointer to the existing texture.
39 */
40 QSharedPointer<QSGTexture> loadTexture(QQuickWindow *window, const QImage &image, QQuickWindow::CreateTextureOptions options);
41
42 QSharedPointer<QSGTexture> loadTexture(QQuickWindow *window, const QImage &image);
43
44private:
45 QScopedPointer<ImageTexturesCachePrivate> d;
46};
47
48#endif // IMAGETEXTURESCACHE_H
49

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