/usr/include/qt5/QtQuick/qsgsimplematerial.h is in qtdeclarative5-dev 5.2.1-3ubuntu15.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | /****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSGSIMPLEMATERIAL_H
#define QSGSIMPLEMATERIAL_H
#include <QtQuick/qsgmaterial.h>
QT_BEGIN_NAMESPACE
template <typename State>
class QSGSimpleMaterialShader : public QSGMaterialShader
{
public:
void initialize() {
QSGMaterialShader::initialize();
m_id_matrix = program()->uniformLocation(uniformMatrixName());
if (m_id_matrix < 0) {
qFatal("QSGSimpleMaterialShader does not implement 'uniform highp mat4 %s;' in its vertex shader",
uniformMatrixName());
}
const char *opacity = uniformOpacityName();
if (opacity) {
m_id_opacity = program()->uniformLocation(uniformOpacityName());
if (m_id_opacity < 0) {
qFatal("QSGSimpleMaterialShader does not implement 'uniform lowp float %s' in its fragment shader",
uniformOpacityName());
}
} else {
m_id_opacity = -1;
}
resolveUniforms();
}
const char *uniformMatrixName() const { return "qt_Matrix"; }
const char *uniformOpacityName() const { return "qt_Opacity"; }
void updateState(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial);
virtual void updateState(const State *newState, const State *oldState) = 0;
virtual void resolveUniforms() {}
virtual QList<QByteArray> attributes() const = 0;
char const *const *attributeNames() const
{
if (m_attribute_pointers.size())
return m_attribute_pointers.constData();
QList<QByteArray> names = attributes();
// Calculate the total number of bytes needed, so we don't get rellocs and
// bad pointers while copying over the individual names.
// Add an extra byte pr entry for the '\0' char.
int total = 0;
for (int i=0; i<names.size(); ++i)
total += names.at(i).size() + 1;
m_attribute_name_data.reserve(total);
// Copy over the names
for (int i=0; i<names.size(); ++i) {
m_attribute_pointers << m_attribute_name_data.constData() + m_attribute_name_data.size();
m_attribute_name_data.append(names.at(i));
m_attribute_name_data.append('\0');
}
// Append the "null" terminator
m_attribute_pointers << 0;
return m_attribute_pointers.constData();
}
private:
int m_id_matrix;
int m_id_opacity;
mutable QByteArray m_attribute_name_data;
mutable QVector<const char *> m_attribute_pointers;
};
#define QSG_DECLARE_SIMPLE_SHADER(Shader, State) \
static QSGMaterialShader *createShader() \
{ \
return new Shader; \
} \
public: \
static QSGSimpleMaterial<State> *createMaterial() \
{ \
return new QSGSimpleMaterial<State>(createShader); \
}
typedef QSGMaterialShader *(*PtrShaderCreateFunc)();
template <typename State>
class QSGSimpleMaterial : public QSGMaterial
{
public:
#ifndef qdoc
QSGSimpleMaterial(const State &aState, PtrShaderCreateFunc func)
: m_state(aState)
, m_func(func)
{
}
QSGSimpleMaterial(PtrShaderCreateFunc func)
: m_func(func)
{
}
QSGMaterialShader *createShader() const { return m_func(); }
QSGMaterialType *type() const { return &m_type; }
State *state() { return &m_state; }
const State *state() const { return &m_state; }
#endif
private:
static QSGMaterialType m_type;
State m_state;
PtrShaderCreateFunc m_func;
};
#define QSG_DECLARE_SIMPLE_COMPARABLE_SHADER(Shader, State) \
static QSGMaterialShader *createShader() \
{ \
return new Shader; \
} \
public: \
static QSGSimpleMaterialComparableMaterial<State> *createMaterial() \
{ \
return new QSGSimpleMaterialComparableMaterial<State>(createShader); \
}
template <typename State>
class QSGSimpleMaterialComparableMaterial : public QSGSimpleMaterial<State>
{
public:
QSGSimpleMaterialComparableMaterial(const State &state, PtrShaderCreateFunc func)
: QSGSimpleMaterial<State>(state, func) {}
QSGSimpleMaterialComparableMaterial(PtrShaderCreateFunc func)
: QSGSimpleMaterial<State>(func) {}
int compare(const QSGMaterial *other) const {
return QSGSimpleMaterialComparableMaterial<State>::state()->compare(static_cast<const QSGSimpleMaterialComparableMaterial<State> *>(other)->state());
}
};
template <typename State>
QSGMaterialType QSGSimpleMaterial<State>::m_type;
template <typename State>
Q_INLINE_TEMPLATE void QSGSimpleMaterialShader<State>::updateState(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
{
if (state.isMatrixDirty())
program()->setUniformValue(m_id_matrix, state.combinedMatrix());
if (state.isOpacityDirty() && m_id_opacity >= 0)
program()->setUniformValue(m_id_opacity, state.opacity());
State *ns = static_cast<QSGSimpleMaterial<State> *>(newMaterial)->state();
State *old = 0;
if (oldMaterial)
old = static_cast<QSGSimpleMaterial<State> *>(oldMaterial)->state();
updateState(ns, old);
}
QT_END_NAMESPACE
#endif
|