From f7cc87719e53df86784d0d953b88c45a3be38953 Mon Sep 17 00:00:00 2001 From: bsalomon Date: Mon, 11 May 2015 11:21:14 -0700 Subject: [PATCH] Add function for logging blend info on XP. Review URL: https://codereview.chromium.org/1132373003 --- include/gpu/GrXferProcessor.h | 17 ++-- src/gpu/GrXferProcessor.cpp | 94 +++++++++++++++++++++++ src/gpu/effects/GrCustomXfermode.cpp | 6 +- src/gpu/gl/GrGLGpu.cpp | 10 +-- src/gpu/gl/GrGLGpu.h | 6 +- src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp | 2 +- 6 files changed, 114 insertions(+), 21 deletions(-) diff --git a/include/gpu/GrXferProcessor.h b/include/gpu/GrXferProcessor.h index 812ce5c..fa9dca2 100644 --- a/include/gpu/GrXferProcessor.h +++ b/include/gpu/GrXferProcessor.h @@ -23,8 +23,6 @@ class GrProcOptInfo; * Equations for alpha-blending. */ enum GrBlendEquation { - kInvalid_GrBlendEquation = -1, - // Basic blend equations. kAdd_GrBlendEquation, //= kFirstAdvancedGrBlendEquation; } @@ -60,8 +59,6 @@ inline bool GrBlendEquationIsAdvanced(GrBlendEquation equation) { * Coeffecients for alpha-blending. */ enum GrBlendCoeff { - kInvalid_GrBlendCoeff = -1, - kZero_GrBlendCoeff, //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, diff --git a/src/gpu/effects/GrCustomXfermode.cpp b/src/gpu/effects/GrCustomXfermode.cpp index 0a525b4..4963198 100644 --- a/src/gpu/effects/GrCustomXfermode.cpp +++ b/src/gpu/effects/GrCustomXfermode.cpp @@ -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(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(-1)) { this->initClassID(); } diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index a212b2b..122331d 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -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)); } /////////////////////////////////////////////////////////////////////////////// @@ -2121,7 +2119,7 @@ void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) { void GrGLGpu::flushBlend(const GrXferProcessor::BlendInfo& blendInfo) { // Any optimization to disable blending should have already been applied and // tweaked the equation to "add" or "subtract", and the coeffs to (1, 0). - + GrBlendEquation equation = blendInfo.fEquation; GrBlendCoeff srcCoeff = blendInfo.fSrcBlend; GrBlendCoeff dstCoeff = blendInfo.fDstBlend; diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h index 016547f..e1bc869 100644 --- a/src/gpu/gl/GrGLGpu.h +++ b/src/gpu/gl/GrGLGpu.h @@ -446,9 +446,9 @@ private: TriState fEnabled; void invalidate() { - fEquation = kInvalid_GrBlendEquation; - fSrcCoeff = kInvalid_GrBlendCoeff; - fDstCoeff = kInvalid_GrBlendCoeff; + fEquation = static_cast(-1); + fSrcCoeff = static_cast(-1); + fDstCoeff = static_cast(-1); fConstColorValid = false; fEnabled = kUnknown_TriState; } diff --git a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp index 8fcb0b9..044752f 100644 --- a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp +++ b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp @@ -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 -- 2.7.4