aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrShaderVar.cpp
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2016-11-21 13:41:08 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-21 19:13:43 +0000
commit99938a8ef24e2dd5b39f78638742e9b50ab6d9bf (patch)
treee3842210db20a4574e9cec37ae7f049aaff27b65 /src/gpu/GrShaderVar.cpp
parentd728f0c1a94fe926b59d8ebc9ae174019ccd3606 (diff)
Merge GrGLSLShaderVar and GrShaderVar
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=5087 Change-Id: Ib8943a1da1ea495554feaf5b0992b94fbb9539ab Reviewed-on: https://skia-review.googlesource.com/5087 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/gpu/GrShaderVar.cpp')
-rw-r--r--src/gpu/GrShaderVar.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/gpu/GrShaderVar.cpp b/src/gpu/GrShaderVar.cpp
new file mode 100644
index 0000000000..ef305cbfc9
--- /dev/null
+++ b/src/gpu/GrShaderVar.cpp
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+
+#include "GrShaderVar.h"
+#include "glsl/GrGLSLCaps.h"
+
+void GrShaderVar::appendDecl(const GrGLSLCaps* glslCaps, SkString* out) const {
+ SkASSERT(kDefault_GrSLPrecision == fPrecision || GrSLTypeAcceptsPrecision(fType));
+ if (!fLayoutQualifier.isEmpty()) {
+ out->appendf("layout(%s) ", fLayoutQualifier.c_str());
+ }
+ out->append(fExtraModifiers);
+ if (this->getTypeModifier() != kNone_TypeModifier) {
+ out->append(TypeModifierString(this->getTypeModifier()));
+ out->append(" ");
+ }
+ GrSLType effectiveType = this->getType();
+ if (glslCaps->usesPrecisionModifiers() && GrSLTypeAcceptsPrecision(effectiveType)) {
+ // Desktop GLSL has added precision qualifiers but they don't do anything.
+ out->appendf("%s ", GrGLSLPrecisionString(fPrecision));
+ }
+ if (this->isArray()) {
+ if (this->isUnsizedArray()) {
+ out->appendf("%s %s[]",
+ GrGLSLTypeString(effectiveType),
+ this->getName().c_str());
+ } else {
+ SkASSERT(this->getArrayCount() > 0);
+ out->appendf("%s %s[%d]",
+ GrGLSLTypeString(effectiveType),
+ this->getName().c_str(),
+ this->getArrayCount());
+ }
+ } else {
+ out->appendf("%s %s",
+ GrGLSLTypeString(effectiveType),
+ this->getName().c_str());
+ }
+}