Remove constexpr workarounds for no-longer-supported compilers.
Skia has a C++17 baseline, which rules out MSVC2015 and gcc 4 as supported platforms. Change-Id: I3ee87d02020b0a45b6b4a59643b437941da6edd9 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/306603 Auto-Submit: John Stiles <johnstiles@google.com> Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
1aaf41b7a7
commit
7b45c2f871
@ -127,82 +127,72 @@ constexpr GrCoverageSetOpXPFactory::GrCoverageSetOpXPFactory(SkRegion::Op region
|
||||
: fRegionOp(regionOp), fInvertCoverage(invertCoverage) {}
|
||||
|
||||
const GrXPFactory* GrCoverageSetOpXPFactory::Get(SkRegion::Op regionOp, bool invertCoverage) {
|
||||
// If these objects are constructed as static constexpr by cl.exe (2015 SP2) the vtables are
|
||||
// null.
|
||||
#ifdef SK_BUILD_FOR_WIN
|
||||
#define _CONSTEXPR_
|
||||
#else
|
||||
#define _CONSTEXPR_ constexpr
|
||||
#endif
|
||||
switch (regionOp) {
|
||||
case SkRegion::kReplace_Op: {
|
||||
if (invertCoverage) {
|
||||
static _CONSTEXPR_ const GrCoverageSetOpXPFactory gReplaceCDXPFI(
|
||||
static constexpr const GrCoverageSetOpXPFactory gReplaceCDXPFI(
|
||||
SkRegion::kReplace_Op, true);
|
||||
return &gReplaceCDXPFI;
|
||||
} else {
|
||||
static _CONSTEXPR_ const GrCoverageSetOpXPFactory gReplaceCDXPF(
|
||||
SkRegion::kReplace_Op, false);
|
||||
static constexpr const GrCoverageSetOpXPFactory gReplaceCDXPF(SkRegion::kReplace_Op,
|
||||
false);
|
||||
return &gReplaceCDXPF;
|
||||
}
|
||||
}
|
||||
case SkRegion::kIntersect_Op: {
|
||||
if (invertCoverage) {
|
||||
static _CONSTEXPR_ const GrCoverageSetOpXPFactory gIntersectCDXPFI(
|
||||
static constexpr const GrCoverageSetOpXPFactory gIntersectCDXPFI(
|
||||
SkRegion::kIntersect_Op, true);
|
||||
return &gIntersectCDXPFI;
|
||||
} else {
|
||||
static _CONSTEXPR_ const GrCoverageSetOpXPFactory gIntersectCDXPF(
|
||||
static constexpr const GrCoverageSetOpXPFactory gIntersectCDXPF(
|
||||
SkRegion::kIntersect_Op, false);
|
||||
return &gIntersectCDXPF;
|
||||
}
|
||||
}
|
||||
case SkRegion::kUnion_Op: {
|
||||
if (invertCoverage) {
|
||||
static _CONSTEXPR_ const GrCoverageSetOpXPFactory gUnionCDXPFI(SkRegion::kUnion_Op,
|
||||
true);
|
||||
static constexpr const GrCoverageSetOpXPFactory gUnionCDXPFI(SkRegion::kUnion_Op,
|
||||
true);
|
||||
return &gUnionCDXPFI;
|
||||
} else {
|
||||
static _CONSTEXPR_ const GrCoverageSetOpXPFactory gUnionCDXPF(SkRegion::kUnion_Op,
|
||||
false);
|
||||
static constexpr const GrCoverageSetOpXPFactory gUnionCDXPF(SkRegion::kUnion_Op,
|
||||
false);
|
||||
return &gUnionCDXPF;
|
||||
}
|
||||
}
|
||||
case SkRegion::kXOR_Op: {
|
||||
if (invertCoverage) {
|
||||
static _CONSTEXPR_ const GrCoverageSetOpXPFactory gXORCDXPFI(SkRegion::kXOR_Op,
|
||||
true);
|
||||
static constexpr const GrCoverageSetOpXPFactory gXORCDXPFI(SkRegion::kXOR_Op, true);
|
||||
return &gXORCDXPFI;
|
||||
} else {
|
||||
static _CONSTEXPR_ const GrCoverageSetOpXPFactory gXORCDXPF(SkRegion::kXOR_Op,
|
||||
false);
|
||||
static constexpr const GrCoverageSetOpXPFactory gXORCDXPF(SkRegion::kXOR_Op, false);
|
||||
return &gXORCDXPF;
|
||||
}
|
||||
}
|
||||
case SkRegion::kDifference_Op: {
|
||||
if (invertCoverage) {
|
||||
static _CONSTEXPR_ const GrCoverageSetOpXPFactory gDifferenceCDXPFI(
|
||||
static constexpr const GrCoverageSetOpXPFactory gDifferenceCDXPFI(
|
||||
SkRegion::kDifference_Op, true);
|
||||
return &gDifferenceCDXPFI;
|
||||
} else {
|
||||
static _CONSTEXPR_ const GrCoverageSetOpXPFactory gDifferenceCDXPF(
|
||||
static constexpr const GrCoverageSetOpXPFactory gDifferenceCDXPF(
|
||||
SkRegion::kDifference_Op, false);
|
||||
return &gDifferenceCDXPF;
|
||||
}
|
||||
}
|
||||
case SkRegion::kReverseDifference_Op: {
|
||||
if (invertCoverage) {
|
||||
static _CONSTEXPR_ const GrCoverageSetOpXPFactory gRevDiffCDXPFI(
|
||||
static constexpr const GrCoverageSetOpXPFactory gRevDiffCDXPFI(
|
||||
SkRegion::kReverseDifference_Op, true);
|
||||
return &gRevDiffCDXPFI;
|
||||
} else {
|
||||
static _CONSTEXPR_ const GrCoverageSetOpXPFactory gRevDiffCDXPF(
|
||||
static constexpr const GrCoverageSetOpXPFactory gRevDiffCDXPF(
|
||||
SkRegion::kReverseDifference_Op, false);
|
||||
return &gRevDiffCDXPF;
|
||||
}
|
||||
}
|
||||
}
|
||||
#undef _CONSTEXPR_
|
||||
SK_ABORT("Unknown region op.");
|
||||
}
|
||||
|
||||
|
@ -377,28 +377,20 @@ const GrXPFactory* CustomXPFactory::TestGet(GrProcessorTestData* d) {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const GrXPFactory* GrCustomXfermode::Get(SkBlendMode mode) {
|
||||
// If these objects are constructed as static constexpr by cl.exe (2015 SP2) the vtables are
|
||||
// null.
|
||||
#ifdef SK_BUILD_FOR_WIN
|
||||
#define _CONSTEXPR_
|
||||
#else
|
||||
#define _CONSTEXPR_ constexpr
|
||||
#endif
|
||||
static _CONSTEXPR_ const CustomXPFactory gOverlay(SkBlendMode::kOverlay);
|
||||
static _CONSTEXPR_ const CustomXPFactory gDarken(SkBlendMode::kDarken);
|
||||
static _CONSTEXPR_ const CustomXPFactory gLighten(SkBlendMode::kLighten);
|
||||
static _CONSTEXPR_ const CustomXPFactory gColorDodge(SkBlendMode::kColorDodge);
|
||||
static _CONSTEXPR_ const CustomXPFactory gColorBurn(SkBlendMode::kColorBurn);
|
||||
static _CONSTEXPR_ const CustomXPFactory gHardLight(SkBlendMode::kHardLight);
|
||||
static _CONSTEXPR_ const CustomXPFactory gSoftLight(SkBlendMode::kSoftLight);
|
||||
static _CONSTEXPR_ const CustomXPFactory gDifference(SkBlendMode::kDifference);
|
||||
static _CONSTEXPR_ const CustomXPFactory gExclusion(SkBlendMode::kExclusion);
|
||||
static _CONSTEXPR_ const CustomXPFactory gMultiply(SkBlendMode::kMultiply);
|
||||
static _CONSTEXPR_ const CustomXPFactory gHue(SkBlendMode::kHue);
|
||||
static _CONSTEXPR_ const CustomXPFactory gSaturation(SkBlendMode::kSaturation);
|
||||
static _CONSTEXPR_ const CustomXPFactory gColor(SkBlendMode::kColor);
|
||||
static _CONSTEXPR_ const CustomXPFactory gLuminosity(SkBlendMode::kLuminosity);
|
||||
#undef _CONSTEXPR_
|
||||
static constexpr const CustomXPFactory gOverlay(SkBlendMode::kOverlay);
|
||||
static constexpr const CustomXPFactory gDarken(SkBlendMode::kDarken);
|
||||
static constexpr const CustomXPFactory gLighten(SkBlendMode::kLighten);
|
||||
static constexpr const CustomXPFactory gColorDodge(SkBlendMode::kColorDodge);
|
||||
static constexpr const CustomXPFactory gColorBurn(SkBlendMode::kColorBurn);
|
||||
static constexpr const CustomXPFactory gHardLight(SkBlendMode::kHardLight);
|
||||
static constexpr const CustomXPFactory gSoftLight(SkBlendMode::kSoftLight);
|
||||
static constexpr const CustomXPFactory gDifference(SkBlendMode::kDifference);
|
||||
static constexpr const CustomXPFactory gExclusion(SkBlendMode::kExclusion);
|
||||
static constexpr const CustomXPFactory gMultiply(SkBlendMode::kMultiply);
|
||||
static constexpr const CustomXPFactory gHue(SkBlendMode::kHue);
|
||||
static constexpr const CustomXPFactory gSaturation(SkBlendMode::kSaturation);
|
||||
static constexpr const CustomXPFactory gColor(SkBlendMode::kColor);
|
||||
static constexpr const CustomXPFactory gLuminosity(SkBlendMode::kLuminosity);
|
||||
switch (mode) {
|
||||
case SkBlendMode::kOverlay:
|
||||
return &gOverlay;
|
||||
|
@ -55,12 +55,7 @@ private:
|
||||
#endif
|
||||
|
||||
inline const GrDisableColorXPFactory* GrDisableColorXPFactory::Get() {
|
||||
// If this is constructed as static constexpr by cl.exe (2015 SP2) the vtable is null.
|
||||
#ifdef SK_BUILD_FOR_WIN
|
||||
static const GrDisableColorXPFactory gDisableColorXPFactory;
|
||||
#else
|
||||
static constexpr const GrDisableColorXPFactory gDisableColorXPFactory;
|
||||
#endif
|
||||
return &gDisableColorXPFactory;
|
||||
}
|
||||
|
||||
|
@ -244,21 +244,12 @@ static constexpr BlendFormula MakeCoverageDstCoeffZeroFormula(GrBlendCoeff srcCo
|
||||
kAdd_GrBlendEquation, srcCoeff, kIS2A_GrBlendCoeff);
|
||||
}
|
||||
|
||||
// Older GCC won't like the constexpr arrays because of
|
||||
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61484.
|
||||
// MSVC 2015 crashes with an internal compiler error.
|
||||
#if !defined(__clang__) && ((defined(__GNUC__) && __GNUC__ < 5) || (defined(_MSC_VER) && _MSC_VER <= 1910))
|
||||
# define MAYBE_CONSTEXPR const
|
||||
#else
|
||||
# define MAYBE_CONSTEXPR constexpr
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This table outlines the blend formulas we will use with each xfermode, with and without coverage,
|
||||
* with and without an opaque input color. Optimization properties are deduced at compile time so we
|
||||
* can make runtime decisions quickly. RGB coverage is not supported.
|
||||
*/
|
||||
static MAYBE_CONSTEXPR BlendFormula gBlendTable[2][2][(int)SkBlendMode::kLastCoeffMode + 1] = {
|
||||
static constexpr BlendFormula gBlendTable[2][2][(int)SkBlendMode::kLastCoeffMode + 1] = {
|
||||
/*>> No coverage, input color unknown <<*/ {{
|
||||
|
||||
/* clear */ MakeCoeffFormula(kZero_GrBlendCoeff, kZero_GrBlendCoeff),
|
||||
@ -336,7 +327,7 @@ static MAYBE_CONSTEXPR BlendFormula gBlendTable[2][2][(int)SkBlendMode::kLastCoe
|
||||
// not specialized for opaque input. For GPUs where dropping to src (and thus able to disable
|
||||
// blending) is an advantage we change the blend mode to src before getitng the blend formula from
|
||||
// this table.
|
||||
static MAYBE_CONSTEXPR BlendFormula gLCDBlendTable[(int)SkBlendMode::kLastCoeffMode + 1] = {
|
||||
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),
|
||||
@ -354,8 +345,6 @@ static MAYBE_CONSTEXPR BlendFormula gLCDBlendTable[(int)SkBlendMode::kLastCoeffM
|
||||
/* screen */ MakeCoeffFormula(kOne_GrBlendCoeff, kISC_GrBlendCoeff),
|
||||
};
|
||||
|
||||
#undef MAYBE_CONSTEXPR
|
||||
|
||||
static BlendFormula get_blend_formula(bool isOpaque,
|
||||
bool hasCoverage,
|
||||
bool hasMixedSamples,
|
||||
@ -674,29 +663,21 @@ constexpr GrPorterDuffXPFactory::GrPorterDuffXPFactory(SkBlendMode xfermode)
|
||||
const GrXPFactory* GrPorterDuffXPFactory::Get(SkBlendMode blendMode) {
|
||||
SkASSERT((unsigned)blendMode <= (unsigned)SkBlendMode::kLastCoeffMode);
|
||||
|
||||
// If these objects are constructed as static constexpr by cl.exe (2015 SP2) the vtables are
|
||||
// null.
|
||||
#ifdef SK_BUILD_FOR_WIN
|
||||
#define _CONSTEXPR_
|
||||
#else
|
||||
#define _CONSTEXPR_ constexpr
|
||||
#endif
|
||||
static _CONSTEXPR_ const GrPorterDuffXPFactory gClearPDXPF(SkBlendMode::kClear);
|
||||
static _CONSTEXPR_ const GrPorterDuffXPFactory gSrcPDXPF(SkBlendMode::kSrc);
|
||||
static _CONSTEXPR_ const GrPorterDuffXPFactory gDstPDXPF(SkBlendMode::kDst);
|
||||
static _CONSTEXPR_ const GrPorterDuffXPFactory gSrcOverPDXPF(SkBlendMode::kSrcOver);
|
||||
static _CONSTEXPR_ const GrPorterDuffXPFactory gDstOverPDXPF(SkBlendMode::kDstOver);
|
||||
static _CONSTEXPR_ const GrPorterDuffXPFactory gSrcInPDXPF(SkBlendMode::kSrcIn);
|
||||
static _CONSTEXPR_ const GrPorterDuffXPFactory gDstInPDXPF(SkBlendMode::kDstIn);
|
||||
static _CONSTEXPR_ const GrPorterDuffXPFactory gSrcOutPDXPF(SkBlendMode::kSrcOut);
|
||||
static _CONSTEXPR_ const GrPorterDuffXPFactory gDstOutPDXPF(SkBlendMode::kDstOut);
|
||||
static _CONSTEXPR_ const GrPorterDuffXPFactory gSrcATopPDXPF(SkBlendMode::kSrcATop);
|
||||
static _CONSTEXPR_ const GrPorterDuffXPFactory gDstATopPDXPF(SkBlendMode::kDstATop);
|
||||
static _CONSTEXPR_ const GrPorterDuffXPFactory gXorPDXPF(SkBlendMode::kXor);
|
||||
static _CONSTEXPR_ const GrPorterDuffXPFactory gPlusPDXPF(SkBlendMode::kPlus);
|
||||
static _CONSTEXPR_ const GrPorterDuffXPFactory gModulatePDXPF(SkBlendMode::kModulate);
|
||||
static _CONSTEXPR_ const GrPorterDuffXPFactory gScreenPDXPF(SkBlendMode::kScreen);
|
||||
#undef _CONSTEXPR_
|
||||
static constexpr const GrPorterDuffXPFactory gClearPDXPF(SkBlendMode::kClear);
|
||||
static constexpr const GrPorterDuffXPFactory gSrcPDXPF(SkBlendMode::kSrc);
|
||||
static constexpr const GrPorterDuffXPFactory gDstPDXPF(SkBlendMode::kDst);
|
||||
static constexpr const GrPorterDuffXPFactory gSrcOverPDXPF(SkBlendMode::kSrcOver);
|
||||
static constexpr const GrPorterDuffXPFactory gDstOverPDXPF(SkBlendMode::kDstOver);
|
||||
static constexpr const GrPorterDuffXPFactory gSrcInPDXPF(SkBlendMode::kSrcIn);
|
||||
static constexpr const GrPorterDuffXPFactory gDstInPDXPF(SkBlendMode::kDstIn);
|
||||
static constexpr const GrPorterDuffXPFactory gSrcOutPDXPF(SkBlendMode::kSrcOut);
|
||||
static constexpr const GrPorterDuffXPFactory gDstOutPDXPF(SkBlendMode::kDstOut);
|
||||
static constexpr const GrPorterDuffXPFactory gSrcATopPDXPF(SkBlendMode::kSrcATop);
|
||||
static constexpr const GrPorterDuffXPFactory gDstATopPDXPF(SkBlendMode::kDstATop);
|
||||
static constexpr const GrPorterDuffXPFactory gXorPDXPF(SkBlendMode::kXor);
|
||||
static constexpr const GrPorterDuffXPFactory gPlusPDXPF(SkBlendMode::kPlus);
|
||||
static constexpr const GrPorterDuffXPFactory gModulatePDXPF(SkBlendMode::kModulate);
|
||||
static constexpr const GrPorterDuffXPFactory gScreenPDXPF(SkBlendMode::kScreen);
|
||||
|
||||
switch (blendMode) {
|
||||
case SkBlendMode::kClear:
|
||||
|
Loading…
Reference in New Issue
Block a user