Flutter Engine
The Flutter Engine
GrShaderVar.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
11
13 switch (t) {
14 case GrShaderVar::TypeModifier::None: return "";
15 case GrShaderVar::TypeModifier::In: return "in";
16 case GrShaderVar::TypeModifier::InOut: return "inout";
17 case GrShaderVar::TypeModifier::Out: return "out";
18 case GrShaderVar::TypeModifier::Uniform: return "uniform";
19 }
20 SK_ABORT("Unknown shader variable type modifier.");
21}
22
23void GrShaderVar::appendDecl(const GrShaderCaps* shaderCaps, SkString* out) const {
24 if (!fLayoutQualifier.isEmpty()) {
25 out->appendf("layout(%s) ", fLayoutQualifier.c_str());
26 }
27 if (!fExtraModifiers.isEmpty()) {
28 out->appendf("%s ", fExtraModifiers.c_str());
29 }
30 if (this->getTypeModifier() != TypeModifier::None) {
31 out->appendf("%s ", type_modifier_string(this->getTypeModifier()));
32 }
33 SkSLType effectiveType = this->getType();
34 if (this->isArray()) {
35 SkASSERT(this->getArrayCount() > 0);
36 out->appendf("%s %s[%d]",
37 SkSLTypeString(effectiveType),
38 this->getName().c_str(),
39 this->getArrayCount());
40 } else {
41 out->appendf("%s %s", SkSLTypeString(effectiveType), this->getName().c_str());
42 }
43}
static const char * type_modifier_string(GrShaderVar::TypeModifier t)
Definition: GrShaderVar.cpp:12
#define SK_ABORT(message,...)
Definition: SkAssert.h:70
#define SkASSERT(cond)
Definition: SkAssert.h:116
const char * SkSLTypeString(SkSLType t)
SkSLType
SkSLType getType() const
Definition: GrShaderVar.h:97
int getArrayCount() const
Definition: GrShaderVar.h:88
bool isArray() const
Definition: GrShaderVar.h:85
const char * c_str() const
Definition: GrShaderVar.h:94
TypeModifier getTypeModifier() const
Definition: GrShaderVar.h:99
const SkString & getName() const
Definition: GrShaderVar.h:91
void appendDecl(const GrShaderCaps *, SkString *out) const
Definition: GrShaderVar.cpp:23
bool isEmpty() const
Definition: SkString.h:130
const char * c_str() const
Definition: SkString.h:133
void void void appendf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:550