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

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: addressing review comments 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
« no previous file with comments | « src/gpu/gl/GrGLSL.h ('k') | src/gpu/gl/GrGLSL_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLSL.cpp
diff --git a/src/gpu/gl/GrGLSL.cpp b/src/gpu/gl/GrGLSL.cpp
index f48f03854647ad2dc2369bdbb2a4f74892d0458e..3dfd5e50edb085cabc825a9014cc48f7f916672a 100644
--- a/src/gpu/gl/GrGLSL.cpp
+++ b/src/gpu/gl/GrGLSL.cpp
@@ -63,26 +63,6 @@ const char* GrGetGLSLVersionDecl(const GrGLContextInfo& info) {
}
}
-const char* GrGLSLVectorHomogCoord(int count) {
- static const char* HOMOGS[] = {"ERROR", "", ".y", ".z", ".w"};
- SkASSERT(count >= 1 && count < (int)GR_ARRAY_COUNT(HOMOGS));
- return HOMOGS[count];
-}
-
-const char* GrGLSLVectorHomogCoord(GrSLType type) {
- return GrGLSLVectorHomogCoord(GrSLTypeToVecLength(type));
-}
-
-const char* GrGLSLVectorNonhomogCoords(int count) {
- static const char* NONHOMOGS[] = {"ERROR", "", ".x", ".xy", ".xyz"};
- SkASSERT(count >= 1 && count < (int)GR_ARRAY_COUNT(NONHOMOGS));
- return NONHOMOGS[count];
-}
-
-const char* GrGLSLVectorNonhomogCoords(GrSLType type) {
- return GrGLSLVectorNonhomogCoords(GrSLTypeToVecLength(type));
-}
-
namespace {
void append_tabs(SkString* outAppend, int tabCnt) {
static const char kTabs[] = "\t\t\t\t\t\t\t\t";
@@ -94,50 +74,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());
}
+
« no previous file with comments | « 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