Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(344)

Unified Diff: src/gpu/gl/GrGLSL.cpp

Issue 25048002: Express (GLSL expression, possibly known value) pairs as a class (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/gpu/gl/GrGLSL.cpp
diff --git a/src/gpu/gl/GrGLSL.cpp b/src/gpu/gl/GrGLSL.cpp
index f48f03854647ad2dc2369bdbb2a4f74892d0458e..9cddd7ec5d3603f121041052cf92ca4d8a3d8597 100644
--- a/src/gpu/gl/GrGLSL.cpp
+++ b/src/gpu/gl/GrGLSL.cpp
@@ -94,50 +94,19 @@ namespace {
}
}
-GrSLConstantVec GrGLSLMulVarBy4f(SkString* outAppend,
- int tabCnt,
- const char* vec4VarName,
- const char* mulFactor,
- GrSLConstantVec mulFactorDefault) {
- bool haveFactor = NULL != mulFactor && '\0' != *mulFactor;
-
- SkASSERT(NULL != outAppend);
- SkASSERT(NULL != vec4VarName);
- SkASSERT(kNone_GrSLConstantVec != mulFactorDefault || haveFactor);
-
- if (!haveFactor) {
- if (kOnes_GrSLConstantVec == mulFactorDefault) {
- return kNone_GrSLConstantVec;
- } else {
- SkASSERT(kZeros_GrSLConstantVec == mulFactorDefault);
- append_tabs(outAppend, tabCnt);
- outAppend->appendf("%s = vec4(0, 0, 0, 0);\n", vec4VarName);
- return kZeros_GrSLConstantVec;
- }
+void GrGLSLMulVarBy4f(SkString* outAppend,
+ unsigned tabCnt,
+ const char* vec4VarName,
+ const GrGLSLExpr<4>& mulFactor) {
+ if (mulFactor.isOnes()) {
+ *outAppend = SkString();
}
+
append_tabs(outAppend, tabCnt);
- outAppend->appendf("%s *= %s;\n", vec4VarName, mulFactor);
- return kNone_GrSLConstantVec;
-}
-GrSLConstantVec GrGLSLGetComponent4f(SkString* outAppend,
- const char* expr,
- GrColorComponentFlags component,
- GrSLConstantVec defaultExpr,
- bool omitIfConst) {
- if (NULL == expr || '\0' == *expr) {
- SkASSERT(defaultExpr != kNone_GrSLConstantVec);
- if (!omitIfConst) {
- if (kOnes_GrSLConstantVec == defaultExpr) {
- outAppend->append("1.0");
- } else {
- SkASSERT(kZeros_GrSLConstantVec == defaultExpr);
- outAppend->append("0.0");
- }
- }
- return defaultExpr;
- } else {
- outAppend->appendf("(%s).%c", expr, GrColorComponentFlagToChar(component));
- return kNone_GrSLConstantVec;
+ if (mulFactor.isZeros()) {
+ outAppend->appendf("%s = vec4(0);\n", vec4VarName);
}
+ outAppend->appendf("%s *= %s;\n", vec4VarName, mulFactor.c_str());
}
+
« src/gpu/gl/GrGLSL.h ('K') | « src/gpu/gl/GrGLSL.h ('k') | src/gpu/gl/GrGLSL_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698