Warning, file /frameworks/kirigami/src/scenegraph/shadowedbordertexturematerial.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  *  SPDX-FileCopyrightText: 2020 Arjen Hiemstra <ahiemstra@heimr.nl>
0003  *
0004  *  SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 
0007 #include "shadowedbordertexturematerial.h"
0008 
0009 #include <QOpenGLContext>
0010 
0011 QSGMaterialType ShadowedBorderTextureMaterial::staticType;
0012 
0013 ShadowedBorderTextureMaterial::ShadowedBorderTextureMaterial()
0014     : ShadowedBorderRectangleMaterial()
0015 {
0016     setFlag(QSGMaterial::Blending, true);
0017 }
0018 
0019 QSGMaterialShader *ShadowedBorderTextureMaterial::createShader(QSGRendererInterface::RenderMode) const
0020 {
0021     return new ShadowedBorderTextureShader{shaderType};
0022 }
0023 
0024 QSGMaterialType *ShadowedBorderTextureMaterial::type() const
0025 {
0026     return &staticType;
0027 }
0028 
0029 int ShadowedBorderTextureMaterial::compare(const QSGMaterial *other) const
0030 {
0031     auto material = static_cast<const ShadowedBorderTextureMaterial *>(other);
0032 
0033     auto result = ShadowedBorderRectangleMaterial::compare(other);
0034     if (result == 0) {
0035         if (material->textureSource == textureSource) {
0036             return 0;
0037         } else {
0038             return (material->textureSource < textureSource) ? 1 : -1;
0039         }
0040     }
0041 
0042     return QSGMaterial::compare(other);
0043 }
0044 
0045 ShadowedBorderTextureShader::ShadowedBorderTextureShader(ShadowedRectangleMaterial::ShaderType shaderType)
0046     : ShadowedBorderRectangleShader(shaderType)
0047 {
0048     setShader(shaderType, QStringLiteral("shadowedbordertexture"));
0049 }
0050 
0051 void ShadowedBorderTextureShader::updateSampledImage(QSGMaterialShader::RenderState &state,
0052                                                      int binding,
0053                                                      QSGTexture **texture,
0054                                                      QSGMaterial *newMaterial,
0055                                                      QSGMaterial *oldMaterial)
0056 {
0057     Q_UNUSED(state);
0058     Q_UNUSED(oldMaterial);
0059     if (binding == 1) {
0060         *texture = static_cast<ShadowedBorderTextureMaterial *>(newMaterial)->textureSource;
0061     }
0062 }