Remove most of GrConfig.h

Change-Id: I0f693bed0778151f93d07cd42c6b597566695ab1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/257999
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Brian Salomon 2019-12-05 09:23:47 -05:00 committed by Skia Commit-Bot
parent 786be72765
commit 80e334dad8
76 changed files with 424 additions and 539 deletions

View File

@ -89,7 +89,7 @@ protected:
"kModulateRGBA",
"kModulateA",
};
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kModeStrs) == GrConstColorProcessor::kInputModeCnt);
static_assert(SK_ARRAY_COUNT(kModeStrs) == GrConstColorProcessor::kInputModeCnt);
SkScalar y = kPad;
SkScalar x = kPad;

View File

@ -919,7 +919,7 @@ static sk_sp<SkImage> make_yuv_gen_image(const SkImageInfo& ii,
static void draw_col_label(SkCanvas* canvas, int x, int yuvColorSpace, bool opaque) {
static const char* kYUVColorSpaceNames[] = { "JPEG", "601", "709", "2020", "Identity" };
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kYUVColorSpaceNames) == kLastEnum_SkYUVColorSpace+1);
static_assert(SK_ARRAY_COUNT(kYUVColorSpaceNames) == kLastEnum_SkYUVColorSpace + 1);
SkPaint paint;
SkFont font(ToolUtils::create_portable_typeface(nullptr, SkFontStyle::Bold()), 16);
@ -946,7 +946,7 @@ static void draw_row_label(SkCanvas* canvas, int y, int yuvFormat) {
static const char* kYUVFormatNames[] = {
"P016", "P010", "P016F", "Y416", "AYUV", "Y410", "NV12", "NV21", "I420", "YV12"
};
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kYUVFormatNames) == kLast_YUVFormat+1);
static_assert(SK_ARRAY_COUNT(kYUVFormatNames) == kLast_YUVFormat + 1);
SkPaint paint;
SkFont font(ToolUtils::create_portable_typeface(nullptr, SkFontStyle::Bold()), 16);

View File

@ -6,28 +6,11 @@
* found in the LICENSE file.
*/
#ifndef GrConfig_DEFINED
#define GrConfig_DEFINED
#include "include/core/SkTypes.h"
///////////////////////////////////////////////////////////////////////////////
// preconfig section:
//
// All the work before including GrUserConfig.h should center around guessing
// what platform we're on, and defining low-level symbols based on that.
//
// A build environment may have already defined symbols, so we first check
// for that
//
// hack to ensure we know what sort of Apple platform we're on
#if defined(__APPLE_CPP__) || defined(__APPLE_CC__)
#include <TargetConditionals.h>
#endif
/**
* Gr defines are set to 0 or 1, rather than being undefined or defined
*/
@ -48,26 +31,7 @@
#endif
#endif
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/*
* Include stdint.h with defines that trigger declaration of C99 limit/const
* macros here before anyone else has a chance to include stdint.h without
* these.
*/
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS
#endif
#ifndef __STDC_CONSTANT_MACROS
#define __STDC_CONSTANT_MACROS
#endif
#include <stdint.h>
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// postconfig section:
//
/**
* GR_STRING makes a string of X where X is expanded before conversion to a string
@ -87,78 +51,3 @@
* Creates a string of the form "<filename>(<linenumber>) : "
*/
#define GR_FILE_AND_LINE_STR __FILE__ "(" GR_STRING(__LINE__) ") : "
/**
* Compilers have different ways of issuing warnings. This macro
* attempts to abstract them, but may need to be specialized for your
* particular compiler.
* To insert compiler warnings use "#pragma message GR_WARN(<string>)"
*/
#if defined(_MSC_VER)
#define GR_WARN(MSG) (GR_FILE_AND_LINE_STR "WARNING: " MSG)
#else//__GNUC__ - may need other defines for different compilers
#define GR_WARN(MSG) ("WARNING: " MSG)
#endif
/**
* GR_ALWAYSBREAK is an unconditional break in all builds.
*/
#if !defined(GR_ALWAYSBREAK)
#if defined(SK_BUILD_FOR_WIN)
#define GR_ALWAYSBREAK SkNO_RETURN_HINT(); __debugbreak()
#else
// TODO: do other platforms really not have continuable breakpoints?
// sign extend for 64bit architectures to be sure this is
// in the high address range
#define GR_ALWAYSBREAK SkNO_RETURN_HINT(); *((int*)(int64_t)(int32_t)0xbeefcafe) = 0;
#endif
#endif
/**
* GR_DEBUGBREAK is an unconditional break in debug builds.
*/
#if !defined(GR_DEBUGBREAK)
#ifdef SK_DEBUG
#define GR_DEBUGBREAK GR_ALWAYSBREAK
#else
#define GR_DEBUGBREAK
#endif
#endif
/**
* GR_ALWAYSASSERT is an assertion in all builds.
*/
#if !defined(GR_ALWAYSASSERT)
#define GR_ALWAYSASSERT(COND) \
do { \
if (!(COND)) { \
SkDebugf("%s %s failed\n", GR_FILE_AND_LINE_STR, #COND); \
GR_ALWAYSBREAK; \
} \
} while (false)
#endif
/**
* GR_DEBUGASSERT is an assertion in debug builds only.
*/
#if !defined(GR_DEBUGASSERT)
#ifdef SK_DEBUG
#define GR_DEBUGASSERT(COND) GR_ALWAYSASSERT(COND)
#else
#define GR_DEBUGASSERT(COND)
#endif
#endif
/**
* Prettier forms of the above macros.
*/
#define GrAlwaysAssert(COND) GR_ALWAYSASSERT(COND)
/**
* GR_STATIC_ASSERT is a compile time assertion. Depending on the platform
* it may print the message in the compiler log. Obviously, the condition must
* be evaluatable at compile time.
*/
#define GR_STATIC_ASSERT(CONDITION) static_assert(CONDITION, "bug")
#endif

View File

@ -123,7 +123,8 @@ struct GrGLDrawArraysIndirectCommand {
GrGLuint fBaseInstance; // Requires EXT_base_instance on ES.
};
GR_STATIC_ASSERT(16 == sizeof(GrGLDrawArraysIndirectCommand));
// static_asserts must have messages in this file because its included in C++14 client code.
static_assert(16 == sizeof(GrGLDrawArraysIndirectCommand), "");
struct GrGLDrawElementsIndirectCommand {
GrGLuint fCount;
@ -133,7 +134,7 @@ struct GrGLDrawElementsIndirectCommand {
GrGLuint fBaseInstance; // Requires EXT_base_instance on ES.
};
GR_STATIC_ASSERT(20 == sizeof(GrGLDrawElementsIndirectCommand));
static_assert(20 == sizeof(GrGLDrawElementsIndirectCommand), "");
/**
* KHR_debug

View File

@ -43,7 +43,6 @@ protected:
/** Reset to an invalid key. */
void reset() {
GR_STATIC_ASSERT((uint16_t)kInvalidDomain == kInvalidDomain);
fKey.reset(kMetaDataCnt);
fKey[kHash_MetaDataIdx] = 0;
fKey[kDomainAndSize_MetaDataIdx] = kInvalidDomain;
@ -118,7 +117,6 @@ protected:
if (nullptr == fKey) {
return;
}
GR_STATIC_ASSERT(0 == kHash_MetaDataIdx);
uint32_t* hash = &fKey->fKey[kHash_MetaDataIdx];
*hash = GrResourceKeyHash(hash + 1, fKey->internalSize() - sizeof(uint32_t));
fKey->validate();

View File

@ -54,9 +54,6 @@
#define RETURN_ON_NULL(ptr) do { if (nullptr == (ptr)) return; } while (0)
#define RETURN_ON_FALSE(pred) do { if (!(pred)) return; } while (0)
// This is a test: static_assert with no message is a c++17 feature.
static_assert(true);
///////////////////////////////////////////////////////////////////////////////////////////////////
/*

View File

@ -49,7 +49,7 @@ const SkScalar gOneQuarter = 0.25f;
#if SK_SUPPORT_GPU
static void setUniformPoint3(const GrGLSLProgramDataManager& pdman, UniformHandle uni,
const SkPoint3& point) {
GR_STATIC_ASSERT(sizeof(SkPoint3) == 3 * sizeof(float));
static_assert(sizeof(SkPoint3) == 3 * sizeof(float));
pdman.set3fv(uni, 1, &point.fX);
}

View File

@ -237,10 +237,10 @@ void GrCaps::dumpJSON(SkJSONWriter* writer) const {
"Advanced",
"Advanced Coherent",
};
GR_STATIC_ASSERT(0 == kBasic_BlendEquationSupport);
GR_STATIC_ASSERT(1 == kAdvanced_BlendEquationSupport);
GR_STATIC_ASSERT(2 == kAdvancedCoherent_BlendEquationSupport);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kBlendEquationSupportNames) == kLast_BlendEquationSupport + 1);
static_assert(0 == kBasic_BlendEquationSupport);
static_assert(1 == kAdvanced_BlendEquationSupport);
static_assert(2 == kAdvancedCoherent_BlendEquationSupport);
static_assert(SK_ARRAY_COUNT(kBlendEquationSupportNames) == kLast_BlendEquationSupport + 1);
writer->appendString("Blend Equation Support",
kBlendEquationSupportNames[fBlendEquationSupport]);

View File

@ -524,7 +524,7 @@ protected:
BlendEquationSupport fBlendEquationSupport;
uint32_t fAdvBlendEqBlacklist;
GR_STATIC_ASSERT(kLast_GrBlendEquation < 32);
static_assert(kLast_GrBlendEquation < 32);
uint32_t fMapBufferFlags;
int fBufferMapThreshold;

View File

@ -230,12 +230,12 @@ public:
void init();
int countPoints() {
GR_STATIC_ASSERT(0 == kLine && 1 == kQuad);
static_assert(0 == kLine && 1 == kQuad);
return fType + 2;
}
const SkPoint& endPt() const {
GR_STATIC_ASSERT(0 == kLine && 1 == kQuad);
static_assert(0 == kLine && 1 == kQuad);
return fPts[fType + 1];
}
};

View File

@ -87,8 +87,8 @@ private:
};
GR_DECL_BITFIELD_CLASS_OPS_FRIENDS(Flags);
GR_STATIC_ASSERT(Flags(GrPrimitiveRestart::kNo) == Flags::kNone);
GR_STATIC_ASSERT(Flags(GrPrimitiveRestart::kYes) == Flags::kUsePrimitiveRestart);
static_assert(Flags(GrPrimitiveRestart::kNo) == Flags::kNone);
static_assert(Flags(GrPrimitiveRestart::kYes) == Flags::kUsePrimitiveRestart);
GrPrimitiveType fPrimitiveType;
sk_sp<const GrBuffer> fIndexBuffer;

View File

@ -41,11 +41,11 @@ struct GrNativeRect {
const int* asInts() const {
return &fX;
GR_STATIC_ASSERT(0 == offsetof(GrNativeRect, fX));
GR_STATIC_ASSERT(4 == offsetof(GrNativeRect, fY));
GR_STATIC_ASSERT(8 == offsetof(GrNativeRect, fWidth));
GR_STATIC_ASSERT(12 == offsetof(GrNativeRect, fHeight));
GR_STATIC_ASSERT(16 == sizeof(GrNativeRect)); // For an array of GrNativeRect.
static_assert(0 == offsetof(GrNativeRect, fX));
static_assert(4 == offsetof(GrNativeRect, fY));
static_assert(8 == offsetof(GrNativeRect, fWidth));
static_assert(12 == offsetof(GrNativeRect, fHeight));
static_assert(16 == sizeof(GrNativeRect)); // For an array of GrNativeRect.
}
int* asInts() { return &fX; }

View File

@ -78,10 +78,10 @@ GrPathRenderer* GrPathRendererChain::getPathRenderer(
const GrPathRenderer::CanDrawPathArgs& args,
DrawType drawType,
GrPathRenderer::StencilSupport* stencilSupport) {
GR_STATIC_ASSERT(GrPathRenderer::kNoSupport_StencilSupport <
GrPathRenderer::kStencilOnly_StencilSupport);
GR_STATIC_ASSERT(GrPathRenderer::kStencilOnly_StencilSupport <
GrPathRenderer::kNoRestriction_StencilSupport);
static_assert(GrPathRenderer::kNoSupport_StencilSupport <
GrPathRenderer::kStencilOnly_StencilSupport);
static_assert(GrPathRenderer::kStencilOnly_StencilSupport <
GrPathRenderer::kNoRestriction_StencilSupport);
GrPathRenderer::StencilSupport minStencilSupport;
if (DrawType::kStencil == drawType) {
minStencilSupport = GrPathRenderer::kStencilOnly_StencilSupport;

View File

@ -101,8 +101,8 @@ void GrPipeline::genKey(GrProcessorKeyBuilder* b, const GrCaps& caps) const {
static const uint32_t kBlendWriteShift = 1;
static const uint32_t kBlendCoeffShift = 5;
GR_STATIC_ASSERT(kLast_GrBlendCoeff < (1 << kBlendCoeffShift));
GR_STATIC_ASSERT(kFirstAdvancedGrBlendEquation - 1 < 4);
static_assert(kLast_GrBlendCoeff < (1 << kBlendCoeffShift));
static_assert(kFirstAdvancedGrBlendEquation - 1 < 4);
uint32_t blendKey = blendInfo.fWriteColor;
blendKey |= (blendInfo.fSrcBlend << kBlendWriteShift);

View File

@ -121,7 +121,7 @@ public:
friend class GrProcessorSet;
};
GR_STATIC_ASSERT(sizeof(Analysis) <= sizeof(uint32_t));
static_assert(sizeof(Analysis) <= sizeof(uint32_t));
/**
* This analyzes the processors given an op's input color and coverage as well as a clip. The

View File

@ -48,7 +48,7 @@ static uint32_t sampler_key(GrTextureType textureType, const GrSwizzle& swizzle,
const GrCaps& caps) {
int samplerTypeKey = texture_type_key(textureType);
GR_STATIC_ASSERT(2 == sizeof(swizzle.asKey()));
static_assert(2 == sizeof(swizzle.asKey()));
uint16_t swizzleKey = 0;
if (caps.shaderCaps()->textureSwizzleAppliedInShader()) {
swizzleKey = swizzle.asKey();
@ -184,7 +184,7 @@ bool GrProgramDesc::Build(GrProgramDesc* desc, const GrRenderTarget* renderTarge
// bindings in use or other descriptor field settings) it should be set
// to a canonical value to avoid duplicate programs with different keys.
GR_STATIC_ASSERT(0 == kProcessorKeysOffset % sizeof(uint32_t));
static_assert(0 == kProcessorKeysOffset % sizeof(uint32_t));
// Make room for everything up to the effect keys.
desc->key().reset();
desc->key().push_back_n(kProcessorKeysOffset);

View File

@ -113,7 +113,7 @@ protected:
// portions added by the platform-specific backends.
uint32_t fInitialKeyLength : 27;
};
GR_STATIC_ASSERT(sizeof(KeyHeader) == 8);
static_assert(sizeof(KeyHeader) == 8);
const KeyHeader& header() const { return *this->atOffset<KeyHeader, kHeaderOffset>(); }

View File

@ -397,13 +397,13 @@ static const int kVertsPerNonAAQuad = 4;
static const int kIndicesPerNonAAQuad = 6;
sk_sp<const GrGpuBuffer> GrResourceProvider::createNonAAQuadIndexBuffer() {
GR_STATIC_ASSERT(kVertsPerNonAAQuad * kMaxNumNonAAQuads <= 65535); // indices fit in a uint16_t
static_assert(kVertsPerNonAAQuad * kMaxNumNonAAQuads <= 65535); // indices fit in a uint16_t
static const uint16_t kNonAAQuadIndexPattern[] = {
0, 1, 2, 2, 1, 3
};
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kNonAAQuadIndexPattern) == kIndicesPerNonAAQuad);
static_assert(SK_ARRAY_COUNT(kNonAAQuadIndexPattern) == kIndicesPerNonAAQuad);
return this->createPatternedIndexBuffer(kNonAAQuadIndexPattern, kIndicesPerNonAAQuad,
kMaxNumNonAAQuads, kVertsPerNonAAQuad, nullptr);
@ -419,7 +419,7 @@ static const int kVertsPerAAQuad = 8;
static const int kIndicesPerAAQuad = 30;
sk_sp<const GrGpuBuffer> GrResourceProvider::createAAQuadIndexBuffer() {
GR_STATIC_ASSERT(kVertsPerAAQuad * kMaxNumAAQuads <= 65535); // indices fit in a uint16_t
static_assert(kVertsPerAAQuad * kMaxNumAAQuads <= 65535); // indices fit in a uint16_t
// clang-format off
static const uint16_t kAAQuadIndexPattern[] = {
@ -431,7 +431,7 @@ sk_sp<const GrGpuBuffer> GrResourceProvider::createAAQuadIndexBuffer() {
};
// clang-format on
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kAAQuadIndexPattern) == kIndicesPerAAQuad);
static_assert(SK_ARRAY_COUNT(kAAQuadIndexPattern) == kIndicesPerAAQuad);
return this->createPatternedIndexBuffer(kAAQuadIndexPattern, kIndicesPerAAQuad,
kMaxNumAAQuads, kVertsPerAAQuad, nullptr);

View File

@ -93,11 +93,11 @@ void GrShaderCaps::dumpJSON(SkJSONWriter* writer) const {
"General Enable",
"Specific Enables",
};
GR_STATIC_ASSERT(0 == kNotSupported_AdvBlendEqInteraction);
GR_STATIC_ASSERT(1 == kAutomatic_AdvBlendEqInteraction);
GR_STATIC_ASSERT(2 == kGeneralEnable_AdvBlendEqInteraction);
GR_STATIC_ASSERT(3 == kSpecificEnables_AdvBlendEqInteraction);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kAdvBlendEqInteractionStr) == kLast_AdvBlendEqInteraction + 1);
static_assert(0 == kNotSupported_AdvBlendEqInteraction);
static_assert(1 == kAutomatic_AdvBlendEqInteraction);
static_assert(2 == kGeneralEnable_AdvBlendEqInteraction);
static_assert(3 == kSpecificEnables_AdvBlendEqInteraction);
static_assert(SK_ARRAY_COUNT(kAdvBlendEqInteractionStr) == kLast_AdvBlendEqInteraction + 1);
writer->appendBool("FB Fetch Support", fFBFetchSupport);
writer->appendBool("Uses precision modifiers", fUsesPrecisionModifiers);

View File

@ -20,7 +20,7 @@ constexpr const GrUserStencilSettings gUnused(
0x0000>()
);
GR_STATIC_ASSERT(kAll_StencilFlags == (gUnused.fCWFlags[0] & gUnused.fCCWFlags[0]));
static_assert(kAll_StencilFlags == (gUnused.fCWFlags[0] & gUnused.fCCWFlags[0]));
const GrUserStencilSettings& GrUserStencilSettings::kUnused = gUnused;
@ -62,8 +62,8 @@ void GrStencilSettings::reset(const GrStencilSettings& that) {
memcpy(&fCWFace, &that.fCWFace, sizeof(Face));
} else {
memcpy(&fCWFace, &that.fCWFace, 2 * sizeof(Face));
GR_STATIC_ASSERT(sizeof(Face) ==
offsetof(GrStencilSettings, fCCWFace) - offsetof(GrStencilSettings, fCWFace));
static_assert(sizeof(Face) ==
offsetof(GrStencilSettings, fCCWFace) - offsetof(GrStencilSettings, fCWFace));
}
}
@ -82,23 +82,23 @@ bool GrStencilSettings::operator==(const GrStencilSettings& that) const {
return false;
} else {
return 0 == memcmp(&fCWFace, &that.fCWFace, 2 * sizeof(Face));
GR_STATIC_ASSERT(sizeof(Face) ==
offsetof(GrStencilSettings, fCCWFace) - offsetof(GrStencilSettings, fCWFace));
static_assert(sizeof(Face) ==
offsetof(GrStencilSettings, fCCWFace) - offsetof(GrStencilSettings, fCWFace));
}
// memcmp relies on GrStencilSettings::Face being tightly packed.
GR_STATIC_ASSERT(0 == offsetof(Face, fRef));
GR_STATIC_ASSERT(2 == sizeof(Face::fRef));
GR_STATIC_ASSERT(2 == offsetof(Face, fTest));
GR_STATIC_ASSERT(2 == sizeof(Face::fTest));
GR_STATIC_ASSERT(4 == offsetof(Face, fTestMask));
GR_STATIC_ASSERT(2 == sizeof(Face::fTestMask));
GR_STATIC_ASSERT(6 == offsetof(Face, fPassOp));
GR_STATIC_ASSERT(1 == sizeof(Face::fPassOp));
GR_STATIC_ASSERT(7 == offsetof(Face, fFailOp));
GR_STATIC_ASSERT(1 == sizeof(Face::fFailOp));
GR_STATIC_ASSERT(8 == offsetof(Face, fWriteMask));
GR_STATIC_ASSERT(2 == sizeof(Face::fWriteMask));
GR_STATIC_ASSERT(10 == sizeof(Face));
static_assert(0 == offsetof(Face, fRef));
static_assert(2 == sizeof(Face::fRef));
static_assert(2 == offsetof(Face, fTest));
static_assert(2 == sizeof(Face::fTest));
static_assert(4 == offsetof(Face, fTestMask));
static_assert(2 == sizeof(Face::fTestMask));
static_assert(6 == offsetof(Face, fPassOp));
static_assert(1 == sizeof(Face::fPassOp));
static_assert(7 == offsetof(Face, fFailOp));
static_assert(1 == sizeof(Face::fFailOp));
static_assert(8 == offsetof(Face, fWriteMask));
static_assert(2 == sizeof(Face::fWriteMask));
static_assert(10 == sizeof(Face));
}
static constexpr GrStencilTest gUserStencilTestToRaw[kGrUserStencilTestCount] = {
@ -119,18 +119,18 @@ static constexpr GrStencilTest gUserStencilTestToRaw[kGrUserStencilTestCount] =
GrStencilTest::kNotEqual
};
GR_STATIC_ASSERT(0 == (int)GrUserStencilTest::kAlwaysIfInClip);
GR_STATIC_ASSERT(1 == (int)GrUserStencilTest::kEqualIfInClip);
GR_STATIC_ASSERT(2 == (int)GrUserStencilTest::kLessIfInClip);
GR_STATIC_ASSERT(3 == (int)GrUserStencilTest::kLEqualIfInClip);
GR_STATIC_ASSERT(4 == (int)GrUserStencilTest::kAlways);
GR_STATIC_ASSERT(5 == (int)GrUserStencilTest::kNever);
GR_STATIC_ASSERT(6 == (int)GrUserStencilTest::kGreater);
GR_STATIC_ASSERT(7 == (int)GrUserStencilTest::kGEqual);
GR_STATIC_ASSERT(8 == (int)GrUserStencilTest::kLess);
GR_STATIC_ASSERT(9 == (int)GrUserStencilTest::kLEqual);
GR_STATIC_ASSERT(10 == (int)GrUserStencilTest::kEqual);
GR_STATIC_ASSERT(11 == (int)GrUserStencilTest::kNotEqual);
static_assert(0 == (int)GrUserStencilTest::kAlwaysIfInClip);
static_assert(1 == (int)GrUserStencilTest::kEqualIfInClip);
static_assert(2 == (int)GrUserStencilTest::kLessIfInClip);
static_assert(3 == (int)GrUserStencilTest::kLEqualIfInClip);
static_assert(4 == (int)GrUserStencilTest::kAlways);
static_assert(5 == (int)GrUserStencilTest::kNever);
static_assert(6 == (int)GrUserStencilTest::kGreater);
static_assert(7 == (int)GrUserStencilTest::kGEqual);
static_assert(8 == (int)GrUserStencilTest::kLess);
static_assert(9 == (int)GrUserStencilTest::kLEqual);
static_assert(10 == (int)GrUserStencilTest::kEqual);
static_assert(11 == (int)GrUserStencilTest::kNotEqual);
static constexpr GrStencilOp gUserStencilOpToRaw[kGrUserStencilOpCount] = {
GrStencilOp::kKeep,
@ -154,19 +154,19 @@ static constexpr GrStencilOp gUserStencilOpToRaw[kGrUserStencilOpCount] = {
GrStencilOp::kZero // kZeroClipAndUserBits.
};
GR_STATIC_ASSERT(0 == (int)GrUserStencilOp::kKeep);
GR_STATIC_ASSERT(1 == (int)GrUserStencilOp::kZero);
GR_STATIC_ASSERT(2 == (int)GrUserStencilOp::kReplace);
GR_STATIC_ASSERT(3 == (int)GrUserStencilOp::kInvert);
GR_STATIC_ASSERT(4 == (int)GrUserStencilOp::kIncWrap);
GR_STATIC_ASSERT(5 == (int)GrUserStencilOp::kDecWrap);
GR_STATIC_ASSERT(6 == (int)GrUserStencilOp::kIncMaybeClamp);
GR_STATIC_ASSERT(7 == (int)GrUserStencilOp::kDecMaybeClamp);
GR_STATIC_ASSERT(8 == (int)GrUserStencilOp::kZeroClipBit);
GR_STATIC_ASSERT(9 == (int)GrUserStencilOp::kSetClipBit);
GR_STATIC_ASSERT(10 == (int)GrUserStencilOp::kInvertClipBit);
GR_STATIC_ASSERT(11 == (int)GrUserStencilOp::kSetClipAndReplaceUserBits);
GR_STATIC_ASSERT(12 == (int)GrUserStencilOp::kZeroClipAndUserBits);
static_assert(0 == (int)GrUserStencilOp::kKeep);
static_assert(1 == (int)GrUserStencilOp::kZero);
static_assert(2 == (int)GrUserStencilOp::kReplace);
static_assert(3 == (int)GrUserStencilOp::kInvert);
static_assert(4 == (int)GrUserStencilOp::kIncWrap);
static_assert(5 == (int)GrUserStencilOp::kDecWrap);
static_assert(6 == (int)GrUserStencilOp::kIncMaybeClamp);
static_assert(7 == (int)GrUserStencilOp::kDecMaybeClamp);
static_assert(8 == (int)GrUserStencilOp::kZeroClipBit);
static_assert(9 == (int)GrUserStencilOp::kSetClipBit);
static_assert(10 == (int)GrUserStencilOp::kInvertClipBit);
static_assert(11 == (int)GrUserStencilOp::kSetClipAndReplaceUserBits);
static_assert(12 == (int)GrUserStencilOp::kZeroClipAndUserBits);
void GrStencilSettings::Face::reset(const GrUserStencilSettings::Face& user, bool hasStencilClip,
int numStencilBits) {
@ -216,8 +216,8 @@ void GrStencilSettings::Face::reset(const GrUserStencilSettings::Face& user, boo
void GrStencilSettings::Face::setDisabled() {
memset(this, 0, sizeof(*this));
GR_STATIC_ASSERT(0 == (int)GrStencilTest::kAlways);
GR_STATIC_ASSERT(0 == (int)GrStencilOp::kKeep);
static_assert(0 == (int)GrStencilTest::kAlways);
static_assert(0 == (int)GrStencilOp::kKeep);
}
////////////////////////////////////////////////////////////////////////////////
@ -367,12 +367,12 @@ static constexpr const GrUserStencilSettings* gUserToClipTable[2][1 + SkRegion::
}
};
GR_STATIC_ASSERT(0 == SkRegion::kDifference_Op);
GR_STATIC_ASSERT(1 == SkRegion::kIntersect_Op);
GR_STATIC_ASSERT(2 == SkRegion::kUnion_Op);
GR_STATIC_ASSERT(3 == SkRegion::kXOR_Op);
GR_STATIC_ASSERT(4 == SkRegion::kReverseDifference_Op);
GR_STATIC_ASSERT(5 == SkRegion::kReplace_Op);
static_assert(0 == SkRegion::kDifference_Op);
static_assert(1 == SkRegion::kIntersect_Op);
static_assert(2 == SkRegion::kUnion_Op);
static_assert(3 == SkRegion::kXOR_Op);
static_assert(4 == SkRegion::kReverseDifference_Op);
static_assert(5 == SkRegion::kReplace_Op);
///////
// Direct to Stencil
@ -432,12 +432,12 @@ static constexpr const GrUserStencilSettings* gDirectDrawTable[1 + SkRegion::kLa
{&gReplaceClip, nullptr} // kReplace_Op.
};
GR_STATIC_ASSERT(0 == SkRegion::kDifference_Op);
GR_STATIC_ASSERT(1 == SkRegion::kIntersect_Op);
GR_STATIC_ASSERT(2 == SkRegion::kUnion_Op);
GR_STATIC_ASSERT(3 == SkRegion::kXOR_Op);
GR_STATIC_ASSERT(4 == SkRegion::kReverseDifference_Op);
GR_STATIC_ASSERT(5 == SkRegion::kReplace_Op);
static_assert(0 == SkRegion::kDifference_Op);
static_assert(1 == SkRegion::kIntersect_Op);
static_assert(2 == SkRegion::kUnion_Op);
static_assert(3 == SkRegion::kXOR_Op);
static_assert(4 == SkRegion::kReverseDifference_Op);
static_assert(5 == SkRegion::kReplace_Op);
GrUserStencilSettings const* const* GrStencilSettings::GetClipPasses(SkRegion::Op op,
bool canBeDirect,
@ -476,31 +476,31 @@ void GrStencilSettings::genKey(GrProcessorKeyBuilder* b) const {
}
if (!this->isTwoSided()) {
constexpr int kCount16 = sizeof(Face) / sizeof(uint16_t);
GR_STATIC_ASSERT(0 == sizeof(Face) % sizeof(uint16_t));
static_assert(0 == sizeof(Face) % sizeof(uint16_t));
uint16_t* key = reinterpret_cast<uint16_t*>(b->add32n((kCount16 + 1) / 2));
memcpy(key, &fCWFace, sizeof(Face));
key[kCount16] = 0;
GR_STATIC_ASSERT(1 == kCount16 % 2);
static_assert(1 == kCount16 % 2);
} else {
constexpr int kCount32 = (2 * sizeof(Face)) / sizeof(uint32_t);
GR_STATIC_ASSERT(0 == (2 * sizeof(Face)) % sizeof(uint32_t));
static_assert(0 == (2 * sizeof(Face)) % sizeof(uint32_t));
uint32_t* key = b->add32n(kCount32);
memcpy(key, &fCWFace, 2 * sizeof(Face));
GR_STATIC_ASSERT(sizeof(Face) ==
offsetof(GrStencilSettings, fCCWFace) - offsetof(GrStencilSettings, fCWFace));
static_assert(sizeof(Face) ==
offsetof(GrStencilSettings, fCCWFace) - offsetof(GrStencilSettings, fCWFace));
}
// We rely on GrStencilSettings::Face being tightly packed for the key to be reliable.
GR_STATIC_ASSERT(0 == offsetof(Face, fRef));
GR_STATIC_ASSERT(2 == sizeof(Face::fRef));
GR_STATIC_ASSERT(2 == offsetof(Face, fTest));
GR_STATIC_ASSERT(2 == sizeof(Face::fTest));
GR_STATIC_ASSERT(4 == offsetof(Face, fTestMask));
GR_STATIC_ASSERT(2 == sizeof(Face::fTestMask));
GR_STATIC_ASSERT(6 == offsetof(Face, fPassOp));
GR_STATIC_ASSERT(1 == sizeof(Face::fPassOp));
GR_STATIC_ASSERT(7 == offsetof(Face, fFailOp));
GR_STATIC_ASSERT(1 == sizeof(Face::fFailOp));
GR_STATIC_ASSERT(8 == offsetof(Face, fWriteMask));
GR_STATIC_ASSERT(2 == sizeof(Face::fWriteMask));
GR_STATIC_ASSERT(10 == sizeof(Face));
static_assert(0 == offsetof(Face, fRef));
static_assert(2 == sizeof(Face::fRef));
static_assert(2 == offsetof(Face, fTest));
static_assert(2 == sizeof(Face::fTest));
static_assert(4 == offsetof(Face, fTestMask));
static_assert(2 == sizeof(Face::fTestMask));
static_assert(6 == offsetof(Face, fPassOp));
static_assert(1 == sizeof(Face::fPassOp));
static_assert(7 == offsetof(Face, fFailOp));
static_assert(1 == sizeof(Face::fFailOp));
static_assert(8 == offsetof(Face, fWriteMask));
static_assert(2 == sizeof(Face::fWriteMask));
static_assert(10 == sizeof(Face));
}

View File

@ -9,7 +9,7 @@
#include "src/utils/SkDashPathPriv.h"
int GrStyle::KeySize(const GrStyle &style, Apply apply, uint32_t flags) {
GR_STATIC_ASSERT(sizeof(uint32_t) == sizeof(SkScalar));
static_assert(sizeof(uint32_t) == sizeof(SkScalar));
int size = 0;
if (style.isDashed()) {
// One scalar for scale, one for dash phase, and one for each dash value.
@ -34,7 +34,7 @@ void GrStyle::WriteKey(uint32_t *key, const GrStyle &style, Apply apply, SkScala
uint32_t flags) {
SkASSERT(key);
SkASSERT(KeySize(style, apply) >= 0);
GR_STATIC_ASSERT(sizeof(uint32_t) == sizeof(SkScalar));
static_assert(sizeof(uint32_t) == sizeof(SkScalar));
int i = 0;
// The scale can influence both the path effect and stroking. We want to preserve the
@ -44,7 +44,7 @@ void GrStyle::WriteKey(uint32_t *key, const GrStyle &style, Apply apply, SkScala
// from SkStrokeRec output by the the path effect (and no additional path effect).
// Since the scale can affect both parts of 2 we write it into the key twice.
if (style.isDashed()) {
GR_STATIC_ASSERT(sizeof(style.dashPhase()) == sizeof(uint32_t));
static_assert(sizeof(style.dashPhase()) == sizeof(uint32_t));
SkScalar phase = style.dashPhase();
memcpy(&key[i++], &scale, sizeof(SkScalar));
memcpy(&key[i++], &phase, sizeof(SkScalar));
@ -70,9 +70,9 @@ void GrStyle::WriteKey(uint32_t *key, const GrStyle &style, Apply apply, SkScala
kJoinShift = kStyleBits,
kCapShift = kJoinShift + kJoinBits,
};
GR_STATIC_ASSERT(SkStrokeRec::kStyleCount <= (1 << kStyleBits));
GR_STATIC_ASSERT(SkPaint::kJoinCount <= (1 << kJoinBits));
GR_STATIC_ASSERT(SkPaint::kCapCount <= (1 << kCapBits));
static_assert(SkStrokeRec::kStyleCount <= (1 << kStyleBits));
static_assert(SkPaint::kJoinCount <= (1 << kJoinBits));
static_assert(SkPaint::kCapCount <= (1 << kCapBits));
// The cap type only matters for unclosed shapes. However, a path effect could unclose
// the shape before it is stroked.
SkPaint::Cap cap = SkPaint::kDefault_Cap;

View File

@ -24,7 +24,7 @@ void GrSwizzle::apply(SkRasterPipeline* pipeline) const {
pipeline->append(SkRasterPipeline::force_opaque);
return;
default: {
GR_STATIC_ASSERT(sizeof(uintptr_t) >= 4 * sizeof(char));
static_assert(sizeof(uintptr_t) >= 4 * sizeof(char));
// Rather than allocate the 4 control bytes on the heap somewhere, just jam them right
// into a uintptr_t context.
uintptr_t ctx;

View File

@ -110,7 +110,7 @@ GrTRecorder<TBase>::emplaceWithData(size_t extraDataSize, Args... args) {
static constexpr size_t kAllocAlign = kTAlign > kHeaderAlign ? kTAlign : kHeaderAlign;
static constexpr size_t kTItemOffset = GrSizeAlignUp(sizeof(Header), kAllocAlign);
// We're assuming if we back up from kItemOffset by sizeof(Header) we will still be aligned.
GR_STATIC_ASSERT(sizeof(Header) % alignof(Header) == 0);
static_assert(sizeof(Header) % alignof(Header) == 0);
const size_t totalSize = kTItemOffset + sizeof(TItem) + extraDataSize;
auto alloc = reinterpret_cast<char*>(fArena.makeBytesAlignedTo(totalSize, kAllocAlign));
Header* header = new (alloc + kTItemOffset - sizeof(Header)) Header();
@ -134,7 +134,7 @@ template <typename TBase> inline void GrTRecorder<TBase>::reset() {
for (auto& i : *this) {
i.~TBase();
}
GR_STATIC_ASSERT(std::is_trivially_destructible<Header>::value);
static_assert(std::is_trivially_destructible<Header>::value);
fHead = fTail = nullptr;
fArena.reset();
}

View File

@ -213,11 +213,11 @@ struct GrUserStencilSettings {
template<GrUserStencilTest Test, GrUserStencilOp PassOp, GrUserStencilOp FailOp>
struct GrUserStencilSettings::Attrs {
// Ensure an op that only modifies user bits isn't paired with one that modifies clip bits.
GR_STATIC_ASSERT(GrUserStencilOp::kKeep == PassOp || GrUserStencilOp::kKeep == FailOp ||
(PassOp <= kLastUserOnlyStencilOp) == (FailOp <= kLastUserOnlyStencilOp));
static_assert(GrUserStencilOp::kKeep == PassOp || GrUserStencilOp::kKeep == FailOp ||
(PassOp <= kLastUserOnlyStencilOp) == (FailOp <= kLastUserOnlyStencilOp));
// Ensure an op that only modifies clip bits isn't paired with one that modifies clip and user.
GR_STATIC_ASSERT(GrUserStencilOp::kKeep == PassOp || GrUserStencilOp::kKeep == FailOp ||
(PassOp <= kLastClipOnlyStencilOp) == (FailOp <= kLastClipOnlyStencilOp));
static_assert(GrUserStencilOp::kKeep == PassOp || GrUserStencilOp::kKeep == FailOp ||
(PassOp <= kLastClipOnlyStencilOp) == (FailOp <= kLastClipOnlyStencilOp));
constexpr static bool TestAlwaysPasses(bool hasStencilClip) {
return (!hasStencilClip && GrUserStencilTest::kAlwaysIfInClip == Test) ||

View File

@ -29,7 +29,7 @@ enum GrXferBarrierType {
kBlend_GrXferBarrierType, //<! Required by certain blend extensions.
};
/** Should be able to treat kNone as false in boolean expressions */
GR_STATIC_ASSERT(SkToBool(kNone_GrXferBarrierType) == false);
static_assert(SkToBool(kNone_GrXferBarrierType) == false);
/**
* GrXferProcessor is responsible for implementing the xfer mode that blends the src color and dst

View File

@ -163,17 +163,17 @@ static inline GrPrimitiveType SkVertexModeToGrPrimitiveType(SkVertices::VertexMo
//////////////////////////////////////////////////////////////////////////////
GR_STATIC_ASSERT((int)kZero_GrBlendCoeff == (int)SkBlendModeCoeff::kZero);
GR_STATIC_ASSERT((int)kOne_GrBlendCoeff == (int)SkBlendModeCoeff::kOne);
GR_STATIC_ASSERT((int)kSC_GrBlendCoeff == (int)SkBlendModeCoeff::kSC);
GR_STATIC_ASSERT((int)kISC_GrBlendCoeff == (int)SkBlendModeCoeff::kISC);
GR_STATIC_ASSERT((int)kDC_GrBlendCoeff == (int)SkBlendModeCoeff::kDC);
GR_STATIC_ASSERT((int)kIDC_GrBlendCoeff == (int)SkBlendModeCoeff::kIDC);
GR_STATIC_ASSERT((int)kSA_GrBlendCoeff == (int)SkBlendModeCoeff::kSA);
GR_STATIC_ASSERT((int)kISA_GrBlendCoeff == (int)SkBlendModeCoeff::kISA);
GR_STATIC_ASSERT((int)kDA_GrBlendCoeff == (int)SkBlendModeCoeff::kDA);
GR_STATIC_ASSERT((int)kIDA_GrBlendCoeff == (int)SkBlendModeCoeff::kIDA);
//GR_STATIC_ASSERT(SkXfermode::kCoeffCount == 10);
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(SkXfermode::kCoeffCount == 10);
////////////////////////////////////////////////////////////////////////////////
// Texture management

View File

@ -147,7 +147,7 @@ public:
memcpy(&out[kStrokeWidthIdx], &width, sizeof(float));
memcpy(&out[kStrokeMiterIdx], &miterLimit, sizeof(float));
out[kStrokeCapJoinIdx] = (stroke.getCap() << 16) | stroke.getJoin();
GR_STATIC_ASSERT(sizeof(out[kStrokeWidthIdx]) == sizeof(float));
static_assert(sizeof(out[kStrokeWidthIdx]) == sizeof(float));
}
// Shape unstyled key.

View File

@ -44,7 +44,7 @@ public:
void set(const GrCCPathCacheEntry&, const SkIVector& shift, uint64_t, GrFillRule);
};
GR_STATIC_ASSERT(4 * 12 == sizeof(Instance));
static_assert(4 * 12 == sizeof(Instance));
static sk_sp<const GrGpuBuffer> FindVertexBuffer(GrOnFlushResourceProvider*);
static sk_sp<const GrGpuBuffer> FindIndexBuffer(GrOnFlushResourceProvider*);

View File

@ -415,15 +415,15 @@ void GrGSCoverageProcessor::reset(PrimitiveType primitiveType, GrResourceProvide
if (4 == this->numInputPoints() || this->hasInputWeight()) {
fInputXOrYValues =
{"x_or_y_values", kFloat4_GrVertexAttribType, kFloat4_GrSLType};
GR_STATIC_ASSERT(sizeof(QuadPointInstance) ==
2 * GrVertexAttribTypeSize(kFloat4_GrVertexAttribType));
GR_STATIC_ASSERT(offsetof(QuadPointInstance, fY) ==
GrVertexAttribTypeSize(kFloat4_GrVertexAttribType));
static_assert(sizeof(QuadPointInstance) ==
2 * GrVertexAttribTypeSize(kFloat4_GrVertexAttribType));
static_assert(offsetof(QuadPointInstance, fY) ==
GrVertexAttribTypeSize(kFloat4_GrVertexAttribType));
} else {
fInputXOrYValues =
{"x_or_y_values", kFloat3_GrVertexAttribType, kFloat3_GrSLType};
GR_STATIC_ASSERT(sizeof(TriPointInstance) ==
2 * GrVertexAttribTypeSize(kFloat3_GrVertexAttribType));
static_assert(sizeof(TriPointInstance) ==
2 * GrVertexAttribTypeSize(kFloat3_GrVertexAttribType));
}
this->setVertexAttributes(&fInputXOrYValues, 1);

View File

@ -504,16 +504,16 @@ void GrVSCoverageProcessor::reset(PrimitiveType primitiveType, GrResourceProvide
GrVertexAttribType xyAttribType;
GrSLType xySLType;
if (4 == this->numInputPoints() || this->hasInputWeight()) {
GR_STATIC_ASSERT(offsetof(QuadPointInstance, fX) == 0);
GR_STATIC_ASSERT(sizeof(QuadPointInstance::fX) ==
GrVertexAttribTypeSize(kFloat4_GrVertexAttribType));
GR_STATIC_ASSERT(sizeof(QuadPointInstance::fY) ==
GrVertexAttribTypeSize(kFloat4_GrVertexAttribType));
static_assert(offsetof(QuadPointInstance, fX) == 0);
static_assert(sizeof(QuadPointInstance::fX) ==
GrVertexAttribTypeSize(kFloat4_GrVertexAttribType));
static_assert(sizeof(QuadPointInstance::fY) ==
GrVertexAttribTypeSize(kFloat4_GrVertexAttribType));
xyAttribType = kFloat4_GrVertexAttribType;
xySLType = kFloat4_GrSLType;
} else {
GR_STATIC_ASSERT(sizeof(TriPointInstance) ==
2 * GrVertexAttribTypeSize(kFloat3_GrVertexAttribType));
static_assert(sizeof(TriPointInstance) ==
2 * GrVertexAttribTypeSize(kFloat3_GrVertexAttribType));
xyAttribType = kFloat3_GrVertexAttribType;
xySLType = kFloat3_GrSLType;
}

View File

@ -221,8 +221,8 @@ static uint32_t get_blend_info_key(const GrPipeline& pipeline) {
static const uint32_t kBlendWriteShift = 1;
static const uint32_t kBlendCoeffShift = 5;
GR_STATIC_ASSERT(kLast_GrBlendCoeff < (1 << kBlendCoeffShift));
GR_STATIC_ASSERT(kFirstAdvancedGrBlendEquation - 1 < 4);
static_assert(kLast_GrBlendCoeff < (1 << kBlendCoeffShift));
static_assert(kFirstAdvancedGrBlendEquation - 1 < 4);
uint32_t key = blendInfo.fWriteColor;
key |= (blendInfo.fSrcBlend << kBlendWriteShift);

View File

@ -215,7 +215,7 @@ template<int N> inline void GrDawnProgramDataManager::setMatrices(UniformHandle
template<int N> struct set_uniform_matrix {
inline static void set(void* buffer, int uniformOffset, int count, const float matrices[]) {
GR_STATIC_ASSERT(sizeof(float) == 4);
static_assert(sizeof(float) == 4);
buffer = static_cast<char*>(buffer) + uniformOffset;
for (int i = 0; i < count; ++i) {
const float* matrix = &matrices[N * N * i];
@ -229,7 +229,7 @@ template<int N> struct set_uniform_matrix {
template<> struct set_uniform_matrix<4> {
inline static void set(void* buffer, int uniformOffset, int count, const float matrices[]) {
GR_STATIC_ASSERT(sizeof(float) == 4);
static_assert(sizeof(float) == 4);
buffer = static_cast<char*>(buffer) + uniformOffset;
memcpy(buffer, matrices, count * 16 * sizeof(float));
}

View File

@ -81,7 +81,7 @@ void GrGLConvexPolyEffect::onSetData(const GrGLSLProgramDataManager& pdman,
void GrGLConvexPolyEffect::GenKey(const GrProcessor& processor, const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const GrConvexPolyEffect& cpe = processor.cast<GrConvexPolyEffect>();
GR_STATIC_ASSERT(kGrClipEdgeTypeCnt <= 8);
static_assert(kGrClipEdgeTypeCnt <= 8);
uint32_t key = (cpe.getEdgeCount() << 3) | (int) cpe.getEdgeType();
b->add32(key);
}

View File

@ -32,23 +32,23 @@ 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)
GR_STATIC_ASSERT(kOverlay_GrBlendEquation == (int)SkBlendMode::kOverlay + EQ_OFFSET);
GR_STATIC_ASSERT(kDarken_GrBlendEquation == (int)SkBlendMode::kDarken + EQ_OFFSET);
GR_STATIC_ASSERT(kLighten_GrBlendEquation == (int)SkBlendMode::kLighten + EQ_OFFSET);
GR_STATIC_ASSERT(kColorDodge_GrBlendEquation == (int)SkBlendMode::kColorDodge + EQ_OFFSET);
GR_STATIC_ASSERT(kColorBurn_GrBlendEquation == (int)SkBlendMode::kColorBurn + EQ_OFFSET);
GR_STATIC_ASSERT(kHardLight_GrBlendEquation == (int)SkBlendMode::kHardLight + EQ_OFFSET);
GR_STATIC_ASSERT(kSoftLight_GrBlendEquation == (int)SkBlendMode::kSoftLight + EQ_OFFSET);
GR_STATIC_ASSERT(kDifference_GrBlendEquation == (int)SkBlendMode::kDifference + EQ_OFFSET);
GR_STATIC_ASSERT(kExclusion_GrBlendEquation == (int)SkBlendMode::kExclusion + EQ_OFFSET);
GR_STATIC_ASSERT(kMultiply_GrBlendEquation == (int)SkBlendMode::kMultiply + EQ_OFFSET);
GR_STATIC_ASSERT(kHSLHue_GrBlendEquation == (int)SkBlendMode::kHue + EQ_OFFSET);
GR_STATIC_ASSERT(kHSLSaturation_GrBlendEquation == (int)SkBlendMode::kSaturation + EQ_OFFSET);
GR_STATIC_ASSERT(kHSLColor_GrBlendEquation == (int)SkBlendMode::kColor + EQ_OFFSET);
GR_STATIC_ASSERT(kHSLLuminosity_GrBlendEquation == (int)SkBlendMode::kLuminosity + EQ_OFFSET);
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);
// There's an illegal GrBlendEquation that corresponds to no SkBlendMode, hence the extra +1.
GR_STATIC_ASSERT(kGrBlendEquationCnt == (int)SkBlendMode::kLastMode + 1 + 1 + EQ_OFFSET);
static_assert(kGrBlendEquationCnt == (int)SkBlendMode::kLastMode + 1 + 1 + EQ_OFFSET);
return static_cast<GrBlendEquation>((int)mode + EQ_OFFSET);
#undef EQ_OFFSET
@ -126,7 +126,7 @@ public:
if (xp.hasHWBlendEquation()) {
SkASSERT(caps.advBlendEqInteraction() > 0); // 0 will mean !xp.hasHWBlendEquation().
key |= caps.advBlendEqInteraction();
GR_STATIC_ASSERT(GrShaderCaps::kLast_AdvBlendEqInteraction < 4);
static_assert(GrShaderCaps::kLast_AdvBlendEqInteraction < 4);
}
if (!xp.hasHWBlendEquation() || caps.mustEnableSpecificAdvBlendEqs()) {
key |= (int)xp.mode() << 3;

View File

@ -158,13 +158,13 @@ private:
uint32_t fData;
};
GR_STATIC_ASSERT(kLast_OutputType < (1 << 3));
GR_STATIC_ASSERT(kLast_GrBlendEquation < (1 << 5));
GR_STATIC_ASSERT(kLast_GrBlendCoeff < (1 << 5));
GR_STATIC_ASSERT(kLast_Property < (1 << 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));
};
GR_STATIC_ASSERT(4 == sizeof(BlendFormula));
static_assert(4 == sizeof(BlendFormula));
GR_MAKE_BITFIELD_OPS(BlendFormula::Properties);
@ -470,7 +470,7 @@ public:
const PorterDuffXferProcessor& xp = processor.cast<PorterDuffXferProcessor>();
b->add32(xp.getBlendFormula().primaryOutput() |
(xp.getBlendFormula().secondaryOutput() << 3));
GR_STATIC_ASSERT(BlendFormula::kLast_OutputType < 8);
static_assert(BlendFormula::kLast_OutputType < 8);
}
private:

View File

@ -285,7 +285,7 @@ void GLCircularRRectEffect::emitCode(EmitArgs& args) {
void GLCircularRRectEffect::GenKey(const GrProcessor& processor, const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const CircularRRectEffect& crre = processor.cast<CircularRRectEffect>();
GR_STATIC_ASSERT(kGrClipEdgeTypeCnt <= 8);
static_assert(kGrClipEdgeTypeCnt <= 8);
b->add32((crre.getCircularCornerFlags() << 3) | (int) crre.getEdgeType());
}
@ -592,7 +592,7 @@ void GLEllipticalRRectEffect::emitCode(EmitArgs& args) {
void GLEllipticalRRectEffect::GenKey(const GrProcessor& effect, const GrShaderCaps&,
GrProcessorKeyBuilder* b) {
const EllipticalRRectEffect& erre = effect.cast<EllipticalRRectEffect>();
GR_STATIC_ASSERT((int) GrClipEdgeType::kLast < (1 << 3));
static_assert((int)GrClipEdgeType::kLast < (1 << 3));
b->add32(erre.getRRect().getType() | (int) erre.getEdgeType() << 3);
}

View File

@ -192,7 +192,7 @@ public:
* computed key. The returned will be limited to the lower kDomainKeyBits bits.
*/
static uint32_t DomainKey(const GrTextureDomain& domain) {
GR_STATIC_ASSERT(kModeCount <= (1 << kModeBits));
static_assert(kModeCount <= (1 << kModeBits));
return domain.modeX() | (domain.modeY() << kModeBits);
}

View File

@ -387,7 +387,7 @@ private:
}
void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
GR_STATIC_ASSERT(((int)SkBlendMode::kLastMode & UINT16_MAX) == (int)SkBlendMode::kLastMode);
static_assert(((int)SkBlendMode::kLastMode & UINT16_MAX) == (int)SkBlendMode::kLastMode);
b->add32((int)fMode | (fChild << 16));
}

View File

@ -637,7 +637,7 @@ using ExcludedTerm = GrPathUtils::ExcludedTerm;
ExcludedTerm GrPathUtils::calcCubicInverseTransposePowerBasisMatrix(const SkPoint p[4],
SkMatrix* out) {
GR_STATIC_ASSERT(SK_SCALAR_IS_FLOAT);
static_assert(SK_SCALAR_IS_FLOAT);
// First convert the bezier coordinates p[0..3] to power basis coefficients X,Y(,W=[0 0 0 1]).
// M3 is the matrix that does this conversion. The homogeneous equation for the cubic becomes:

View File

@ -185,8 +185,8 @@ static int path_key_from_data_size(const SkPath& path) {
const int pointCnt = path.countPoints();
const int conicWeightCnt = SkPathPriv::ConicWeightCnt(path);
GR_STATIC_ASSERT(sizeof(SkPoint) == 2 * sizeof(uint32_t));
GR_STATIC_ASSERT(sizeof(SkScalar) == sizeof(uint32_t));
static_assert(sizeof(SkPoint) == 2 * sizeof(uint32_t));
static_assert(sizeof(SkScalar) == sizeof(uint32_t));
// 2 is for the verb cnt and a fill type. Each verb is a byte but we'll pad the verb data out to
// a uint32_t length.
return 2 + (SkAlign4(verbCnt) >> 2) + 2 * pointCnt + conicWeightCnt;
@ -211,10 +211,10 @@ static void write_path_key_from_data(const SkPath& path, uint32_t* origKey) {
key += verbKeySize >> 2;
memcpy(key, SkPathPriv::PointData(path), sizeof(SkPoint) * pointCnt);
GR_STATIC_ASSERT(sizeof(SkPoint) == 2 * sizeof(uint32_t));
static_assert(sizeof(SkPoint) == 2 * sizeof(uint32_t));
key += 2 * pointCnt;
sk_careful_memcpy(key, SkPathPriv::ConicWeightData(path), sizeof(SkScalar) * conicWeightCnt);
GR_STATIC_ASSERT(sizeof(SkScalar) == sizeof(uint32_t));
static_assert(sizeof(SkScalar) == sizeof(uint32_t));
SkDEBUGCODE(key += conicWeightCnt);
SkASSERT(key - origKey == path_key_from_data_size(path));
}
@ -230,15 +230,15 @@ int GrShape::unstyledKeySize() const {
return 1;
case Type::kRRect:
SkASSERT(!fInheritedKey.count());
GR_STATIC_ASSERT(0 == SkRRect::kSizeInMemory % sizeof(uint32_t));
static_assert(0 == SkRRect::kSizeInMemory % sizeof(uint32_t));
// + 1 for the direction, start index, and inverseness.
return SkRRect::kSizeInMemory / sizeof(uint32_t) + 1;
case Type::kArc:
SkASSERT(!fInheritedKey.count());
GR_STATIC_ASSERT(0 == sizeof(fArcData) % sizeof(uint32_t));
static_assert(0 == sizeof(fArcData) % sizeof(uint32_t));
return sizeof(fArcData) / sizeof(uint32_t);
case Type::kLine:
GR_STATIC_ASSERT(2 * sizeof(uint32_t) == sizeof(SkPoint));
static_assert(2 * sizeof(uint32_t) == sizeof(SkPoint));
// 4 for the end points and 1 for the inverseness
return 5;
case Type::kPath: {

View File

@ -1105,22 +1105,22 @@ void GrGLCaps::onDumpJSON(SkJSONWriter* writer) const {
"IMG MS To Texture",
"EXT MS To Texture",
};
GR_STATIC_ASSERT(0 == kNone_MSFBOType);
GR_STATIC_ASSERT(1 == kStandard_MSFBOType);
GR_STATIC_ASSERT(2 == kES_Apple_MSFBOType);
GR_STATIC_ASSERT(3 == kES_IMG_MsToTexture_MSFBOType);
GR_STATIC_ASSERT(4 == kES_EXT_MsToTexture_MSFBOType);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMSFBOExtStr) == kLast_MSFBOType + 1);
static_assert(0 == kNone_MSFBOType);
static_assert(1 == kStandard_MSFBOType);
static_assert(2 == kES_Apple_MSFBOType);
static_assert(3 == kES_IMG_MsToTexture_MSFBOType);
static_assert(4 == kES_EXT_MsToTexture_MSFBOType);
static_assert(SK_ARRAY_COUNT(kMSFBOExtStr) == kLast_MSFBOType + 1);
static const char* kInvalidateFBTypeStr[] = {
"None",
"Discard",
"Invalidate",
};
GR_STATIC_ASSERT(0 == kNone_InvalidateFBType);
GR_STATIC_ASSERT(1 == kDiscard_InvalidateFBType);
GR_STATIC_ASSERT(2 == kInvalidate_InvalidateFBType);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kInvalidateFBTypeStr) == kLast_InvalidateFBType + 1);
static_assert(0 == kNone_InvalidateFBType);
static_assert(1 == kDiscard_InvalidateFBType);
static_assert(2 == kInvalidate_InvalidateFBType);
static_assert(SK_ARRAY_COUNT(kInvalidateFBTypeStr) == kLast_InvalidateFBType + 1);
static const char* kMapBufferTypeStr[] = {
"None",
@ -1128,11 +1128,11 @@ void GrGLCaps::onDumpJSON(SkJSONWriter* writer) const {
"MapBufferRange",
"Chromium",
};
GR_STATIC_ASSERT(0 == kNone_MapBufferType);
GR_STATIC_ASSERT(1 == kMapBuffer_MapBufferType);
GR_STATIC_ASSERT(2 == kMapBufferRange_MapBufferType);
GR_STATIC_ASSERT(3 == kChromium_MapBufferType);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMapBufferTypeStr) == kLast_MapBufferType + 1);
static_assert(0 == kNone_MapBufferType);
static_assert(1 == kMapBuffer_MapBufferType);
static_assert(2 == kMapBufferRange_MapBufferType);
static_assert(3 == kChromium_MapBufferType);
static_assert(SK_ARRAY_COUNT(kMapBufferTypeStr) == kLast_MapBufferType + 1);
writer->appendBool("Core Profile", fIsCoreProfile);
writer->appendString("MSAA Type", kMSFBOExtStr[fMSFBOType]);

View File

@ -85,25 +85,25 @@ static const GrGLenum gXfermodeEquation2Blend[] = {
// Illegal... needs to map to something.
GR_GL_FUNC_ADD,
};
GR_STATIC_ASSERT(0 == kAdd_GrBlendEquation);
GR_STATIC_ASSERT(1 == kSubtract_GrBlendEquation);
GR_STATIC_ASSERT(2 == kReverseSubtract_GrBlendEquation);
GR_STATIC_ASSERT(3 == kScreen_GrBlendEquation);
GR_STATIC_ASSERT(4 == kOverlay_GrBlendEquation);
GR_STATIC_ASSERT(5 == kDarken_GrBlendEquation);
GR_STATIC_ASSERT(6 == kLighten_GrBlendEquation);
GR_STATIC_ASSERT(7 == kColorDodge_GrBlendEquation);
GR_STATIC_ASSERT(8 == kColorBurn_GrBlendEquation);
GR_STATIC_ASSERT(9 == kHardLight_GrBlendEquation);
GR_STATIC_ASSERT(10 == kSoftLight_GrBlendEquation);
GR_STATIC_ASSERT(11 == kDifference_GrBlendEquation);
GR_STATIC_ASSERT(12 == kExclusion_GrBlendEquation);
GR_STATIC_ASSERT(13 == kMultiply_GrBlendEquation);
GR_STATIC_ASSERT(14 == kHSLHue_GrBlendEquation);
GR_STATIC_ASSERT(15 == kHSLSaturation_GrBlendEquation);
GR_STATIC_ASSERT(16 == kHSLColor_GrBlendEquation);
GR_STATIC_ASSERT(17 == kHSLLuminosity_GrBlendEquation);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(gXfermodeEquation2Blend) == kGrBlendEquationCnt);
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 const GrGLenum gXfermodeCoeff2Blend[] = {
GR_GL_ZERO,
@ -158,30 +158,30 @@ bool GrGLGpu::BlendCoeffReferencesConstant(GrBlendCoeff coeff) {
false,
};
return gCoeffReferencesBlendConst[coeff];
GR_STATIC_ASSERT(kGrBlendCoeffCnt == SK_ARRAY_COUNT(gCoeffReferencesBlendConst));
static_assert(kGrBlendCoeffCnt == SK_ARRAY_COUNT(gCoeffReferencesBlendConst));
GR_STATIC_ASSERT(0 == kZero_GrBlendCoeff);
GR_STATIC_ASSERT(1 == kOne_GrBlendCoeff);
GR_STATIC_ASSERT(2 == kSC_GrBlendCoeff);
GR_STATIC_ASSERT(3 == kISC_GrBlendCoeff);
GR_STATIC_ASSERT(4 == kDC_GrBlendCoeff);
GR_STATIC_ASSERT(5 == kIDC_GrBlendCoeff);
GR_STATIC_ASSERT(6 == kSA_GrBlendCoeff);
GR_STATIC_ASSERT(7 == kISA_GrBlendCoeff);
GR_STATIC_ASSERT(8 == kDA_GrBlendCoeff);
GR_STATIC_ASSERT(9 == kIDA_GrBlendCoeff);
GR_STATIC_ASSERT(10 == kConstC_GrBlendCoeff);
GR_STATIC_ASSERT(11 == kIConstC_GrBlendCoeff);
GR_STATIC_ASSERT(12 == kConstA_GrBlendCoeff);
GR_STATIC_ASSERT(13 == kIConstA_GrBlendCoeff);
static_assert(0 == kZero_GrBlendCoeff);
static_assert(1 == kOne_GrBlendCoeff);
static_assert(2 == kSC_GrBlendCoeff);
static_assert(3 == kISC_GrBlendCoeff);
static_assert(4 == kDC_GrBlendCoeff);
static_assert(5 == kIDC_GrBlendCoeff);
static_assert(6 == kSA_GrBlendCoeff);
static_assert(7 == kISA_GrBlendCoeff);
static_assert(8 == kDA_GrBlendCoeff);
static_assert(9 == kIDA_GrBlendCoeff);
static_assert(10 == kConstC_GrBlendCoeff);
static_assert(11 == kIConstC_GrBlendCoeff);
static_assert(12 == kConstA_GrBlendCoeff);
static_assert(13 == kIConstA_GrBlendCoeff);
GR_STATIC_ASSERT(14 == kS2C_GrBlendCoeff);
GR_STATIC_ASSERT(15 == kIS2C_GrBlendCoeff);
GR_STATIC_ASSERT(16 == kS2A_GrBlendCoeff);
GR_STATIC_ASSERT(17 == kIS2A_GrBlendCoeff);
static_assert(14 == kS2C_GrBlendCoeff);
static_assert(15 == kIS2C_GrBlendCoeff);
static_assert(16 == kS2A_GrBlendCoeff);
static_assert(17 == kIS2A_GrBlendCoeff);
// assertion for gXfermodeCoeff2Blend have to be in GrGpu scope
GR_STATIC_ASSERT(kGrBlendCoeffCnt == SK_ARRAY_COUNT(gXfermodeCoeff2Blend));
static_assert(kGrBlendCoeffCnt == SK_ARRAY_COUNT(gXfermodeCoeff2Blend));
}
//////////////////////////////////////////////////////////////////////////////
@ -405,7 +405,7 @@ GrGLGpu::GrGLGpu(std::unique_ptr<GrGLContext> ctx, GrContext* context)
for (int i = 0; i < kGrGpuBufferTypeCount; ++i) {
fHWBufferState[i].invalidate();
}
GR_STATIC_ASSERT(4 == SK_ARRAY_COUNT(fHWBufferState));
static_assert(4 == SK_ARRAY_COUNT(fHWBufferState));
if (this->glCaps().shaderCaps()->pathRenderingSupport()) {
fPathRendering.reset(new GrGLPathRendering(this));
@ -2397,14 +2397,14 @@ GrGLenum gr_to_gl_stencil_op(GrStencilOp op) {
GR_GL_INCR, // kIncClamp
GR_GL_DECR, // kDecClamp
};
GR_STATIC_ASSERT(0 == (int)GrStencilOp::kKeep);
GR_STATIC_ASSERT(1 == (int)GrStencilOp::kZero);
GR_STATIC_ASSERT(2 == (int)GrStencilOp::kReplace);
GR_STATIC_ASSERT(3 == (int)GrStencilOp::kInvert);
GR_STATIC_ASSERT(4 == (int)GrStencilOp::kIncWrap);
GR_STATIC_ASSERT(5 == (int)GrStencilOp::kDecWrap);
GR_STATIC_ASSERT(6 == (int)GrStencilOp::kIncClamp);
GR_STATIC_ASSERT(7 == (int)GrStencilOp::kDecClamp);
static_assert(0 == (int)GrStencilOp::kKeep);
static_assert(1 == (int)GrStencilOp::kZero);
static_assert(2 == (int)GrStencilOp::kReplace);
static_assert(3 == (int)GrStencilOp::kInvert);
static_assert(4 == (int)GrStencilOp::kIncWrap);
static_assert(5 == (int)GrStencilOp::kDecWrap);
static_assert(6 == (int)GrStencilOp::kIncClamp);
static_assert(7 == (int)GrStencilOp::kDecClamp);
SkASSERT(op < (GrStencilOp)kGrStencilOpCount);
return gTable[(int)op];
}
@ -2691,7 +2691,7 @@ void GrGLGpu::bindTexture(int unitIdx, GrSamplerState samplerState, const GrSwiz
get_gl_swizzle_values(swizzle, glValues);
this->setTextureUnit(unitIdx);
if (GR_IS_GR_GL(this->glStandard())) {
GR_STATIC_ASSERT(sizeof(glValues[0]) == sizeof(GrGLint));
static_assert(sizeof(glValues[0]) == sizeof(GrGLint));
GL_CALL(TexParameteriv(target, GR_GL_TEXTURE_SWIZZLE_RGBA,
reinterpret_cast<const GrGLint*>(glValues)));
} else if (GR_IS_GR_GL_ES(this->glStandard())) {
@ -3897,7 +3897,7 @@ GrFence SK_WARN_UNUSED_RESULT GrGLGpu::insertFence() {
SkASSERT(this->caps()->fenceSyncSupport());
GrGLsync sync;
GL_CALL_RET(sync, FenceSync(GR_GL_SYNC_GPU_COMMANDS_COMPLETE, 0));
GR_STATIC_ASSERT(sizeof(GrFence) >= sizeof(GrGLsync));
static_assert(sizeof(GrFence) >= sizeof(GrGLsync));
return (GrFence)sync;
}

View File

@ -20,12 +20,12 @@ inline GrGLubyte verb_to_gl_path_cmd(SkPath::Verb verb) {
GR_GL_CUBIC_CURVE_TO,
GR_GL_CLOSE_PATH,
};
GR_STATIC_ASSERT(0 == SkPath::kMove_Verb);
GR_STATIC_ASSERT(1 == SkPath::kLine_Verb);
GR_STATIC_ASSERT(2 == SkPath::kQuad_Verb);
GR_STATIC_ASSERT(3 == SkPath::kConic_Verb);
GR_STATIC_ASSERT(4 == SkPath::kCubic_Verb);
GR_STATIC_ASSERT(5 == SkPath::kClose_Verb);
static_assert(0 == SkPath::kMove_Verb);
static_assert(1 == SkPath::kLine_Verb);
static_assert(2 == SkPath::kQuad_Verb);
static_assert(3 == SkPath::kConic_Verb);
static_assert(4 == SkPath::kCubic_Verb);
static_assert(5 == SkPath::kClose_Verb);
SkASSERT(verb >= 0 && (size_t)verb < SK_ARRAY_COUNT(gTable));
return gTable[verb];
@ -41,12 +41,12 @@ inline int num_coords(SkPath::Verb verb) {
6, // cubic
0, // close
};
GR_STATIC_ASSERT(0 == SkPath::kMove_Verb);
GR_STATIC_ASSERT(1 == SkPath::kLine_Verb);
GR_STATIC_ASSERT(2 == SkPath::kQuad_Verb);
GR_STATIC_ASSERT(3 == SkPath::kConic_Verb);
GR_STATIC_ASSERT(4 == SkPath::kCubic_Verb);
GR_STATIC_ASSERT(5 == SkPath::kClose_Verb);
static_assert(0 == SkPath::kMove_Verb);
static_assert(1 == SkPath::kLine_Verb);
static_assert(2 == SkPath::kQuad_Verb);
static_assert(3 == SkPath::kConic_Verb);
static_assert(4 == SkPath::kCubic_Verb);
static_assert(5 == SkPath::kClose_Verb);
SkASSERT(verb >= 0 && (size_t)verb < SK_ARRAY_COUNT(gTable));
return gTable[verb];
@ -60,10 +60,10 @@ inline GrGLenum join_to_gl_join(SkPaint::Join join) {
GR_GL_BEVEL
};
return gSkJoinsToGrGLJoins[join];
GR_STATIC_ASSERT(0 == SkPaint::kMiter_Join);
GR_STATIC_ASSERT(1 == SkPaint::kRound_Join);
GR_STATIC_ASSERT(2 == SkPaint::kBevel_Join);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(gSkJoinsToGrGLJoins) == SkPaint::kJoinCount);
static_assert(0 == SkPaint::kMiter_Join);
static_assert(1 == SkPaint::kRound_Join);
static_assert(2 == SkPaint::kBevel_Join);
static_assert(SK_ARRAY_COUNT(gSkJoinsToGrGLJoins) == SkPaint::kJoinCount);
}
inline GrGLenum cap_to_gl_cap(SkPaint::Cap cap) {
@ -73,10 +73,10 @@ inline GrGLenum cap_to_gl_cap(SkPaint::Cap cap) {
GR_GL_SQUARE
};
return gSkCapsToGrGLCaps[cap];
GR_STATIC_ASSERT(0 == SkPaint::kButt_Cap);
GR_STATIC_ASSERT(1 == SkPaint::kRound_Cap);
GR_STATIC_ASSERT(2 == SkPaint::kSquare_Cap);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(gSkCapsToGrGLCaps) == SkPaint::kCapCount);
static_assert(0 == SkPaint::kButt_Cap);
static_assert(1 == SkPaint::kRound_Cap);
static_assert(2 == SkPaint::kSquare_Cap);
static_assert(SK_ARRAY_COUNT(gSkCapsToGrGLCaps) == SkPaint::kCapCount);
}
#ifdef SK_DEBUG

View File

@ -23,12 +23,12 @@
// implementation. The call has a result value, and thus waiting for the call completion is needed.
static const GrGLsizei kPathIDPreallocationAmount = 65536;
GR_STATIC_ASSERT(0 == GrPathRendering::kNone_PathTransformType);
GR_STATIC_ASSERT(1 == GrPathRendering::kTranslateX_PathTransformType);
GR_STATIC_ASSERT(2 == GrPathRendering::kTranslateY_PathTransformType);
GR_STATIC_ASSERT(3 == GrPathRendering::kTranslate_PathTransformType);
GR_STATIC_ASSERT(4 == GrPathRendering::kAffine_PathTransformType);
GR_STATIC_ASSERT(GrPathRendering::kAffine_PathTransformType == GrPathRendering::kLast_PathTransformType);
static_assert(0 == GrPathRendering::kNone_PathTransformType);
static_assert(1 == GrPathRendering::kTranslateX_PathTransformType);
static_assert(2 == GrPathRendering::kTranslateY_PathTransformType);
static_assert(3 == GrPathRendering::kTranslate_PathTransformType);
static_assert(4 == GrPathRendering::kAffine_PathTransformType);
static_assert(GrPathRendering::kAffine_PathTransformType == GrPathRendering::kLast_PathTransformType);
#ifdef SK_DEBUG

View File

@ -603,14 +603,14 @@ GrGLenum GrToGLStencilFunc(GrStencilTest test) {
GR_GL_EQUAL, // kEqual
GR_GL_NOTEQUAL, // kNotEqual
};
GR_STATIC_ASSERT(0 == (int)GrStencilTest::kAlways);
GR_STATIC_ASSERT(1 == (int)GrStencilTest::kNever);
GR_STATIC_ASSERT(2 == (int)GrStencilTest::kGreater);
GR_STATIC_ASSERT(3 == (int)GrStencilTest::kGEqual);
GR_STATIC_ASSERT(4 == (int)GrStencilTest::kLess);
GR_STATIC_ASSERT(5 == (int)GrStencilTest::kLEqual);
GR_STATIC_ASSERT(6 == (int)GrStencilTest::kEqual);
GR_STATIC_ASSERT(7 == (int)GrStencilTest::kNotEqual);
static_assert(0 == (int)GrStencilTest::kAlways);
static_assert(1 == (int)GrStencilTest::kNever);
static_assert(2 == (int)GrStencilTest::kGreater);
static_assert(3 == (int)GrStencilTest::kGEqual);
static_assert(4 == (int)GrStencilTest::kLess);
static_assert(5 == (int)GrStencilTest::kLEqual);
static_assert(6 == (int)GrStencilTest::kEqual);
static_assert(7 == (int)GrStencilTest::kNotEqual);
SkASSERT(test < (GrStencilTest)kGrStencilTestCount);
return gTable[(int)test];

View File

@ -16,7 +16,7 @@ struct AttribLayout {
uint16_t fType;
};
GR_STATIC_ASSERT(4 == sizeof(AttribLayout));
static_assert(4 == sizeof(AttribLayout));
static AttribLayout attrib_layout(GrVertexAttribType type) {
switch (type) {

View File

@ -38,32 +38,32 @@ static const char* specific_layout_qualifier_name(GrBlendEquation equation) {
};
return kLayoutQualifierNames[equation - kFirstAdvancedGrBlendEquation];
GR_STATIC_ASSERT(0 == kScreen_GrBlendEquation - kFirstAdvancedGrBlendEquation);
GR_STATIC_ASSERT(1 == kOverlay_GrBlendEquation - kFirstAdvancedGrBlendEquation);
GR_STATIC_ASSERT(2 == kDarken_GrBlendEquation - kFirstAdvancedGrBlendEquation);
GR_STATIC_ASSERT(3 == kLighten_GrBlendEquation - kFirstAdvancedGrBlendEquation);
GR_STATIC_ASSERT(4 == kColorDodge_GrBlendEquation - kFirstAdvancedGrBlendEquation);
GR_STATIC_ASSERT(5 == kColorBurn_GrBlendEquation - kFirstAdvancedGrBlendEquation);
GR_STATIC_ASSERT(6 == kHardLight_GrBlendEquation - kFirstAdvancedGrBlendEquation);
GR_STATIC_ASSERT(7 == kSoftLight_GrBlendEquation - kFirstAdvancedGrBlendEquation);
GR_STATIC_ASSERT(8 == kDifference_GrBlendEquation - kFirstAdvancedGrBlendEquation);
GR_STATIC_ASSERT(9 == kExclusion_GrBlendEquation - kFirstAdvancedGrBlendEquation);
GR_STATIC_ASSERT(10 == kMultiply_GrBlendEquation - kFirstAdvancedGrBlendEquation);
GR_STATIC_ASSERT(11 == kHSLHue_GrBlendEquation - kFirstAdvancedGrBlendEquation);
GR_STATIC_ASSERT(12 == kHSLSaturation_GrBlendEquation - kFirstAdvancedGrBlendEquation);
GR_STATIC_ASSERT(13 == kHSLColor_GrBlendEquation - kFirstAdvancedGrBlendEquation);
GR_STATIC_ASSERT(14 == kHSLLuminosity_GrBlendEquation - kFirstAdvancedGrBlendEquation);
static_assert(0 == kScreen_GrBlendEquation - kFirstAdvancedGrBlendEquation);
static_assert(1 == kOverlay_GrBlendEquation - kFirstAdvancedGrBlendEquation);
static_assert(2 == kDarken_GrBlendEquation - kFirstAdvancedGrBlendEquation);
static_assert(3 == kLighten_GrBlendEquation - kFirstAdvancedGrBlendEquation);
static_assert(4 == kColorDodge_GrBlendEquation - kFirstAdvancedGrBlendEquation);
static_assert(5 == kColorBurn_GrBlendEquation - kFirstAdvancedGrBlendEquation);
static_assert(6 == kHardLight_GrBlendEquation - kFirstAdvancedGrBlendEquation);
static_assert(7 == kSoftLight_GrBlendEquation - kFirstAdvancedGrBlendEquation);
static_assert(8 == kDifference_GrBlendEquation - kFirstAdvancedGrBlendEquation);
static_assert(9 == kExclusion_GrBlendEquation - kFirstAdvancedGrBlendEquation);
static_assert(10 == kMultiply_GrBlendEquation - kFirstAdvancedGrBlendEquation);
static_assert(11 == kHSLHue_GrBlendEquation - kFirstAdvancedGrBlendEquation);
static_assert(12 == kHSLSaturation_GrBlendEquation - kFirstAdvancedGrBlendEquation);
static_assert(13 == kHSLColor_GrBlendEquation - kFirstAdvancedGrBlendEquation);
static_assert(14 == kHSLLuminosity_GrBlendEquation - kFirstAdvancedGrBlendEquation);
// There's an illegal GrBlendEquation at the end there, hence the -1.
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kLayoutQualifierNames) ==
kGrBlendEquationCnt - kFirstAdvancedGrBlendEquation - 1);
static_assert(SK_ARRAY_COUNT(kLayoutQualifierNames) ==
kGrBlendEquationCnt - kFirstAdvancedGrBlendEquation - 1);
}
uint8_t GrGLSLFragmentShaderBuilder::KeyForSurfaceOrigin(GrSurfaceOrigin origin) {
SkASSERT(kTopLeft_GrSurfaceOrigin == origin || kBottomLeft_GrSurfaceOrigin == origin);
return origin + 1;
GR_STATIC_ASSERT(0 == kTopLeft_GrSurfaceOrigin);
GR_STATIC_ASSERT(1 == kBottomLeft_GrSurfaceOrigin);
static_assert(0 == kTopLeft_GrSurfaceOrigin);
static_assert(1 == kBottomLeft_GrSurfaceOrigin);
}
GrGLSLFragmentShaderBuilder::GrGLSLFragmentShaderBuilder(GrGLSLProgramBuilder* program)

View File

@ -254,9 +254,9 @@ void GrGLSLShaderBuilder::compileAndAppendLayoutQualifiers() {
this->layoutQualifiers().appendf(") %s;\n", interfaceQualifierNames[interface]);
}
GR_STATIC_ASSERT(0 == GrGLSLShaderBuilder::kIn_InterfaceQualifier);
GR_STATIC_ASSERT(1 == GrGLSLShaderBuilder::kOut_InterfaceQualifier);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(interfaceQualifierNames) == kLastInterfaceQualifier + 1);
static_assert(0 == GrGLSLShaderBuilder::kIn_InterfaceQualifier);
static_assert(1 == GrGLSLShaderBuilder::kOut_InterfaceQualifier);
static_assert(SK_ARRAY_COUNT(interfaceQualifierNames) == kLastInterfaceQualifier + 1);
}
void GrGLSLShaderBuilder::finalize(uint32_t visibility) {

View File

@ -69,6 +69,6 @@ void main() {
params.fColorCount, params.fTileMode);
GrTest::TestAsFPArgs asFPArgs(d);
std::unique_ptr<GrFragmentProcessor> fp = as_SB(shader)->asFragmentProcessor(asFPArgs.args());
GrAlwaysAssert(fp);
SkASSERT_RELEASE(fp);
return fp;
}

View File

@ -78,6 +78,6 @@ void main() {
params.fStops, params.fColorCount);
GrTest::TestAsFPArgs asFPArgs(d);
std::unique_ptr<GrFragmentProcessor> fp = as_SB(shader)->asFragmentProcessor(asFPArgs.args());
GrAlwaysAssert(fp);
SkASSERT_RELEASE(fp);
return fp;
}

View File

@ -297,6 +297,6 @@ void main() {
GrTest::TestAsFPArgs asFPArgs(d);
std::unique_ptr<GrFragmentProcessor> fp = as_SB(shader)->asFragmentProcessor(asFPArgs.args());
GrAlwaysAssert(fp);
SkASSERT_RELEASE(fp);
return fp;
}

View File

@ -73,7 +73,7 @@ std::unique_ptr<GrFragmentProcessor> GrLinearGradientLayout::TestCreate(GrProces
params.fColorCount, params.fTileMode);
GrTest::TestAsFPArgs asFPArgs(d);
std::unique_ptr<GrFragmentProcessor> fp = as_SB(shader)->asFragmentProcessor(asFPArgs.args());
GrAlwaysAssert(fp);
SkASSERT_RELEASE(fp);
return fp;
}
#endif

View File

@ -107,7 +107,7 @@ std::unique_ptr<GrFragmentProcessor> GrSweepGradientLayout::TestCreate(GrProcess
params.fStops, params.fColorCount);
GrTest::TestAsFPArgs asFPArgs(d);
std::unique_ptr<GrFragmentProcessor> fp = as_SB(shader)->asFragmentProcessor(asFPArgs.args());
GrAlwaysAssert(fp);
SkASSERT_RELEASE(fp);
return fp;
}
#endif

View File

@ -222,7 +222,7 @@ std::unique_ptr<GrFragmentProcessor> GrTwoPointConicalGradientLayout::TestCreate
GrTest::TestAsFPArgs asFPArgs(d);
std::unique_ptr<GrFragmentProcessor> fp = as_SB(shader)->asFragmentProcessor(asFPArgs.args());
GrAlwaysAssert(fp);
SkASSERT_RELEASE(fp);
return fp;
}
#endif

View File

@ -181,9 +181,9 @@ void GrMtlOpsRenderPass::setupRenderPass(
MTLLoadActionClear,
MTLLoadActionDontCare
};
GR_STATIC_ASSERT((int)GrLoadOp::kLoad == 0);
GR_STATIC_ASSERT((int)GrLoadOp::kClear == 1);
GR_STATIC_ASSERT((int)GrLoadOp::kDiscard == 2);
static_assert((int)GrLoadOp::kLoad == 0);
static_assert((int)GrLoadOp::kClear == 1);
static_assert((int)GrLoadOp::kDiscard == 2);
SkASSERT(colorInfo.fLoadOp <= GrLoadOp::kDiscard);
SkASSERT(stencilInfo.fLoadOp <= GrLoadOp::kDiscard);
@ -191,8 +191,8 @@ void GrMtlOpsRenderPass::setupRenderPass(
MTLStoreActionStore,
MTLStoreActionDontCare
};
GR_STATIC_ASSERT((int)GrStoreOp::kStore == 0);
GR_STATIC_ASSERT((int)GrStoreOp::kDiscard == 1);
static_assert((int)GrStoreOp::kStore == 0);
static_assert((int)GrStoreOp::kDiscard == 1);
SkASSERT(colorInfo.fStoreOp <= GrStoreOp::kDiscard);
SkASSERT(stencilInfo.fStoreOp <= GrStoreOp::kDiscard);
@ -246,11 +246,11 @@ static MTLPrimitiveType gr_to_mtl_primitive(GrPrimitiveType primitiveType) {
MTLPrimitiveTypeLine,
MTLPrimitiveTypeLineStrip
};
GR_STATIC_ASSERT((int)GrPrimitiveType::kTriangles == 0);
GR_STATIC_ASSERT((int)GrPrimitiveType::kTriangleStrip == 1);
GR_STATIC_ASSERT((int)GrPrimitiveType::kPoints == 2);
GR_STATIC_ASSERT((int)GrPrimitiveType::kLines == 3);
GR_STATIC_ASSERT((int)GrPrimitiveType::kLineStrip == 4);
static_assert((int)GrPrimitiveType::kTriangles == 0);
static_assert((int)GrPrimitiveType::kTriangleStrip == 1);
static_assert((int)GrPrimitiveType::kPoints == 2);
static_assert((int)GrPrimitiveType::kLines == 3);
static_assert((int)GrPrimitiveType::kLineStrip == 4);
SkASSERT(primitiveType <= GrPrimitiveType::kLineStrip);
return mtlPrimitiveType[static_cast<int>(primitiveType)];

View File

@ -286,10 +286,10 @@ static MTLBlendOperation blend_equation_to_mtl_blend_op(GrBlendEquation equation
MTLBlendOperationSubtract, // kSubtract_GrBlendEquation
MTLBlendOperationReverseSubtract, // kReverseSubtract_GrBlendEquation
};
GR_STATIC_ASSERT(SK_ARRAY_COUNT(gTable) == kFirstAdvancedGrBlendEquation);
GR_STATIC_ASSERT(0 == kAdd_GrBlendEquation);
GR_STATIC_ASSERT(1 == kSubtract_GrBlendEquation);
GR_STATIC_ASSERT(2 == kReverseSubtract_GrBlendEquation);
static_assert(SK_ARRAY_COUNT(gTable) == kFirstAdvancedGrBlendEquation);
static_assert(0 == kAdd_GrBlendEquation);
static_assert(1 == kSubtract_GrBlendEquation);
static_assert(2 == kReverseSubtract_GrBlendEquation);
SkASSERT((unsigned)equation < kGrBlendEquationCnt);
return gTable[equation];

View File

@ -299,7 +299,7 @@ template<int N> inline void GrMtlPipelineStateDataManager::setMatrices(
template<> struct set_uniform_matrix<2> {
inline static void set(void* buffer, int uniformOffset, int count, const float matrices[]) {
GR_STATIC_ASSERT(sizeof(float) == 4);
static_assert(sizeof(float) == 4);
buffer = static_cast<char*>(buffer) + uniformOffset;
memcpy(buffer, matrices, count * 4 * sizeof(float));
}
@ -307,7 +307,7 @@ template<> struct set_uniform_matrix<2> {
template<> struct set_uniform_matrix<3> {
inline static void set(void* buffer, int uniformOffset, int count, const float matrices[]) {
GR_STATIC_ASSERT(sizeof(float) == 4);
static_assert(sizeof(float) == 4);
buffer = static_cast<char*>(buffer) + uniformOffset;
for (int i = 0; i < count; ++i) {
const float* matrix = &matrices[3 * 3 * i];
@ -321,7 +321,7 @@ template<> struct set_uniform_matrix<3> {
template<> struct set_uniform_matrix<4> {
inline static void set(void* buffer, int uniformOffset, int count, const float matrices[]) {
GR_STATIC_ASSERT(sizeof(float) == 4);
static_assert(sizeof(float) == 4);
buffer = static_cast<char*>(buffer) + uniformOffset;
memcpy(buffer, matrices, count * 16 * sizeof(float));
}

View File

@ -47,9 +47,9 @@ GrMtlSampler* GrMtlSampler::Create(const GrMtlGpu* gpu, const GrSamplerState& sa
MTLSamplerMinMagFilterLinear
};
GR_STATIC_ASSERT((int)GrSamplerState::Filter::kNearest == 0);
GR_STATIC_ASSERT((int)GrSamplerState::Filter::kBilerp == 1);
GR_STATIC_ASSERT((int)GrSamplerState::Filter::kMipMap == 2);
static_assert((int)GrSamplerState::Filter::kNearest == 0);
static_assert((int)GrSamplerState::Filter::kBilerp == 1);
static_assert((int)GrSamplerState::Filter::kMipMap == 2);
auto samplerDesc = [[MTLSamplerDescriptor alloc] init];
samplerDesc.rAddressMode = MTLSamplerAddressModeClampToEdge;

View File

@ -48,15 +48,15 @@ struct Segment {
SkVector fMid;
int countPoints() {
GR_STATIC_ASSERT(0 == kLine && 1 == kQuad);
static_assert(0 == kLine && 1 == kQuad);
return fType + 1;
}
const SkPoint& endPt() const {
GR_STATIC_ASSERT(0 == kLine && 1 == kQuad);
static_assert(0 == kLine && 1 == kQuad);
return fPts[fType];
}
const SkPoint& endNorm() const {
GR_STATIC_ASSERT(0 == kLine && 1 == kQuad);
static_assert(0 == kLine && 1 == kQuad);
return fNorms[fType];
}
};

View File

@ -111,7 +111,7 @@ static sk_sp<const GrBuffer> get_lines_index_buffer(GrResourceProvider* resource
// Takes 178th time of logf on Z600 / VC2010
static int get_float_exp(float x) {
GR_STATIC_ASSERT(sizeof(int) == sizeof(float));
static_assert(sizeof(int) == sizeof(float));
#ifdef SK_DEBUG
static bool tested;
if (!tested) {
@ -487,7 +487,7 @@ struct BezierVertex {
};
};
GR_STATIC_ASSERT(sizeof(BezierVertex) == 3 * sizeof(SkPoint));
static_assert(sizeof(BezierVertex) == 3 * sizeof(SkPoint));
static void intersect_lines(const SkPoint& ptA, const SkVector& normA,
const SkPoint& ptB, const SkVector& normB,

View File

@ -298,8 +298,8 @@ void GrAtlasTextOp::onPrepareDraws(Target* target) {
SkASSERT(proxies[0]);
static constexpr int kMaxTextures = GrBitmapTextGeoProc::kMaxTextures;
GR_STATIC_ASSERT(GrDistanceFieldA8TextGeoProc::kMaxTextures == kMaxTextures);
GR_STATIC_ASSERT(GrDistanceFieldLCDTextGeoProc::kMaxTextures == kMaxTextures);
static_assert(GrDistanceFieldA8TextGeoProc::kMaxTextures == kMaxTextures);
static_assert(GrDistanceFieldLCDTextGeoProc::kMaxTextures == kMaxTextures);
auto fixedDynamicState = target->makeFixedDynamicState(kMaxTextures);
for (unsigned i = 0; i < numActiveProxies; ++i) {

View File

@ -198,7 +198,7 @@ GR_DRAW_OP_TEST_DEFINE(RegionOp) {
op = SkRegion::kReplace_Op;
} else {
// Pick an other than replace.
GR_STATIC_ASSERT(SkRegion::kLastOp == SkRegion::kReplace_Op);
static_assert(SkRegion::kLastOp == SkRegion::kReplace_Op);
op = (SkRegion::Op)random->nextULessThan(SkRegion::kLastOp);
}
region.op(rect, op);

View File

@ -319,7 +319,7 @@ private:
int instanceCount = fShapes.count();
static constexpr int kMaxTextures = GrDistanceFieldPathGeoProc::kMaxTextures;
GR_STATIC_ASSERT(GrBitmapTextGeoProc::kMaxTextures == kMaxTextures);
static_assert(GrBitmapTextGeoProc::kMaxTextures == kMaxTextures);
FlushInfo flushInfo;
flushInfo.fFixedDynamicState = target->makeFixedDynamicState(kMaxTextures);

View File

@ -544,7 +544,7 @@ sk_sp<const GrGpuBuffer> AAStrokeRectOp::GetIndexBuffer(GrResourceProvider* reso
3 + 8, 0 + 8, 4 + 8, 4 + 8, 7 + 8, 3 + 8,
};
// clang-format on
GR_STATIC_ASSERT(SK_ARRAY_COUNT(gMiterIndices) == kMiterIndexCnt);
static_assert(SK_ARRAY_COUNT(gMiterIndices) == kMiterIndexCnt);
GR_DEFINE_STATIC_UNIQUE_KEY(gMiterIndexBufferKey);
return resourceProvider->findOrCreatePatternedIndexBuffer(
gMiterIndices, kMiterIndexCnt, kNumMiterRectsInIndexBuffer, kMiterVertexCnt,
@ -608,7 +608,7 @@ sk_sp<const GrGpuBuffer> AAStrokeRectOp::GetIndexBuffer(GrResourceProvider* reso
3 + 16, 0 + 16, 4 + 16, 4 + 16, 7 + 16, 3 + 16,
};
// clang-format on
GR_STATIC_ASSERT(SK_ARRAY_COUNT(gBevelIndices) == kBevelIndexCnt);
static_assert(SK_ARRAY_COUNT(gBevelIndices) == kBevelIndexCnt);
GR_DEFINE_STATIC_UNIQUE_KEY(gBevelIndexBufferKey);
return resourceProvider->findOrCreatePatternedIndexBuffer(

View File

@ -2543,7 +2543,7 @@ GrFence SK_WARN_UNUSED_RESULT GrVkGpu::insertFence() {
return 0;
}
GR_STATIC_ASSERT(sizeof(GrFence) >= sizeof(VkFence));
static_assert(sizeof(GrFence) >= sizeof(VkFence));
return (GrFence)fence;
}

View File

@ -188,15 +188,15 @@ static VkStencilOp stencil_op_to_vk_stencil_op(GrStencilOp op) {
VK_STENCIL_OP_INCREMENT_AND_CLAMP, // kIncClamp
VK_STENCIL_OP_DECREMENT_AND_CLAMP, // kDecClamp
};
GR_STATIC_ASSERT(SK_ARRAY_COUNT(gTable) == kGrStencilOpCount);
GR_STATIC_ASSERT(0 == (int)GrStencilOp::kKeep);
GR_STATIC_ASSERT(1 == (int)GrStencilOp::kZero);
GR_STATIC_ASSERT(2 == (int)GrStencilOp::kReplace);
GR_STATIC_ASSERT(3 == (int)GrStencilOp::kInvert);
GR_STATIC_ASSERT(4 == (int)GrStencilOp::kIncWrap);
GR_STATIC_ASSERT(5 == (int)GrStencilOp::kDecWrap);
GR_STATIC_ASSERT(6 == (int)GrStencilOp::kIncClamp);
GR_STATIC_ASSERT(7 == (int)GrStencilOp::kDecClamp);
static_assert(SK_ARRAY_COUNT(gTable) == kGrStencilOpCount);
static_assert(0 == (int)GrStencilOp::kKeep);
static_assert(1 == (int)GrStencilOp::kZero);
static_assert(2 == (int)GrStencilOp::kReplace);
static_assert(3 == (int)GrStencilOp::kInvert);
static_assert(4 == (int)GrStencilOp::kIncWrap);
static_assert(5 == (int)GrStencilOp::kDecWrap);
static_assert(6 == (int)GrStencilOp::kIncClamp);
static_assert(7 == (int)GrStencilOp::kDecClamp);
SkASSERT(op < (GrStencilOp)kGrStencilOpCount);
return gTable[(int)op];
}
@ -212,15 +212,15 @@ static VkCompareOp stencil_func_to_vk_compare_op(GrStencilTest test) {
VK_COMPARE_OP_EQUAL, // kEqual
VK_COMPARE_OP_NOT_EQUAL, // kNotEqual
};
GR_STATIC_ASSERT(SK_ARRAY_COUNT(gTable) == kGrStencilTestCount);
GR_STATIC_ASSERT(0 == (int)GrStencilTest::kAlways);
GR_STATIC_ASSERT(1 == (int)GrStencilTest::kNever);
GR_STATIC_ASSERT(2 == (int)GrStencilTest::kGreater);
GR_STATIC_ASSERT(3 == (int)GrStencilTest::kGEqual);
GR_STATIC_ASSERT(4 == (int)GrStencilTest::kLess);
GR_STATIC_ASSERT(5 == (int)GrStencilTest::kLEqual);
GR_STATIC_ASSERT(6 == (int)GrStencilTest::kEqual);
GR_STATIC_ASSERT(7 == (int)GrStencilTest::kNotEqual);
static_assert(SK_ARRAY_COUNT(gTable) == kGrStencilTestCount);
static_assert(0 == (int)GrStencilTest::kAlways);
static_assert(1 == (int)GrStencilTest::kNever);
static_assert(2 == (int)GrStencilTest::kGreater);
static_assert(3 == (int)GrStencilTest::kGEqual);
static_assert(4 == (int)GrStencilTest::kLess);
static_assert(5 == (int)GrStencilTest::kLEqual);
static_assert(6 == (int)GrStencilTest::kEqual);
static_assert(7 == (int)GrStencilTest::kNotEqual);
SkASSERT(test < (GrStencilTest)kGrStencilTestCount);
return gTable[(int)test];
@ -355,25 +355,25 @@ static VkBlendFactor blend_coeff_to_vk_blend(GrBlendCoeff coeff) {
VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA, // kIS2A_GrBlendCoeff
VK_BLEND_FACTOR_ZERO, // kIllegal_GrBlendCoeff
};
GR_STATIC_ASSERT(SK_ARRAY_COUNT(gTable) == kGrBlendCoeffCnt);
GR_STATIC_ASSERT(0 == kZero_GrBlendCoeff);
GR_STATIC_ASSERT(1 == kOne_GrBlendCoeff);
GR_STATIC_ASSERT(2 == kSC_GrBlendCoeff);
GR_STATIC_ASSERT(3 == kISC_GrBlendCoeff);
GR_STATIC_ASSERT(4 == kDC_GrBlendCoeff);
GR_STATIC_ASSERT(5 == kIDC_GrBlendCoeff);
GR_STATIC_ASSERT(6 == kSA_GrBlendCoeff);
GR_STATIC_ASSERT(7 == kISA_GrBlendCoeff);
GR_STATIC_ASSERT(8 == kDA_GrBlendCoeff);
GR_STATIC_ASSERT(9 == kIDA_GrBlendCoeff);
GR_STATIC_ASSERT(10 == kConstC_GrBlendCoeff);
GR_STATIC_ASSERT(11 == kIConstC_GrBlendCoeff);
GR_STATIC_ASSERT(12 == kConstA_GrBlendCoeff);
GR_STATIC_ASSERT(13 == kIConstA_GrBlendCoeff);
GR_STATIC_ASSERT(14 == kS2C_GrBlendCoeff);
GR_STATIC_ASSERT(15 == kIS2C_GrBlendCoeff);
GR_STATIC_ASSERT(16 == kS2A_GrBlendCoeff);
GR_STATIC_ASSERT(17 == kIS2A_GrBlendCoeff);
static_assert(SK_ARRAY_COUNT(gTable) == kGrBlendCoeffCnt);
static_assert(0 == kZero_GrBlendCoeff);
static_assert(1 == kOne_GrBlendCoeff);
static_assert(2 == kSC_GrBlendCoeff);
static_assert(3 == kISC_GrBlendCoeff);
static_assert(4 == kDC_GrBlendCoeff);
static_assert(5 == kIDC_GrBlendCoeff);
static_assert(6 == kSA_GrBlendCoeff);
static_assert(7 == kISA_GrBlendCoeff);
static_assert(8 == kDA_GrBlendCoeff);
static_assert(9 == kIDA_GrBlendCoeff);
static_assert(10 == kConstC_GrBlendCoeff);
static_assert(11 == kIConstC_GrBlendCoeff);
static_assert(12 == kConstA_GrBlendCoeff);
static_assert(13 == kIConstA_GrBlendCoeff);
static_assert(14 == kS2C_GrBlendCoeff);
static_assert(15 == kIS2C_GrBlendCoeff);
static_assert(16 == kS2A_GrBlendCoeff);
static_assert(17 == kIS2A_GrBlendCoeff);
SkASSERT((unsigned)coeff < kGrBlendCoeffCnt);
return gTable[coeff];
@ -407,25 +407,25 @@ static VkBlendOp blend_equation_to_vk_blend_op(GrBlendEquation equation) {
// Illegal.
VK_BLEND_OP_ADD,
};
GR_STATIC_ASSERT(0 == kAdd_GrBlendEquation);
GR_STATIC_ASSERT(1 == kSubtract_GrBlendEquation);
GR_STATIC_ASSERT(2 == kReverseSubtract_GrBlendEquation);
GR_STATIC_ASSERT(3 == kScreen_GrBlendEquation);
GR_STATIC_ASSERT(4 == kOverlay_GrBlendEquation);
GR_STATIC_ASSERT(5 == kDarken_GrBlendEquation);
GR_STATIC_ASSERT(6 == kLighten_GrBlendEquation);
GR_STATIC_ASSERT(7 == kColorDodge_GrBlendEquation);
GR_STATIC_ASSERT(8 == kColorBurn_GrBlendEquation);
GR_STATIC_ASSERT(9 == kHardLight_GrBlendEquation);
GR_STATIC_ASSERT(10 == kSoftLight_GrBlendEquation);
GR_STATIC_ASSERT(11 == kDifference_GrBlendEquation);
GR_STATIC_ASSERT(12 == kExclusion_GrBlendEquation);
GR_STATIC_ASSERT(13 == kMultiply_GrBlendEquation);
GR_STATIC_ASSERT(14 == kHSLHue_GrBlendEquation);
GR_STATIC_ASSERT(15 == kHSLSaturation_GrBlendEquation);
GR_STATIC_ASSERT(16 == kHSLColor_GrBlendEquation);
GR_STATIC_ASSERT(17 == kHSLLuminosity_GrBlendEquation);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(gTable) == kGrBlendEquationCnt);
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);
SkASSERT((unsigned)equation < kGrBlendCoeffCnt);
return gTable[equation];
@ -458,7 +458,7 @@ static bool blend_coeff_refs_constant(GrBlendCoeff coeff) {
false,
};
return gCoeffReferencesBlendConst[coeff];
GR_STATIC_ASSERT(kGrBlendCoeffCnt == SK_ARRAY_COUNT(gCoeffReferencesBlendConst));
static_assert(kGrBlendCoeffCnt == SK_ARRAY_COUNT(gCoeffReferencesBlendConst));
// Individual enum asserts already made in blend_coeff_to_vk_blend
}

View File

@ -313,7 +313,7 @@ template<int N> inline void GrVkPipelineStateDataManager::setMatrices(UniformHan
template<int N> struct set_uniform_matrix {
inline static void set(void* buffer, int uniformOffset, int count, const float matrices[]) {
GR_STATIC_ASSERT(sizeof(float) == 4);
static_assert(sizeof(float) == 4);
buffer = static_cast<char*>(buffer) + uniformOffset;
for (int i = 0; i < count; ++i) {
const float* matrix = &matrices[N * N * i];
@ -327,7 +327,7 @@ template<int N> struct set_uniform_matrix {
template<> struct set_uniform_matrix<4> {
inline static void set(void* buffer, int uniformOffset, int count, const float matrices[]) {
GR_STATIC_ASSERT(sizeof(float) == 4);
static_assert(sizeof(float) == 4);
buffer = static_cast<char*>(buffer) + uniformOffset;
memcpy(buffer, matrices, count * 16 * sizeof(float));
}

View File

@ -100,7 +100,7 @@ GrVkSamplerYcbcrConversion::Key GrVkSamplerYcbcrConversion::GenerateKey(
SkASSERT(static_cast<int>(ycbcrInfo.fChromaFilter) <= 1);
static const int kReconShift = kChromaFilterShift + 1;
SkASSERT(static_cast<int>(ycbcrInfo.fForceExplicitReconstruction) <= 1);
GR_STATIC_ASSERT(kReconShift <= 7);
static_assert(kReconShift <= 7);
uint8_t ycbcrKey = static_cast<uint8_t>(ycbcrInfo.fYcbcrModel);
ycbcrKey |= (static_cast<uint8_t>(ycbcrInfo.fYcbcrRange) << kRangeShift);

View File

@ -597,7 +597,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ColorTypeBackendAllocationTest, reporter, ctx
{ kR16G16B16A16_unorm_SkColorType,{ .25f, .5f, .75f, 1 } },
};
GR_STATIC_ASSERT(kLastEnum_SkColorType == SK_ARRAY_COUNT(combinations));
static_assert(kLastEnum_SkColorType == SK_ARRAY_COUNT(combinations));
for (auto combo : combinations) {
SkColorType colorType = combo.fColorType;

View File

@ -1048,7 +1048,7 @@ static void test_reduced_clip_stack(skiatest::Reporter* reporter) {
// will be kInvalidGenID if left uninitialized.
SkAlignedSTStorage<1, GrReducedClip> storage;
memset(storage.get(), 0, sizeof(GrReducedClip));
GR_STATIC_ASSERT(0 == SkClipStack::kInvalidGenID);
static_assert(0 == SkClipStack::kInvalidGenID);
// Get the reduced version of the stack.
SkRect queryBounds = kBounds;
@ -1117,7 +1117,7 @@ static void test_reduced_clip_stack_genid(skiatest::Reporter* reporter) {
SkAlignedSTStorage<1, GrReducedClip> storage;
memset(storage.get(), 0, sizeof(GrReducedClip));
GR_STATIC_ASSERT(0 == SkClipStack::kInvalidGenID);
static_assert(0 == SkClipStack::kInvalidGenID);
const GrReducedClip* reduced = new (storage.get()) GrReducedClip(stack, bounds, caps);
REPORTER_ASSERT(reporter, reduced->maskElements().count() == 1);

View File

@ -179,7 +179,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrMeshTest, reporter, ctxInfo) {
// Start at various repetitions within the patterned index buffer to exercise base
// index.
while (i < kBoxCount) {
GR_STATIC_ASSERT(kIndexPatternRepeatCount >= 3);
static_assert(kIndexPatternRepeatCount >= 3);
int repetitionCount = SkTMin(3 - baseRepetition, kBoxCount - i);
GrMesh mesh(GrPrimitiveType::kTriangles);

View File

@ -62,7 +62,7 @@ static bool test_bounds_by_rasterizing(const SkPath& path, const SkRect& bounds)
static constexpr int kRes = 2000;
// This tolerance is in units of 1/kRes fractions of the bounds width/height.
static constexpr int kTol = 2;
GR_STATIC_ASSERT(kRes % 4 == 0);
static_assert(kRes % 4 == 0);
SkImageInfo info = SkImageInfo::MakeA8(kRes, kRes);
sk_sp<SkSurface> surface = SkSurface::MakeRaster(info);
surface->getCanvas()->clear(0x0);

View File

@ -31,7 +31,7 @@ private:
static constexpr GrGLbitfield GL_SYNC_FLUSH_COMMANDS_BIT = 0x00000001;
typedef struct __GLsync *GLsync;
GR_STATIC_ASSERT(sizeof(GLsync) <= sizeof(sk_gpu_test::PlatformFence));
static_assert(sizeof(GLsync) <= sizeof(sk_gpu_test::PlatformFence));
typedef GLsync (GR_GL_FUNCTION_TYPE* GLFenceSyncProc) (GrGLenum, GrGLbitfield);
typedef GrGLenum (GR_GL_FUNCTION_TYPE* GLClientWaitSyncProc) (GLsync, GrGLbitfield, GrGLuint64);
@ -272,7 +272,7 @@ void GLGpuTimer::deleteQuery(sk_gpu_test::PlatformTimerQuery platformTimer) {
fGLDeleteQueries(1, &queryID);
}
GR_STATIC_ASSERT(sizeof(GrGLuint) <= sizeof(sk_gpu_test::PlatformTimerQuery));
static_assert(sizeof(GrGLuint) <= sizeof(sk_gpu_test::PlatformTimerQuery));
} // anonymous namespace

View File

@ -373,7 +373,7 @@ void EGLFenceSync::deleteFence(sk_gpu_test::PlatformFence platformFence) const {
fEGLDestroySyncKHR(fDisplay, eglsync);
}
GR_STATIC_ASSERT(sizeof(EGLSyncKHR) <= sizeof(sk_gpu_test::PlatformFence));
static_assert(sizeof(EGLSyncKHR) <= sizeof(sk_gpu_test::PlatformFence));
} // anonymous namespace

View File

@ -65,7 +65,7 @@ private:
typedef sk_gpu_test::FenceSync INHERITED;
};
GR_STATIC_ASSERT(sizeof(uint64_t) <= sizeof(sk_gpu_test::PlatformFence));
static_assert(sizeof(uint64_t) <= sizeof(sk_gpu_test::PlatformFence));
class MtlTestContextImpl : public sk_gpu_test::MtlTestContext {
public:

View File

@ -141,7 +141,7 @@ private:
typedef sk_gpu_test::FenceSync INHERITED;
};
GR_STATIC_ASSERT(sizeof(VkFence) <= sizeof(sk_gpu_test::PlatformFence));
static_assert(sizeof(VkFence) <= sizeof(sk_gpu_test::PlatformFence));
// TODO: Implement swap buffers and finish
class VkTestContextImpl : public sk_gpu_test::VkTestContext {