Kirigami2

shadowedtexturematerial.cpp
1/*
2 * SPDX-FileCopyrightText: 2020 Arjen Hiemstra <ahiemstra@heimr.nl>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7#include "shadowedtexturematerial.h"
8
9#include <QOpenGLContext>
10
11QSGMaterialType ShadowedTextureMaterial::staticType;
12
13ShadowedTextureMaterial::ShadowedTextureMaterial()
15{
16 setFlag(QSGMaterial::Blending, true);
17}
18
19QSGMaterialShader *ShadowedTextureMaterial::createShader(QSGRendererInterface::RenderMode) const
20{
21 return new ShadowedTextureShader{shaderType};
22}
23
24QSGMaterialType *ShadowedTextureMaterial::type() const
25{
26 return &staticType;
27}
28
29int ShadowedTextureMaterial::compare(const QSGMaterial *other) const
30{
31 auto material = static_cast<const ShadowedTextureMaterial *>(other);
32
33 auto result = ShadowedRectangleMaterial::compare(other);
34 if (result == 0) {
35 if (material->textureSource == textureSource) {
36 return 0;
37 } else {
38 return (material->textureSource < textureSource) ? 1 : -1;
39 }
40 }
41
42 return QSGMaterial::compare(other);
43}
44
45ShadowedTextureShader::ShadowedTextureShader(ShadowedRectangleMaterial::ShaderType shaderType)
46 : ShadowedRectangleShader(shaderType)
47{
48 setShader(shaderType, QStringLiteral("shadowedtexture"));
49}
50
51void ShadowedTextureShader::updateSampledImage(QSGMaterialShader::RenderState &state,
52 int binding,
53 QSGTexture **texture,
54 QSGMaterial *newMaterial,
55 QSGMaterial *oldMaterial)
56{
57 Q_UNUSED(state);
58 Q_UNUSED(oldMaterial);
59 if (binding == 1) {
60 *texture = static_cast<ShadowedTextureMaterial *>(newMaterial)->textureSource;
61 }
62}
A material rendering a rectangle with a shadow.
A material rendering a rectangle with a shadow.
virtual int compare(const QSGMaterial *other) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:18:46 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.