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

Unified Diff: src/gpu/effects/GrConfigConversionEffect.cpp

Issue 491673002: Initial refactor of shaderbuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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/effects/GrBicubicEffect.cpp ('k') | src/gpu/effects/GrConvexPolyEffect.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/effects/GrConfigConversionEffect.cpp
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index d7ba6865c96be6ce8724f9be29004958bc18e958..84e60cd76cfdfc771686e2e9ee5ab22ff4286bf8 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -10,7 +10,7 @@
#include "GrTBackendEffectFactory.h"
#include "GrSimpleTextureEffect.h"
#include "gl/GrGLEffect.h"
-#include "gl/GrGLShaderBuilder.h"
+#include "gl/builders/GrGLProgramBuilder.h"
#include "SkMatrix.h"
class GrGLConfigConversionEffect : public GrGLEffect {
@@ -23,7 +23,7 @@ public:
fPMConversion = effect.pmConversion();
}
- virtual void emitCode(GrGLShaderBuilder* builder,
+ virtual void emitCode(GrGLProgramBuilder* builder,
const GrDrawEffect&,
const GrEffectKey& key,
const char* outputColor,
@@ -34,20 +34,23 @@ public:
GrGLShaderVar tmpVar("tmpColor", kVec4f_GrSLType, 0, GrGLShaderVar::kHigh_Precision);
SkString tmpDecl;
tmpVar.appendDecl(builder->ctxInfo(), &tmpDecl);
- builder->fsCodeAppendf("%s;", tmpDecl.c_str());
- builder->fsCodeAppendf("%s = ", tmpVar.c_str());
- builder->fsAppendTextureLookup(samplers[0], coords[0].c_str(), coords[0].type());
- builder->fsCodeAppend(";");
+ GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
+
+ fsBuilder->codeAppendf("%s;", tmpDecl.c_str());
+
+ fsBuilder->codeAppendf("%s = ", tmpVar.c_str());
+ fsBuilder->appendTextureLookup(samplers[0], coords[0].c_str(), coords[0].type());
+ fsBuilder->codeAppend(";");
if (GrConfigConversionEffect::kNone_PMConversion == fPMConversion) {
SkASSERT(fSwapRedAndBlue);
- builder->fsCodeAppendf("%s = %s.bgra;", outputColor, tmpVar.c_str());
+ fsBuilder->codeAppendf("%s = %s.bgra;", outputColor, tmpVar.c_str());
} else {
const char* swiz = fSwapRedAndBlue ? "bgr" : "rgb";
switch (fPMConversion) {
case GrConfigConversionEffect::kMulByAlpha_RoundUp_PMConversion:
- builder->fsCodeAppendf(
+ fsBuilder->codeAppendf(
"%s = vec4(ceil(%s.%s * %s.a * 255.0) / 255.0, %s.a);",
tmpVar.c_str(), tmpVar.c_str(), swiz, tmpVar.c_str(), tmpVar.c_str());
break;
@@ -56,17 +59,17 @@ public:
// In Intel GPUs, the integer value converted from floor(%s.r * 255.0) / 255.0
// is less than the integer value converted from %s.r by 1 when the %s.r is
// converted from the integer value 2^n, such as 1, 2, 4, 8, etc.
- builder->fsCodeAppendf(
+ fsBuilder->codeAppendf(
"%s = vec4(floor(%s.%s * %s.a * 255.0 + 0.001) / 255.0, %s.a);",
tmpVar.c_str(), tmpVar.c_str(), swiz, tmpVar.c_str(), tmpVar.c_str());
break;
case GrConfigConversionEffect::kDivByAlpha_RoundUp_PMConversion:
- builder->fsCodeAppendf(
+ fsBuilder->codeAppendf(
"%s = %s.a <= 0.0 ? vec4(0,0,0,0) : vec4(ceil(%s.%s / %s.a * 255.0) / 255.0, %s.a);",
tmpVar.c_str(), tmpVar.c_str(), tmpVar.c_str(), swiz, tmpVar.c_str(), tmpVar.c_str());
break;
case GrConfigConversionEffect::kDivByAlpha_RoundDown_PMConversion:
- builder->fsCodeAppendf(
+ fsBuilder->codeAppendf(
"%s = %s.a <= 0.0 ? vec4(0,0,0,0) : vec4(floor(%s.%s / %s.a * 255.0) / 255.0, %s.a);",
tmpVar.c_str(), tmpVar.c_str(), tmpVar.c_str(), swiz, tmpVar.c_str(), tmpVar.c_str());
break;
@@ -74,11 +77,11 @@ public:
SkFAIL("Unknown conversion op.");
break;
}
- builder->fsCodeAppendf("%s = %s;", outputColor, tmpVar.c_str());
+ fsBuilder->codeAppendf("%s = %s;", outputColor, tmpVar.c_str());
}
SkString modulate;
GrGLSLMulVarBy4f(&modulate, 2, outputColor, inputColor);
- builder->fsCodeAppend(modulate.c_str());
+ fsBuilder->codeAppend(modulate.c_str());
}
static inline void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
« no previous file with comments | « src/gpu/effects/GrBicubicEffect.cpp ('k') | src/gpu/effects/GrConvexPolyEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698