[graphite] Make GrBlend shareable between Graphite and Ganesh

Additionally make the enums enum-classes.

We will need this to specify fixed function blend modes in Graphite.

This CL is mainly mechanical (i.e., global replace) but some fix-ups were required for our internal bit twiddling with the enum-classes.

Bug: skia:12701
Change-Id: I67abcf8274d14e691974cf253bf65dcb4697bd9a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/515318
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2022-03-04 12:28:48 -05:00 committed by SkCQ
parent 5e9388d170
commit 0c43db950c
26 changed files with 856 additions and 824 deletions

View File

@ -47,7 +47,6 @@ skia_gpu_sources = [
"$_src/gpu/GrBackendUtils.cpp",
"$_src/gpu/GrBackendUtils.h",
"$_src/gpu/GrBaseContextPriv.h",
"$_src/gpu/GrBlend.h",
"$_src/gpu/GrBuffer.h",
"$_src/gpu/GrBufferAllocPool.cpp",
"$_src/gpu/GrBufferAllocPool.h",
@ -816,6 +815,7 @@ skia_native_gpu_sources = [
skia_shared_gpu_sources = [
"$_include/gpu/ShaderErrorHandler.h",
"$_include/private/SingleOwner.h",
"$_src/gpu/Blend.h",
"$_src/gpu/BufferWriter.h",
"$_src/gpu/KeyBuilder.h",
"$_src/gpu/ResourceKey.cpp",

View File

@ -83,7 +83,7 @@ skvm::Color SkModeColorFilter::onProgram(skvm::Builder* p, skvm::Color c,
///////////////////////////////////////////////////////////////////////////////
#if SK_SUPPORT_GPU
#include "src/gpu/GrBlend.h"
#include "src/gpu/Blend.h"
#include "src/gpu/GrFragmentProcessor.h"
#include "src/gpu/SkGr.h"
#include "src/gpu/effects/GrBlendFragmentProcessor.h"

168
src/gpu/Blend.h Normal file
View File

@ -0,0 +1,168 @@
/*
* Copyright 2013 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef skgpu_Blend_DEFINED
#define skgpu_Blend_DEFINED
#include "include/core/SkTypes.h"
namespace skgpu {
/**
* Equations for alpha-blending.
*/
enum class BlendEquation {
// Basic blend equations.
kAdd, //<! Cs*S + Cd*D
kSubtract, //<! Cs*S - Cd*D
kReverseSubtract, //<! Cd*D - Cs*S
// Advanced blend equations. These are described in the SVG and PDF specs.
kScreen,
kOverlay,
kDarken,
kLighten,
kColorDodge,
kColorBurn,
kHardLight,
kSoftLight,
kDifference,
kExclusion,
kMultiply,
kHSLHue,
kHSLSaturation,
kHSLColor,
kHSLLuminosity,
kIllegal,
kFirstAdvanced = kScreen,
kLast = kIllegal,
};
static const int kBlendEquationCnt = static_cast<int>(BlendEquation::kLast) + 1;
/**
* Coefficients for alpha-blending.
*/
enum class BlendCoeff {
kZero, //<! 0
kOne, //<! 1
kSC, //<! src color
kISC, //<! one minus src color
kDC, //<! dst color
kIDC, //<! one minus dst color
kSA, //<! src alpha
kISA, //<! one minus src alpha
kDA, //<! dst alpha
kIDA, //<! one minus dst alpha
kConstC, //<! constant color
kIConstC, //<! one minus constant color
kS2C,
kIS2C,
kS2A,
kIS2A,
kIllegal,
kLast = kIllegal,
};
static const int kBlendCoeffCnt = static_cast<int>(BlendCoeff::kLast) + 1;
static constexpr bool BlendCoeffRefsSrc(const BlendCoeff coeff) {
return BlendCoeff::kSC == coeff || BlendCoeff::kISC == coeff || BlendCoeff::kSA == coeff ||
BlendCoeff::kISA == coeff;
}
static constexpr bool BlendCoeffRefsDst(const BlendCoeff coeff) {
return BlendCoeff::kDC == coeff || BlendCoeff::kIDC == coeff || BlendCoeff::kDA == coeff ||
BlendCoeff::kIDA == coeff;
}
static constexpr bool BlendCoeffRefsSrc2(const BlendCoeff coeff) {
return BlendCoeff::kS2C == coeff || BlendCoeff::kIS2C == coeff ||
BlendCoeff::kS2A == coeff || BlendCoeff::kIS2A == coeff;
}
static constexpr bool BlendCoeffsUseSrcColor(BlendCoeff srcCoeff, BlendCoeff dstCoeff) {
return BlendCoeff::kZero != srcCoeff || BlendCoeffRefsSrc(dstCoeff);
}
static constexpr bool BlendCoeffsUseDstColor(BlendCoeff srcCoeff,
BlendCoeff dstCoeff,
bool srcColorIsOpaque) {
return BlendCoeffRefsDst(srcCoeff) ||
(dstCoeff != BlendCoeff::kZero && !(dstCoeff == BlendCoeff::kISA && srcColorIsOpaque));
}
static constexpr bool BlendEquationIsAdvanced(BlendEquation equation) {
return equation >= BlendEquation::kFirstAdvanced &&
equation != BlendEquation::kIllegal;
}
static constexpr bool BlendModifiesDst(BlendEquation equation,
BlendCoeff srcCoeff,
BlendCoeff dstCoeff) {
return (BlendEquation::kAdd != equation && BlendEquation::kReverseSubtract != equation) ||
BlendCoeff::kZero != srcCoeff || BlendCoeff::kOne != dstCoeff;
}
static constexpr bool BlendCoeffRefsConstant(const BlendCoeff coeff) {
return coeff == BlendCoeff::kConstC || coeff == BlendCoeff::kIConstC;
}
static constexpr bool BlendShouldDisable(BlendEquation equation,
BlendCoeff srcCoeff,
BlendCoeff dstCoeff) {
return (BlendEquation::kAdd == equation || BlendEquation::kSubtract == equation) &&
BlendCoeff::kOne == srcCoeff && BlendCoeff::kZero == dstCoeff;
}
/**
* Advanced blend equations can always tweak alpha for coverage. (See GrCustomXfermode.cpp)
*
* For "add" and "reverse subtract" the blend equation with f=coverage is:
*
* D' = f * (S * srcCoeff + D * dstCoeff) + (1-f) * D
* = f * S * srcCoeff + D * (f * dstCoeff + (1 - f))
*
* (Let srcCoeff be negative for reverse subtract.) We can tweak alpha for coverage when the
* following relationship holds:
*
* (f*S) * srcCoeff' + D * dstCoeff' == f * S * srcCoeff + D * (f * dstCoeff + (1 - f))
*
* (Where srcCoeff' and dstCoeff' have any reference to S pre-multiplied by f.)
*
* It's easy to see this works for the src term as long as srcCoeff' == srcCoeff (meaning srcCoeff
* does not reference S). For the dst term, this will work as long as the following is true:
*|
* dstCoeff' == f * dstCoeff + (1 - f)
* dstCoeff' == 1 - f * (1 - dstCoeff)
*
* By inspection we can see this will work as long as dstCoeff has a 1, and any other term in
* dstCoeff references S.
*
* Moreover, if the blend doesn't modify the dst at all then it is ok to arbitrarily modify the src
* color so folding in coverage is allowed.
*/
static constexpr bool BlendAllowsCoverageAsAlpha(BlendEquation equation,
BlendCoeff srcCoeff,
BlendCoeff dstCoeff) {
return BlendEquationIsAdvanced(equation) ||
!BlendModifiesDst(equation, srcCoeff, dstCoeff) ||
((BlendEquation::kAdd == equation || BlendEquation::kReverseSubtract == equation) &&
!BlendCoeffRefsSrc(srcCoeff) &&
(BlendCoeff::kOne == dstCoeff || BlendCoeff::kISC == dstCoeff ||
BlendCoeff::kISA == dstCoeff));
}
} // namespace skgpu
#endif // skgpu_Blend_DEFINED

View File

@ -1,161 +0,0 @@
/*
* Copyright 2013 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrBlend_DEFINED
#define GrBlend_DEFINED
#include "include/core/SkTypes.h"
/**
* Equations for alpha-blending.
*/
enum GrBlendEquation {
// Basic blend equations.
kAdd_GrBlendEquation, //<! Cs*S + Cd*D
kSubtract_GrBlendEquation, //<! Cs*S - Cd*D
kReverseSubtract_GrBlendEquation, //<! Cd*D - Cs*S
// Advanced blend equations. These are described in the SVG and PDF specs.
kScreen_GrBlendEquation,
kOverlay_GrBlendEquation,
kDarken_GrBlendEquation,
kLighten_GrBlendEquation,
kColorDodge_GrBlendEquation,
kColorBurn_GrBlendEquation,
kHardLight_GrBlendEquation,
kSoftLight_GrBlendEquation,
kDifference_GrBlendEquation,
kExclusion_GrBlendEquation,
kMultiply_GrBlendEquation,
kHSLHue_GrBlendEquation,
kHSLSaturation_GrBlendEquation,
kHSLColor_GrBlendEquation,
kHSLLuminosity_GrBlendEquation,
kIllegal_GrBlendEquation,
kFirstAdvancedGrBlendEquation = kScreen_GrBlendEquation,
kLast_GrBlendEquation = kIllegal_GrBlendEquation,
};
static const int kGrBlendEquationCnt = kLast_GrBlendEquation + 1;
/**
* Coefficients for alpha-blending.
*/
enum GrBlendCoeff {
kZero_GrBlendCoeff, //<! 0
kOne_GrBlendCoeff, //<! 1
kSC_GrBlendCoeff, //<! src color
kISC_GrBlendCoeff, //<! one minus src color
kDC_GrBlendCoeff, //<! dst color
kIDC_GrBlendCoeff, //<! one minus dst color
kSA_GrBlendCoeff, //<! src alpha
kISA_GrBlendCoeff, //<! one minus src alpha
kDA_GrBlendCoeff, //<! dst alpha
kIDA_GrBlendCoeff, //<! one minus dst alpha
kConstC_GrBlendCoeff, //<! constant color
kIConstC_GrBlendCoeff, //<! one minus constant color
kS2C_GrBlendCoeff,
kIS2C_GrBlendCoeff,
kS2A_GrBlendCoeff,
kIS2A_GrBlendCoeff,
kIllegal_GrBlendCoeff,
kLast_GrBlendCoeff = kIllegal_GrBlendCoeff,
};
static const int kGrBlendCoeffCnt = kLast_GrBlendCoeff + 1;
static constexpr bool GrBlendCoeffRefsSrc(const GrBlendCoeff coeff) {
return kSC_GrBlendCoeff == coeff || kISC_GrBlendCoeff == coeff || kSA_GrBlendCoeff == coeff ||
kISA_GrBlendCoeff == coeff;
}
static constexpr bool GrBlendCoeffRefsDst(const GrBlendCoeff coeff) {
return kDC_GrBlendCoeff == coeff || kIDC_GrBlendCoeff == coeff || kDA_GrBlendCoeff == coeff ||
kIDA_GrBlendCoeff == coeff;
}
static constexpr bool GrBlendCoeffRefsSrc2(const GrBlendCoeff coeff) {
return kS2C_GrBlendCoeff == coeff || kIS2C_GrBlendCoeff == coeff ||
kS2A_GrBlendCoeff == coeff || kIS2A_GrBlendCoeff == coeff;
}
static constexpr bool GrBlendCoeffsUseSrcColor(GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff) {
return kZero_GrBlendCoeff != srcCoeff || GrBlendCoeffRefsSrc(dstCoeff);
}
static constexpr bool GrBlendCoeffsUseDstColor(GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff,
bool srcColorIsOpaque) {
return GrBlendCoeffRefsDst(srcCoeff) ||
(dstCoeff != kZero_GrBlendCoeff && !(dstCoeff == kISA_GrBlendCoeff && srcColorIsOpaque));
}
static constexpr bool GrBlendEquationIsAdvanced(GrBlendEquation equation) {
return equation >= kFirstAdvancedGrBlendEquation
&& equation != kIllegal_GrBlendEquation;
}
static constexpr bool GrBlendModifiesDst(GrBlendEquation equation, GrBlendCoeff srcCoeff,
GrBlendCoeff dstCoeff) {
return (kAdd_GrBlendEquation != equation && kReverseSubtract_GrBlendEquation != equation) ||
kZero_GrBlendCoeff != srcCoeff || kOne_GrBlendCoeff != dstCoeff;
}
static constexpr bool GrBlendCoeffRefsConstant(const GrBlendCoeff coeff) {
return coeff == kConstC_GrBlendCoeff || coeff == kIConstC_GrBlendCoeff;
}
static constexpr bool GrBlendShouldDisable(GrBlendEquation equation, GrBlendCoeff srcCoeff,
GrBlendCoeff dstCoeff) {
return (kAdd_GrBlendEquation == equation || kSubtract_GrBlendEquation == equation) &&
kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCoeff;
}
/**
* Advanced blend equations can always tweak alpha for coverage. (See GrCustomXfermode.cpp)
*
* For "add" and "reverse subtract" the blend equation with f=coverage is:
*
* D' = f * (S * srcCoeff + D * dstCoeff) + (1-f) * D
* = f * S * srcCoeff + D * (f * dstCoeff + (1 - f))
*
* (Let srcCoeff be negative for reverse subtract.) We can tweak alpha for coverage when the
* following relationship holds:
*
* (f*S) * srcCoeff' + D * dstCoeff' == f * S * srcCoeff + D * (f * dstCoeff + (1 - f))
*
* (Where srcCoeff' and dstCoeff' have any reference to S pre-multiplied by f.)
*
* It's easy to see this works for the src term as long as srcCoeff' == srcCoeff (meaning srcCoeff
* does not reference S). For the dst term, this will work as long as the following is true:
*|
* dstCoeff' == f * dstCoeff + (1 - f)
* dstCoeff' == 1 - f * (1 - dstCoeff)
*
* By inspection we can see this will work as long as dstCoeff has a 1, and any other term in
* dstCoeff references S.
*
* Moreover, if the blend doesn't modify the dst at all then it is ok to arbitrarily modify the src
* color so folding in coverage is allowed.
*/
static constexpr bool GrBlendAllowsCoverageAsAlpha(GrBlendEquation equation,
GrBlendCoeff srcCoeff,
GrBlendCoeff dstCoeff) {
return GrBlendEquationIsAdvanced(equation) ||
!GrBlendModifiesDst(equation, srcCoeff, dstCoeff) ||
((kAdd_GrBlendEquation == equation || kReverseSubtract_GrBlendEquation == equation) &&
!GrBlendCoeffRefsSrc(srcCoeff) &&
(kOne_GrBlendCoeff == dstCoeff || kISC_GrBlendCoeff == dstCoeff ||
kISA_GrBlendCoeff == dstCoeff));
}
#endif

View File

@ -14,7 +14,7 @@
#include "include/gpu/GrDriverBugWorkarounds.h"
#include "include/private/GrTypesPriv.h"
#include "src/core/SkCompressedDataUtils.h"
#include "src/gpu/GrBlend.h"
#include "src/gpu/Blend.h"
#include "src/gpu/GrSamplerState.h"
#include "src/gpu/GrShaderCaps.h"
#include "src/gpu/GrSurfaceProxy.h"
@ -149,10 +149,10 @@ public:
return kAdvancedCoherent_BlendEquationSupport == fBlendEquationSupport;
}
bool isAdvancedBlendEquationDisabled(GrBlendEquation equation) const {
SkASSERT(GrBlendEquationIsAdvanced(equation));
bool isAdvancedBlendEquationDisabled(skgpu::BlendEquation equation) const {
SkASSERT(skgpu::BlendEquationIsAdvanced(equation));
SkASSERT(this->advancedBlendEquationSupport());
return SkToBool(fAdvBlendEqDisableFlags & (1 << equation));
return SkToBool(fAdvBlendEqDisableFlags & (1 << static_cast<int>(equation)));
}
// On some GPUs it is a performance win to disable blending instead of doing src-over with a src
@ -597,7 +597,7 @@ protected:
BlendEquationSupport fBlendEquationSupport;
uint32_t fAdvBlendEqDisableFlags;
static_assert(kLast_GrBlendEquation < 32);
static_assert(static_cast<int>(skgpu::BlendEquation::kLast) < 32);
uint32_t fMapBufferFlags;
int fBufferMapThreshold;

View File

@ -84,13 +84,13 @@ void GrPipeline::genKey(skgpu::KeyBuilder* b, const GrCaps& caps) const {
static constexpr uint32_t kBlendCoeffSize = 5;
static constexpr uint32_t kBlendEquationSize = 5;
static_assert(kLast_GrBlendCoeff < (1 << kBlendCoeffSize));
static_assert(kLast_GrBlendEquation < (1 << kBlendEquationSize));
static_assert(static_cast<int>(skgpu::BlendCoeff::kLast) < (1 << kBlendCoeffSize));
static_assert(static_cast<int>(skgpu::BlendEquation::kLast) < (1 << kBlendEquationSize));
b->addBool(blendInfo.fWriteColor, "writeColor");
b->addBits(kBlendCoeffSize, blendInfo.fSrcBlend, "srcBlend");
b->addBits(kBlendCoeffSize, blendInfo.fDstBlend, "dstBlend");
b->addBits(kBlendEquationSize, blendInfo.fEquation, "equation");
b->addBits(kBlendCoeffSize, static_cast<int>(blendInfo.fSrcBlend), "srcBlend");
b->addBits(kBlendCoeffSize, static_cast<int>(blendInfo.fDstBlend), "dstBlend");
b->addBits(kBlendEquationSize, static_cast<int>(blendInfo.fEquation), "equation");
b->addBool(this->usesDstInputAttachment(), "inputAttach");
}

View File

@ -55,86 +55,86 @@ void GrXferProcessor::addToKey(const GrShaderCaps& caps,
}
#ifdef SK_DEBUG
static const char* equation_string(GrBlendEquation eq) {
static const char* equation_string(skgpu::BlendEquation eq) {
switch (eq) {
case kAdd_GrBlendEquation:
case skgpu::BlendEquation::kAdd:
return "add";
case kSubtract_GrBlendEquation:
case skgpu::BlendEquation::kSubtract:
return "subtract";
case kReverseSubtract_GrBlendEquation:
case skgpu::BlendEquation::kReverseSubtract:
return "reverse_subtract";
case kScreen_GrBlendEquation:
case skgpu::BlendEquation::kScreen:
return "screen";
case kOverlay_GrBlendEquation:
case skgpu::BlendEquation::kOverlay:
return "overlay";
case kDarken_GrBlendEquation:
case skgpu::BlendEquation::kDarken:
return "darken";
case kLighten_GrBlendEquation:
case skgpu::BlendEquation::kLighten:
return "lighten";
case kColorDodge_GrBlendEquation:
case skgpu::BlendEquation::kColorDodge:
return "color_dodge";
case kColorBurn_GrBlendEquation:
case skgpu::BlendEquation::kColorBurn:
return "color_burn";
case kHardLight_GrBlendEquation:
case skgpu::BlendEquation::kHardLight:
return "hard_light";
case kSoftLight_GrBlendEquation:
case skgpu::BlendEquation::kSoftLight:
return "soft_light";
case kDifference_GrBlendEquation:
case skgpu::BlendEquation::kDifference:
return "difference";
case kExclusion_GrBlendEquation:
case skgpu::BlendEquation::kExclusion:
return "exclusion";
case kMultiply_GrBlendEquation:
case skgpu::BlendEquation::kMultiply:
return "multiply";
case kHSLHue_GrBlendEquation:
case skgpu::BlendEquation::kHSLHue:
return "hsl_hue";
case kHSLSaturation_GrBlendEquation:
case skgpu::BlendEquation::kHSLSaturation:
return "hsl_saturation";
case kHSLColor_GrBlendEquation:
case skgpu::BlendEquation::kHSLColor:
return "hsl_color";
case kHSLLuminosity_GrBlendEquation:
case skgpu::BlendEquation::kHSLLuminosity:
return "hsl_luminosity";
case kIllegal_GrBlendEquation:
case skgpu::BlendEquation::kIllegal:
SkASSERT(false);
return "<illegal>";
}
return "";
}
static const char* coeff_string(GrBlendCoeff coeff) {
static const char* coeff_string(skgpu::BlendCoeff coeff) {
switch (coeff) {
case kZero_GrBlendCoeff:
case skgpu::BlendCoeff::kZero:
return "zero";
case kOne_GrBlendCoeff:
case skgpu::BlendCoeff::kOne:
return "one";
case kSC_GrBlendCoeff:
case skgpu::BlendCoeff::kSC:
return "src_color";
case kISC_GrBlendCoeff:
case skgpu::BlendCoeff::kISC:
return "inv_src_color";
case kDC_GrBlendCoeff:
case skgpu::BlendCoeff::kDC:
return "dst_color";
case kIDC_GrBlendCoeff:
case skgpu::BlendCoeff::kIDC:
return "inv_dst_color";
case kSA_GrBlendCoeff:
case skgpu::BlendCoeff::kSA:
return "src_alpha";
case kISA_GrBlendCoeff:
case skgpu::BlendCoeff::kISA:
return "inv_src_alpha";
case kDA_GrBlendCoeff:
case skgpu::BlendCoeff::kDA:
return "dst_alpha";
case kIDA_GrBlendCoeff:
case skgpu::BlendCoeff::kIDA:
return "inv_dst_alpha";
case kConstC_GrBlendCoeff:
case skgpu::BlendCoeff::kConstC:
return "const_color";
case kIConstC_GrBlendCoeff:
case skgpu::BlendCoeff::kIConstC:
return "inv_const_color";
case kS2C_GrBlendCoeff:
case skgpu::BlendCoeff::kS2C:
return "src2_color";
case kIS2C_GrBlendCoeff:
case skgpu::BlendCoeff::kIS2C:
return "inv_src2_color";
case kS2A_GrBlendCoeff:
case skgpu::BlendCoeff::kS2A:
return "src2_alpha";
case kIS2A_GrBlendCoeff:
case skgpu::BlendCoeff::kIS2A:
return "inv_src2_alpha";
case kIllegal_GrBlendCoeff:
case skgpu::BlendCoeff::kIllegal:
SkASSERT(false);
return "<illegal>";
}

View File

@ -9,7 +9,7 @@
#define GrXferProcessor_DEFINED
#include "include/gpu/GrTypes.h"
#include "src/gpu/GrBlend.h"
#include "src/gpu/Blend.h"
#include "src/gpu/GrNonAtomicRef.h"
#include "src/gpu/GrProcessor.h"
#include "src/gpu/GrProcessorAnalysis.h"
@ -92,11 +92,11 @@ public:
struct BlendInfo {
SkDEBUGCODE(SkString dump() const;)
GrBlendEquation fEquation = kAdd_GrBlendEquation;
GrBlendCoeff fSrcBlend = kOne_GrBlendCoeff;
GrBlendCoeff fDstBlend = kZero_GrBlendCoeff;
SkPMColor4f fBlendConstant = SK_PMColor4fTRANSPARENT;
bool fWriteColor = true;
skgpu::BlendEquation fEquation = skgpu::BlendEquation::kAdd;
skgpu::BlendCoeff fSrcBlend = skgpu::BlendCoeff::kOne;
skgpu::BlendCoeff fDstBlend = skgpu::BlendCoeff::kZero;
SkPMColor4f fBlendConstant = SK_PMColor4fTRANSPARENT;
bool fWriteColor = true;
};
inline BlendInfo getBlendInfo() const {

View File

@ -16,7 +16,7 @@
#include "include/gpu/GrTypes.h"
#include "include/private/SkColorData.h"
#include "src/core/SkBlendModePriv.h"
#include "src/gpu/GrBlend.h"
#include "src/gpu/Blend.h"
#include "src/gpu/GrCaps.h"
#include "src/gpu/GrColor.h"
#include "src/gpu/GrSamplerState.h"
@ -115,16 +115,16 @@ bool SkPaintToGrPaintWithBlend(GrRecordingContext* context,
////////////////////////////////////////////////////////////////////////////////
// Misc Sk to Gr type conversions
static_assert((int)kZero_GrBlendCoeff == (int)SkBlendModeCoeff::kZero);
static_assert((int)kOne_GrBlendCoeff == (int)SkBlendModeCoeff::kOne);
static_assert((int)kSC_GrBlendCoeff == (int)SkBlendModeCoeff::kSC);
static_assert((int)kISC_GrBlendCoeff == (int)SkBlendModeCoeff::kISC);
static_assert((int)kDC_GrBlendCoeff == (int)SkBlendModeCoeff::kDC);
static_assert((int)kIDC_GrBlendCoeff == (int)SkBlendModeCoeff::kIDC);
static_assert((int)kSA_GrBlendCoeff == (int)SkBlendModeCoeff::kSA);
static_assert((int)kISA_GrBlendCoeff == (int)SkBlendModeCoeff::kISA);
static_assert((int)kDA_GrBlendCoeff == (int)SkBlendModeCoeff::kDA);
static_assert((int)kIDA_GrBlendCoeff == (int)SkBlendModeCoeff::kIDA);
static_assert((int)skgpu::BlendCoeff::kZero == (int)SkBlendModeCoeff::kZero);
static_assert((int)skgpu::BlendCoeff::kOne == (int)SkBlendModeCoeff::kOne);
static_assert((int)skgpu::BlendCoeff::kSC == (int)SkBlendModeCoeff::kSC);
static_assert((int)skgpu::BlendCoeff::kISC == (int)SkBlendModeCoeff::kISC);
static_assert((int)skgpu::BlendCoeff::kDC == (int)SkBlendModeCoeff::kDC);
static_assert((int)skgpu::BlendCoeff::kIDC == (int)SkBlendModeCoeff::kIDC);
static_assert((int)skgpu::BlendCoeff::kSA == (int)SkBlendModeCoeff::kSA);
static_assert((int)skgpu::BlendCoeff::kISA == (int)SkBlendModeCoeff::kISA);
static_assert((int)skgpu::BlendCoeff::kDA == (int)SkBlendModeCoeff::kDA);
static_assert((int)skgpu::BlendCoeff::kIDA == (int)SkBlendModeCoeff::kIDA);
// static_assert(SkXfermode::kCoeffCount == 10);
////////////////////////////////////////////////////////////////////////////////

View File

@ -94,10 +94,10 @@ void set_blend_factor(GrD3DGpu* gpu, const GrProgramInfo& info) {
const GrXferProcessor& xferProcessor = info.pipeline().getXferProcessor();
const skgpu::Swizzle& swizzle = info.pipeline().writeSwizzle();
const GrXferProcessor::BlendInfo& blendInfo = xferProcessor.getBlendInfo();
GrBlendCoeff srcCoeff = blendInfo.fSrcBlend;
GrBlendCoeff dstCoeff = blendInfo.fDstBlend;
skgpu::BlendCoeff srcCoeff = blendInfo.fSrcBlend;
skgpu::BlendCoeff dstCoeff = blendInfo.fDstBlend;
float floatColors[4];
if (GrBlendCoeffRefsConstant(srcCoeff) || GrBlendCoeffRefsConstant(dstCoeff)) {
if (skgpu::BlendCoeffRefsConstant(srcCoeff) || skgpu::BlendCoeffRefsConstant(dstCoeff)) {
// Swizzle the blend to match what the shader will output.
SkPMColor4f blendConst = swizzle.applyTo(blendInfo.fBlendConstant);
floatColors[0] = blendConst.fR;

View File

@ -267,60 +267,60 @@ static void setup_vertex_input_layout(const GrGeometryProcessor& geomProc,
}
}
static D3D12_BLEND blend_coeff_to_d3d_blend(GrBlendCoeff coeff) {
static D3D12_BLEND blend_coeff_to_d3d_blend(skgpu::BlendCoeff coeff) {
switch (coeff) {
case kZero_GrBlendCoeff:
case skgpu::BlendCoeff::kZero:
return D3D12_BLEND_ZERO;
case kOne_GrBlendCoeff:
case skgpu::BlendCoeff::kOne:
return D3D12_BLEND_ONE;
case kSC_GrBlendCoeff:
case skgpu::BlendCoeff::kSC:
return D3D12_BLEND_SRC_COLOR;
case kISC_GrBlendCoeff:
case skgpu::BlendCoeff::kISC:
return D3D12_BLEND_INV_SRC_COLOR;
case kDC_GrBlendCoeff:
case skgpu::BlendCoeff::kDC:
return D3D12_BLEND_DEST_COLOR;
case kIDC_GrBlendCoeff:
case skgpu::BlendCoeff::kIDC:
return D3D12_BLEND_INV_DEST_COLOR;
case kSA_GrBlendCoeff:
case skgpu::BlendCoeff::kSA:
return D3D12_BLEND_SRC_ALPHA;
case kISA_GrBlendCoeff:
case skgpu::BlendCoeff::kISA:
return D3D12_BLEND_INV_SRC_ALPHA;
case kDA_GrBlendCoeff:
case skgpu::BlendCoeff::kDA:
return D3D12_BLEND_DEST_ALPHA;
case kIDA_GrBlendCoeff:
case skgpu::BlendCoeff::kIDA:
return D3D12_BLEND_INV_DEST_ALPHA;
case kConstC_GrBlendCoeff:
case skgpu::BlendCoeff::kConstC:
return D3D12_BLEND_BLEND_FACTOR;
case kIConstC_GrBlendCoeff:
case skgpu::BlendCoeff::kIConstC:
return D3D12_BLEND_INV_BLEND_FACTOR;
case kS2C_GrBlendCoeff:
case skgpu::BlendCoeff::kS2C:
return D3D12_BLEND_SRC1_COLOR;
case kIS2C_GrBlendCoeff:
case skgpu::BlendCoeff::kIS2C:
return D3D12_BLEND_INV_SRC1_COLOR;
case kS2A_GrBlendCoeff:
case skgpu::BlendCoeff::kS2A:
return D3D12_BLEND_SRC1_ALPHA;
case kIS2A_GrBlendCoeff:
case skgpu::BlendCoeff::kIS2A:
return D3D12_BLEND_INV_SRC1_ALPHA;
case kIllegal_GrBlendCoeff:
case skgpu::BlendCoeff::kIllegal:
return D3D12_BLEND_ZERO;
}
SkUNREACHABLE;
}
static D3D12_BLEND blend_coeff_to_d3d_blend_for_alpha(GrBlendCoeff coeff) {
static D3D12_BLEND blend_coeff_to_d3d_blend_for_alpha(skgpu::BlendCoeff coeff) {
switch (coeff) {
// Force all srcColor used in alpha slot to alpha version.
case kSC_GrBlendCoeff:
case skgpu::BlendCoeff::kSC:
return D3D12_BLEND_SRC_ALPHA;
case kISC_GrBlendCoeff:
case skgpu::BlendCoeff::kISC:
return D3D12_BLEND_INV_SRC_ALPHA;
case kDC_GrBlendCoeff:
case skgpu::BlendCoeff::kDC:
return D3D12_BLEND_DEST_ALPHA;
case kIDC_GrBlendCoeff:
case skgpu::BlendCoeff::kIDC:
return D3D12_BLEND_INV_DEST_ALPHA;
case kS2C_GrBlendCoeff:
case skgpu::BlendCoeff::kS2C:
return D3D12_BLEND_SRC1_ALPHA;
case kIS2C_GrBlendCoeff:
case skgpu::BlendCoeff::kIS2C:
return D3D12_BLEND_INV_SRC1_ALPHA;
default:
@ -329,13 +329,13 @@ static D3D12_BLEND blend_coeff_to_d3d_blend_for_alpha(GrBlendCoeff coeff) {
}
static D3D12_BLEND_OP blend_equation_to_d3d_op(GrBlendEquation equation) {
static D3D12_BLEND_OP blend_equation_to_d3d_op(skgpu::BlendEquation equation) {
switch (equation) {
case kAdd_GrBlendEquation:
case skgpu::BlendEquation::kAdd:
return D3D12_BLEND_OP_ADD;
case kSubtract_GrBlendEquation:
case skgpu::BlendEquation::kSubtract:
return D3D12_BLEND_OP_SUBTRACT;
case kReverseSubtract_GrBlendEquation:
case skgpu::BlendEquation::kReverseSubtract:
return D3D12_BLEND_OP_REV_SUBTRACT;
default:
SkUNREACHABLE;
@ -348,10 +348,10 @@ static void fill_in_blend_state(const GrPipeline& pipeline, D3D12_BLEND_DESC* bl
const GrXferProcessor::BlendInfo& blendInfo = pipeline.getXferProcessor().getBlendInfo();
GrBlendEquation equation = blendInfo.fEquation;
GrBlendCoeff srcCoeff = blendInfo.fSrcBlend;
GrBlendCoeff dstCoeff = blendInfo.fDstBlend;
bool blendOff = GrBlendShouldDisable(equation, srcCoeff, dstCoeff);
skgpu::BlendEquation equation = blendInfo.fEquation;
skgpu::BlendCoeff srcCoeff = blendInfo.fSrcBlend;
skgpu::BlendCoeff dstCoeff = blendInfo.fDstBlend;
bool blendOff = skgpu::BlendShouldDisable(equation, srcCoeff, dstCoeff);
auto& rtBlend = blendDesc->RenderTarget[0];
rtBlend.BlendEnable = !blendOff;
@ -704,4 +704,3 @@ sk_sp<GrD3DPipeline> GrD3DPipelineStateBuilder::MakeComputePipeline(GrD3DGpu* gp
return GrD3DPipeline::Make(std::move(pipelineState));
}

View File

@ -156,13 +156,13 @@ static uint32_t get_blend_info_key(const GrPipeline& pipeline) {
static const uint32_t kBlendWriteShift = 1;
static const uint32_t kBlendCoeffShift = 5;
static_assert(kLast_GrBlendCoeff < (1 << kBlendCoeffShift));
static_assert(kFirstAdvancedGrBlendEquation - 1 < 4);
static_assert((int)skgpu::BlendCoeff::kLast < (1 << kBlendCoeffShift));
static_assert((int)skgpu::BlendEquation::kFirstAdvanced - 1 < 4);
uint32_t key = blendInfo.fWriteColor;
key |= (blendInfo.fSrcBlend << kBlendWriteShift);
key |= (blendInfo.fDstBlend << (kBlendWriteShift + kBlendCoeffShift));
key |= (blendInfo.fEquation << (kBlendWriteShift + 2 * kBlendCoeffShift));
key |= ((int)blendInfo.fSrcBlend << kBlendWriteShift);
key |= ((int)blendInfo.fDstBlend << (kBlendWriteShift + kBlendCoeffShift));
key |= ((int)blendInfo.fEquation << (kBlendWriteShift + 2 * kBlendCoeffShift));
return key;
}

View File

@ -15,65 +15,65 @@
#include "src/gpu/effects/GrTextureEffect.h"
#include "src/utils/SkShaderUtils.h"
static wgpu::BlendFactor to_dawn_blend_factor(GrBlendCoeff coeff) {
static wgpu::BlendFactor to_dawn_blend_factor(skgpu::BlendCoeff coeff) {
switch (coeff) {
case kZero_GrBlendCoeff:
case skgpu::BlendCoeff::kZero:
return wgpu::BlendFactor::Zero;
case kOne_GrBlendCoeff:
case skgpu::BlendCoeff::kOne:
return wgpu::BlendFactor::One;
case kSC_GrBlendCoeff:
case skgpu::BlendCoeff::kSC:
return wgpu::BlendFactor::Src;
case kISC_GrBlendCoeff:
case skgpu::BlendCoeff::kISC:
return wgpu::BlendFactor::OneMinusSrc;
case kDC_GrBlendCoeff:
case skgpu::BlendCoeff::kDC:
return wgpu::BlendFactor::Dst;
case kIDC_GrBlendCoeff:
case skgpu::BlendCoeff::kIDC:
return wgpu::BlendFactor::OneMinusDst;
case kSA_GrBlendCoeff:
case skgpu::BlendCoeff::kSA:
return wgpu::BlendFactor::SrcAlpha;
case kISA_GrBlendCoeff:
case skgpu::BlendCoeff::kISA:
return wgpu::BlendFactor::OneMinusSrcAlpha;
case kDA_GrBlendCoeff:
case skgpu::BlendCoeff::kDA:
return wgpu::BlendFactor::DstAlpha;
case kIDA_GrBlendCoeff:
case skgpu::BlendCoeff::kIDA:
return wgpu::BlendFactor::OneMinusDstAlpha;
case kConstC_GrBlendCoeff:
case skgpu::BlendCoeff::kConstC:
return wgpu::BlendFactor::Constant;
case kIConstC_GrBlendCoeff:
case skgpu::BlendCoeff::kIConstC:
return wgpu::BlendFactor::OneMinusConstant;
case kS2C_GrBlendCoeff:
case kIS2C_GrBlendCoeff:
case kS2A_GrBlendCoeff:
case kIS2A_GrBlendCoeff:
case skgpu::BlendCoeff::kS2C:
case skgpu::BlendCoeff::kIS2C:
case skgpu::BlendCoeff::kS2A:
case skgpu::BlendCoeff::kIS2A:
default:
SkASSERT(!"unsupported blend coefficient");
return wgpu::BlendFactor::One;
}
}
static wgpu::BlendFactor to_dawn_blend_factor_for_alpha(GrBlendCoeff coeff) {
static wgpu::BlendFactor to_dawn_blend_factor_for_alpha(skgpu::BlendCoeff coeff) {
switch (coeff) {
// Force all srcColor used in alpha slot to alpha version.
case kSC_GrBlendCoeff:
case skgpu::BlendCoeff::kSC:
return wgpu::BlendFactor::SrcAlpha;
case kISC_GrBlendCoeff:
case skgpu::BlendCoeff::kISC:
return wgpu::BlendFactor::OneMinusSrcAlpha;
case kDC_GrBlendCoeff:
case skgpu::BlendCoeff::kDC:
return wgpu::BlendFactor::DstAlpha;
case kIDC_GrBlendCoeff:
case skgpu::BlendCoeff::kIDC:
return wgpu::BlendFactor::OneMinusDstAlpha;
default:
return to_dawn_blend_factor(coeff);
}
}
static wgpu::BlendOperation to_dawn_blend_operation(GrBlendEquation equation) {
static wgpu::BlendOperation to_dawn_blend_operation(skgpu::BlendEquation equation) {
switch (equation) {
case kAdd_GrBlendEquation:
case skgpu::BlendEquation::kAdd:
return wgpu::BlendOperation::Add;
case kSubtract_GrBlendEquation:
case skgpu::BlendEquation::kSubtract:
return wgpu::BlendOperation::Subtract;
case kReverseSubtract_GrBlendEquation:
case skgpu::BlendEquation::kReverseSubtract:
return wgpu::BlendOperation::ReverseSubtract;
default:
SkASSERT(!"unsupported blend equation");
@ -175,9 +175,9 @@ static wgpu::VertexFormat to_dawn_vertex_format(GrVertexAttribType type) {
static wgpu::BlendState create_blend_state(const GrDawnGpu* gpu, const GrPipeline& pipeline) {
GrXferProcessor::BlendInfo blendInfo = pipeline.getXferProcessor().getBlendInfo();
GrBlendEquation equation = blendInfo.fEquation;
GrBlendCoeff srcCoeff = blendInfo.fSrcBlend;
GrBlendCoeff dstCoeff = blendInfo.fDstBlend;
skgpu::BlendEquation equation = blendInfo.fEquation;
skgpu::BlendCoeff srcCoeff = blendInfo.fSrcBlend;
skgpu::BlendCoeff dstCoeff = blendInfo.fDstBlend;
wgpu::BlendFactor srcFactor = to_dawn_blend_factor(srcCoeff);
wgpu::BlendFactor dstFactor = to_dawn_blend_factor(dstCoeff);

View File

@ -67,28 +67,28 @@ std::unique_ptr<GrXferProcessor::ProgramImpl> CoverageSetOpXP::makeProgramImpl()
void CoverageSetOpXP::onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const {
switch (fRegionOp) {
case SkRegion::kReplace_Op:
blendInfo->fSrcBlend = kOne_GrBlendCoeff;
blendInfo->fDstBlend = kZero_GrBlendCoeff;
blendInfo->fSrcBlend = skgpu::BlendCoeff::kOne;
blendInfo->fDstBlend = skgpu::BlendCoeff::kZero;
break;
case SkRegion::kIntersect_Op:
blendInfo->fSrcBlend = kDC_GrBlendCoeff;
blendInfo->fDstBlend = kZero_GrBlendCoeff;
blendInfo->fSrcBlend = skgpu::BlendCoeff::kDC;
blendInfo->fDstBlend = skgpu::BlendCoeff::kZero;
break;
case SkRegion::kUnion_Op:
blendInfo->fSrcBlend = kOne_GrBlendCoeff;
blendInfo->fDstBlend = kISC_GrBlendCoeff;
blendInfo->fSrcBlend = skgpu::BlendCoeff::kOne;
blendInfo->fDstBlend = skgpu::BlendCoeff::kISC;
break;
case SkRegion::kXOR_Op:
blendInfo->fSrcBlend = kIDC_GrBlendCoeff;
blendInfo->fDstBlend = kISC_GrBlendCoeff;
blendInfo->fSrcBlend = skgpu::BlendCoeff::kIDC;
blendInfo->fDstBlend = skgpu::BlendCoeff::kISC;
break;
case SkRegion::kDifference_Op:
blendInfo->fSrcBlend = kZero_GrBlendCoeff;
blendInfo->fDstBlend = kISC_GrBlendCoeff;
blendInfo->fSrcBlend = skgpu::BlendCoeff::kZero;
blendInfo->fDstBlend = skgpu::BlendCoeff::kISC;
break;
case SkRegion::kReverseDifference_Op:
blendInfo->fSrcBlend = kIDC_GrBlendCoeff;
blendInfo->fDstBlend = kZero_GrBlendCoeff;
blendInfo->fSrcBlend = skgpu::BlendCoeff::kIDC;
blendInfo->fDstBlend = skgpu::BlendCoeff::kZero;
break;
}
blendInfo->fBlendConstant = SK_PMColor4fTRANSPARENT;

View File

@ -28,31 +28,31 @@ bool GrCustomXfermode::IsSupportedMode(SkBlendMode mode) {
// Static helpers
///////////////////////////////////////////////////////////////////////////////
static constexpr GrBlendEquation hw_blend_equation(SkBlendMode mode) {
constexpr int kEqOffset = (kOverlay_GrBlendEquation - (int)SkBlendMode::kOverlay);
static_assert(kOverlay_GrBlendEquation == (int)SkBlendMode::kOverlay + kEqOffset);
static_assert(kDarken_GrBlendEquation == (int)SkBlendMode::kDarken + kEqOffset);
static_assert(kLighten_GrBlendEquation == (int)SkBlendMode::kLighten + kEqOffset);
static_assert(kColorDodge_GrBlendEquation == (int)SkBlendMode::kColorDodge + kEqOffset);
static_assert(kColorBurn_GrBlendEquation == (int)SkBlendMode::kColorBurn + kEqOffset);
static_assert(kHardLight_GrBlendEquation == (int)SkBlendMode::kHardLight + kEqOffset);
static_assert(kSoftLight_GrBlendEquation == (int)SkBlendMode::kSoftLight + kEqOffset);
static_assert(kDifference_GrBlendEquation == (int)SkBlendMode::kDifference + kEqOffset);
static_assert(kExclusion_GrBlendEquation == (int)SkBlendMode::kExclusion + kEqOffset);
static_assert(kMultiply_GrBlendEquation == (int)SkBlendMode::kMultiply + kEqOffset);
static_assert(kHSLHue_GrBlendEquation == (int)SkBlendMode::kHue + kEqOffset);
static_assert(kHSLSaturation_GrBlendEquation == (int)SkBlendMode::kSaturation + kEqOffset);
static_assert(kHSLColor_GrBlendEquation == (int)SkBlendMode::kColor + kEqOffset);
static_assert(kHSLLuminosity_GrBlendEquation == (int)SkBlendMode::kLuminosity + kEqOffset);
static constexpr skgpu::BlendEquation hw_blend_equation(SkBlendMode mode) {
constexpr int kEqOffset = ((int)skgpu::BlendEquation::kOverlay - (int)SkBlendMode::kOverlay);
static_assert((int)skgpu::BlendEquation::kOverlay == (int)SkBlendMode::kOverlay + kEqOffset);
static_assert((int)skgpu::BlendEquation::kDarken == (int)SkBlendMode::kDarken + kEqOffset);
static_assert((int)skgpu::BlendEquation::kLighten == (int)SkBlendMode::kLighten + kEqOffset);
static_assert((int)skgpu::BlendEquation::kColorDodge == (int)SkBlendMode::kColorDodge + kEqOffset);
static_assert((int)skgpu::BlendEquation::kColorBurn == (int)SkBlendMode::kColorBurn + kEqOffset);
static_assert((int)skgpu::BlendEquation::kHardLight == (int)SkBlendMode::kHardLight + kEqOffset);
static_assert((int)skgpu::BlendEquation::kSoftLight == (int)SkBlendMode::kSoftLight + kEqOffset);
static_assert((int)skgpu::BlendEquation::kDifference == (int)SkBlendMode::kDifference + kEqOffset);
static_assert((int)skgpu::BlendEquation::kExclusion == (int)SkBlendMode::kExclusion + kEqOffset);
static_assert((int)skgpu::BlendEquation::kMultiply == (int)SkBlendMode::kMultiply + kEqOffset);
static_assert((int)skgpu::BlendEquation::kHSLHue == (int)SkBlendMode::kHue + kEqOffset);
static_assert((int)skgpu::BlendEquation::kHSLSaturation == (int)SkBlendMode::kSaturation + kEqOffset);
static_assert((int)skgpu::BlendEquation::kHSLColor == (int)SkBlendMode::kColor + kEqOffset);
static_assert((int)skgpu::BlendEquation::kHSLLuminosity == (int)SkBlendMode::kLuminosity + kEqOffset);
// There's an illegal GrBlendEquation that corresponds to no SkBlendMode, hence the extra +1.
static_assert(kGrBlendEquationCnt == (int)SkBlendMode::kLastMode + 1 + 1 + kEqOffset);
// There's an illegal BlendEquation that corresponds to no SkBlendMode, hence the extra +1.
static_assert(skgpu::kBlendEquationCnt == (int)SkBlendMode::kLastMode + 1 + 1 + kEqOffset);
return static_cast<GrBlendEquation>((int)mode + kEqOffset);
return static_cast<skgpu::BlendEquation>((int)mode + kEqOffset);
#undef EQ_OFFSET
}
static bool can_use_hw_blend_equation(GrBlendEquation equation,
static bool can_use_hw_blend_equation(skgpu::BlendEquation equation,
GrProcessorAnalysisCoverage coverage, const GrCaps& caps) {
if (!caps.advancedBlendEquationSupport()) {
return false;
@ -72,7 +72,7 @@ static bool can_use_hw_blend_equation(GrBlendEquation equation,
class CustomXP : public GrXferProcessor {
public:
CustomXP(SkBlendMode mode, GrBlendEquation hwBlendEquation)
CustomXP(SkBlendMode mode, skgpu::BlendEquation hwBlendEquation)
: INHERITED(kCustomXP_ClassID)
, fMode(mode)
, fHWBlendEquation(hwBlendEquation) {}
@ -80,7 +80,7 @@ public:
CustomXP(SkBlendMode mode, GrProcessorAnalysisCoverage coverage)
: INHERITED(kCustomXP_ClassID, /*willReadDstColor=*/true, coverage)
, fMode(mode)
, fHWBlendEquation(kIllegal_GrBlendEquation) {
, fHWBlendEquation(skgpu::BlendEquation::kIllegal) {
}
const char* name() const override { return "Custom Xfermode"; }
@ -90,7 +90,7 @@ public:
GrXferBarrierType xferBarrierType(const GrCaps&) const override;
private:
bool hasHWBlendEquation() const { return kIllegal_GrBlendEquation != fHWBlendEquation; }
bool hasHWBlendEquation() const { return skgpu::BlendEquation::kIllegal != fHWBlendEquation; }
void onAddToKey(const GrShaderCaps&, skgpu::KeyBuilder*) const override;
@ -98,8 +98,8 @@ private:
bool onIsEqual(const GrXferProcessor& xpBase) const override;
const SkBlendMode fMode;
const GrBlendEquation fHWBlendEquation;
const SkBlendMode fMode;
const skgpu::BlendEquation fHWBlendEquation;
using INHERITED = GrXferProcessor;
};
@ -210,7 +210,7 @@ private:
GR_DECLARE_XP_FACTORY_TEST
SkBlendMode fMode;
GrBlendEquation fHWBlendEquation;
skgpu::BlendEquation fHWBlendEquation;
using INHERITED = GrXPFactory;
};

View File

@ -10,7 +10,7 @@
#include "include/gpu/GrTypes.h"
#include "include/private/SkMacros.h"
#include "include/private/SkTo.h"
#include "src/gpu/GrBlend.h"
#include "src/gpu/Blend.h"
#include "src/gpu/GrCaps.h"
#include "src/gpu/GrPipeline.h"
#include "src/gpu/GrProcessor.h"
@ -42,13 +42,16 @@ public:
kLast_OutputType = kISCModulate_OutputType
};
constexpr BlendFormula(OutputType primaryOut, OutputType secondaryOut, GrBlendEquation equation,
GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff)
constexpr BlendFormula(OutputType primaryOut,
OutputType secondaryOut,
skgpu::BlendEquation equation,
skgpu::BlendCoeff srcCoeff,
skgpu::BlendCoeff dstCoeff)
: fPrimaryOutputType(primaryOut)
, fSecondaryOutputType(secondaryOut)
, fBlendEquation(equation)
, fSrcCoeff(srcCoeff)
, fDstCoeff(dstCoeff)
, fBlendEquation(SkTo<uint8_t>(equation))
, fSrcCoeff(SkTo<uint8_t>(srcCoeff))
, fDstCoeff(SkTo<uint8_t>(dstCoeff))
, fProps(GetProperties(primaryOut, secondaryOut, equation, srcCoeff, dstCoeff)) {}
BlendFormula(const BlendFormula&) = default;
@ -84,16 +87,16 @@ public:
return SkToBool(fProps & kCanTweakAlphaForCoverage_Property);
}
GrBlendEquation equation() const {
return fBlendEquation;
skgpu::BlendEquation equation() const {
return static_cast<skgpu::BlendEquation>(fBlendEquation);
}
GrBlendCoeff srcCoeff() const {
return fSrcCoeff;
skgpu::BlendCoeff srcCoeff() const {
return static_cast<skgpu::BlendCoeff>(fSrcCoeff);
}
GrBlendCoeff dstCoeff() const {
return fDstCoeff;
skgpu::BlendCoeff dstCoeff() const {
return static_cast<skgpu::BlendCoeff>(fDstCoeff);
}
OutputType primaryOutput() const {
@ -119,25 +122,27 @@ private:
/**
* Deduce the properties of a BlendFormula.
*/
static constexpr Properties GetProperties(OutputType PrimaryOut, OutputType SecondaryOut,
GrBlendEquation BlendEquation, GrBlendCoeff SrcCoeff,
GrBlendCoeff DstCoeff);
static constexpr Properties GetProperties(OutputType PrimaryOut,
OutputType SecondaryOut,
skgpu::BlendEquation BlendEquation,
skgpu::BlendCoeff SrcCoeff,
skgpu::BlendCoeff DstCoeff);
struct {
// We allot the enums one more bit than they require because MSVC seems to sign-extend
// them when the top bit is set. (This is in violation of the C++03 standard 9.6/4)
OutputType fPrimaryOutputType : 4;
OutputType fSecondaryOutputType : 4;
GrBlendEquation fBlendEquation : 6;
GrBlendCoeff fSrcCoeff : 6;
GrBlendCoeff fDstCoeff : 6;
Properties fProps : 32 - (4 + 4 + 6 + 6 + 6);
OutputType fPrimaryOutputType : 4;
OutputType fSecondaryOutputType : 4;
uint32_t fBlendEquation : 6;
uint32_t fSrcCoeff : 6;
uint32_t fDstCoeff : 6;
Properties fProps : 32 - (4 + 4 + 6 + 6 + 6);
};
static_assert(kLast_OutputType < (1 << 3));
static_assert(kLast_GrBlendEquation < (1 << 5));
static_assert(kLast_GrBlendCoeff < (1 << 5));
static_assert(kLast_Property < (1 << 6));
static_assert(kLast_OutputType < (1 << 3));
static_assert(static_cast<int>(skgpu::BlendEquation::kLast) < (1 << 5));
static_assert(static_cast<int>(skgpu::BlendCoeff::kLast) < (1 << 5));
static_assert(kLast_Property < (1 << 6));
};
static_assert(4 == sizeof(BlendFormula));
@ -146,34 +151,36 @@ SK_MAKE_BITFIELD_OPS(BlendFormula::Properties)
constexpr BlendFormula::Properties BlendFormula::GetProperties(OutputType PrimaryOut,
OutputType SecondaryOut,
GrBlendEquation BlendEquation,
GrBlendCoeff SrcCoeff,
GrBlendCoeff DstCoeff) {
skgpu::BlendEquation BlendEquation,
skgpu::BlendCoeff SrcCoeff,
skgpu::BlendCoeff DstCoeff) {
return
// The provided formula should already be optimized before a BlendFormula is constructed.
// Assert that here while setting up the properties in the constexpr constructor.
SkASSERT((kNone_OutputType == PrimaryOut) == !GrBlendCoeffsUseSrcColor(SrcCoeff, DstCoeff)),
SkASSERT(!GrBlendCoeffRefsSrc2(SrcCoeff)),
SkASSERT((kNone_OutputType == SecondaryOut) == !GrBlendCoeffRefsSrc2(DstCoeff)),
SkASSERT((kNone_OutputType == PrimaryOut) ==
!skgpu::BlendCoeffsUseSrcColor(SrcCoeff, DstCoeff)),
SkASSERT(!skgpu::BlendCoeffRefsSrc2(SrcCoeff)),
SkASSERT((kNone_OutputType == SecondaryOut) == !skgpu::BlendCoeffRefsSrc2(DstCoeff)),
SkASSERT(PrimaryOut != SecondaryOut || kNone_OutputType == PrimaryOut),
SkASSERT(kNone_OutputType != PrimaryOut || kNone_OutputType == SecondaryOut),
static_cast<Properties>(
(GrBlendModifiesDst(BlendEquation, SrcCoeff, DstCoeff) ? kModifiesDst_Property : 0) |
(!GrBlendCoeffsUseDstColor(SrcCoeff, DstCoeff, false/*srcColorIsOpaque*/)
(skgpu::BlendModifiesDst(BlendEquation, SrcCoeff, DstCoeff) ? kModifiesDst_Property : 0) |
(!skgpu::BlendCoeffsUseDstColor(SrcCoeff, DstCoeff, false/*srcColorIsOpaque*/)
? kUnaffectedByDst_Property
: 0) |
(!GrBlendCoeffsUseDstColor(SrcCoeff, DstCoeff, true/*srcColorIsOpaque*/)
(!skgpu::BlendCoeffsUseDstColor(SrcCoeff, DstCoeff, true/*srcColorIsOpaque*/)
? kUnaffectedByDstIfOpaque_Property
: 0) |
((PrimaryOut >= kModulate_OutputType && GrBlendCoeffsUseSrcColor(SrcCoeff, DstCoeff)) ||
((PrimaryOut >= kModulate_OutputType &&
skgpu::BlendCoeffsUseSrcColor(SrcCoeff, DstCoeff)) ||
(SecondaryOut >= kModulate_OutputType &&
GrBlendCoeffRefsSrc2(DstCoeff))
skgpu::BlendCoeffRefsSrc2(DstCoeff))
? kUsesInputColor_Property
: 0) | // We assert later that SrcCoeff doesn't ref src2.
((kModulate_OutputType == PrimaryOut || kNone_OutputType == PrimaryOut) &&
kNone_OutputType == SecondaryOut &&
GrBlendAllowsCoverageAsAlpha(BlendEquation, SrcCoeff, DstCoeff)
skgpu::BlendAllowsCoverageAsAlpha(BlendEquation, SrcCoeff, DstCoeff)
? kCanTweakAlphaForCoverage_Property
: 0));
}
@ -182,23 +189,25 @@ constexpr BlendFormula::Properties BlendFormula::GetProperties(OutputType Primar
* When there is no coverage, or the blend mode can tweak alpha for coverage, we use the standard
* Porter Duff formula.
*/
static constexpr BlendFormula MakeCoeffFormula(GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff) {
static constexpr BlendFormula MakeCoeffFormula(skgpu::BlendCoeff srcCoeff,
skgpu::BlendCoeff dstCoeff) {
// When the coeffs are (Zero, Zero) or (Zero, One) we set the primary output to none.
return (kZero_GrBlendCoeff == srcCoeff &&
(kZero_GrBlendCoeff == dstCoeff || kOne_GrBlendCoeff == dstCoeff))
return (skgpu::BlendCoeff::kZero == srcCoeff &&
(skgpu::BlendCoeff::kZero == dstCoeff || skgpu::BlendCoeff::kOne == dstCoeff))
? BlendFormula(BlendFormula::kNone_OutputType, BlendFormula::kNone_OutputType,
kAdd_GrBlendEquation, kZero_GrBlendCoeff, dstCoeff)
skgpu::BlendEquation::kAdd, skgpu::BlendCoeff::kZero, dstCoeff)
: BlendFormula(BlendFormula::kModulate_OutputType, BlendFormula::kNone_OutputType,
kAdd_GrBlendEquation, srcCoeff, dstCoeff);
skgpu::BlendEquation::kAdd, srcCoeff, dstCoeff);
}
/**
* Basic coeff formula similar to MakeCoeffFormula but we will make the src f*Sa. This is used in
* LCD dst-out.
*/
static constexpr BlendFormula MakeSAModulateFormula(GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff) {
static constexpr BlendFormula MakeSAModulateFormula(skgpu::BlendCoeff srcCoeff,
skgpu::BlendCoeff dstCoeff) {
return BlendFormula(BlendFormula::kSAModulate_OutputType, BlendFormula::kNone_OutputType,
kAdd_GrBlendEquation, srcCoeff, dstCoeff);
skgpu::BlendEquation::kAdd, srcCoeff, dstCoeff);
}
/**
@ -216,9 +225,9 @@ static constexpr BlendFormula MakeSAModulateFormula(GrBlendCoeff srcCoeff, GrBle
* Xfer modes: dst-atop (Sa!=1)
*/
static constexpr BlendFormula MakeCoverageFormula(
BlendFormula::OutputType oneMinusDstCoeffModulateOutput, GrBlendCoeff srcCoeff) {
BlendFormula::OutputType oneMinusDstCoeffModulateOutput, skgpu::BlendCoeff srcCoeff) {
return BlendFormula(BlendFormula::kModulate_OutputType, oneMinusDstCoeffModulateOutput,
kAdd_GrBlendEquation, srcCoeff, kIS2C_GrBlendCoeff);
skgpu::BlendEquation::kAdd, srcCoeff, skgpu::BlendCoeff::kIS2C);
}
/**
@ -238,7 +247,8 @@ static constexpr BlendFormula MakeCoverageFormula(
static constexpr BlendFormula MakeCoverageSrcCoeffZeroFormula(
BlendFormula::OutputType oneMinusDstCoeffModulateOutput) {
return BlendFormula(oneMinusDstCoeffModulateOutput, BlendFormula::kNone_OutputType,
kReverseSubtract_GrBlendEquation, kDC_GrBlendCoeff, kOne_GrBlendCoeff);
skgpu::BlendEquation::kReverseSubtract, skgpu::BlendCoeff::kDC,
skgpu::BlendCoeff::kOne);
}
/**
@ -251,9 +261,9 @@ static constexpr BlendFormula MakeCoverageSrcCoeffZeroFormula(
*
* Xfer modes (Sa!=1): src, src-in, src-out
*/
static constexpr BlendFormula MakeCoverageDstCoeffZeroFormula(GrBlendCoeff srcCoeff) {
static constexpr BlendFormula MakeCoverageDstCoeffZeroFormula(skgpu::BlendCoeff srcCoeff) {
return BlendFormula(BlendFormula::kModulate_OutputType, BlendFormula::kCoverage_OutputType,
kAdd_GrBlendEquation, srcCoeff, kIS2A_GrBlendCoeff);
skgpu::BlendEquation::kAdd, srcCoeff, skgpu::BlendCoeff::kIS2A);
}
/**
@ -264,75 +274,77 @@ static constexpr BlendFormula MakeCoverageDstCoeffZeroFormula(GrBlendCoeff srcCo
static constexpr BlendFormula gBlendTable[2][2][(int)SkBlendMode::kLastCoeffMode + 1] = {
/*>> No coverage, input color unknown <<*/ {{
/* clear */ MakeCoeffFormula(kZero_GrBlendCoeff, kZero_GrBlendCoeff),
/* src */ MakeCoeffFormula(kOne_GrBlendCoeff, kZero_GrBlendCoeff),
/* dst */ MakeCoeffFormula(kZero_GrBlendCoeff, kOne_GrBlendCoeff),
/* src-over */ MakeCoeffFormula(kOne_GrBlendCoeff, kISA_GrBlendCoeff),
/* dst-over */ MakeCoeffFormula(kIDA_GrBlendCoeff, kOne_GrBlendCoeff),
/* src-in */ MakeCoeffFormula(kDA_GrBlendCoeff, kZero_GrBlendCoeff),
/* dst-in */ MakeCoeffFormula(kZero_GrBlendCoeff, kSA_GrBlendCoeff),
/* src-out */ MakeCoeffFormula(kIDA_GrBlendCoeff, kZero_GrBlendCoeff),
/* dst-out */ MakeCoeffFormula(kZero_GrBlendCoeff, kISA_GrBlendCoeff),
/* src-atop */ MakeCoeffFormula(kDA_GrBlendCoeff, kISA_GrBlendCoeff),
/* dst-atop */ MakeCoeffFormula(kIDA_GrBlendCoeff, kSA_GrBlendCoeff),
/* xor */ MakeCoeffFormula(kIDA_GrBlendCoeff, kISA_GrBlendCoeff),
/* plus */ MakeCoeffFormula(kOne_GrBlendCoeff, kOne_GrBlendCoeff),
/* modulate */ MakeCoeffFormula(kZero_GrBlendCoeff, kSC_GrBlendCoeff),
/* screen */ MakeCoeffFormula(kOne_GrBlendCoeff, kISC_GrBlendCoeff),
/* clear */ MakeCoeffFormula(skgpu::BlendCoeff::kZero, skgpu::BlendCoeff::kZero),
/* src */ MakeCoeffFormula(skgpu::BlendCoeff::kOne, skgpu::BlendCoeff::kZero),
/* dst */ MakeCoeffFormula(skgpu::BlendCoeff::kZero, skgpu::BlendCoeff::kOne),
/* src-over */ MakeCoeffFormula(skgpu::BlendCoeff::kOne, skgpu::BlendCoeff::kISA),
/* dst-over */ MakeCoeffFormula(skgpu::BlendCoeff::kIDA, skgpu::BlendCoeff::kOne),
/* src-in */ MakeCoeffFormula(skgpu::BlendCoeff::kDA, skgpu::BlendCoeff::kZero),
/* dst-in */ MakeCoeffFormula(skgpu::BlendCoeff::kZero, skgpu::BlendCoeff::kSA),
/* src-out */ MakeCoeffFormula(skgpu::BlendCoeff::kIDA, skgpu::BlendCoeff::kZero),
/* dst-out */ MakeCoeffFormula(skgpu::BlendCoeff::kZero, skgpu::BlendCoeff::kISA),
/* src-atop */ MakeCoeffFormula(skgpu::BlendCoeff::kDA, skgpu::BlendCoeff::kISA),
/* dst-atop */ MakeCoeffFormula(skgpu::BlendCoeff::kIDA, skgpu::BlendCoeff::kSA),
/* xor */ MakeCoeffFormula(skgpu::BlendCoeff::kIDA, skgpu::BlendCoeff::kISA),
/* plus */ MakeCoeffFormula(skgpu::BlendCoeff::kOne, skgpu::BlendCoeff::kOne),
/* modulate */ MakeCoeffFormula(skgpu::BlendCoeff::kZero, skgpu::BlendCoeff::kSC),
/* screen */ MakeCoeffFormula(skgpu::BlendCoeff::kOne, skgpu::BlendCoeff::kISC),
}, /*>> Has coverage, input color unknown <<*/ {
/* clear */ MakeCoverageSrcCoeffZeroFormula(BlendFormula::kCoverage_OutputType),
/* src */ MakeCoverageDstCoeffZeroFormula(kOne_GrBlendCoeff),
/* dst */ MakeCoeffFormula(kZero_GrBlendCoeff, kOne_GrBlendCoeff),
/* src-over */ MakeCoeffFormula(kOne_GrBlendCoeff, kISA_GrBlendCoeff),
/* dst-over */ MakeCoeffFormula(kIDA_GrBlendCoeff, kOne_GrBlendCoeff),
/* src-in */ MakeCoverageDstCoeffZeroFormula(kDA_GrBlendCoeff),
/* src */ MakeCoverageDstCoeffZeroFormula(skgpu::BlendCoeff::kOne),
/* dst */ MakeCoeffFormula(skgpu::BlendCoeff::kZero, skgpu::BlendCoeff::kOne),
/* src-over */ MakeCoeffFormula(skgpu::BlendCoeff::kOne, skgpu::BlendCoeff::kISA),
/* dst-over */ MakeCoeffFormula(skgpu::BlendCoeff::kIDA, skgpu::BlendCoeff::kOne),
/* src-in */ MakeCoverageDstCoeffZeroFormula(skgpu::BlendCoeff::kDA),
/* dst-in */ MakeCoverageSrcCoeffZeroFormula(BlendFormula::kISAModulate_OutputType),
/* src-out */ MakeCoverageDstCoeffZeroFormula(kIDA_GrBlendCoeff),
/* dst-out */ MakeCoeffFormula(kZero_GrBlendCoeff, kISA_GrBlendCoeff),
/* src-atop */ MakeCoeffFormula(kDA_GrBlendCoeff, kISA_GrBlendCoeff),
/* dst-atop */ MakeCoverageFormula(BlendFormula::kISAModulate_OutputType, kIDA_GrBlendCoeff),
/* xor */ MakeCoeffFormula(kIDA_GrBlendCoeff, kISA_GrBlendCoeff),
/* plus */ MakeCoeffFormula(kOne_GrBlendCoeff, kOne_GrBlendCoeff),
/* src-out */ MakeCoverageDstCoeffZeroFormula(skgpu::BlendCoeff::kIDA),
/* dst-out */ MakeCoeffFormula(skgpu::BlendCoeff::kZero, skgpu::BlendCoeff::kISA),
/* src-atop */ MakeCoeffFormula(skgpu::BlendCoeff::kDA, skgpu::BlendCoeff::kISA),
/* dst-atop */ MakeCoverageFormula(BlendFormula::kISAModulate_OutputType,
skgpu::BlendCoeff::kIDA),
/* xor */ MakeCoeffFormula(skgpu::BlendCoeff::kIDA, skgpu::BlendCoeff::kISA),
/* plus */ MakeCoeffFormula(skgpu::BlendCoeff::kOne, skgpu::BlendCoeff::kOne),
/* modulate */ MakeCoverageSrcCoeffZeroFormula(BlendFormula::kISCModulate_OutputType),
/* screen */ MakeCoeffFormula(kOne_GrBlendCoeff, kISC_GrBlendCoeff),
/* screen */ MakeCoeffFormula(skgpu::BlendCoeff::kOne, skgpu::BlendCoeff::kISC),
}}, /*>> No coverage, input color opaque <<*/ {{
/* clear */ MakeCoeffFormula(kZero_GrBlendCoeff, kZero_GrBlendCoeff),
/* src */ MakeCoeffFormula(kOne_GrBlendCoeff, kZero_GrBlendCoeff),
/* dst */ MakeCoeffFormula(kZero_GrBlendCoeff, kOne_GrBlendCoeff),
/* src-over */ MakeCoeffFormula(kOne_GrBlendCoeff, kISA_GrBlendCoeff), // see comment below
/* dst-over */ MakeCoeffFormula(kIDA_GrBlendCoeff, kOne_GrBlendCoeff),
/* src-in */ MakeCoeffFormula(kDA_GrBlendCoeff, kZero_GrBlendCoeff),
/* dst-in */ MakeCoeffFormula(kZero_GrBlendCoeff, kOne_GrBlendCoeff),
/* src-out */ MakeCoeffFormula(kIDA_GrBlendCoeff, kZero_GrBlendCoeff),
/* dst-out */ MakeCoeffFormula(kZero_GrBlendCoeff, kZero_GrBlendCoeff),
/* src-atop */ MakeCoeffFormula(kDA_GrBlendCoeff, kZero_GrBlendCoeff),
/* dst-atop */ MakeCoeffFormula(kIDA_GrBlendCoeff, kOne_GrBlendCoeff),
/* xor */ MakeCoeffFormula(kIDA_GrBlendCoeff, kZero_GrBlendCoeff),
/* plus */ MakeCoeffFormula(kOne_GrBlendCoeff, kOne_GrBlendCoeff),
/* modulate */ MakeCoeffFormula(kZero_GrBlendCoeff, kSC_GrBlendCoeff),
/* screen */ MakeCoeffFormula(kOne_GrBlendCoeff, kISC_GrBlendCoeff),
/* clear */ MakeCoeffFormula(skgpu::BlendCoeff::kZero, skgpu::BlendCoeff::kZero),
/* src */ MakeCoeffFormula(skgpu::BlendCoeff::kOne, skgpu::BlendCoeff::kZero),
/* dst */ MakeCoeffFormula(skgpu::BlendCoeff::kZero, skgpu::BlendCoeff::kOne),
/* src-over */ MakeCoeffFormula(skgpu::BlendCoeff::kOne,
skgpu::BlendCoeff::kISA), // see comment below
/* dst-over */ MakeCoeffFormula(skgpu::BlendCoeff::kIDA, skgpu::BlendCoeff::kOne),
/* src-in */ MakeCoeffFormula(skgpu::BlendCoeff::kDA, skgpu::BlendCoeff::kZero),
/* dst-in */ MakeCoeffFormula(skgpu::BlendCoeff::kZero, skgpu::BlendCoeff::kOne),
/* src-out */ MakeCoeffFormula(skgpu::BlendCoeff::kIDA, skgpu::BlendCoeff::kZero),
/* dst-out */ MakeCoeffFormula(skgpu::BlendCoeff::kZero, skgpu::BlendCoeff::kZero),
/* src-atop */ MakeCoeffFormula(skgpu::BlendCoeff::kDA, skgpu::BlendCoeff::kZero),
/* dst-atop */ MakeCoeffFormula(skgpu::BlendCoeff::kIDA, skgpu::BlendCoeff::kOne),
/* xor */ MakeCoeffFormula(skgpu::BlendCoeff::kIDA, skgpu::BlendCoeff::kZero),
/* plus */ MakeCoeffFormula(skgpu::BlendCoeff::kOne, skgpu::BlendCoeff::kOne),
/* modulate */ MakeCoeffFormula(skgpu::BlendCoeff::kZero, skgpu::BlendCoeff::kSC),
/* screen */ MakeCoeffFormula(skgpu::BlendCoeff::kOne, skgpu::BlendCoeff::kISC),
}, /*>> Has coverage, input color opaque <<*/ {
/* clear */ MakeCoverageSrcCoeffZeroFormula(BlendFormula::kCoverage_OutputType),
/* src */ MakeCoeffFormula(kOne_GrBlendCoeff, kISA_GrBlendCoeff),
/* dst */ MakeCoeffFormula(kZero_GrBlendCoeff, kOne_GrBlendCoeff),
/* src-over */ MakeCoeffFormula(kOne_GrBlendCoeff, kISA_GrBlendCoeff),
/* dst-over */ MakeCoeffFormula(kIDA_GrBlendCoeff, kOne_GrBlendCoeff),
/* src-in */ MakeCoeffFormula(kDA_GrBlendCoeff, kISA_GrBlendCoeff),
/* dst-in */ MakeCoeffFormula(kZero_GrBlendCoeff, kOne_GrBlendCoeff),
/* src-out */ MakeCoeffFormula(kIDA_GrBlendCoeff, kISA_GrBlendCoeff),
/* src */ MakeCoeffFormula(skgpu::BlendCoeff::kOne, skgpu::BlendCoeff::kISA),
/* dst */ MakeCoeffFormula(skgpu::BlendCoeff::kZero, skgpu::BlendCoeff::kOne),
/* src-over */ MakeCoeffFormula(skgpu::BlendCoeff::kOne, skgpu::BlendCoeff::kISA),
/* dst-over */ MakeCoeffFormula(skgpu::BlendCoeff::kIDA, skgpu::BlendCoeff::kOne),
/* src-in */ MakeCoeffFormula(skgpu::BlendCoeff::kDA, skgpu::BlendCoeff::kISA),
/* dst-in */ MakeCoeffFormula(skgpu::BlendCoeff::kZero, skgpu::BlendCoeff::kOne),
/* src-out */ MakeCoeffFormula(skgpu::BlendCoeff::kIDA, skgpu::BlendCoeff::kISA),
/* dst-out */ MakeCoverageSrcCoeffZeroFormula(BlendFormula::kCoverage_OutputType),
/* src-atop */ MakeCoeffFormula(kDA_GrBlendCoeff, kISA_GrBlendCoeff),
/* dst-atop */ MakeCoeffFormula(kIDA_GrBlendCoeff, kOne_GrBlendCoeff),
/* xor */ MakeCoeffFormula(kIDA_GrBlendCoeff, kISA_GrBlendCoeff),
/* plus */ MakeCoeffFormula(kOne_GrBlendCoeff, kOne_GrBlendCoeff),
/* src-atop */ MakeCoeffFormula(skgpu::BlendCoeff::kDA, skgpu::BlendCoeff::kISA),
/* dst-atop */ MakeCoeffFormula(skgpu::BlendCoeff::kIDA, skgpu::BlendCoeff::kOne),
/* xor */ MakeCoeffFormula(skgpu::BlendCoeff::kIDA, skgpu::BlendCoeff::kISA),
/* plus */ MakeCoeffFormula(skgpu::BlendCoeff::kOne, skgpu::BlendCoeff::kOne),
/* modulate */ MakeCoverageSrcCoeffZeroFormula(BlendFormula::kISCModulate_OutputType),
/* screen */ MakeCoeffFormula(kOne_GrBlendCoeff, kISC_GrBlendCoeff),
/* screen */ MakeCoeffFormula(skgpu::BlendCoeff::kOne, skgpu::BlendCoeff::kISC),
}}};
// In the above table src-over is not optimized to src mode when the color is opaque because we
// found no advantage to doing so. Also, we are using a global src-over XP in most cases which is
@ -341,20 +353,32 @@ static constexpr BlendFormula gBlendTable[2][2][(int)SkBlendMode::kLastCoeffMode
// this table.
static constexpr BlendFormula gLCDBlendTable[(int)SkBlendMode::kLastCoeffMode + 1] = {
/* clear */ MakeCoverageSrcCoeffZeroFormula(BlendFormula::kCoverage_OutputType),
/* src */ MakeCoverageFormula(BlendFormula::kCoverage_OutputType, kOne_GrBlendCoeff),
/* dst */ MakeCoeffFormula(kZero_GrBlendCoeff, kOne_GrBlendCoeff),
/* src-over */ MakeCoverageFormula(BlendFormula::kSAModulate_OutputType, kOne_GrBlendCoeff),
/* dst-over */ MakeCoeffFormula(kIDA_GrBlendCoeff, kOne_GrBlendCoeff),
/* src-in */ MakeCoverageFormula(BlendFormula::kCoverage_OutputType, kDA_GrBlendCoeff),
/* src */ MakeCoverageFormula(BlendFormula::kCoverage_OutputType,
skgpu::BlendCoeff::kOne),
/* dst */ MakeCoeffFormula(skgpu::BlendCoeff::kZero,
skgpu::BlendCoeff::kOne),
/* src-over */ MakeCoverageFormula(BlendFormula::kSAModulate_OutputType,
skgpu::BlendCoeff::kOne),
/* dst-over */ MakeCoeffFormula(skgpu::BlendCoeff::kIDA,
skgpu::BlendCoeff::kOne),
/* src-in */ MakeCoverageFormula(BlendFormula::kCoverage_OutputType,
skgpu::BlendCoeff::kDA),
/* dst-in */ MakeCoverageSrcCoeffZeroFormula(BlendFormula::kISAModulate_OutputType),
/* src-out */ MakeCoverageFormula(BlendFormula::kCoverage_OutputType, kIDA_GrBlendCoeff),
/* dst-out */ MakeSAModulateFormula(kZero_GrBlendCoeff, kISC_GrBlendCoeff),
/* src-atop */ MakeCoverageFormula(BlendFormula::kSAModulate_OutputType, kDA_GrBlendCoeff),
/* dst-atop */ MakeCoverageFormula(BlendFormula::kISAModulate_OutputType, kIDA_GrBlendCoeff),
/* xor */ MakeCoverageFormula(BlendFormula::kSAModulate_OutputType, kIDA_GrBlendCoeff),
/* plus */ MakeCoeffFormula(kOne_GrBlendCoeff, kOne_GrBlendCoeff),
/* src-out */ MakeCoverageFormula(BlendFormula::kCoverage_OutputType,
skgpu::BlendCoeff::kIDA),
/* dst-out */ MakeSAModulateFormula(skgpu::BlendCoeff::kZero,
skgpu::BlendCoeff::kISC),
/* src-atop */ MakeCoverageFormula(BlendFormula::kSAModulate_OutputType,
skgpu::BlendCoeff::kDA),
/* dst-atop */ MakeCoverageFormula(BlendFormula::kISAModulate_OutputType,
skgpu::BlendCoeff::kIDA),
/* xor */ MakeCoverageFormula(BlendFormula::kSAModulate_OutputType,
skgpu::BlendCoeff::kIDA),
/* plus */ MakeCoeffFormula(skgpu::BlendCoeff::kOne,
skgpu::BlendCoeff::kOne),
/* modulate */ MakeCoverageSrcCoeffZeroFormula(BlendFormula::kISCModulate_OutputType),
/* screen */ MakeCoeffFormula(kOne_GrBlendCoeff, kISC_GrBlendCoeff),
/* screen */ MakeCoeffFormula(skgpu::BlendCoeff::kOne,
skgpu::BlendCoeff::kISC),
};
static BlendFormula get_blend_formula(bool isOpaque,
@ -551,8 +575,8 @@ private:
void onAddToKey(const GrShaderCaps&, skgpu::KeyBuilder*) const override {}
void onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const override {
blendInfo->fSrcBlend = kConstC_GrBlendCoeff;
blendInfo->fDstBlend = kISC_GrBlendCoeff;
blendInfo->fSrcBlend = skgpu::BlendCoeff::kConstC;
blendInfo->fDstBlend = skgpu::BlendCoeff::kISC;
blendInfo->fBlendConstant = fBlendConstant;
}
@ -818,7 +842,7 @@ void GrPorterDuffXPFactory::TestGetXPOutputTypes(const GrXferProcessor* xp,
////////////////////////////////////////////////////////////////////////////////////////////////
const GrXferProcessor& GrPorterDuffXPFactory::SimpleSrcOverXP() {
static BlendFormula gSrcOverBlendFormula =
MakeCoeffFormula(kOne_GrBlendCoeff, kISA_GrBlendCoeff);
MakeCoeffFormula(skgpu::BlendCoeff::kOne, skgpu::BlendCoeff::kISA);
static PorterDuffXferProcessor gSrcOverXP(gSrcOverBlendFormula,
GrProcessorAnalysisCoverage::kSingleChannel);
return gSrcOverXP;

View File

@ -4116,12 +4116,12 @@ void GrGLCaps::applyDriverCorrectnessWorkarounds(const GrGLContextInfo& ctxInfo,
if (ctxInfo.driver() == GrGLDriver::kNVIDIA &&
ctxInfo.driverVersion() < GR_GL_DRIVER_VER(355, 00, 0)) {
// Disable color-dodge and color-burn on pre-355.00 NVIDIA.
fAdvBlendEqDisableFlags |= (1 << kColorDodge_GrBlendEquation) |
(1 << kColorBurn_GrBlendEquation);
fAdvBlendEqDisableFlags |= (1 << static_cast<int>(skgpu::BlendEquation::kColorDodge)) |
(1 << static_cast<int>(skgpu::BlendEquation::kColorBurn));
}
if (ctxInfo.vendor() == GrGLVendor::kARM) {
// Disable color-burn on ARM until the fix is released.
fAdvBlendEqDisableFlags |= (1 << kColorBurn_GrBlendEquation);
fAdvBlendEqDisableFlags |= (1 << static_cast<int>(skgpu::BlendEquation::kColorBurn));
}
}

View File

@ -90,25 +90,25 @@ static const GrGLenum gXfermodeEquation2Blend[] = {
// Illegal... needs to map to something.
GR_GL_FUNC_ADD,
};
static_assert(0 == kAdd_GrBlendEquation);
static_assert(1 == kSubtract_GrBlendEquation);
static_assert(2 == kReverseSubtract_GrBlendEquation);
static_assert(3 == kScreen_GrBlendEquation);
static_assert(4 == kOverlay_GrBlendEquation);
static_assert(5 == kDarken_GrBlendEquation);
static_assert(6 == kLighten_GrBlendEquation);
static_assert(7 == kColorDodge_GrBlendEquation);
static_assert(8 == kColorBurn_GrBlendEquation);
static_assert(9 == kHardLight_GrBlendEquation);
static_assert(10 == kSoftLight_GrBlendEquation);
static_assert(11 == kDifference_GrBlendEquation);
static_assert(12 == kExclusion_GrBlendEquation);
static_assert(13 == kMultiply_GrBlendEquation);
static_assert(14 == kHSLHue_GrBlendEquation);
static_assert(15 == kHSLSaturation_GrBlendEquation);
static_assert(16 == kHSLColor_GrBlendEquation);
static_assert(17 == kHSLLuminosity_GrBlendEquation);
static_assert(SK_ARRAY_COUNT(gXfermodeEquation2Blend) == kGrBlendEquationCnt);
static_assert(0 == (int)skgpu::BlendEquation::kAdd);
static_assert(1 == (int)skgpu::BlendEquation::kSubtract);
static_assert(2 == (int)skgpu::BlendEquation::kReverseSubtract);
static_assert(3 == (int)skgpu::BlendEquation::kScreen);
static_assert(4 == (int)skgpu::BlendEquation::kOverlay);
static_assert(5 == (int)skgpu::BlendEquation::kDarken);
static_assert(6 == (int)skgpu::BlendEquation::kLighten);
static_assert(7 == (int)skgpu::BlendEquation::kColorDodge);
static_assert(8 == (int)skgpu::BlendEquation::kColorBurn);
static_assert(9 == (int)skgpu::BlendEquation::kHardLight);
static_assert(10 == (int)skgpu::BlendEquation::kSoftLight);
static_assert(11 == (int)skgpu::BlendEquation::kDifference);
static_assert(12 == (int)skgpu::BlendEquation::kExclusion);
static_assert(13 == (int)skgpu::BlendEquation::kMultiply);
static_assert(14 == (int)skgpu::BlendEquation::kHSLHue);
static_assert(15 == (int)skgpu::BlendEquation::kHSLSaturation);
static_assert(16 == (int)skgpu::BlendEquation::kHSLColor);
static_assert(17 == (int)skgpu::BlendEquation::kHSLLuminosity);
static_assert(SK_ARRAY_COUNT(gXfermodeEquation2Blend) == skgpu::kBlendEquationCnt);
static const GrGLenum gXfermodeCoeff2Blend[] = {
GR_GL_ZERO,
@ -2552,19 +2552,19 @@ void GrGLGpu::flushBlendAndColorWrite(
// We need to work around a driver bug by using a blend state that preserves the dst color,
// rather than disabling color writes.
GrXferProcessor::BlendInfo preserveDstBlend;
preserveDstBlend.fSrcBlend = kZero_GrBlendCoeff;
preserveDstBlend.fDstBlend = kOne_GrBlendCoeff;
preserveDstBlend.fSrcBlend = skgpu::BlendCoeff::kZero;
preserveDstBlend.fDstBlend = skgpu::BlendCoeff::kOne;
this->flushBlendAndColorWrite(preserveDstBlend, swizzle);
return;
}
GrBlendEquation equation = blendInfo.fEquation;
GrBlendCoeff srcCoeff = blendInfo.fSrcBlend;
GrBlendCoeff dstCoeff = blendInfo.fDstBlend;
skgpu::BlendEquation equation = blendInfo.fEquation;
skgpu::BlendCoeff srcCoeff = blendInfo.fSrcBlend;
skgpu::BlendCoeff dstCoeff = blendInfo.fDstBlend;
// Any optimization to disable blending should have already been applied and
// tweaked the equation to "add" or "subtract", and the coeffs to (1, 0).
bool blendOff = GrBlendShouldDisable(equation, srcCoeff, dstCoeff) ||
bool blendOff = skgpu::BlendShouldDisable(equation, srcCoeff, dstCoeff) ||
!blendInfo.fWriteColor;
if (blendOff) {
@ -2574,12 +2574,12 @@ void GrGLGpu::flushBlendAndColorWrite(
// Workaround for the ARM KHR_blend_equation_advanced disable flags issue
// https://code.google.com/p/skia/issues/detail?id=3943
if (this->ctxInfo().vendor() == GrGLVendor::kARM &&
GrBlendEquationIsAdvanced(fHWBlendState.fEquation)) {
skgpu::BlendEquationIsAdvanced(fHWBlendState.fEquation)) {
SkASSERT(this->caps()->advancedBlendEquationSupport());
// Set to any basic blending equation.
GrBlendEquation blend_equation = kAdd_GrBlendEquation;
GL_CALL(BlendEquation(gXfermodeEquation2Blend[blend_equation]));
fHWBlendState.fEquation = blend_equation;
skgpu::BlendEquation blendEquation = skgpu::BlendEquation::kAdd;
GL_CALL(BlendEquation(gXfermodeEquation2Blend[(int)blendEquation]));
fHWBlendState.fEquation = blendEquation;
}
// Workaround for Adreno 5xx BlendFunc bug. See crbug.com/1241134.
@ -2587,14 +2587,14 @@ void GrGLGpu::flushBlendAndColorWrite(
// reset our gl state and thus we will have forgotten if the previous use was a coeff
// that referenced src2.
if (this->glCaps().mustResetBlendFuncBetweenDualSourceAndDisable() &&
(GrBlendCoeffRefsSrc2(fHWBlendState.fSrcCoeff) ||
GrBlendCoeffRefsSrc2(fHWBlendState.fDstCoeff) ||
fHWBlendState.fSrcCoeff == kIllegal_GrBlendCoeff ||
fHWBlendState.fDstCoeff == kIllegal_GrBlendCoeff)) {
(skgpu::BlendCoeffRefsSrc2(fHWBlendState.fSrcCoeff) ||
skgpu::BlendCoeffRefsSrc2(fHWBlendState.fDstCoeff) ||
fHWBlendState.fSrcCoeff == skgpu::BlendCoeff::kIllegal ||
fHWBlendState.fDstCoeff == skgpu::BlendCoeff::kIllegal)) {
// We just reset the blend func to anything that doesn't reference src2
GL_CALL(BlendFunc(GR_GL_ONE, GR_GL_ZERO));
fHWBlendState.fSrcCoeff = kOne_GrBlendCoeff;
fHWBlendState.fDstCoeff = kZero_GrBlendCoeff;
fHWBlendState.fSrcCoeff = skgpu::BlendCoeff::kOne;
fHWBlendState.fDstCoeff = skgpu::BlendCoeff::kZero;
}
fHWBlendState.fEnabled = kNo_TriState;
@ -2607,24 +2607,24 @@ void GrGLGpu::flushBlendAndColorWrite(
}
if (fHWBlendState.fEquation != equation) {
GL_CALL(BlendEquation(gXfermodeEquation2Blend[equation]));
GL_CALL(BlendEquation(gXfermodeEquation2Blend[(int)equation]));
fHWBlendState.fEquation = equation;
}
if (GrBlendEquationIsAdvanced(equation)) {
if (skgpu::BlendEquationIsAdvanced(equation)) {
SkASSERT(this->caps()->advancedBlendEquationSupport());
// Advanced equations have no other blend state.
return;
}
if (fHWBlendState.fSrcCoeff != srcCoeff || fHWBlendState.fDstCoeff != dstCoeff) {
GL_CALL(BlendFunc(gXfermodeCoeff2Blend[srcCoeff],
gXfermodeCoeff2Blend[dstCoeff]));
GL_CALL(BlendFunc(gXfermodeCoeff2Blend[(int)srcCoeff],
gXfermodeCoeff2Blend[(int)dstCoeff]));
fHWBlendState.fSrcCoeff = srcCoeff;
fHWBlendState.fDstCoeff = dstCoeff;
}
if (GrBlendCoeffRefsConstant(srcCoeff) || GrBlendCoeffRefsConstant(dstCoeff)) {
if (skgpu::BlendCoeffRefsConstant(srcCoeff) || skgpu::BlendCoeffRefsConstant(dstCoeff)) {
SkPMColor4f blendConst = swizzle.applyTo(blendInfo.fBlendConstant);
if (!fHWBlendState.fConstColorValid || fHWBlendState.fConstColor != blendConst) {
GL_CALL(BlendColor(blendConst.fR, blendConst.fG, blendConst.fB, blendConst.fA));

View File

@ -705,17 +705,17 @@ private:
void setNeedsFlush() { fNeedsGLFlush = true; }
struct {
GrBlendEquation fEquation;
GrBlendCoeff fSrcCoeff;
GrBlendCoeff fDstCoeff;
SkPMColor4f fConstColor;
bool fConstColorValid;
TriState fEnabled;
skgpu::BlendEquation fEquation;
skgpu::BlendCoeff fSrcCoeff;
skgpu::BlendCoeff fDstCoeff;
SkPMColor4f fConstColor;
bool fConstColorValid;
TriState fEnabled;
void invalidate() {
fEquation = kIllegal_GrBlendEquation;
fSrcCoeff = kIllegal_GrBlendCoeff;
fDstCoeff = kIllegal_GrBlendCoeff;
fEquation = skgpu::BlendEquation::kIllegal;
fSrcCoeff = skgpu::BlendCoeff::kIllegal;
fDstCoeff = skgpu::BlendCoeff::kIllegal;
fConstColorValid = false;
fEnabled = kUnknown_TriState;
}

View File

@ -38,8 +38,9 @@ const char* GrGLSLFragmentShaderBuilder::dstColor() {
return kDstColorName;
}
void GrGLSLFragmentShaderBuilder::enableAdvancedBlendEquationIfNeeded(GrBlendEquation equation) {
SkASSERT(GrBlendEquationIsAdvanced(equation));
void GrGLSLFragmentShaderBuilder::enableAdvancedBlendEquationIfNeeded(
skgpu::BlendEquation equation) {
SkASSERT(skgpu::BlendEquationIsAdvanced(equation));
if (fProgramBuilder->shaderCaps()->mustEnableAdvBlendEqs()) {
this->addFeature(1 << kBlendEquationAdvanced_GLSLPrivateFeature,

View File

@ -8,7 +8,7 @@
#ifndef GrGLSLFragmentShaderBuilder_DEFINED
#define GrGLSLFragmentShaderBuilder_DEFINED
#include "src/gpu/GrBlend.h"
#include "src/gpu/Blend.h"
#include "src/gpu/GrFragmentProcessor.h"
#include "src/gpu/GrProcessor.h"
#include "src/gpu/glsl/GrGLSLShaderBuilder.h"
@ -74,7 +74,7 @@ public:
/** Adds any necessary layout qualifiers in order to legalize the supplied blend equation with
this shader. It is only legal to call this method with an advanced blend equation, and only
if these equations are supported. */
virtual void enableAdvancedBlendEquationIfNeeded(GrBlendEquation) = 0;
virtual void enableAdvancedBlendEquationIfNeeded(skgpu::BlendEquation) = 0;
};
/*
@ -93,7 +93,7 @@ public:
// GrGLSLXPFragmentBuilder interface.
bool hasCustomColorOutput() const override { return SkToBool(fCustomColorOutput); }
bool hasSecondaryOutput() const override { return fHasSecondaryOutput; }
void enableAdvancedBlendEquationIfNeeded(GrBlendEquation) override;
void enableAdvancedBlendEquationIfNeeded(skgpu::BlendEquation) override;
private:
// Private public interface, used by GrGLProgramBuilder to build a fragment shader

View File

@ -165,9 +165,9 @@ void GrMtlPipelineState::setBlendConstants(GrMtlRenderCommandEncoder* renderCmdE
}
const GrXferProcessor::BlendInfo& blendInfo = xferProcessor.getBlendInfo();
GrBlendCoeff srcCoeff = blendInfo.fSrcBlend;
GrBlendCoeff dstCoeff = blendInfo.fDstBlend;
if (GrBlendCoeffRefsConstant(srcCoeff) || GrBlendCoeffRefsConstant(dstCoeff)) {
skgpu::BlendCoeff srcCoeff = blendInfo.fSrcBlend;
skgpu::BlendCoeff dstCoeff = blendInfo.fDstBlend;
if (skgpu::BlendCoeffRefsConstant(srcCoeff) || skgpu::BlendCoeffRefsConstant(dstCoeff)) {
// Swizzle the blend to match what the shader will output.
SkPMColor4f blendConst = swizzle.applyTo(blendInfo.fBlendConstant);

View File

@ -259,76 +259,76 @@ static MTLVertexDescriptor* create_vertex_descriptor(const GrGeometryProcessor&
return vertexDescriptor;
}
static MTLBlendFactor blend_coeff_to_mtl_blend(GrBlendCoeff coeff) {
static MTLBlendFactor blend_coeff_to_mtl_blend(skgpu::BlendCoeff coeff) {
switch (coeff) {
case kZero_GrBlendCoeff:
case skgpu::BlendCoeff::kZero:
return MTLBlendFactorZero;
case kOne_GrBlendCoeff:
case skgpu::BlendCoeff::kOne:
return MTLBlendFactorOne;
case kSC_GrBlendCoeff:
case skgpu::BlendCoeff::kSC:
return MTLBlendFactorSourceColor;
case kISC_GrBlendCoeff:
case skgpu::BlendCoeff::kISC:
return MTLBlendFactorOneMinusSourceColor;
case kDC_GrBlendCoeff:
case skgpu::BlendCoeff::kDC:
return MTLBlendFactorDestinationColor;
case kIDC_GrBlendCoeff:
case skgpu::BlendCoeff::kIDC:
return MTLBlendFactorOneMinusDestinationColor;
case kSA_GrBlendCoeff:
case skgpu::BlendCoeff::kSA:
return MTLBlendFactorSourceAlpha;
case kISA_GrBlendCoeff:
case skgpu::BlendCoeff::kISA:
return MTLBlendFactorOneMinusSourceAlpha;
case kDA_GrBlendCoeff:
case skgpu::BlendCoeff::kDA:
return MTLBlendFactorDestinationAlpha;
case kIDA_GrBlendCoeff:
case skgpu::BlendCoeff::kIDA:
return MTLBlendFactorOneMinusDestinationAlpha;
case kConstC_GrBlendCoeff:
case skgpu::BlendCoeff::kConstC:
return MTLBlendFactorBlendColor;
case kIConstC_GrBlendCoeff:
case skgpu::BlendCoeff::kIConstC:
return MTLBlendFactorOneMinusBlendColor;
case kS2C_GrBlendCoeff:
case skgpu::BlendCoeff::kS2C:
if (@available(macOS 10.12, iOS 11.0, *)) {
return MTLBlendFactorSource1Color;
} else {
return MTLBlendFactorZero;
}
case kIS2C_GrBlendCoeff:
case skgpu::BlendCoeff::kIS2C:
if (@available(macOS 10.12, iOS 11.0, *)) {
return MTLBlendFactorOneMinusSource1Color;
} else {
return MTLBlendFactorZero;
}
case kS2A_GrBlendCoeff:
case skgpu::BlendCoeff::kS2A:
if (@available(macOS 10.12, iOS 11.0, *)) {
return MTLBlendFactorSource1Alpha;
} else {
return MTLBlendFactorZero;
}
case kIS2A_GrBlendCoeff:
case skgpu::BlendCoeff::kIS2A:
if (@available(macOS 10.12, iOS 11.0, *)) {
return MTLBlendFactorOneMinusSource1Alpha;
} else {
return MTLBlendFactorZero;
}
case kIllegal_GrBlendCoeff:
case skgpu::BlendCoeff::kIllegal:
return MTLBlendFactorZero;
}
SK_ABORT("Unknown blend coefficient");
}
static MTLBlendOperation blend_equation_to_mtl_blend_op(GrBlendEquation equation) {
static MTLBlendOperation blend_equation_to_mtl_blend_op(skgpu::BlendEquation equation) {
static const MTLBlendOperation gTable[] = {
MTLBlendOperationAdd, // kAdd_GrBlendEquation
MTLBlendOperationSubtract, // kSubtract_GrBlendEquation
MTLBlendOperationReverseSubtract, // kReverseSubtract_GrBlendEquation
MTLBlendOperationAdd, // skgpu::BlendEquation::kAdd
MTLBlendOperationSubtract, // skgpu::BlendEquation::kSubtract
MTLBlendOperationReverseSubtract, // skgpu::BlendEquation::kReverseSubtract
};
static_assert(SK_ARRAY_COUNT(gTable) == kFirstAdvancedGrBlendEquation);
static_assert(0 == kAdd_GrBlendEquation);
static_assert(1 == kSubtract_GrBlendEquation);
static_assert(2 == kReverseSubtract_GrBlendEquation);
static_assert(SK_ARRAY_COUNT(gTable) == (int)skgpu::BlendEquation::kFirstAdvanced);
static_assert(0 == (int)skgpu::BlendEquation::kAdd);
static_assert(1 == (int)skgpu::BlendEquation::kSubtract);
static_assert(2 == (int)skgpu::BlendEquation::kReverseSubtract);
SkASSERT((unsigned)equation < kGrBlendEquationCnt);
return gTable[equation];
SkASSERT((unsigned)equation < skgpu::kBlendEquationCnt);
return gTable[(int)equation];
}
static MTLRenderPipelineColorAttachmentDescriptor* create_color_attachment(
@ -344,10 +344,10 @@ static MTLRenderPipelineColorAttachmentDescriptor* create_color_attachment(
// blending
const GrXferProcessor::BlendInfo& blendInfo = pipeline.getXferProcessor().getBlendInfo();
GrBlendEquation equation = blendInfo.fEquation;
GrBlendCoeff srcCoeff = blendInfo.fSrcBlend;
GrBlendCoeff dstCoeff = blendInfo.fDstBlend;
bool blendOn = !GrBlendShouldDisable(equation, srcCoeff, dstCoeff);
skgpu::BlendEquation equation = blendInfo.fEquation;
skgpu::BlendCoeff srcCoeff = blendInfo.fSrcBlend;
skgpu::BlendCoeff dstCoeff = blendInfo.fDstBlend;
bool blendOn = !skgpu::BlendShouldDisable(equation, srcCoeff, dstCoeff);
mtlColorAttachment.blendingEnabled = blendOn;
if (writer) {

View File

@ -289,47 +289,47 @@ static void setup_multisample_state(int numSamples,
multisampleInfo->alphaToOneEnable = VK_FALSE;
}
static VkBlendFactor blend_coeff_to_vk_blend(GrBlendCoeff coeff) {
static VkBlendFactor blend_coeff_to_vk_blend(skgpu::BlendCoeff coeff) {
switch (coeff) {
case kZero_GrBlendCoeff:
case skgpu::BlendCoeff::kZero:
return VK_BLEND_FACTOR_ZERO;
case kOne_GrBlendCoeff:
case skgpu::BlendCoeff::kOne:
return VK_BLEND_FACTOR_ONE;
case kSC_GrBlendCoeff:
case skgpu::BlendCoeff::kSC:
return VK_BLEND_FACTOR_SRC_COLOR;
case kISC_GrBlendCoeff:
case skgpu::BlendCoeff::kISC:
return VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR;
case kDC_GrBlendCoeff:
case skgpu::BlendCoeff::kDC:
return VK_BLEND_FACTOR_DST_COLOR;
case kIDC_GrBlendCoeff:
case skgpu::BlendCoeff::kIDC:
return VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR;
case kSA_GrBlendCoeff:
case skgpu::BlendCoeff::kSA:
return VK_BLEND_FACTOR_SRC_ALPHA;
case kISA_GrBlendCoeff:
case skgpu::BlendCoeff::kISA:
return VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
case kDA_GrBlendCoeff:
case skgpu::BlendCoeff::kDA:
return VK_BLEND_FACTOR_DST_ALPHA;
case kIDA_GrBlendCoeff:
case skgpu::BlendCoeff::kIDA:
return VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA;
case kConstC_GrBlendCoeff:
case skgpu::BlendCoeff::kConstC:
return VK_BLEND_FACTOR_CONSTANT_COLOR;
case kIConstC_GrBlendCoeff:
case skgpu::BlendCoeff::kIConstC:
return VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR;
case kS2C_GrBlendCoeff:
case skgpu::BlendCoeff::kS2C:
return VK_BLEND_FACTOR_SRC1_COLOR;
case kIS2C_GrBlendCoeff:
case skgpu::BlendCoeff::kIS2C:
return VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR;
case kS2A_GrBlendCoeff:
case skgpu::BlendCoeff::kS2A:
return VK_BLEND_FACTOR_SRC1_ALPHA;
case kIS2A_GrBlendCoeff:
case skgpu::BlendCoeff::kIS2A:
return VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA;
case kIllegal_GrBlendCoeff:
case skgpu::BlendCoeff::kIllegal:
return VK_BLEND_FACTOR_ZERO;
}
SkUNREACHABLE;
}
static VkBlendOp blend_equation_to_vk_blend_op(GrBlendEquation equation) {
static VkBlendOp blend_equation_to_vk_blend_op(skgpu::BlendEquation equation) {
static const VkBlendOp gTable[] = {
// Basic blend ops
VK_BLEND_OP_ADD,
@ -356,37 +356,37 @@ static VkBlendOp blend_equation_to_vk_blend_op(GrBlendEquation equation) {
// Illegal.
VK_BLEND_OP_ADD,
};
static_assert(0 == kAdd_GrBlendEquation);
static_assert(1 == kSubtract_GrBlendEquation);
static_assert(2 == kReverseSubtract_GrBlendEquation);
static_assert(3 == kScreen_GrBlendEquation);
static_assert(4 == kOverlay_GrBlendEquation);
static_assert(5 == kDarken_GrBlendEquation);
static_assert(6 == kLighten_GrBlendEquation);
static_assert(7 == kColorDodge_GrBlendEquation);
static_assert(8 == kColorBurn_GrBlendEquation);
static_assert(9 == kHardLight_GrBlendEquation);
static_assert(10 == kSoftLight_GrBlendEquation);
static_assert(11 == kDifference_GrBlendEquation);
static_assert(12 == kExclusion_GrBlendEquation);
static_assert(13 == kMultiply_GrBlendEquation);
static_assert(14 == kHSLHue_GrBlendEquation);
static_assert(15 == kHSLSaturation_GrBlendEquation);
static_assert(16 == kHSLColor_GrBlendEquation);
static_assert(17 == kHSLLuminosity_GrBlendEquation);
static_assert(SK_ARRAY_COUNT(gTable) == kGrBlendEquationCnt);
static_assert(0 == (int)skgpu::BlendEquation::kAdd);
static_assert(1 == (int)skgpu::BlendEquation::kSubtract);
static_assert(2 == (int)skgpu::BlendEquation::kReverseSubtract);
static_assert(3 == (int)skgpu::BlendEquation::kScreen);
static_assert(4 == (int)skgpu::BlendEquation::kOverlay);
static_assert(5 == (int)skgpu::BlendEquation::kDarken);
static_assert(6 == (int)skgpu::BlendEquation::kLighten);
static_assert(7 == (int)skgpu::BlendEquation::kColorDodge);
static_assert(8 == (int)skgpu::BlendEquation::kColorBurn);
static_assert(9 == (int)skgpu::BlendEquation::kHardLight);
static_assert(10 == (int)skgpu::BlendEquation::kSoftLight);
static_assert(11 == (int)skgpu::BlendEquation::kDifference);
static_assert(12 == (int)skgpu::BlendEquation::kExclusion);
static_assert(13 == (int)skgpu::BlendEquation::kMultiply);
static_assert(14 == (int)skgpu::BlendEquation::kHSLHue);
static_assert(15 == (int)skgpu::BlendEquation::kHSLSaturation);
static_assert(16 == (int)skgpu::BlendEquation::kHSLColor);
static_assert(17 == (int)skgpu::BlendEquation::kHSLLuminosity);
static_assert(SK_ARRAY_COUNT(gTable) == skgpu::kBlendEquationCnt);
SkASSERT((unsigned)equation < kGrBlendEquationCnt);
return gTable[equation];
SkASSERT((unsigned)equation < skgpu::kBlendEquationCnt);
return gTable[(int)equation];
}
static void setup_color_blend_state(const GrXferProcessor::BlendInfo& blendInfo,
VkPipelineColorBlendStateCreateInfo* colorBlendInfo,
VkPipelineColorBlendAttachmentState* attachmentState) {
GrBlendEquation equation = blendInfo.fEquation;
GrBlendCoeff srcCoeff = blendInfo.fSrcBlend;
GrBlendCoeff dstCoeff = blendInfo.fDstBlend;
bool blendOff = GrBlendShouldDisable(equation, srcCoeff, dstCoeff);
skgpu::BlendEquation equation = blendInfo.fEquation;
skgpu::BlendCoeff srcCoeff = blendInfo.fSrcBlend;
skgpu::BlendCoeff dstCoeff = blendInfo.fDstBlend;
bool blendOff = skgpu::BlendShouldDisable(equation, srcCoeff, dstCoeff);
memset(attachmentState, 0, sizeof(VkPipelineColorBlendAttachmentState));
attachmentState->blendEnable = !blendOff;
@ -648,10 +648,10 @@ void GrVkPipeline::SetDynamicBlendConstantState(GrVkGpu* gpu,
const skgpu::Swizzle& swizzle,
const GrXferProcessor& xferProcessor) {
const GrXferProcessor::BlendInfo& blendInfo = xferProcessor.getBlendInfo();
GrBlendCoeff srcCoeff = blendInfo.fSrcBlend;
GrBlendCoeff dstCoeff = blendInfo.fDstBlend;
skgpu::BlendCoeff srcCoeff = blendInfo.fSrcBlend;
skgpu::BlendCoeff dstCoeff = blendInfo.fDstBlend;
float floatColors[4];
if (GrBlendCoeffRefsConstant(srcCoeff) || GrBlendCoeffRefsConstant(dstCoeff)) {
if (skgpu::BlendCoeffRefsConstant(srcCoeff) || skgpu::BlendCoeffRefsConstant(dstCoeff)) {
// Swizzle the blend to match what the shader will output.
SkPMColor4f blendConst = swizzle.applyTo(blendInfo.fBlendConstant);
floatColors[0] = blendConst.fR;

View File

@ -9,7 +9,7 @@
#include "include/gpu/GrDirectContext.h"
#include "include/private/GrTypesPriv.h"
#include "include/private/SkColorData.h"
#include "src/gpu/GrBlend.h"
#include "src/gpu/Blend.h"
#include "src/gpu/GrCaps.h"
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrPaint.h"
@ -30,8 +30,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(AdvancedBlendTest, reporter, ctxInfo) {
for (int mode = (int)SkBlendMode::kLastMode; mode > (int)SkBlendMode::kLastCoeffMode; --mode) {
const SkBlendMode blendMode = (SkBlendMode)mode;
const GrBlendEquation blendEquation =
(GrBlendEquation)(mode + (kOverlay_GrBlendEquation - (int)SkBlendMode::kOverlay));
const skgpu::BlendEquation blendEquation = (skgpu::BlendEquation)(mode +
((int)skgpu::BlendEquation::kOverlay - (int)SkBlendMode::kOverlay));
const GrXPFactory* xpf = GrCustomXfermode::Get(blendMode);
GrXPFactory::AnalysisProperties xpfAnalysis =

View File

@ -104,7 +104,8 @@ public:
TEST_ASSERT(!xp->willReadDstColor() ||
(isLCD && (SkBlendMode::kSrcOver != xfermode ||
!inputColor.isOpaque())));
TEST_ASSERT(xp->hasSecondaryOutput() == GrBlendCoeffRefsSrc2(fBlendInfo.fDstBlend));
TEST_ASSERT(xp->hasSecondaryOutput() ==
skgpu::BlendCoeffRefsSrc2(fBlendInfo.fDstBlend));
}
bool fCompatibleWithCoverageAsAlpha;
@ -134,9 +135,9 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps)
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kSrc:
@ -145,9 +146,9 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps)
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kDst:
@ -156,9 +157,9 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps)
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kSrcOver:
@ -167,9 +168,9 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps)
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kSAModulate_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kIS2C == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kDstOver:
@ -178,9 +179,9 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps)
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kSrcIn:
@ -189,9 +190,9 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps)
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kDstIn:
@ -200,9 +201,9 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps)
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kSrcOut:
@ -211,9 +212,9 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps)
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kDstOut:
@ -222,9 +223,9 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps)
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kSrcATop:
@ -233,9 +234,9 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps)
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kDstATop:
@ -244,9 +245,9 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps)
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kXor:
@ -255,9 +256,9 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps)
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kPlus:
@ -266,9 +267,9 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps)
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kModulate:
@ -277,9 +278,9 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps)
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kScreen:
@ -288,9 +289,9 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps)
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
default:
@ -313,9 +314,9 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kReverseSubtract == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kDC == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kSrc:
@ -324,9 +325,9 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kIS2A_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kIS2A == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kDst:
@ -335,9 +336,9 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(!xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kSrcOver:
@ -346,9 +347,9 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kISA == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kDstOver:
@ -357,9 +358,9 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kIDA == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kSrcIn:
@ -368,9 +369,9 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kIS2A_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kDA == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kIS2A == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kDstIn:
@ -379,9 +380,9 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kISAModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kReverseSubtract == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kDC == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kSrcOut:
@ -390,9 +391,9 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kIS2A_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kIDA == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kIS2A == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kDstOut:
@ -401,9 +402,9 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kISA == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kSrcATop:
@ -412,9 +413,9 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kDA == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kISA == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kDstATop:
@ -423,9 +424,9 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kISAModulate_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kIDA == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kIS2C == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kXor:
@ -434,9 +435,9 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kIDA == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kISA == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kPlus:
@ -445,9 +446,9 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kModulate:
@ -456,9 +457,9 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kISCModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kReverseSubtract == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kDC == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kScreen:
@ -467,9 +468,9 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kISC == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
default:
@ -494,9 +495,9 @@ static void test_color_not_opaque_no_coverage(skiatest::Reporter* reporter, cons
TEST_ASSERT(xpi.fUnaffectedByDstValue);
TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kSrc:
@ -505,9 +506,9 @@ static void test_color_not_opaque_no_coverage(skiatest::Reporter* reporter, cons
TEST_ASSERT(xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kDst:
@ -516,9 +517,9 @@ static void test_color_not_opaque_no_coverage(skiatest::Reporter* reporter, cons
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(!xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kSrcOver:
@ -527,9 +528,9 @@ static void test_color_not_opaque_no_coverage(skiatest::Reporter* reporter, cons
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kISA == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kDstOver:
@ -538,9 +539,9 @@ static void test_color_not_opaque_no_coverage(skiatest::Reporter* reporter, cons
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kIDA == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kSrcIn:
@ -549,9 +550,9 @@ static void test_color_not_opaque_no_coverage(skiatest::Reporter* reporter, cons
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kDA == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kDstIn:
@ -560,9 +561,9 @@ static void test_color_not_opaque_no_coverage(skiatest::Reporter* reporter, cons
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kSA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kSA == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kSrcOut:
@ -571,9 +572,9 @@ static void test_color_not_opaque_no_coverage(skiatest::Reporter* reporter, cons
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kIDA == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kDstOut:
@ -582,9 +583,9 @@ static void test_color_not_opaque_no_coverage(skiatest::Reporter* reporter, cons
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kISA == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kSrcATop:
@ -593,9 +594,9 @@ static void test_color_not_opaque_no_coverage(skiatest::Reporter* reporter, cons
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kDA == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kISA == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kDstATop:
@ -604,9 +605,9 @@ static void test_color_not_opaque_no_coverage(skiatest::Reporter* reporter, cons
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kSA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kIDA == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kSA == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kXor:
@ -615,9 +616,9 @@ static void test_color_not_opaque_no_coverage(skiatest::Reporter* reporter, cons
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kIDA == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kISA == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kPlus:
@ -626,9 +627,9 @@ static void test_color_not_opaque_no_coverage(skiatest::Reporter* reporter, cons
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kModulate:
@ -637,9 +638,9 @@ static void test_color_not_opaque_no_coverage(skiatest::Reporter* reporter, cons
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kSC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kSC == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kScreen:
@ -648,9 +649,9 @@ static void test_color_not_opaque_no_coverage(skiatest::Reporter* reporter, cons
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kISC == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
default:
@ -674,9 +675,9 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kReverseSubtract == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kDC == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kSrc:
@ -685,9 +686,9 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kISA == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kDst:
@ -696,9 +697,9 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(!xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kSrcOver:
@ -707,9 +708,9 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kISA == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kDstOver:
@ -718,9 +719,9 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kIDA == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kSrcIn:
@ -729,9 +730,9 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kDA == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kISA == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kDstIn:
@ -740,9 +741,9 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(!xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kSrcOut:
@ -751,9 +752,9 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kIDA == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kISA == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kDstOut:
@ -762,9 +763,9 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kReverseSubtract == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kDC == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kSrcATop:
@ -773,9 +774,9 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kDA == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kISA == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kDstATop:
@ -784,9 +785,9 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kIDA == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kXor:
@ -795,9 +796,9 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kIDA == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kISA == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kPlus:
@ -806,18 +807,18 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kModulate:
TEST_ASSERT(!xpi.fIgnoresInputColor);
TEST_ASSERT(kISCModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kReverseSubtract == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kDC == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kScreen:
@ -826,9 +827,9 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kISC == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
default:
@ -853,9 +854,9 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr
TEST_ASSERT(xpi.fUnaffectedByDstValue);
TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kSrc:
@ -864,9 +865,9 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr
TEST_ASSERT(xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kDst:
@ -875,9 +876,9 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(!xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kSrcOver:
@ -887,12 +888,12 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr
TEST_ASSERT(xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
if (caps.shouldCollapseSrcOverToSrcWhenAble()) {
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fDstBlend);
} else {
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendCoeff::kISA == xpi.fBlendInfo.fDstBlend);
}
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
@ -902,9 +903,9 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kIDA == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kSrcIn:
@ -913,9 +914,9 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kDA == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kDstIn:
@ -924,9 +925,9 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(!xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kSrcOut:
@ -935,9 +936,9 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kIDA == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kDstOut:
@ -946,9 +947,9 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr
TEST_ASSERT(xpi.fUnaffectedByDstValue);
TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kSrcATop:
@ -957,9 +958,9 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kDA == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kDstATop:
@ -968,9 +969,9 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kIDA == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kXor:
@ -979,9 +980,9 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kIDA == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kPlus:
@ -990,9 +991,9 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kModulate:
@ -1001,9 +1002,9 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kSC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kZero == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kSC == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
case SkBlendMode::kScreen:
@ -1012,9 +1013,9 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr
TEST_ASSERT(!xpi.fUnaffectedByDstValue);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(skgpu::BlendEquation::kAdd == xpi.fBlendInfo.fEquation);
TEST_ASSERT(skgpu::BlendCoeff::kOne == xpi.fBlendInfo.fSrcBlend);
TEST_ASSERT(skgpu::BlendCoeff::kISC == xpi.fBlendInfo.fDstBlend);
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
break;
default: