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 | |
11 | QSGMaterialType ShadowedBorderTextureMaterial::staticType; |
12 | |
13 | ShadowedBorderTextureMaterial::ShadowedBorderTextureMaterial() |
14 | : ShadowedBorderRectangleMaterial() |
15 | { |
16 | setFlag(flags: QSGMaterial::Blending, on: true); |
17 | } |
18 | |
19 | QSGMaterialShader *ShadowedBorderTextureMaterial::createShader(QSGRendererInterface::RenderMode) const |
20 | { |
21 | return new ShadowedBorderTextureShader{shaderType}; |
22 | } |
23 | |
24 | QSGMaterialType *ShadowedBorderTextureMaterial::type() const |
25 | { |
26 | return &staticType; |
27 | } |
28 | |
29 | int 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 | |
45 | ShadowedBorderTextureShader::ShadowedBorderTextureShader(ShadowedRectangleMaterial::ShaderType shaderType) |
46 | : ShadowedBorderRectangleShader(shaderType) |
47 | { |
48 | setShader(shaderType, QStringLiteral("shadowedbordertexture")); |
49 | } |
50 | |
51 | void 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 | } |
63 |