Replace macro with constexpr now that we require C++14.

Change-Id: I71531f4cb3b306687c0d532d5e5e9c1c36ed5357
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406476
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:
John Stiles 2021-05-10 17:33:22 -04:00 committed by Skia Commit-Bot
parent dae1676d56
commit 7c328b4b42
2 changed files with 18 additions and 19 deletions

View File

@ -29,7 +29,7 @@ class GrOp;
class GrSurfaceDrawContext;
/**
* This immutable object contains information needed to set build a shader program and set API
* This immutable object contains information needed to build a shader program and set API
* state for a draw. It is used along with a GrGeometryProcessor and a source of geometric
* data to draw.
*/

View File

@ -29,27 +29,26 @@ bool GrCustomXfermode::IsSupportedMode(SkBlendMode mode) {
///////////////////////////////////////////////////////////////////////////////
static constexpr GrBlendEquation hw_blend_equation(SkBlendMode mode) {
// In C++14 this could be a constexpr int variable.
#define EQ_OFFSET (kOverlay_GrBlendEquation - (int)SkBlendMode::kOverlay)
static_assert(kOverlay_GrBlendEquation == (int)SkBlendMode::kOverlay + EQ_OFFSET);
static_assert(kDarken_GrBlendEquation == (int)SkBlendMode::kDarken + EQ_OFFSET);
static_assert(kLighten_GrBlendEquation == (int)SkBlendMode::kLighten + EQ_OFFSET);
static_assert(kColorDodge_GrBlendEquation == (int)SkBlendMode::kColorDodge + EQ_OFFSET);
static_assert(kColorBurn_GrBlendEquation == (int)SkBlendMode::kColorBurn + EQ_OFFSET);
static_assert(kHardLight_GrBlendEquation == (int)SkBlendMode::kHardLight + EQ_OFFSET);
static_assert(kSoftLight_GrBlendEquation == (int)SkBlendMode::kSoftLight + EQ_OFFSET);
static_assert(kDifference_GrBlendEquation == (int)SkBlendMode::kDifference + EQ_OFFSET);
static_assert(kExclusion_GrBlendEquation == (int)SkBlendMode::kExclusion + EQ_OFFSET);
static_assert(kMultiply_GrBlendEquation == (int)SkBlendMode::kMultiply + EQ_OFFSET);
static_assert(kHSLHue_GrBlendEquation == (int)SkBlendMode::kHue + EQ_OFFSET);
static_assert(kHSLSaturation_GrBlendEquation == (int)SkBlendMode::kSaturation + EQ_OFFSET);
static_assert(kHSLColor_GrBlendEquation == (int)SkBlendMode::kColor + EQ_OFFSET);
static_assert(kHSLLuminosity_GrBlendEquation == (int)SkBlendMode::kLuminosity + EQ_OFFSET);
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);
// There's an illegal GrBlendEquation that corresponds to no SkBlendMode, hence the extra +1.
static_assert(kGrBlendEquationCnt == (int)SkBlendMode::kLastMode + 1 + 1 + EQ_OFFSET);
static_assert(kGrBlendEquationCnt == (int)SkBlendMode::kLastMode + 1 + 1 + kEqOffset);
return static_cast<GrBlendEquation>((int)mode + EQ_OFFSET);
return static_cast<GrBlendEquation>((int)mode + kEqOffset);
#undef EQ_OFFSET
}