Make GrGLConfigConversionEffect work for Imagination and some other GPUs.
BUG=372341 R=tomhudson@chromium.org, bsalomon@google.com Author: changjun.yang@intel.com Review URL: https://codereview.chromium.org/277323002
This commit is contained in:
parent
b4edbffd7c
commit
93cf46f7d6
@ -37,6 +37,7 @@ public:
|
||||
builder->fsCodeAppendf("\t%s = %s.bgra;\n", outputColor, outputColor);
|
||||
} else {
|
||||
const char* swiz = fSwapRedAndBlue ? "bgr" : "rgb";
|
||||
const char* outputColorH = "outputColorH";
|
||||
switch (fPMConversion) {
|
||||
case GrConfigConversionEffect::kMulByAlpha_RoundUp_PMConversion:
|
||||
builder->fsCodeAppendf(
|
||||
@ -60,6 +61,36 @@ public:
|
||||
builder->fsCodeAppendf("\t\t%s = %s.a <= 0.0 ? vec4(0,0,0,0) : vec4(floor(%s.%s / %s.a * 255.0) / 255.0, %s.a);\n",
|
||||
outputColor, outputColor, outputColor, swiz, outputColor, outputColor);
|
||||
break;
|
||||
case GrConfigConversionEffect::kMulByAlpha_RoundUp_HIGHP_PMConversion:
|
||||
builder->fsCodeAppendf("\thighp vec4 %s;\n", outputColorH);
|
||||
builder->fsCodeAppendf("\t\t%s = %s;\n", outputColorH, outputColor);
|
||||
builder->fsCodeAppendf(
|
||||
"\t\t%s = vec4(ceil(%s.%s * %s.a * 255.0) / 255.0, %s.a);\n",
|
||||
outputColorH, outputColorH, swiz, outputColorH, outputColorH);
|
||||
builder->fsCodeAppendf("\t\t%s = %s;\n", outputColor, outputColorH);
|
||||
break;
|
||||
case GrConfigConversionEffect::kMulByAlpha_RoundDown_HIGHP_PMConversion:
|
||||
builder->fsCodeAppendf("\thighp vec4 %s;\n", outputColorH);
|
||||
builder->fsCodeAppendf("\t\t%s = %s;\n", outputColorH, outputColor);
|
||||
builder->fsCodeAppendf(
|
||||
"\t\t%s = vec4(floor(%s.%s * %s.a * 255.0) / 255.0, %s.a);\n",
|
||||
outputColorH, outputColorH, swiz, outputColorH, outputColorH);
|
||||
builder->fsCodeAppendf("\t\t%s = %s;\n", outputColor, outputColorH);
|
||||
break;
|
||||
case GrConfigConversionEffect::kDivByAlpha_RoundUp_HIGHP_PMConversion:
|
||||
builder->fsCodeAppendf("\thighp vec4 %s;\n", outputColorH);
|
||||
builder->fsCodeAppendf("\t\t%s = %s;\n", outputColorH, outputColor);
|
||||
builder->fsCodeAppendf("\t\t%s = %s.a <= 0.0 ? vec4(0,0,0,0) : vec4(ceil(%s.%s / %s.a * 255.0) / 255.0, %s.a);\n",
|
||||
outputColorH, outputColorH, outputColorH, swiz, outputColorH, outputColorH);
|
||||
builder->fsCodeAppendf("\t\t%s = %s;\n", outputColor, outputColorH);
|
||||
break;
|
||||
case GrConfigConversionEffect::kDivByAlpha_RoundDown_HIGHP_PMConversion:
|
||||
builder->fsCodeAppendf("\thighp vec4 %s;\n", outputColorH);
|
||||
builder->fsCodeAppendf("\t\t%s = %s;\n", outputColorH, outputColor);
|
||||
builder->fsCodeAppendf("\t\t%s = %s.a <= 0.0 ? vec4(0,0,0,0) : vec4(floor(%s.%s / %s.a * 255.0) / 255.0, %s.a);\n",
|
||||
outputColorH, outputColorH, outputColorH, swiz, outputColorH, outputColorH);
|
||||
builder->fsCodeAppendf("\t\t%s = %s;\n", outputColor, outputColorH);
|
||||
break;
|
||||
default:
|
||||
SkFAIL("Unknown conversion op.");
|
||||
break;
|
||||
@ -183,6 +214,8 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
|
||||
static const PMConversion kConversionRules[][2] = {
|
||||
{kDivByAlpha_RoundDown_PMConversion, kMulByAlpha_RoundUp_PMConversion},
|
||||
{kDivByAlpha_RoundUp_PMConversion, kMulByAlpha_RoundDown_PMConversion},
|
||||
{kDivByAlpha_RoundDown_HIGHP_PMConversion, kMulByAlpha_RoundUp_HIGHP_PMConversion},
|
||||
{kDivByAlpha_RoundUp_HIGHP_PMConversion, kMulByAlpha_RoundDown_HIGHP_PMConversion},
|
||||
};
|
||||
|
||||
GrContext::AutoWideOpenIdentityDraw awoid(context, NULL);
|
||||
|
@ -30,6 +30,10 @@ public:
|
||||
kMulByAlpha_RoundDown_PMConversion,
|
||||
kDivByAlpha_RoundUp_PMConversion,
|
||||
kDivByAlpha_RoundDown_PMConversion,
|
||||
kMulByAlpha_RoundUp_HIGHP_PMConversion,
|
||||
kMulByAlpha_RoundDown_HIGHP_PMConversion,
|
||||
kDivByAlpha_RoundUp_HIGHP_PMConversion,
|
||||
kDivByAlpha_RoundDown_HIGHP_PMConversion,
|
||||
|
||||
kPMConversionCnt
|
||||
};
|
||||
|
@ -630,7 +630,6 @@ void GrGLShaderBuilder::createAndEmitEffects(GrGLProgramEffectsBuilder* programE
|
||||
this->fsCodeAppendf("\tvec4 %s;\n", outColorName.c_str());
|
||||
outColor = outColorName;
|
||||
|
||||
|
||||
programEffectsBuilder->emitEffect(stage,
|
||||
effectKeys[e],
|
||||
outColor.c_str(),
|
||||
|
Loading…
Reference in New Issue
Block a user