File indexing completed on 2024-05-12 15:42:40

0001 /*
0002  *  SPDX-FileCopyrightText: 2020 Arjen Hiemstra <ahiemstra@heimr.nl>
0003  *
0004  *  SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 
0007 #pragma once
0008 
0009 #include <QSGTexture>
0010 
0011 #include "shadowedrectanglematerial.h"
0012 
0013 /**
0014  * A material rendering a rectangle with a shadow.
0015  *
0016  * This material uses a distance field shader to render a rectangle with a
0017  * shadow below it, optionally with rounded corners.
0018  */
0019 class ShadowedTextureMaterial : public ShadowedRectangleMaterial
0020 {
0021 public:
0022     ShadowedTextureMaterial();
0023 
0024 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
0025     QSGMaterialShader *createShader() const override;
0026 #else
0027     QSGMaterialShader *createShader(QSGRendererInterface::RenderMode) const override;
0028 #endif
0029     QSGMaterialType *type() const override;
0030     int compare(const QSGMaterial *other) const override;
0031 
0032     QSGTexture *textureSource = nullptr;
0033 
0034     static QSGMaterialType staticType;
0035 };
0036 
0037 class ShadowedTextureShader : public ShadowedRectangleShader
0038 {
0039 public:
0040     ShadowedTextureShader(ShadowedRectangleMaterial::ShaderType shaderType);
0041 
0042 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
0043     void initialize() override;
0044     void updateState(const QSGMaterialShader::RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
0045 #else
0046     void
0047     updateSampledImage(QSGMaterialShader::RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
0048 #endif
0049 };