48 #include <QTextStream> 63 QFile file(sourceFile);
66 qDebug() <<
"Missing source file" << sourceFile;
76 if (fragmentProgram && line[0] ==
'#' && !line.
startsWith(
"#var"))
101 qDebug() <<
"Missing file" << confFile;
108 while (!in.
atEnd()) {
119 lineStream >> enumerator;
121 if (lineStream.
atEnd()) {
122 qDebug() <<
"Error in file" << confFile <<
'(' << enumerator <<
')';
126 lineStream >> sourceFile;
137 QFile tempSourceFile(
"__tmp__.glsl");
139 qDebug() <<
"Failed opening __tmp__.glsl";
147 if (std::system(
"cgc -quiet -oglsl -profile arbfp1 __tmp__.glsl >__tmp__.frag") == -1) {
148 qDebug() <<
"Failed running cgc";
161 for (
int i = 0; i < word; ++i)
171 for (
int i = 0; i < str.
size(); ++i) {
172 if (str[i] <
'0' || str[i] >
'9')
176 value += (str[i] -
'0');
187 foreach (
QString variable, variables)
188 locations[variable] = -1;
190 while (!in.
atEnd()) {
201 lineStream >> temp >> temp >>
name;
205 while (!lineStream.
atEnd()) {
208 if (temp.startsWith(
"c[")) {
209 location =
toInt(temp.right(temp.size() - 2));
213 if (temp ==
"texunit") {
215 location =
toInt(temp);
226 foreach (
QString variable, variables)
227 result << locations[variable];
239 while (!in.
atEnd()) {
242 result += line +
'\n';
250 out <<
"enum " << name <<
" {";
253 out <<
"\n" TAB "VAR_" << it->toUpper();
254 for (++it; it != s.
end(); ++
it)
255 out <<
",\n" TAB "VAR_" << it->toUpper();
262 out <<
"enum " << name <<
" {";
265 out <<
"\n" TAB << it->first;
266 for (++it; it != s.
end(); ++
it)
267 out <<
",\n" TAB << it->first;
278 QFile includeFile(
"fragmentprograms_p.h");
280 qDebug() <<
"Failed opening fragmentprograms_p.h";
288 out <<
"/****************************************************************************\n" 290 "** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).\n" 291 "** Contact: http://www.qt-project.org/legal\n" 293 "** This file is part of the QtOpenGL module of the Qt Toolkit.\n" 295 "** $QT_BEGIN_LICENSE:LGPL$\n" 296 "** Commercial License Usage\n" 297 "** Licensees holding valid commercial Qt licenses may use this file in\n" 298 "** accordance with the commercial license agreement provided with the\n" 299 "** Software or, alternatively, in accordance with the terms contained in\n" 300 "** a written agreement between you and Digia. For licensing terms and\n" 301 "** conditions see http://qt.digia.com/licensing. For further information\n" 302 "** use the contact form at http://qt.digia.com/contact-us.\n" 304 "** GNU Lesser General Public License Usage\n" 305 "** Alternatively, this file may be used under the terms of the GNU Lesser\n" 306 "** General Public License version 2.1 as published by the Free Software\n" 307 "** Foundation and appearing in the file LICENSE.LGPL included in the\n" 308 "** packaging of this file. Please review the following information to\n" 309 "** ensure the GNU Lesser General Public License version 2.1 requirements\n" 310 "** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.\n" 312 "** In addition, as a special exception, Digia gives you certain additional\n" 313 "** rights. These rights are described in the Digia Qt LGPL Exception\n" 314 "** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.\n" 316 "** GNU General Public License Usage\n" 317 "** Alternatively, this file may be used under the terms of the GNU\n" 318 "** General Public License version 3.0 as published by the Free Software\n" 319 "** Foundation and appearing in the file LICENSE.GPL included in the\n" 320 "** packaging of this file. Please review the following information to\n" 321 "** ensure the GNU General Public License version 3.0 requirements will be\n" 322 "** met: http://www.gnu.org/copyleft/gpl.html.\n" 325 "** $QT_END_LICENSE$\n" 327 "****************************************************************************/\n" 329 "#ifndef FRAGMENTPROGRAMS_P_H\n" 330 "#define FRAGMENTPROGRAMS_P_H\n" 336 "// This file is not part of the Qt API. It exists purely as an\n" 337 "// implementation detail. This header file may change from version to\n" 338 "// version without notice, or even be removed.\n" 346 writeTypesEnum(out,
"FragmentCompositionModeType", compositionModes);
349 out <<
"static const unsigned int num_fragment_variables = " << variables.
size() <<
";\n\n";
350 out <<
"static const unsigned int num_fragment_brushes = " << brushes.
size() <<
";\n";
351 out <<
"static const unsigned int num_fragment_composition_modes = " << compositionModes.
size() <<
";\n";
352 out <<
"static const unsigned int num_fragment_masks = " << masks.
size() <<
";\n\n";
355 const QString compiledSource = compiled[mask.
first][
"MASK__"];
357 out <<
"static const char *FragmentProgram_" << mask.
first <<
" =\n" 366 out <<
"static const char *FragmentProgram_" << brush.
first <<
'_' << mode.
first <<
" =\n" 372 out <<
"static const char *mask_fragment_program_sources[num_fragment_masks] = {\n";
374 out << tab <<
"FragmentProgram_" << mask.
first <<
",\n";
377 out <<
"static const char *painter_fragment_program_sources[num_fragment_brushes][num_fragment_composition_modes] = {\n";
382 out << tab << tab <<
"FragmentProgram_" << brush.
first <<
'_' << mode.
first <<
",\n";
384 out << tab <<
"},\n";
388 out <<
"static int painter_variable_locations[num_fragment_brushes][num_fragment_composition_modes][num_fragment_variables] = {\n";
393 out << tab << tab <<
"{ ";
398 out << location <<
", ";
403 out << tab <<
"},\n";
407 out <<
"static int mask_variable_locations[num_fragment_masks][num_fragment_variables] = {\n";
414 out << location <<
", ";
427 while (!in.
atEnd()) {
432 result << word.
left(word.
size() - 1);
457 for (
int i = 0; i < 3; ++i)
471 combinedSource = brush.
second + mode.
second + painterNoMaskSource;
478 compiled[brush.
first][
"COMPOSITION_MODE_BLEND_MODE_MASK"] =
compileSource(fastSource);
479 compiled[brush.
first][
"COMPOSITION_MODE_BLEND_MODE_NOMASK"] =
compileSource(brushSource);
487 compositionModes += temp;
489 compositionModes <<
QStringPair(
"COMPOSITION_MODE_BLEND_MODE_MASK",
"")
490 <<
QStringPair(
"COMPOSITION_MODE_BLEND_MODE_NOMASK",
"");
492 foreach (QStringPair mask, masks)
QString compileSource(const QString &source)
#define QT_END_NAMESPACE
This macro expands to.
QString readLine(qint64 maxlen=0)
Reads one line of text from the stream, and returns it as a QString.
#define it(className, varName)
bool open(OpenMode flags)
Opens the file using OpenMode mode, returning true if successful; otherwise false.
The QByteArray class provides an array of bytes.
QString getWord(QString line, int word)
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
The QList::const_iterator class provides an STL-style const iterator for QList and QQueue...
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QString readSourceFile(const QString &sourceFile, bool fragmentProgram=false)
The QString class provides a Unicode character string.
QPair< QString, QString > QStringPair
void writeIncludeFile(const QSet< QString > &variables, const QList< QStringPair > &brushes, const QList< QStringPair > &compositionModes, const QList< QStringPair > &masks, const QMap< QString, QMap< QString, QString > > &compiled)
Q_CORE_EXPORT void qDebug(const char *,...)
#define QT_BEGIN_NAMESPACE
This macro expands to.
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
QString trimmed() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end.
int size() const
Returns the number of characters in this string.
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
static int toInt(const QByteArray &str)
QList< QString > getVariables(QString program)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
QString right(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n rightmost characters of the string.
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
QString & append(QChar c)
The QFile class provides an interface for reading from and writing to files.
QString trimmed(QString source)
The QTextStream class provides a convenient interface for reading and writing text.
static QTestResult::TestLocation location
int size() const
Returns the number of items in the list.
QList< QStringPair > readConf(const QString &confFile)
int size() const
Returns the number of bytes in this byte array.
void writeTypesEnum(QTextStream &out, const char *name, const QList< QStringPair > &s)
#define QT_USE_NAMESPACE
This macro expands to using QT_NAMESPACE if QT_NAMESPACE is defined and nothing otherwise.
QList< int > getLocations(const QSet< QString > &variables, QString source)
bool atEnd() const
Returns true if there is no more data to be read from the QTextStream; otherwise returns false...
void writeVariablesEnum(QTextStream &out, const char *name, const QSet< QString > &s)
static QSet< T > fromList(const QList< T > &list)
The QList class is a template class that provides lists.