Kirigami2

shadowedbordertexturematerial.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 "shadowedbordertexturematerial.h"
8
9#include <QOpenGLContext>
10
11QSGMaterialType ShadowedBorderTextureMaterial::staticType;
12
13ShadowedBorderTextureMaterial::ShadowedBorderTextureMaterial()
15{
16 setFlag(QSGMaterial::Blending, true);
17}
18
19QSGMaterialShader *ShadowedBorderTextureMaterial::createShader(QSGRendererInterface::RenderMode) const
20{
21 return new ShadowedBorderTextureShader{shaderType};
22}
23
24QSGMaterialType *ShadowedBorderTextureMaterial::type() const
25{
26 return &staticType;
27}
28
29int ShadowedBorderTextureMaterial::compare(const QSGMaterial *other) const
30{
31 auto material = static_cast<const ShadowedBorderTextureMaterial *>(other);
32
33 auto result = ShadowedBorderRectangleMaterial::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
45ShadowedBorderTextureShader::ShadowedBorderTextureShader(ShadowedRectangleMaterial::ShaderType shaderType)
46 : ShadowedBorderRectangleShader(shaderType)
47{
48 setShader(shaderType, QStringLiteral("shadowedbordertexture"));
49}
50
51void ShadowedBorderTextureShader::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<ShadowedBorderTextureMaterial *>(newMaterial)->textureSource;
61 }
62}
A material rendering a rectangle with a shadow and a border.
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 Fri Nov 29 2024 11:51:50 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.