/* SPDX-FileCopyrightText: 2014 Aleix Pol Gonzalez SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef IMAGETEXTURESCACHE_H #define IMAGETEXTURESCACHE_H #include #include class QImage; class QSGTexture; struct ImageTexturesCachePrivate; /** * @short Helps to manage textures by creating images and reference counts them. * * Use this class as a factory for textures, when creating them from a QImage * instance. * Keeps track of all the created textures in a map between the QImage::cacheKey() and * the cached texture until it gets de-referenced. * * @see ManagedTextureNode */ class ImageTexturesCache { public: ImageTexturesCache(); ~ImageTexturesCache(); /** * @returns the texture for a given @p window and @p image. * * If an @p image id is the same as one already provided before, we won't create * a new texture and return a shared pointer to the existing texture. */ QSharedPointer loadTexture(QQuickWindow *window, const QImage &image, QQuickWindow::CreateTextureOptions options); QSharedPointer loadTexture(QQuickWindow *window, const QImage &image); private: QScopedPointer d; }; #endif // IMAGETEXTURESCACHE_H