jvanverth | cba99b8 | 2015-06-24 06:59:57 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2011 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 | |
| 8 | #include "GrGLSL.h" |
| 9 | #include "SkString.h" |
| 10 | |
| 11 | bool GrGLSLSupportsNamedFragmentShaderOutputs(GrGLSLGeneration gen) { |
| 12 | switch (gen) { |
| 13 | case k110_GrGLSLGeneration: |
| 14 | return false; |
| 15 | case k130_GrGLSLGeneration: |
| 16 | case k140_GrGLSLGeneration: |
| 17 | case k150_GrGLSLGeneration: |
| 18 | case k330_GrGLSLGeneration: |
| 19 | case k310es_GrGLSLGeneration: |
| 20 | return true; |
| 21 | } |
| 22 | return false; |
| 23 | } |
| 24 | |
| 25 | void GrGLSLMulVarBy4f(SkString* outAppend, const char* vec4VarName, const GrGLSLExpr4& mulFactor) { |
| 26 | if (mulFactor.isOnes()) { |
| 27 | *outAppend = SkString(); |
| 28 | } |
| 29 | |
| 30 | if (mulFactor.isZeros()) { |
| 31 | outAppend->appendf("%s = vec4(0);", vec4VarName); |
| 32 | } else { |
| 33 | outAppend->appendf("%s *= %s;", vec4VarName, mulFactor.c_str()); |
| 34 | } |
| 35 | } |