Add function for logging blend info on XP.

Review URL: https://codereview.chromium.org/1132373003
This commit is contained in:
bsalomon 2015-05-11 11:21:14 -07:00 committed by Commit bot
parent 8e5c177c85
commit f7cc87719e
6 changed files with 114 additions and 21 deletions

View File

@ -23,8 +23,6 @@ class GrProcOptInfo;
* Equations for alpha-blending.
*/
enum GrBlendEquation {
kInvalid_GrBlendEquation = -1,
// Basic blend equations.
kAdd_GrBlendEquation, //<! Cs*S + Cd*D
kSubtract_GrBlendEquation, //<! Cs*S - Cd*D
@ -47,11 +45,12 @@ enum GrBlendEquation {
kHSLColor_GrBlendEquation,
kHSLLuminosity_GrBlendEquation,
kTotalGrBlendEquationCount,
kFirstAdvancedGrBlendEquation = kScreen_GrBlendEquation
kFirstAdvancedGrBlendEquation = kScreen_GrBlendEquation,
kLast_GrBlendEquation = kHSLLuminosity_GrBlendEquation
};
static const int kGrBlendEquationCnt = kLast_GrBlendEquation + 1;
inline bool GrBlendEquationIsAdvanced(GrBlendEquation equation) {
return equation >= kFirstAdvancedGrBlendEquation;
}
@ -60,8 +59,6 @@ inline bool GrBlendEquationIsAdvanced(GrBlendEquation equation) {
* Coeffecients for alpha-blending.
*/
enum GrBlendCoeff {
kInvalid_GrBlendCoeff = -1,
kZero_GrBlendCoeff, //<! 0
kOne_GrBlendCoeff, //<! 1
kSC_GrBlendCoeff, //<! src color
@ -81,9 +78,11 @@ enum GrBlendCoeff {
kS2A_GrBlendCoeff,
kIS2A_GrBlendCoeff,
kTotalGrBlendCoeffCount
kLast_GrBlendCoeff = kIS2A_GrBlendCoeff
};
static const int kGrBlendCoeffCnt = kLast_GrBlendCoeff + 1;
/**
* Barriers for blending. When a shader reads the dst directly, an Xfer barrier is sometimes
* required after a pixel has been written, before it can be safely read again.
@ -187,6 +186,8 @@ public:
fWriteColor = true;
}
SkDEBUGCODE(SkString dump() const;)
GrBlendEquation fEquation;
GrBlendCoeff fSrcBlend;
GrBlendCoeff fDstBlend;

View File

@ -64,6 +64,100 @@ bool GrXferProcessor::willNeedXferBarrier(const GrRenderTarget* rt,
return this->onWillNeedXferBarrier(rt, caps, outBarrierType);
}
#ifdef SK_DEBUG
static const char* equation_string(GrBlendEquation eq) {
switch (eq) {
case kAdd_GrBlendEquation:
return "add";
case kSubtract_GrBlendEquation:
return "subtract";
case kReverseSubtract_GrBlendEquation:
return "reverse_subtract";
case kScreen_GrBlendEquation:
return "screen";
case kOverlay_GrBlendEquation:
return "overlay";
case kDarken_GrBlendEquation:
return "darken";
case kLighten_GrBlendEquation:
return "lighten";
case kColorDodge_GrBlendEquation:
return "color_dodge";
case kColorBurn_GrBlendEquation:
return "color_burn";
case kHardLight_GrBlendEquation:
return "hard_light";
case kSoftLight_GrBlendEquation:
return "soft_light";
case kDifference_GrBlendEquation:
return "difference";
case kExclusion_GrBlendEquation:
return "exclusion";
case kMultiply_GrBlendEquation:
return "multiply";
case kHSLHue_GrBlendEquation:
return "hsl_hue";
case kHSLSaturation_GrBlendEquation:
return "hsl_saturation";
case kHSLColor_GrBlendEquation:
return "hsl_color";
case kHSLLuminosity_GrBlendEquation:
return "hsl_luminosity";
};
return "";
}
static const char* coeff_string(GrBlendCoeff coeff) {
switch (coeff) {
case kZero_GrBlendCoeff:
return "zero";
case kOne_GrBlendCoeff:
return "one";
case kSC_GrBlendCoeff:
return "src_color";
case kISC_GrBlendCoeff:
return "inv_src_color";
case kDC_GrBlendCoeff:
return "dst_color";
case kIDC_GrBlendCoeff:
return "inv_dst_color";
case kSA_GrBlendCoeff:
return "src_alpha";
case kISA_GrBlendCoeff:
return "inv_src_alpha";
case kDA_GrBlendCoeff:
return "dst_alpha";
case kIDA_GrBlendCoeff:
return "inv_dst_alpha";
case kConstC_GrBlendCoeff:
return "const_color";
case kIConstC_GrBlendCoeff:
return "inv_const_color";
case kConstA_GrBlendCoeff:
return "const_alpha";
case kIConstA_GrBlendCoeff:
return "inv_const_alpha";
case kS2C_GrBlendCoeff:
return "src2_color";
case kIS2C_GrBlendCoeff:
return "inv_src2_color";
case kS2A_GrBlendCoeff:
return "src2_alpha";
case kIS2A_GrBlendCoeff:
return "inv_src2_alpha";
}
return "";
}
SkString GrXferProcessor::BlendInfo::dump() const {
SkString out;
out.printf("write_color(%d) equation(%s) src_coeff(%s) dst_coeff:(%s) const(0x%08x)",
fWriteColor, equation_string(fEquation), coeff_string(fSrcBlend),
coeff_string(fDstBlend), fBlendConstant);
return out;
}
#endif
///////////////////////////////////////////////////////////////////////////////
GrXferProcessor* GrXPFactory::createXferProcessor(const GrProcOptInfo& colorPOI,

View File

@ -48,7 +48,7 @@ static GrBlendEquation hw_blend_equation(SkXfermode::Mode mode) {
GR_STATIC_ASSERT(kHSLSaturation_GrBlendEquation == SkXfermode::kSaturation_Mode + kOffset);
GR_STATIC_ASSERT(kHSLColor_GrBlendEquation == SkXfermode::kColor_Mode + kOffset);
GR_STATIC_ASSERT(kHSLLuminosity_GrBlendEquation == SkXfermode::kLuminosity_Mode + kOffset);
GR_STATIC_ASSERT(kTotalGrBlendEquationCount == SkXfermode::kLastMode + 1 + kOffset);
GR_STATIC_ASSERT(kGrBlendEquationCnt == SkXfermode::kLastMode + 1 + kOffset);
}
static void hard_light(GrGLFragmentBuilder* fsBuilder,
@ -526,7 +526,7 @@ public:
bool hasSecondaryOutput() const override { return false; }
SkXfermode::Mode mode() const { return fMode; }
bool hasHWBlendEquation() const { return kInvalid_GrBlendEquation != fHWBlendEquation; }
bool hasHWBlendEquation() const { return -1 != static_cast<int>(fHWBlendEquation); }
GrBlendEquation hwBlendEquation() const {
SkASSERT(this->hasHWBlendEquation());
@ -630,7 +630,7 @@ CustomXP::CustomXP(SkXfermode::Mode mode, const GrDeviceCoordTexture* dstCopy,
bool willReadDstColor)
: INHERITED(dstCopy, willReadDstColor),
fMode(mode),
fHWBlendEquation(kInvalid_GrBlendEquation) {
fHWBlendEquation(static_cast<GrBlendEquation>(-1)) {
this->initClassID<CustomXP>();
}

View File

@ -80,7 +80,7 @@ GR_STATIC_ASSERT(14 == kHSLHue_GrBlendEquation);
GR_STATIC_ASSERT(15 == kHSLSaturation_GrBlendEquation);
GR_STATIC_ASSERT(16 == kHSLColor_GrBlendEquation);
GR_STATIC_ASSERT(17 == kHSLLuminosity_GrBlendEquation);
GR_STATIC_ASSERT(18 == kTotalGrBlendEquationCount);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(gXfermodeEquation2Blend) == kGrBlendEquationCnt);
static const GrGLenum gXfermodeCoeff2Blend[] = {
GR_GL_ZERO,
@ -129,8 +129,7 @@ bool GrGLGpu::BlendCoeffReferencesConstant(GrBlendCoeff coeff) {
false,
};
return gCoeffReferencesBlendConst[coeff];
GR_STATIC_ASSERT(kTotalGrBlendCoeffCount ==
SK_ARRAY_COUNT(gCoeffReferencesBlendConst));
GR_STATIC_ASSERT(kGrBlendCoeffCnt == SK_ARRAY_COUNT(gCoeffReferencesBlendConst));
GR_STATIC_ASSERT(0 == kZero_GrBlendCoeff);
GR_STATIC_ASSERT(1 == kOne_GrBlendCoeff);
@ -153,8 +152,7 @@ bool GrGLGpu::BlendCoeffReferencesConstant(GrBlendCoeff coeff) {
GR_STATIC_ASSERT(17 == kIS2A_GrBlendCoeff);
// assertion for gXfermodeCoeff2Blend have to be in GrGpu scope
GR_STATIC_ASSERT(kTotalGrBlendCoeffCount ==
SK_ARRAY_COUNT(gXfermodeCoeff2Blend));
GR_STATIC_ASSERT(kGrBlendCoeffCnt == SK_ARRAY_COUNT(gXfermodeCoeff2Blend));
}
///////////////////////////////////////////////////////////////////////////////

View File

@ -446,9 +446,9 @@ private:
TriState fEnabled;
void invalidate() {
fEquation = kInvalid_GrBlendEquation;
fSrcCoeff = kInvalid_GrBlendCoeff;
fDstCoeff = kInvalid_GrBlendCoeff;
fEquation = static_cast<GrBlendEquation>(-1);
fSrcCoeff = static_cast<GrBlendCoeff>(-1);
fDstCoeff = static_cast<GrBlendCoeff>(-1);
fConstColorValid = false;
fEnabled = kUnknown_TriState;
}

View File

@ -74,7 +74,7 @@ static const char* specific_layout_qualifier_name(GrBlendEquation equation) {
GR_STATIC_ASSERT(13 == kHSLColor_GrBlendEquation - kFirstAdvancedGrBlendEquation);
GR_STATIC_ASSERT(14 == kHSLLuminosity_GrBlendEquation - kFirstAdvancedGrBlendEquation);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kLayoutQualifierNames) ==
kTotalGrBlendEquationCount - kFirstAdvancedGrBlendEquation);
kGrBlendEquationCnt - kFirstAdvancedGrBlendEquation);
}
GrGLFragmentShaderBuilder::DstReadKey