/* * SPDX-FileCopyrightText: 2011 Marco Martin * SPDX-FileCopyrightText: 2014 Aleix Pol Gonzalez * SPDX-FileCopyrightText: 2020 Carson Black * * SPDX-License-Identifier: LGPL-2.0-or-later */ #pragma once #include #include #include #include #include class ManagedTextureNode : public QSGSimpleTextureNode { Q_DISABLE_COPY(ManagedTextureNode) public: ManagedTextureNode(); void setTexture(std::shared_ptr texture); private: std::shared_ptr m_texture; }; typedef QHash>> TexturesCache; struct ImageTexturesCachePrivate { TexturesCache cache; }; 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. */ std::shared_ptr loadTexture(QQuickWindow *window, const QImage &image, QQuickWindow::CreateTextureOptions options); std::shared_ptr loadTexture(QQuickWindow *window, const QImage &image); private: std::unique_ptr d; };