Remove alpha versions of constant blend coeffs.

Change-Id: Iccff036e59f76f7d9651d7fd6ec005d329e3b593
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/280349
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Chris Dalton <csmartdalton@google.com>
diff --git a/src/gpu/GrBlend.h b/src/gpu/GrBlend.h
index 8b681e8..42790fe 100644
--- a/src/gpu/GrBlend.h
+++ b/src/gpu/GrBlend.h
@@ -62,8 +62,6 @@
     kIDA_GrBlendCoeff,     //<! one minus dst alpha
     kConstC_GrBlendCoeff,  //<! constant color
     kIConstC_GrBlendCoeff, //<! one minus constant color
-    kConstA_GrBlendCoeff,  //<! constant color alpha
-    kIConstA_GrBlendCoeff, //<! one minus constant color alpha
     kS2C_GrBlendCoeff,
     kIS2C_GrBlendCoeff,
     kS2A_GrBlendCoeff,
@@ -110,6 +108,10 @@
            kZero_GrBlendCoeff != srcCoeff || kOne_GrBlendCoeff != dstCoeff;
 }
 
+static constexpr bool GrBlendCoeffRefsConstant(const GrBlendCoeff coeff) {
+    return coeff == kConstC_GrBlendCoeff || coeff == kIConstC_GrBlendCoeff;
+}
+
 /**
  * Advanced blend equations can always tweak alpha for coverage. (See GrCustomXfermode.cpp)
  *
diff --git a/src/gpu/GrXferProcessor.cpp b/src/gpu/GrXferProcessor.cpp
index bcfa550..643c04e 100644
--- a/src/gpu/GrXferProcessor.cpp
+++ b/src/gpu/GrXferProcessor.cpp
@@ -123,10 +123,6 @@
             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:
diff --git a/src/gpu/dawn/GrDawnProgramBuilder.cpp b/src/gpu/dawn/GrDawnProgramBuilder.cpp
index 4acdf23..106740f 100644
--- a/src/gpu/dawn/GrDawnProgramBuilder.cpp
+++ b/src/gpu/dawn/GrDawnProgramBuilder.cpp
@@ -40,40 +40,38 @@
 
 static wgpu::BlendFactor to_dawn_blend_factor(GrBlendCoeff coeff) {
     switch (coeff) {
-    case kZero_GrBlendCoeff:
-        return wgpu::BlendFactor::Zero;
-    case kOne_GrBlendCoeff:
-        return wgpu::BlendFactor::One;
-    case kSC_GrBlendCoeff:
-        return wgpu::BlendFactor::SrcColor;
-    case kISC_GrBlendCoeff:
-        return wgpu::BlendFactor::OneMinusSrcColor;
-    case kDC_GrBlendCoeff:
-        return wgpu::BlendFactor::DstColor;
-    case kIDC_GrBlendCoeff:
-        return wgpu::BlendFactor::OneMinusDstColor;
-    case kSA_GrBlendCoeff:
-        return wgpu::BlendFactor::SrcAlpha;
-    case kISA_GrBlendCoeff:
-        return wgpu::BlendFactor::OneMinusSrcAlpha;
-    case kDA_GrBlendCoeff:
-        return wgpu::BlendFactor::DstAlpha;
-    case kIDA_GrBlendCoeff:
-        return wgpu::BlendFactor::OneMinusDstAlpha;
-    case kConstC_GrBlendCoeff:
-        return wgpu::BlendFactor::BlendColor;
-    case kIConstC_GrBlendCoeff:
-        return wgpu::BlendFactor::OneMinusBlendColor;
-    case kConstA_GrBlendCoeff:
-    case kIConstA_GrBlendCoeff:
-    case kS2C_GrBlendCoeff:
-    case kIS2C_GrBlendCoeff:
-    case kS2A_GrBlendCoeff:
-    case kIS2A_GrBlendCoeff:
-    default:
-        SkASSERT(!"unsupported blend coefficient");
-        return wgpu::BlendFactor::One;
-    }
+        case kZero_GrBlendCoeff:
+            return wgpu::BlendFactor::Zero;
+        case kOne_GrBlendCoeff:
+            return wgpu::BlendFactor::One;
+        case kSC_GrBlendCoeff:
+            return wgpu::BlendFactor::SrcColor;
+        case kISC_GrBlendCoeff:
+            return wgpu::BlendFactor::OneMinusSrcColor;
+        case kDC_GrBlendCoeff:
+            return wgpu::BlendFactor::DstColor;
+        case kIDC_GrBlendCoeff:
+            return wgpu::BlendFactor::OneMinusDstColor;
+        case kSA_GrBlendCoeff:
+            return wgpu::BlendFactor::SrcAlpha;
+        case kISA_GrBlendCoeff:
+            return wgpu::BlendFactor::OneMinusSrcAlpha;
+        case kDA_GrBlendCoeff:
+            return wgpu::BlendFactor::DstAlpha;
+        case kIDA_GrBlendCoeff:
+            return wgpu::BlendFactor::OneMinusDstAlpha;
+        case kConstC_GrBlendCoeff:
+            return wgpu::BlendFactor::BlendColor;
+        case kIConstC_GrBlendCoeff:
+            return wgpu::BlendFactor::OneMinusBlendColor;
+        case kS2C_GrBlendCoeff:
+        case kIS2C_GrBlendCoeff:
+        case kS2A_GrBlendCoeff:
+        case kIS2A_GrBlendCoeff:
+        default:
+            SkASSERT(!"unsupported blend coefficient");
+            return wgpu::BlendFactor::One;
+        }
 }
 
 static wgpu::BlendFactor to_dawn_blend_factor_for_alpha(GrBlendCoeff coeff) {
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 0397fb8..94b18ff 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -119,8 +119,6 @@
     GR_GL_ONE_MINUS_DST_ALPHA,
     GR_GL_CONSTANT_COLOR,
     GR_GL_ONE_MINUS_CONSTANT_COLOR,
-    GR_GL_CONSTANT_ALPHA,
-    GR_GL_ONE_MINUS_CONSTANT_ALPHA,
 
     // extended blend coeffs
     GR_GL_SRC1_COLOR,
@@ -132,59 +130,6 @@
     GR_GL_ZERO,
 };
 
-bool GrGLGpu::BlendCoeffReferencesConstant(GrBlendCoeff coeff) {
-    static const bool gCoeffReferencesBlendConst[] = {
-        false,
-        false,
-        false,
-        false,
-        false,
-        false,
-        false,
-        false,
-        false,
-        false,
-        true,
-        true,
-        true,
-        true,
-
-        // extended blend coeffs
-        false,
-        false,
-        false,
-        false,
-
-        // Illegal.
-        false,
-    };
-    return gCoeffReferencesBlendConst[coeff];
-    static_assert(kGrBlendCoeffCnt == SK_ARRAY_COUNT(gCoeffReferencesBlendConst));
-
-    static_assert(0 == kZero_GrBlendCoeff);
-    static_assert(1 == kOne_GrBlendCoeff);
-    static_assert(2 == kSC_GrBlendCoeff);
-    static_assert(3 == kISC_GrBlendCoeff);
-    static_assert(4 == kDC_GrBlendCoeff);
-    static_assert(5 == kIDC_GrBlendCoeff);
-    static_assert(6 == kSA_GrBlendCoeff);
-    static_assert(7 == kISA_GrBlendCoeff);
-    static_assert(8 == kDA_GrBlendCoeff);
-    static_assert(9 == kIDA_GrBlendCoeff);
-    static_assert(10 == kConstC_GrBlendCoeff);
-    static_assert(11 == kIConstC_GrBlendCoeff);
-    static_assert(12 == kConstA_GrBlendCoeff);
-    static_assert(13 == kIConstA_GrBlendCoeff);
-
-    static_assert(14 == kS2C_GrBlendCoeff);
-    static_assert(15 == kIS2C_GrBlendCoeff);
-    static_assert(16 == kS2A_GrBlendCoeff);
-    static_assert(17 == kIS2A_GrBlendCoeff);
-
-    // assertion for gXfermodeCoeff2Blend have to be in GrGpu scope
-    static_assert(kGrBlendCoeffCnt == SK_ARRAY_COUNT(gXfermodeCoeff2Blend));
-}
-
 //////////////////////////////////////////////////////////////////////////////
 
 static int gl_target_to_binding_index(GrGLenum target) {
@@ -2595,7 +2540,7 @@
             fHWBlendState.fDstCoeff = dstCoeff;
         }
 
-        if ((BlendCoeffReferencesConstant(srcCoeff) || BlendCoeffReferencesConstant(dstCoeff))) {
+        if ((GrBlendCoeffRefsConstant(srcCoeff) || GrBlendCoeffRefsConstant(dstCoeff))) {
             SkPMColor4f blendConst = swizzle.applyTo(blendInfo.fBlendConstant);
             if (!fHWBlendState.fConstColorValid || fHWBlendState.fConstColor != blendConst) {
                 GL_CALL(BlendColor(blendConst.fR, blendConst.fG, blendConst.fB, blendConst.fA));
diff --git a/src/gpu/mtl/GrMtlPipelineState.mm b/src/gpu/mtl/GrMtlPipelineState.mm
index 8550fab..8ec6a65 100644
--- a/src/gpu/mtl/GrMtlPipelineState.mm
+++ b/src/gpu/mtl/GrMtlPipelineState.mm
@@ -160,18 +160,6 @@
     }
 }
 
-static bool blend_coeff_refs_constant(GrBlendCoeff coeff) {
-    switch (coeff) {
-        case kConstC_GrBlendCoeff:
-        case kIConstC_GrBlendCoeff:
-        case kConstA_GrBlendCoeff:
-        case kIConstA_GrBlendCoeff:
-            return true;
-        default:
-            return false;
-    }
-}
-
 void GrMtlPipelineState::setBlendConstants(id<MTLRenderCommandEncoder> renderCmdEncoder,
                                            const GrSwizzle& swizzle,
                                            const GrXferProcessor& xferProcessor) {
@@ -182,7 +170,7 @@
     const GrXferProcessor::BlendInfo& blendInfo = xferProcessor.getBlendInfo();
     GrBlendCoeff srcCoeff = blendInfo.fSrcBlend;
     GrBlendCoeff dstCoeff = blendInfo.fDstBlend;
-    if (blend_coeff_refs_constant(srcCoeff) || blend_coeff_refs_constant(dstCoeff)) {
+    if (GrBlendCoeffRefsConstant(srcCoeff) || GrBlendCoeffRefsConstant(dstCoeff)) {
         // Swizzle the blend to match what the shader will output.
         SkPMColor4f blendConst = swizzle.applyTo(blendInfo.fBlendConstant);
 
diff --git a/src/gpu/mtl/GrMtlPipelineStateBuilder.mm b/src/gpu/mtl/GrMtlPipelineStateBuilder.mm
index 6a452ae..e98cccb1 100644
--- a/src/gpu/mtl/GrMtlPipelineStateBuilder.mm
+++ b/src/gpu/mtl/GrMtlPipelineStateBuilder.mm
@@ -287,10 +287,6 @@
             return MTLBlendFactorBlendColor;
         case kIConstC_GrBlendCoeff:
             return MTLBlendFactorOneMinusBlendColor;
-        case kConstA_GrBlendCoeff:
-            return MTLBlendFactorBlendAlpha;
-        case kIConstA_GrBlendCoeff:
-            return MTLBlendFactorOneMinusBlendAlpha;
         case kS2C_GrBlendCoeff:
             if (@available(macOS 10.12, iOS 11.0, *)) {
                 return MTLBlendFactorSource1Color;
diff --git a/src/gpu/vk/GrVkPipeline.cpp b/src/gpu/vk/GrVkPipeline.cpp
index 9e2e3fa..52dd2b4 100644
--- a/src/gpu/vk/GrVkPipeline.cpp
+++ b/src/gpu/vk/GrVkPipeline.cpp
@@ -329,52 +329,45 @@
 }
 
 static VkBlendFactor blend_coeff_to_vk_blend(GrBlendCoeff coeff) {
-    static const VkBlendFactor gTable[] = {
-        VK_BLEND_FACTOR_ZERO,                      // kZero_GrBlendCoeff
-        VK_BLEND_FACTOR_ONE,                       // kOne_GrBlendCoeff
-        VK_BLEND_FACTOR_SRC_COLOR,                 // kSC_GrBlendCoeff
-        VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR,       // kISC_GrBlendCoeff
-        VK_BLEND_FACTOR_DST_COLOR,                 // kDC_GrBlendCoeff
-        VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR,       // kIDC_GrBlendCoeff
-        VK_BLEND_FACTOR_SRC_ALPHA,                 // kSA_GrBlendCoeff
-        VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,       // kISA_GrBlendCoeff
-        VK_BLEND_FACTOR_DST_ALPHA,                 // kDA_GrBlendCoeff
-        VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA,       // kIDA_GrBlendCoeff
-        VK_BLEND_FACTOR_CONSTANT_COLOR,            // kConstC_GrBlendCoeff
-        VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR,  // kIConstC_GrBlendCoeff
-        VK_BLEND_FACTOR_CONSTANT_ALPHA,            // kConstA_GrBlendCoeff
-        VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA,  // kIConstA_GrBlendCoeff
-        VK_BLEND_FACTOR_SRC1_COLOR,                // kS2C_GrBlendCoeff
-        VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR,      // kIS2C_GrBlendCoeff
-        VK_BLEND_FACTOR_SRC1_ALPHA,                // kS2A_GrBlendCoeff
-        VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA,      // kIS2A_GrBlendCoeff
-        VK_BLEND_FACTOR_ZERO,                      // kIllegal_GrBlendCoeff
-    };
-    static_assert(SK_ARRAY_COUNT(gTable) == kGrBlendCoeffCnt);
-    static_assert(0 == kZero_GrBlendCoeff);
-    static_assert(1 == kOne_GrBlendCoeff);
-    static_assert(2 == kSC_GrBlendCoeff);
-    static_assert(3 == kISC_GrBlendCoeff);
-    static_assert(4 == kDC_GrBlendCoeff);
-    static_assert(5 == kIDC_GrBlendCoeff);
-    static_assert(6 == kSA_GrBlendCoeff);
-    static_assert(7 == kISA_GrBlendCoeff);
-    static_assert(8 == kDA_GrBlendCoeff);
-    static_assert(9 == kIDA_GrBlendCoeff);
-    static_assert(10 == kConstC_GrBlendCoeff);
-    static_assert(11 == kIConstC_GrBlendCoeff);
-    static_assert(12 == kConstA_GrBlendCoeff);
-    static_assert(13 == kIConstA_GrBlendCoeff);
-    static_assert(14 == kS2C_GrBlendCoeff);
-    static_assert(15 == kIS2C_GrBlendCoeff);
-    static_assert(16 == kS2A_GrBlendCoeff);
-    static_assert(17 == kIS2A_GrBlendCoeff);
-
-    SkASSERT((unsigned)coeff < kGrBlendCoeffCnt);
-    return gTable[coeff];
+    switch (coeff) {
+        case kZero_GrBlendCoeff:
+            return VK_BLEND_FACTOR_ZERO;
+        case kOne_GrBlendCoeff:
+            return VK_BLEND_FACTOR_ONE;
+        case kSC_GrBlendCoeff:
+            return VK_BLEND_FACTOR_SRC_COLOR;
+        case kISC_GrBlendCoeff:
+            return VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR;
+        case kDC_GrBlendCoeff:
+            return VK_BLEND_FACTOR_DST_COLOR;
+        case kIDC_GrBlendCoeff:
+            return VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR;
+        case kSA_GrBlendCoeff:
+            return VK_BLEND_FACTOR_SRC_ALPHA;
+        case kISA_GrBlendCoeff:
+            return VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
+        case kDA_GrBlendCoeff:
+            return VK_BLEND_FACTOR_DST_ALPHA;
+        case kIDA_GrBlendCoeff:
+            return VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA;
+        case kConstC_GrBlendCoeff:
+            return VK_BLEND_FACTOR_CONSTANT_COLOR;
+        case kIConstC_GrBlendCoeff:
+            return VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR;
+        case kS2C_GrBlendCoeff:
+            return VK_BLEND_FACTOR_SRC1_COLOR;
+        case kIS2C_GrBlendCoeff:
+            return VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR;
+        case kS2A_GrBlendCoeff:
+            return VK_BLEND_FACTOR_SRC1_ALPHA;
+        case kIS2A_GrBlendCoeff:
+            return VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA;
+        case kIllegal_GrBlendCoeff:
+            return VK_BLEND_FACTOR_ZERO;
+    }
+    SkUNREACHABLE;
 }
 
-
 static VkBlendOp blend_equation_to_vk_blend_op(GrBlendEquation equation) {
     static const VkBlendOp gTable[] = {
         // Basic blend ops
@@ -422,41 +415,10 @@
     static_assert(17 == kHSLLuminosity_GrBlendEquation);
     static_assert(SK_ARRAY_COUNT(gTable) == kGrBlendEquationCnt);
 
-    SkASSERT((unsigned)equation < kGrBlendCoeffCnt);
+    SkASSERT((unsigned)equation < kGrBlendEquationCnt);
     return gTable[equation];
 }
 
-static bool blend_coeff_refs_constant(GrBlendCoeff coeff) {
-    static const bool gCoeffReferencesBlendConst[] = {
-        false,
-        false,
-        false,
-        false,
-        false,
-        false,
-        false,
-        false,
-        false,
-        false,
-        true,
-        true,
-        true,
-        true,
-
-        // extended blend coeffs
-        false,
-        false,
-        false,
-        false,
-
-        // Illegal
-        false,
-    };
-    return gCoeffReferencesBlendConst[coeff];
-    static_assert(kGrBlendCoeffCnt == SK_ARRAY_COUNT(gCoeffReferencesBlendConst));
-    // Individual enum asserts already made in blend_coeff_to_vk_blend
-}
-
 static void setup_color_blend_state(const GrPipeline& pipeline,
                                     VkPipelineColorBlendStateCreateInfo* colorBlendInfo,
                                     VkPipelineColorBlendAttachmentState* attachmentState) {
@@ -701,7 +663,7 @@
     GrBlendCoeff srcCoeff = blendInfo.fSrcBlend;
     GrBlendCoeff dstCoeff = blendInfo.fDstBlend;
     float floatColors[4];
-    if (blend_coeff_refs_constant(srcCoeff) || blend_coeff_refs_constant(dstCoeff)) {
+    if (GrBlendCoeffRefsConstant(srcCoeff) || GrBlendCoeffRefsConstant(dstCoeff)) {
         // Swizzle the blend to match what the shader will output.
         SkPMColor4f blendConst = swizzle.applyTo(blendInfo.fBlendConstant);
         floatColors[0] = blendConst.fR;