Use static_assert instead of SK_COMPILE_ASSERT.

Now that static_assert is allowed, there is no need to use a non-
standard compile time assertion

Review URL: https://codereview.chromium.org/1306443004
This commit is contained in:
bungeman 2015-08-20 07:57:51 -07:00 committed by Commit bot
parent 915881fe74
commit 99fe822606
66 changed files with 181 additions and 209 deletions

View File

@ -311,7 +311,7 @@ public:
static const char* LineTypeName(LineType lt) {
static const char* gNames[] = { "hori", "vert", "diag" };
SK_COMPILE_ASSERT(kLineTypeCount == SK_ARRAY_COUNT(gNames), names_wrong_size);
static_assert(kLineTypeCount == SK_ARRAY_COUNT(gNames), "names_wrong_size");
return gNames[lt];
}

View File

@ -163,7 +163,7 @@ protected:
SK_ARRAY_COUNT(gPoints9),
SK_ARRAY_COUNT(gPoints10),
};
SK_COMPILE_ASSERT(SK_ARRAY_COUNT(gSizes) == SK_ARRAY_COUNT(gPoints), array_mismatch);
static_assert(SK_ARRAY_COUNT(gSizes) == SK_ARRAY_COUNT(gPoints), "array_mismatch");
SkAutoTDeleteArray<SkPoint> data(NULL);
const SkPoint* points;

View File

@ -23,7 +23,7 @@ protected:
static const int kSubPixelSteps = 8;
static const int kLabelTextSize = 9;
SK_COMPILE_ASSERT(kSubPixelSteps < 99, label_offset_too_small);
static_assert(kSubPixelSteps < 99, "label_offset_too_small");
static const int kLabelOffsetX = 2 * kLabelTextSize + kLabelPad;
static const int kLabelOffsetY = kLabelTextSize + kLabelPad;

View File

@ -58,7 +58,7 @@ protected:
SkScalar w = SkIntToScalar(size.fWidth);
SkScalar h = SkIntToScalar(size.fHeight);
SK_COMPILE_ASSERT(4 == SK_ARRAY_COUNT(fTypefacesToUnref), typeface_cnt);
static_assert(4 == SK_ARRAY_COUNT(fTypefacesToUnref), "typeface_cnt");
fTypefacesToUnref[0] = sk_tool_utils::create_portable_typeface("sans-serif", SkTypeface::kNormal);
fTypefacesToUnref[1] = sk_tool_utils::create_portable_typeface("sans-serif", SkTypeface::kBold);
fTypefacesToUnref[2] = sk_tool_utils::create_portable_typeface("serif", SkTypeface::kNormal);

View File

@ -112,8 +112,8 @@ static int SkColorTypeBytesPerPixel(SkColorType ct) {
1, // kIndex_8
1, // kGray_8
};
SK_COMPILE_ASSERT(SK_ARRAY_COUNT(gSize) == (size_t)(kLastEnum_SkColorType + 1),
size_mismatch_with_SkColorType_enum);
static_assert(SK_ARRAY_COUNT(gSize) == (size_t)(kLastEnum_SkColorType + 1),
"size_mismatch_with_SkColorType_enum");
SkASSERT((size_t)ct < SK_ARRAY_COUNT(gSize));
return gSize[ct];

View File

@ -505,10 +505,10 @@ public:
* kInverseEvenOdd_FillType -> true
*/
static bool IsInverseFillType(FillType fill) {
SK_COMPILE_ASSERT(0 == kWinding_FillType, fill_type_mismatch);
SK_COMPILE_ASSERT(1 == kEvenOdd_FillType, fill_type_mismatch);
SK_COMPILE_ASSERT(2 == kInverseWinding_FillType, fill_type_mismatch);
SK_COMPILE_ASSERT(3 == kInverseEvenOdd_FillType, fill_type_mismatch);
static_assert(0 == kWinding_FillType, "fill_type_mismatch");
static_assert(1 == kEvenOdd_FillType, "fill_type_mismatch");
static_assert(2 == kInverseWinding_FillType, "fill_type_mismatch");
static_assert(3 == kInverseEvenOdd_FillType, "fill_type_mismatch");
return (fill & 2) != 0;
}
@ -521,10 +521,10 @@ public:
* kInverseEvenOdd_FillType -> kEvenOdd_FillType
*/
static FillType ConvertToNonInverseFillType(FillType fill) {
SK_COMPILE_ASSERT(0 == kWinding_FillType, fill_type_mismatch);
SK_COMPILE_ASSERT(1 == kEvenOdd_FillType, fill_type_mismatch);
SK_COMPILE_ASSERT(2 == kInverseWinding_FillType, fill_type_mismatch);
SK_COMPILE_ASSERT(3 == kInverseEvenOdd_FillType, fill_type_mismatch);
static_assert(0 == kWinding_FillType, "fill_type_mismatch");
static_assert(1 == kEvenOdd_FillType, "fill_type_mismatch");
static_assert(2 == kInverseWinding_FillType, "fill_type_mismatch");
static_assert(3 == kInverseEvenOdd_FillType, "fill_type_mismatch");
return (FillType)(fill & 1);
}

View File

@ -154,20 +154,6 @@ inline void operator delete(void* p) {
#define SK_TO_STRING_OVERRIDE() void toString(SkString* str) const override;
#endif
template <bool>
struct SkCompileAssert {
};
// Uses static_cast<bool>(expr) instead of bool(expr) due to
// https://connect.microsoft.com/VisualStudio/feedback/details/832915
// The extra parentheses in SkCompileAssert<(...)> are a work around for
// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57771
// which was fixed in gcc 4.8.2.
#define SK_COMPILE_ASSERT(expr, msg) \
typedef SkCompileAssert<(static_cast<bool>(expr))> \
msg[static_cast<bool>(expr) ? 1 : -1] SK_UNUSED
/*
* Usage: SK_MACRO_CONCAT(a, b) to construct the symbol ab
*
@ -209,7 +195,7 @@ struct SkCompileAssert {
* Take a look at SkAutoFree and SkAutoMalloc in this file for examples.
*/
#define SK_REQUIRE_LOCAL_VAR(classname) \
SK_COMPILE_ASSERT(false, missing_name_for_##classname)
static_assert(false, "missing name for " #classname)
///////////////////////////////////////////////////////////////////////

View File

@ -185,10 +185,10 @@ static inline int GrMaskFormatBytesPerPixel(GrMaskFormat format) {
// kA565 (1) -> 2
// kARGB (2) -> 4
static const int sBytesPerPixel[] = { 1, 2, 4 };
SK_COMPILE_ASSERT(SK_ARRAY_COUNT(sBytesPerPixel) == kMaskFormatCount, array_size_mismatch);
SK_COMPILE_ASSERT(kA8_GrMaskFormat == 0, enum_order_dependency);
SK_COMPILE_ASSERT(kA565_GrMaskFormat == 1, enum_order_dependency);
SK_COMPILE_ASSERT(kARGB_GrMaskFormat == 2, enum_order_dependency);
static_assert(SK_ARRAY_COUNT(sBytesPerPixel) == kMaskFormatCount, "array_size_mismatch");
static_assert(kA8_GrMaskFormat == 0, "enum_order_dependency");
static_assert(kA565_GrMaskFormat == 1, "enum_order_dependency");
static_assert(kARGB_GrMaskFormat == 2, "enum_order_dependency");
return sBytesPerPixel[(int) format];
}

View File

@ -247,7 +247,7 @@ struct RegionOpAndAA {
SkRegion::Op op : 31; // This really only needs to be 3, but there's no win today to do so.
unsigned aa : 1; // MSVC won't pack an enum with an bool, so we call this an unsigned.
};
SK_COMPILE_ASSERT(sizeof(RegionOpAndAA) == 4, RegionOpAndAASize);
static_assert(sizeof(RegionOpAndAA) == 4, "RegionOpAndAASize");
RECORD3(ClipPath, SkIRect, devBounds, PreCachedPath, path, RegionOpAndAA, opAA);
RECORD3(ClipRRect, SkIRect, devBounds, SkRRect, rrect, RegionOpAndAA, opAA);

View File

@ -598,8 +598,8 @@ static const struct TilingInfo gTilingInfo[] = {
{ "1/1x1/16" , SK_Scalar1 , SK_Scalar1 / 16 }, // kRel_1x16_Tiling
{ "1/16x1/1" , SK_Scalar1 / 16 , SK_Scalar1 }, // kRel_16x1_Tiling
};
SK_COMPILE_ASSERT((SK_ARRAY_COUNT(gTilingInfo) == kLast_TilingMode_Enum),
Incomplete_tiling_labels);
static_assert((SK_ARRAY_COUNT(gTilingInfo) == kLast_TilingMode_Enum),
"Incomplete_tiling_labels");
SkSize SampleWindow::tileSize() const {
SkASSERT((TilingMode)fTilingMode < kLast_TilingMode_Enum);
@ -673,7 +673,7 @@ static inline SampleWindow::DeviceType cycle_devicetype(SampleWindow::DeviceType
#endif // SK_SUPPORT_GPU
SampleWindow::kRaster_DeviceType,
};
SK_COMPILE_ASSERT(SK_ARRAY_COUNT(gCT) == SampleWindow::kDeviceTypeCnt, array_size_mismatch);
static_assert(SK_ARRAY_COUNT(gCT) == SampleWindow::kDeviceTypeCnt, "array_size_mismatch");
return gCT[ct];
}
@ -1942,8 +1942,8 @@ static const char* gDeviceTypePrefix[] = {
#endif // SK_ANGLE
#endif // SK_SUPPORT_GPU
};
SK_COMPILE_ASSERT(SK_ARRAY_COUNT(gDeviceTypePrefix) == SampleWindow::kDeviceTypeCnt,
array_size_mismatch);
static_assert(SK_ARRAY_COUNT(gDeviceTypePrefix) == SampleWindow::kDeviceTypeCnt,
"array_size_mismatch");
static const char* trystate_str(SkOSMenu::TriState state,
const char trueStr[], const char falseStr[]) {

View File

@ -48,15 +48,15 @@
*/
bool SkCanvas::wouldOverwriteEntireSurface(const SkRect* rect, const SkPaint* paint,
ShaderOverrideOpacity overrideOpacity) const {
SK_COMPILE_ASSERT((int)SkPaintPriv::kNone_ShaderOverrideOpacity ==
(int)kNone_ShaderOverrideOpacity,
need_matching_enums0);
SK_COMPILE_ASSERT((int)SkPaintPriv::kOpaque_ShaderOverrideOpacity ==
(int)kOpaque_ShaderOverrideOpacity,
need_matching_enums1);
SK_COMPILE_ASSERT((int)SkPaintPriv::kNotOpaque_ShaderOverrideOpacity ==
(int)kNotOpaque_ShaderOverrideOpacity,
need_matching_enums2);
static_assert((int)SkPaintPriv::kNone_ShaderOverrideOpacity ==
(int)kNone_ShaderOverrideOpacity,
"need_matching_enums0");
static_assert((int)SkPaintPriv::kOpaque_ShaderOverrideOpacity ==
(int)kOpaque_ShaderOverrideOpacity,
"need_matching_enums1");
static_assert((int)SkPaintPriv::kNotOpaque_ShaderOverrideOpacity ==
(int)kNotOpaque_ShaderOverrideOpacity,
"need_matching_enums2");
const SkISize size = this->getBaseLayerSize();
const SkRect bounds = SkRect::MakeIWH(size.width(), size.height());
@ -2791,7 +2791,7 @@ void SkCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* matrix,
///////////////////////////////////////////////////////////////////////////////
SkCanvas::LayerIter::LayerIter(SkCanvas* canvas, bool skipEmptyClips) {
SK_COMPILE_ASSERT(sizeof(fStorage) >= sizeof(SkDrawIter), fStorage_too_small);
static_assert(sizeof(fStorage) >= sizeof(SkDrawIter), "fStorage_too_small");
SkASSERT(canvas);

View File

@ -862,11 +862,11 @@ void SkClipStack::Element::dump() const {
"rrect",
"path"
};
SK_COMPILE_ASSERT(0 == kEmpty_Type, type_str);
SK_COMPILE_ASSERT(1 == kRect_Type, type_str);
SK_COMPILE_ASSERT(2 == kRRect_Type, type_str);
SK_COMPILE_ASSERT(3 == kPath_Type, type_str);
SK_COMPILE_ASSERT(SK_ARRAY_COUNT(kTypeStrings) == kTypeCnt, type_str);
static_assert(0 == kEmpty_Type, "type_str");
static_assert(1 == kRect_Type, "type_str");
static_assert(2 == kRRect_Type, "type_str");
static_assert(3 == kPath_Type, "type_str");
static_assert(SK_ARRAY_COUNT(kTypeStrings) == kTypeCnt, "type_str");
static const char* kOpStrings[] = {
"difference",
@ -876,13 +876,13 @@ void SkClipStack::Element::dump() const {
"reverse-difference",
"replace",
};
SK_COMPILE_ASSERT(0 == SkRegion::kDifference_Op, op_str);
SK_COMPILE_ASSERT(1 == SkRegion::kIntersect_Op, op_str);
SK_COMPILE_ASSERT(2 == SkRegion::kUnion_Op, op_str);
SK_COMPILE_ASSERT(3 == SkRegion::kXOR_Op, op_str);
SK_COMPILE_ASSERT(4 == SkRegion::kReverseDifference_Op, op_str);
SK_COMPILE_ASSERT(5 == SkRegion::kReplace_Op, op_str);
SK_COMPILE_ASSERT(SK_ARRAY_COUNT(kOpStrings) == SkRegion::kOpCnt, op_str);
static_assert(0 == SkRegion::kDifference_Op, "op_str");
static_assert(1 == SkRegion::kIntersect_Op, "op_str");
static_assert(2 == SkRegion::kUnion_Op, "op_str");
static_assert(3 == SkRegion::kXOR_Op, "op_str");
static_assert(4 == SkRegion::kReverseDifference_Op, "op_str");
static_assert(5 == SkRegion::kReplace_Op, "op_str");
static_assert(SK_ARRAY_COUNT(kOpStrings) == SkRegion::kOpCnt, "op_str");
SkDebugf("Type: %s, Op: %s, AA: %s, Save Count: %d\n", kTypeStrings[fType],
kOpStrings[fOp], (fDoAA ? "yes" : "no"), fSaveCount);

View File

@ -46,7 +46,7 @@ public:
// The cast relies on ConvolutionFixed being a short, implying that on
// the platforms we care about all (16) bits will fit into
// the mantissa of a (32-bit) float.
SK_COMPILE_ASSERT(sizeof(ConvolutionFixed) == 2, ConvolutionFixed_type_should_fit_in_float_mantissa);
static_assert(sizeof(ConvolutionFixed) == 2, "ConvolutionFixed_type_should_fit_in_float_mantissa");
float raw = static_cast<float>(x);
return ldexpf(raw, -kShiftBits);
}

View File

@ -106,8 +106,8 @@ struct SkImageFilter::Cache::Key {
Key(const uint32_t uniqueID, const SkMatrix& matrix, const SkIRect& clipBounds, uint32_t srcGenID)
: fUniqueID(uniqueID), fMatrix(matrix), fClipBounds(clipBounds), fSrcGenID(srcGenID) {
// Assert that Key is tightly-packed, since it is hashed.
SK_COMPILE_ASSERT(sizeof(Key) == sizeof(uint32_t) + sizeof(SkMatrix) + sizeof(SkIRect) +
sizeof(uint32_t), image_filter_key_tight_packing);
static_assert(sizeof(Key) == sizeof(uint32_t) + sizeof(SkMatrix) + sizeof(SkIRect) +
sizeof(uint32_t), "image_filter_key_tight_packing");
fMatrix.getType(); // force initialization of type, so hashes match
}
uint32_t fUniqueID;

View File

@ -1592,13 +1592,13 @@ struct PODMatrix {
const SkMatrix& asSkMatrix() const { return *reinterpret_cast<const SkMatrix*>(this); }
};
SK_COMPILE_ASSERT(sizeof(PODMatrix) == sizeof(SkMatrix), PODMatrixSizeMismatch);
static_assert(sizeof(PODMatrix) == sizeof(SkMatrix), "PODMatrixSizeMismatch");
} // namespace
const SkMatrix& SkMatrix::I() {
SK_COMPILE_ASSERT(offsetof(SkMatrix, fMat) == offsetof(PODMatrix, matrix), BadfMat);
SK_COMPILE_ASSERT(offsetof(SkMatrix, fTypeMask) == offsetof(PODMatrix, typemask), BadfTypeMask);
static_assert(offsetof(SkMatrix, fMat) == offsetof(PODMatrix, matrix), "BadfMat");
static_assert(offsetof(SkMatrix, fTypeMask) == offsetof(PODMatrix, typemask), "BadfTypeMask");
static const PODMatrix identity = { {SK_Scalar1, 0, 0,
0, SK_Scalar1, 0,
@ -1609,8 +1609,8 @@ const SkMatrix& SkMatrix::I() {
}
const SkMatrix& SkMatrix::InvalidMatrix() {
SK_COMPILE_ASSERT(offsetof(SkMatrix, fMat) == offsetof(PODMatrix, matrix), BadfMat);
SK_COMPILE_ASSERT(offsetof(SkMatrix, fTypeMask) == offsetof(PODMatrix, typemask), BadfTypeMask);
static_assert(offsetof(SkMatrix, fMat) == offsetof(PODMatrix, matrix), "BadfMat");
static_assert(offsetof(SkMatrix, fTypeMask) == offsetof(PODMatrix, typemask), "BadfTypeMask");
static const PODMatrix invalid =
{ {SK_ScalarMax, SK_ScalarMax, SK_ScalarMax,

View File

@ -2429,8 +2429,8 @@ bool SkPaint::nothingToDraw() const {
uint32_t SkPaint::getHash() const {
// We're going to hash 10 pointers and 7 32-bit values, finishing up with fBitfields,
// so fBitfields should be 10 pointers and 6 32-bit values from the start.
SK_COMPILE_ASSERT(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 * sizeof(uint32_t),
SkPaint_notPackedTightly);
static_assert(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 * sizeof(uint32_t),
"SkPaint_notPackedTightly");
return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this),
offsetof(SkPaint, fBitfields) + sizeof(fBitfields));
}

View File

@ -105,8 +105,7 @@ static inline size_t get_paint_offset(DrawType op, size_t opSize) {
1, // DRAW_IMAGE_RECT - right after op code
};
SK_COMPILE_ASSERT(sizeof(gPaintOffsets) == LAST_DRAWTYPE_ENUM + 1,
need_to_be_in_sync);
static_assert(sizeof(gPaintOffsets) == LAST_DRAWTYPE_ENUM + 1, "need_to_be_in_sync");
SkASSERT((unsigned)op <= (unsigned)LAST_DRAWTYPE_ENUM);
int overflow = 0;

View File

@ -36,9 +36,9 @@ void SkResourceCache::Key::init(void* nameSpace, uint64_t sharedID, size_t lengt
static const int kHashedLocal32s = kSharedIDLocal32s + (sizeof(fNamespace) >> 2);
static const int kLocal32s = kUnhashedLocal32s + kHashedLocal32s;
SK_COMPILE_ASSERT(sizeof(Key) == (kLocal32s << 2), unaccounted_key_locals);
SK_COMPILE_ASSERT(sizeof(Key) == offsetof(Key, fNamespace) + sizeof(fNamespace),
namespace_field_must_be_last);
static_assert(sizeof(Key) == (kLocal32s << 2), "unaccounted_key_locals");
static_assert(sizeof(Key) == offsetof(Key, fNamespace) + sizeof(fNamespace),
"namespace_field_must_be_last");
fCount32 = SkToS32(kLocal32s + (length >> 2));
fSharedID_lo = (uint32_t)sharedID;

View File

@ -21,10 +21,10 @@ enum {
// largest seen for normal quads : 11
static const int kRecursiveLimits[] = { 5*3, 26*3, 11*3, 11*3 }; // 3x limits seen in practice
SK_COMPILE_ASSERT(0 == kTangent_RecursiveLimit, cubic_stroke_relies_on_tangent_equalling_zero);
SK_COMPILE_ASSERT(1 == kCubic_RecursiveLimit, cubic_stroke_relies_on_cubic_equalling_one);
SK_COMPILE_ASSERT(SK_ARRAY_COUNT(kRecursiveLimits) == kQuad_RecursiveLimit + 1,
recursive_limits_mismatch);
static_assert(0 == kTangent_RecursiveLimit, "cubic_stroke_relies_on_tangent_equalling_zero");
static_assert(1 == kCubic_RecursiveLimit, "cubic_stroke_relies_on_cubic_equalling_one");
static_assert(SK_ARRAY_COUNT(kRecursiveLimits) == kQuad_RecursiveLimit + 1,
"recursive_limits_mismatch");
#ifdef SK_DEBUG
int gMaxRecursion[SK_ARRAY_COUNT(kRecursiveLimits)] = { 0 };
@ -544,9 +544,9 @@ SkPathStroker::ReductionType SkPathStroker::CheckCubicLinear(const SkPoint cubic
SkScalar t = tValues[index];
SkEvalCubicAt(cubic, t, &reduction[index], NULL, NULL);
}
SK_COMPILE_ASSERT(kQuad_ReductionType + 1 == kDegenerate_ReductionType, enum_out_of_whack);
SK_COMPILE_ASSERT(kQuad_ReductionType + 2 == kDegenerate2_ReductionType, enum_out_of_whack);
SK_COMPILE_ASSERT(kQuad_ReductionType + 3 == kDegenerate3_ReductionType, enum_out_of_whack);
static_assert(kQuad_ReductionType + 1 == kDegenerate_ReductionType, "enum_out_of_whack");
static_assert(kQuad_ReductionType + 2 == kDegenerate2_ReductionType, "enum_out_of_whack");
static_assert(kQuad_ReductionType + 3 == kDegenerate3_ReductionType, "enum_out_of_whack");
return (ReductionType) (kQuad_ReductionType + count);
}

View File

@ -73,9 +73,9 @@ private:
SkAutoTUnref<SkTypeface> fTypeface;
SkScalar fSkewX;
SK_COMPILE_ASSERT(SkPaint::kFull_Hinting < 4, insufficient_hinting_bits);
static_assert(SkPaint::kFull_Hinting < 4, "insufficient_hinting_bits");
uint32_t fHinting : 2;
SK_COMPILE_ASSERT((kFlagsMask & 0xffff) == kFlagsMask, insufficient_flags_bits);
static_assert((kFlagsMask & 0xffff) == kFlagsMask, "insufficient_flags_bits");
uint32_t fFlags : 16;
typedef SkNoncopyable INHERITED;
@ -87,7 +87,7 @@ struct RunFontStorageEquivalent {
SkScalar fSkewX;
uint32_t fFlags;
};
SK_COMPILE_ASSERT(sizeof(RunFont) == sizeof(RunFontStorageEquivalent), runfont_should_stay_packed);
static_assert(sizeof(RunFont) == sizeof(RunFontStorageEquivalent), "runfont_should_stay_packed");
} // anonymous namespace

View File

@ -30,12 +30,10 @@ static const SkScalar kStdFakeBoldInterpKeys[] = {
};
static const SkScalar kStdFakeBoldInterpValues[] = {
SK_Scalar1/24,
SK_Scalar1/32
SK_Scalar1/32,
};
SK_COMPILE_ASSERT(SK_ARRAY_COUNT(kStdFakeBoldInterpKeys) ==
SK_ARRAY_COUNT(kStdFakeBoldInterpValues),
mismatched_array_size);
static const int kStdFakeBoldInterpLength =
SK_ARRAY_COUNT(kStdFakeBoldInterpKeys);
static_assert(SK_ARRAY_COUNT(kStdFakeBoldInterpKeys) == SK_ARRAY_COUNT(kStdFakeBoldInterpValues),
"mismatched_array_size");
static const int kStdFakeBoldInterpLength = SK_ARRAY_COUNT(kStdFakeBoldInterpKeys);
#endif //SkTextFormatParams_DEFINES

View File

@ -50,6 +50,6 @@ private:
struct Block;
Block* fBlock;
};
SK_COMPILE_ASSERT(sizeof(SkVarAlloc) <= 32, SkVarAllocSize);
static_assert(sizeof(SkVarAlloc) <= 32, "SkVarAllocSize");
#endif//SkVarAlloc_DEFINED

View File

@ -966,7 +966,7 @@ const char* SkXfermode::ModeName(Mode mode) {
"Multiply", "Hue", "Saturation", "Color", "Luminosity"
};
return gModeStrings[mode];
SK_COMPILE_ASSERT(SK_ARRAY_COUNT(gModeStrings) == kLastMode + 1, mode_count);
static_assert(SK_ARRAY_COUNT(gModeStrings) == kLastMode + 1, "mode_count");
}
#ifndef SK_IGNORE_TO_STRING

View File

@ -153,7 +153,7 @@ void SkDropShadowImageFilter::toString(SkString* str) const {
"kDrawShadowAndForeground", "kDrawShadowOnly"
};
SK_COMPILE_ASSERT(kShadowModeCount == SK_ARRAY_COUNT(gModeStrings), enum_mismatch);
static_assert(kShadowModeCount == SK_ARRAY_COUNT(gModeStrings), "enum_mismatch");
str->appendf(" mode: %s", gModeStrings[fShadowMode]);

View File

@ -13,7 +13,7 @@
#define kSQRT_TABLE_BITS 11
#define kSQRT_TABLE_SIZE (1 << kSQRT_TABLE_BITS)
SK_COMPILE_ASSERT(sizeof(gSqrt8Table) == kSQRT_TABLE_SIZE, SqrtTableSizesMatch);
static_assert(sizeof(gSqrt8Table) == kSQRT_TABLE_SIZE, "SqrtTableSizesMatch");
#if 0

View File

@ -103,8 +103,8 @@ GrAtlasTextContext::GrAtlasTextContext(GrContext* context,
, fDistanceAdjustTable(SkNEW(DistanceAdjustTable)) {
// We overallocate vertices in our textblobs based on the assumption that A8 has the greatest
// vertexStride
SK_COMPILE_ASSERT(kGrayTextVASize >= kColorTextVASize && kGrayTextVASize >= kLCDTextVASize,
vertex_attribute_changed);
static_assert(kGrayTextVASize >= kColorTextVASize && kGrayTextVASize >= kLCDTextVASize,
"vertex_attribute_changed");
fCurrStrike = NULL;
fCache = context->getTextBlobCache();
}

View File

@ -179,7 +179,7 @@ private:
kRGB_565_GrPixelConfig,
kSkia8888_GrPixelConfig
};
SK_COMPILE_ASSERT(SK_ARRAY_COUNT(kPixelConfigs) == kMaskFormatCount, array_size_mismatch);
static_assert(SK_ARRAY_COUNT(kPixelConfigs) == kMaskFormatCount, "array_size_mismatch");
return kPixelConfigs[format];
}
@ -191,7 +191,7 @@ private:
kA565_GrMaskFormat,
kARGB_GrMaskFormat,
};
SK_COMPILE_ASSERT(SK_ARRAY_COUNT(sAtlasIndices) == kMaskFormatCount, array_size_mismatch);
static_assert(SK_ARRAY_COUNT(sAtlasIndices) == kMaskFormatCount, "array_size_mismatch");
SkASSERT(sAtlasIndices[format] < kMaskFormatCount);
return sAtlasIndices[format];

View File

@ -18,8 +18,8 @@ inline static bool compute_key_for_line_path(const SkPath& path, const GrStrokeI
if (!path.isLine(pts)) {
return false;
}
SK_COMPILE_ASSERT((sizeof(pts) % sizeof(uint32_t)) == 0 && sizeof(pts) > sizeof(uint32_t),
pts_needs_padding);
static_assert((sizeof(pts) % sizeof(uint32_t)) == 0 && sizeof(pts) > sizeof(uint32_t),
"pts_needs_padding");
const int kBaseData32Cnt = 1 + sizeof(pts) / sizeof(uint32_t);
int strokeDataCnt = stroke.computeUniqueKeyFragmentData32Cnt();
@ -39,8 +39,8 @@ inline static bool compute_key_for_oval_path(const SkPath& path, const GrStrokeI
if (!path.isOval(&rect)) {
return false;
}
SK_COMPILE_ASSERT((sizeof(rect) % sizeof(uint32_t)) == 0 && sizeof(rect) > sizeof(uint32_t),
rect_needs_padding);
static_assert((sizeof(rect) % sizeof(uint32_t)) == 0 && sizeof(rect) > sizeof(uint32_t),
"rect_needs_padding");
const int kBaseData32Cnt = 1 + sizeof(rect) / sizeof(uint32_t);
int strokeDataCnt = stroke.computeUniqueKeyFragmentData32Cnt();
@ -69,8 +69,8 @@ inline static bool compute_key_for_simple_path(const SkPath& path, const GrStrok
}
// If somebody goes wild with the constant, it might cause an overflow.
SK_COMPILE_ASSERT(kSimpleVolatilePathVerbLimit <= 100,
big_simple_volatile_path_verb_limit_may_cause_overflow);
static_assert(kSimpleVolatilePathVerbLimit <= 100,
"big_simple_volatile_path_verb_limit_may_cause_overflow");
const int pointCnt = path.countPoints();
if (pointCnt < 0) {
@ -121,8 +121,8 @@ inline static bool compute_key_for_simple_path(const SkPath& path, const GrStrok
path.getVerbs(reinterpret_cast<uint8_t*>(&builder[i]), verbCnt);
i += verbData32Cnt;
SK_COMPILE_ASSERT(((sizeof(SkPoint) % sizeof(uint32_t)) == 0) &&
sizeof(SkPoint) > sizeof(uint32_t), skpoint_array_needs_padding);
static_assert(((sizeof(SkPoint) % sizeof(uint32_t)) == 0) && sizeof(SkPoint) > sizeof(uint32_t),
"skpoint_array_needs_padding");
// Here we assume getPoints does a memcpy, so that we do not need to worry about the alignment.
path.getPoints(reinterpret_cast<SkPoint*>(&builder[i]), pointCnt);

View File

@ -36,9 +36,9 @@ void GrStrokeInfo::asUniqueKeyFragment(uint32_t* data) const {
kCapShift = kJoinShift + kJoinBits,
};
SK_COMPILE_ASSERT(SkStrokeRec::kStyleCount <= (1 << kStyleBits), style_shift_will_be_wrong);
SK_COMPILE_ASSERT(SkPaint::kJoinCount <= (1 << kJoinBits), cap_shift_will_be_wrong);
SK_COMPILE_ASSERT(SkPaint::kCapCount <= (1 << kCapBits), cap_does_not_fit);
static_assert(SkStrokeRec::kStyleCount <= (1 << kStyleBits), "style_shift_will_be_wrong");
static_assert(SkPaint::kJoinCount <= (1 << kJoinBits), "cap_shift_will_be_wrong");
static_assert(SkPaint::kCapCount <= (1 << kCapBits), "cap_does_not_fit");
uint32_t styleKey = this->getStyle();
if (this->needToApply()) {
styleKey |= this->getJoin() << kJoinShift;

View File

@ -105,7 +105,7 @@ void GrGLPath::InitPathObject(GrGLGpu* gpu,
if ((skPath.getSegmentMasks() & SkPath::kConic_SegmentMask) == 0) {
// This branch does type punning, converting SkPoint* to GrGLfloat*.
SK_COMPILE_ASSERT(sizeof(SkPoint) == sizeof(GrGLfloat) * 2, sk_point_not_two_floats);
static_assert(sizeof(SkPoint) == sizeof(GrGLfloat) * 2, "sk_point_not_two_floats");
// This branch does not convert with SkScalarToFloat.
#ifndef SK_SCALAR_IS_FLOAT
#error Need SK_SCALAR_IS_FLOAT.

View File

@ -660,8 +660,8 @@ bool SkScaledBitmapSampler::begin(SkBitmap* dst, SrcConfig sc,
// The jump between dst configs in the table
static const int gProcDstConfigSpan = 5;
SK_COMPILE_ASSERT(SK_ARRAY_COUNT(gProcChoosers) == 5 * gProcDstConfigSpan,
gProcs_has_the_wrong_number_of_entries);
static_assert(SK_ARRAY_COUNT(gProcChoosers) == 5 * gProcDstConfigSpan,
"gProcs_has_the_wrong_number_of_entries");
fCTable = ctable;

View File

@ -353,17 +353,12 @@ static bool calculate_inverse_path(const SkRect& bounds, const SkPath& invPath,
// enums so region_op_to_pathops_op can do a straight passthrough cast.
// If these are failing, it may be necessary to make region_op_to_pathops_op
// do more.
SK_COMPILE_ASSERT(SkRegion::kDifference_Op == (int)kDifference_SkPathOp,
region_pathop_mismatch);
SK_COMPILE_ASSERT(SkRegion::kIntersect_Op == (int)kIntersect_SkPathOp,
region_pathop_mismatch);
SK_COMPILE_ASSERT(SkRegion::kUnion_Op == (int)kUnion_SkPathOp,
region_pathop_mismatch);
SK_COMPILE_ASSERT(SkRegion::kXOR_Op == (int)kXOR_SkPathOp,
region_pathop_mismatch);
SK_COMPILE_ASSERT(SkRegion::kReverseDifference_Op ==
(int)kReverseDifference_SkPathOp,
region_pathop_mismatch);
static_assert(SkRegion::kDifference_Op == (int)kDifference_SkPathOp, "region_pathop_mismatch");
static_assert(SkRegion::kIntersect_Op == (int)kIntersect_SkPathOp, "region_pathop_mismatch");
static_assert(SkRegion::kUnion_Op == (int)kUnion_SkPathOp, "region_pathop_mismatch");
static_assert(SkRegion::kXOR_Op == (int)kXOR_SkPathOp, "region_pathop_mismatch");
static_assert(SkRegion::kReverseDifference_Op == (int)kReverseDifference_SkPathOp,
"region_pathop_mismatch");
static SkPathOp region_op_to_pathops_op(SkRegion::Op op) {
SkASSERT(op >= 0);
@ -559,11 +554,9 @@ void GraphicStackState::updateDrawingState(const GraphicStateEntry& state) {
currentEntry()->fTextScaleX = state.fTextScaleX;
}
if (state.fTextFill != currentEntry()->fTextFill) {
SK_COMPILE_ASSERT(SkPaint::kFill_Style == 0, enum_must_match_value);
SK_COMPILE_ASSERT(SkPaint::kStroke_Style == 1,
enum_must_match_value);
SK_COMPILE_ASSERT(SkPaint::kStrokeAndFill_Style == 2,
enum_must_match_value);
static_assert(SkPaint::kFill_Style == 0, "enum_must_match_value");
static_assert(SkPaint::kStroke_Style == 1, "enum_must_match_value");
static_assert(SkPaint::kStrokeAndFill_Style == 2, "enum_must_match_value");
fContentStream->writeDecAsText(state.fTextFill);
fContentStream->writeText(" Tr\n");
currentEntry()->fTextFill = state.fTextFill;

View File

@ -603,8 +603,7 @@ static size_t get_subset_font_stream(const char* fontName,
unsigned char* subsetFont = NULL;
// sfntly requires unsigned int* to be passed in, as far as we know,
// unsigned int is equivalent to uint32_t on all platforms.
SK_COMPILE_ASSERT(sizeof(unsigned int) == sizeof(uint32_t),
unsigned_int_not_32_bits);
static_assert(sizeof(unsigned int) == sizeof(uint32_t), "unsigned_int_not_32_bits");
int subsetFontSize = SfntlyWrapper::SubsetFont(fontName,
originalFont.begin(),
fontSize,

View File

@ -210,17 +210,17 @@ void SkPDFGraphicState::emitObject(
SkPaint::Join strokeJoin = (SkPaint::Join)fStrokeJoin;
SkXfermode::Mode xferMode = (SkXfermode::Mode)fMode;
SK_COMPILE_ASSERT(SkPaint::kButt_Cap == 0, paint_cap_mismatch);
SK_COMPILE_ASSERT(SkPaint::kRound_Cap == 1, paint_cap_mismatch);
SK_COMPILE_ASSERT(SkPaint::kSquare_Cap == 2, paint_cap_mismatch);
SK_COMPILE_ASSERT(SkPaint::kCapCount == 3, paint_cap_mismatch);
static_assert(SkPaint::kButt_Cap == 0, "paint_cap_mismatch");
static_assert(SkPaint::kRound_Cap == 1, "paint_cap_mismatch");
static_assert(SkPaint::kSquare_Cap == 2, "paint_cap_mismatch");
static_assert(SkPaint::kCapCount == 3, "paint_cap_mismatch");
SkASSERT(strokeCap >= 0 && strokeCap <= 2);
dict->insertInt("LC", strokeCap);
SK_COMPILE_ASSERT(SkPaint::kMiter_Join == 0, paint_join_mismatch);
SK_COMPILE_ASSERT(SkPaint::kRound_Join == 1, paint_join_mismatch);
SK_COMPILE_ASSERT(SkPaint::kBevel_Join == 2, paint_join_mismatch);
SK_COMPILE_ASSERT(SkPaint::kJoinCount == 3, paint_join_mismatch);
static_assert(SkPaint::kMiter_Join == 0, "paint_join_mismatch");
static_assert(SkPaint::kRound_Join == 1, "paint_join_mismatch");
static_assert(SkPaint::kBevel_Join == 2, "paint_join_mismatch");
static_assert(SkPaint::kJoinCount == 3, "paint_join_mismatch");
SkASSERT(strokeJoin >= 0 && strokeJoin <= 2);
dict->insertInt("LJ", strokeJoin);

View File

@ -12,14 +12,10 @@
// expected values as defined in the arrays below.
// If these are failing, you may need to update the resource_type_prefixes
// and resource_type_names arrays below.
SK_COMPILE_ASSERT(SkPDFResourceDict::kExtGState_ResourceType == 0,
resource_type_mismatch);
SK_COMPILE_ASSERT(SkPDFResourceDict::kPattern_ResourceType == 1,
resource_type_mismatch);
SK_COMPILE_ASSERT(SkPDFResourceDict::kXObject_ResourceType == 2,
resource_type_mismatch);
SK_COMPILE_ASSERT(SkPDFResourceDict::kFont_ResourceType == 3,
resource_type_mismatch);
static_assert(SkPDFResourceDict::kExtGState_ResourceType == 0, "resource_type_mismatch");
static_assert(SkPDFResourceDict::kPattern_ResourceType == 1, "resource_type_mismatch");
static_assert(SkPDFResourceDict::kXObject_ResourceType == 2, "resource_type_mismatch");
static_assert(SkPDFResourceDict::kFont_ResourceType == 3, "resource_type_mismatch");
static const char resource_type_prefixes[] = {
'G',

View File

@ -158,7 +158,7 @@ private:
SkPDFUnion& operator=(const SkPDFUnion&) = delete;
SkPDFUnion(const SkPDFUnion&) = delete;
};
SK_COMPILE_ASSERT(sizeof(SkString) == sizeof(void*), SkString_size);
static_assert(sizeof(SkString) == sizeof(void*), "SkString_size");
////////////////////////////////////////////////////////////////////////////////

View File

@ -1855,7 +1855,7 @@ ReturnInfo:
//Length of GUID representation from create_id, including NULL terminator.
#define BASE64_GUID_ID_LEN SK_ARRAY_COUNT(BASE64_GUID_ID)
SK_COMPILE_ASSERT(BASE64_GUID_ID_LEN < LF_FACESIZE, GUID_longer_than_facesize);
static_assert(BASE64_GUID_ID_LEN < LF_FACESIZE, "GUID_longer_than_facesize");
/**
NameID 6 Postscript names cannot have the character '/'.

View File

@ -126,7 +126,7 @@ void GetCustomFontFamilies(SkTDArray<FontFamily*>& fontFamilies,
* If the string cannot be parsed into 'value', returns false and does not change 'value'.
*/
template <typename T> static bool parse_non_negative_integer(const char* s, T* value) {
SK_COMPILE_ASSERT(std::numeric_limits<T>::is_integer, T_must_be_integer);
static_assert(std::numeric_limits<T>::is_integer, "T_must_be_integer");
if (*s == '\0') {
return false;
@ -163,9 +163,9 @@ template <typename T> static bool parse_non_negative_integer(const char* s, T* v
* If the string cannot be parsed into 'value', returns false and does not change 'value'.
*/
template <int N, typename T> static bool parse_fixed(const char* s, T* value) {
SK_COMPILE_ASSERT(std::numeric_limits<T>::is_integer, T_must_be_integer);
SK_COMPILE_ASSERT(std::numeric_limits<T>::is_signed, T_must_be_signed);
SK_COMPILE_ASSERT(sizeof(T) * CHAR_BIT - N >= 5, N_must_leave_four_bits_plus_sign);
static_assert(std::numeric_limits<T>::is_integer, "T_must_be_integer");
static_assert(std::numeric_limits<T>::is_signed, "T_must_be_signed");
static_assert(sizeof(T) * CHAR_BIT - N >= 5, "N_must_leave_four_bits_plus_sign");
bool negate = false;
if (*s == '-') {

View File

@ -301,7 +301,7 @@ static int map_ranges(int val, MapRanges const ranges[], int rangesCount) {
}
template<int n> struct SkTFixed {
SK_COMPILE_ASSERT(-32768 <= n && n <= 32767, SkTFixed_n_not_in_range);
static_assert(-32768 <= n && n <= 32767, "SkTFixed_n_not_in_range");
static const SkFixed value = static_cast<SkFixed>(n << 16);
};

View File

@ -102,7 +102,7 @@ struct SkOSFileIterData {
DIR* fDIR;
SkString fPath, fSuffix;
};
SK_COMPILE_ASSERT(sizeof(SkOSFileIterData) <= SkOSFile::Iter::kStorageSize, not_enough_space);
static_assert(sizeof(SkOSFileIterData) <= SkOSFile::Iter::kStorageSize, "not_enough_space");
SkOSFile::Iter::Iter() {
SkNEW_PLACEMENT(fSelf.get(), SkOSFileIterData);

View File

@ -128,7 +128,7 @@ struct SkOSFileIterData {
HANDLE fHandle;
uint16_t* fPath16;
};
SK_COMPILE_ASSERT(sizeof(SkOSFileIterData) <= SkOSFile::Iter::kStorageSize, not_enough_space);
static_assert(sizeof(SkOSFileIterData) <= SkOSFile::Iter::kStorageSize, "not_enough_space");
static uint16_t* concat_to_16(const char src[], const char suffix[]) {
size_t i, len = strlen(src);

View File

@ -169,6 +169,6 @@ struct SkIBMFamilyClass {
#pragma pack(pop)
SK_COMPILE_ASSERT(sizeof(SkIBMFamilyClass) == 2, sizeof_SkIBMFamilyClass_not_2);
static_assert(sizeof(SkIBMFamilyClass) == 2, "sizeof_SkIBMFamilyClass_not_2");
#endif

View File

@ -47,14 +47,14 @@ public:
/** SkOTSetUSHORTBit<N>::value is an SK_OT_USHORT with the Nth BE bit set. */
template <unsigned N> struct SkOTSetUSHORTBit {
SK_COMPILE_ASSERT(N < 16, NTooBig);
static_assert(N < 16, "NTooBig");
static const uint16_t bit = 1u << N;
static const SK_OT_USHORT value = SkTEndian_SwapBE16(bit);
};
/** SkOTSetULONGBit<N>::value is an SK_OT_ULONG with the Nth BE bit set. */
template <unsigned N> struct SkOTSetULONGBit {
SK_COMPILE_ASSERT(N < 32, NTooBig);
static_assert(N < 32, "NTooBig");
static const uint32_t bit = 1u << N;
static const SK_OT_ULONG value = SkTEndian_SwapBE32(bit);
};

View File

@ -42,11 +42,11 @@ struct SkOTTableOS2 {
#pragma pack(pop)
SK_COMPILE_ASSERT(sizeof(SkOTTableOS2::Version::VA) == 68, sizeof_SkOTTableOS2__VA_not_68);
SK_COMPILE_ASSERT(sizeof(SkOTTableOS2::Version::V0) == 78, sizeof_SkOTTableOS2__V0_not_78);
SK_COMPILE_ASSERT(sizeof(SkOTTableOS2::Version::V1) == 86, sizeof_SkOTTableOS2__V1_not_86);
SK_COMPILE_ASSERT(sizeof(SkOTTableOS2::Version::V2) == 96, sizeof_SkOTTableOS2__V2_not_96);
SK_COMPILE_ASSERT(sizeof(SkOTTableOS2::Version::V3) == 96, sizeof_SkOTTableOS2__V3_not_96);
SK_COMPILE_ASSERT(sizeof(SkOTTableOS2::Version::V4) == 96, sizeof_SkOTTableOS2__V4_not_96);
static_assert(sizeof(SkOTTableOS2::Version::VA) == 68, "sizeof_SkOTTableOS2__VA_not_68");
static_assert(sizeof(SkOTTableOS2::Version::V0) == 78, "sizeof_SkOTTableOS2__V0_not_78");
static_assert(sizeof(SkOTTableOS2::Version::V1) == 86, "sizeof_SkOTTableOS2__V1_not_86");
static_assert(sizeof(SkOTTableOS2::Version::V2) == 96, "sizeof_SkOTTableOS2__V2_not_96");
static_assert(sizeof(SkOTTableOS2::Version::V3) == 96, "sizeof_SkOTTableOS2__V3_not_96");
static_assert(sizeof(SkOTTableOS2::Version::V4) == 96, "sizeof_SkOTTableOS2__V4_not_96");
#endif

View File

@ -144,6 +144,6 @@ struct SkOTTableOS2_V0 {
#pragma pack(pop)
SK_COMPILE_ASSERT(sizeof(SkOTTableOS2_V0) == 78, sizeof_SkOTTableOS2_V0_not_78);
static_assert(sizeof(SkOTTableOS2_V0) == 78, "sizeof_SkOTTableOS2_V0_not_78");
#endif

View File

@ -513,6 +513,6 @@ struct SkOTTableOS2_V1 {
#pragma pack(pop)
SK_COMPILE_ASSERT(sizeof(SkOTTableOS2_V1) == 86, sizeof_SkOTTableOS2_V1_not_86);
static_assert(sizeof(SkOTTableOS2_V1) == 86, "sizeof_SkOTTableOS2_V1_not_86");
#endif

View File

@ -535,6 +535,6 @@ struct SkOTTableOS2_V2 {
#pragma pack(pop)
SK_COMPILE_ASSERT(sizeof(SkOTTableOS2_V2) == 96, sizeof_SkOTTableOS2_V2_not_96);
static_assert(sizeof(SkOTTableOS2_V2) == 96, "sizeof_SkOTTableOS2_V2_not_96");
#endif

View File

@ -545,6 +545,6 @@ struct SkOTTableOS2_V3 {
#pragma pack(pop)
SK_COMPILE_ASSERT(sizeof(SkOTTableOS2_V3) == 96, sizeof_SkOTTableOS2_V3_not_96);
static_assert(sizeof(SkOTTableOS2_V3) == 96, "sizeof_SkOTTableOS2_V3_not_96");
#endif

View File

@ -580,6 +580,6 @@ struct SkOTTableOS2_V4 {
#pragma pack(pop)
SK_COMPILE_ASSERT(sizeof(SkOTTableOS2_V4) == 96, sizeof_SkOTTableOS2_V4_not_96);
static_assert(sizeof(SkOTTableOS2_V4) == 96, "sizeof_SkOTTableOS2_V4_not_96");
#endif

View File

@ -137,6 +137,6 @@ struct SkOTTableOS2_VA {
#pragma pack(pop)
SK_COMPILE_ASSERT(sizeof(SkOTTableOS2_VA) == 68, sizeof_SkOTTableOS2_VA_not_68);
static_assert(sizeof(SkOTTableOS2_VA) == 68, "sizeof_SkOTTableOS2_VA_not_68");
#endif

View File

@ -67,7 +67,7 @@ struct SkOTTableGridAndScanProcedure {
#include <stddef.h>
SK_COMPILE_ASSERT(offsetof(SkOTTableGridAndScanProcedure, numRanges) == 2, SkOTTableGridAndScanProcedure_numRanges_not_at_2);
SK_COMPILE_ASSERT(sizeof(SkOTTableGridAndScanProcedure) == 4, sizeof_SkOTTableGridAndScanProcedure_not_4);
static_assert(offsetof(SkOTTableGridAndScanProcedure, numRanges) == 2, "SkOTTableGridAndScanProcedure_numRanges_not_at_2");
static_assert(sizeof(SkOTTableGridAndScanProcedure) == 4, "sizeof_SkOTTableGridAndScanProcedure_not_4");
#endif

View File

@ -144,7 +144,7 @@ struct SkOTTableHead {
#include <stddef.h>
SK_COMPILE_ASSERT(offsetof(SkOTTableHead, glyphDataFormat) == 52, SkOTTableHead_glyphDataFormat_not_at_52);
SK_COMPILE_ASSERT(sizeof(SkOTTableHead) == 54, sizeof_SkOTTableHead_not_54);
static_assert(offsetof(SkOTTableHead, glyphDataFormat) == 52, "SkOTTableHead_glyphDataFormat_not_at_52");
static_assert(sizeof(SkOTTableHead) == 54, "sizeof_SkOTTableHead_not_54");
#endif

View File

@ -50,7 +50,7 @@ struct SkOTTableHorizontalHeader {
#include <stddef.h>
SK_COMPILE_ASSERT(offsetof(SkOTTableHorizontalHeader, numberOfHMetrics) == 34, SkOTTableHorizontalHeader_numberOfHMetrics_not_at_34);
SK_COMPILE_ASSERT(sizeof(SkOTTableHorizontalHeader) == 36, sizeof_SkOTTableHorizontalHeader_not_36);
static_assert(offsetof(SkOTTableHorizontalHeader, numberOfHMetrics) == 34, "SkOTTableHorizontalHeader_numberOfHMetrics_not_at_34");
static_assert(sizeof(SkOTTableHorizontalHeader) == 36, "sizeof_SkOTTableHorizontalHeader_not_36");
#endif

View File

@ -24,7 +24,7 @@ struct SkOTTableMaximumProfile_CFF {
#include <stddef.h>
SK_COMPILE_ASSERT(offsetof(SkOTTableMaximumProfile_CFF, numGlyphs) == 4, SkOTTableMaximumProfile_CFF_numGlyphs_not_at_4);
SK_COMPILE_ASSERT(sizeof(SkOTTableMaximumProfile_CFF) == 6, sizeof_SkOTTableMaximumProfile_CFF_not_6);
static_assert(offsetof(SkOTTableMaximumProfile_CFF, numGlyphs) == 4, "SkOTTableMaximumProfile_CFF_numGlyphs_not_at_4");
static_assert(sizeof(SkOTTableMaximumProfile_CFF) == 6, "sizeof_SkOTTableMaximumProfile_CFF_not_6");
#endif

View File

@ -44,7 +44,7 @@ struct SkOTTableMaximumProfile_TT {
#include <stddef.h>
SK_COMPILE_ASSERT(offsetof(SkOTTableMaximumProfile_TT, maxComponentDepth) == 30, SkOTTableMaximumProfile_TT_maxComponentDepth_not_at_30);
SK_COMPILE_ASSERT(sizeof(SkOTTableMaximumProfile_TT) == 32, sizeof_SkOTTableMaximumProfile_TT_not_32);
static_assert(offsetof(SkOTTableMaximumProfile_TT, maxComponentDepth) == 30, "SkOTTableMaximumProfile_TT_maxComponentDepth_not_at_30");
static_assert(sizeof(SkOTTableMaximumProfile_TT) == 32, "sizeof_SkOTTableMaximumProfile_TT_not_32");
#endif

View File

@ -576,9 +576,9 @@ struct SkOTTableName {
#pragma pack(pop)
SK_COMPILE_ASSERT(sizeof(SkOTTableName) == 6, sizeof_SkOTTableName_not_6);
SK_COMPILE_ASSERT(sizeof(SkOTTableName::Format1Ext) == 2, sizeof_SkOTTableNameF1_not_2);
SK_COMPILE_ASSERT(sizeof(SkOTTableName::Format1Ext::LangTagRecord) == 4, sizeof_SkOTTableNameLangTagRecord_not_4);
SK_COMPILE_ASSERT(sizeof(SkOTTableName::Record) == 12, sizeof_SkOTTableNameRecord_not_12);
static_assert(sizeof(SkOTTableName) == 6, "sizeof_SkOTTableName_not_6");
static_assert(sizeof(SkOTTableName::Format1Ext) == 2, "sizeof_SkOTTableNameF1_not_2");
static_assert(sizeof(SkOTTableName::Format1Ext::LangTagRecord) == 4, "sizeof_SkOTTableNameLangTagRecord_not_4");
static_assert(sizeof(SkOTTableName::Record) == 12, "sizeof_SkOTTableNameRecord_not_12");
#endif

View File

@ -46,7 +46,7 @@ struct SkOTTablePostScript {
#include <stddef.h>
SK_COMPILE_ASSERT(offsetof(SkOTTablePostScript, maxMemType1) == 28, SkOTTablePostScript_maxMemType1_not_at_28);
SK_COMPILE_ASSERT(sizeof(SkOTTablePostScript) == 32, sizeof_SkOTTablePostScript_not_32);
static_assert(offsetof(SkOTTablePostScript, maxMemType1) == 28, "SkOTTablePostScript_maxMemType1_not_at_28");
static_assert(sizeof(SkOTTablePostScript) == 32, "sizeof_SkOTTablePostScript_not_32");
#endif

View File

@ -634,6 +634,6 @@ struct SkPanose {
#pragma pack(pop)
SK_COMPILE_ASSERT(sizeof(SkPanose) == 10, sizeof_SkPanose_not_10);
static_assert(sizeof(SkPanose) == 10, "sizeof_SkPanose_not_10");
#endif

View File

@ -64,7 +64,7 @@ struct SkSFNTHeader {
#pragma pack(pop)
SK_COMPILE_ASSERT(sizeof(SkSFNTHeader) == 12, sizeof_SkSFNTHeader_not_12);
SK_COMPILE_ASSERT(sizeof(SkSFNTHeader::TableDirectoryEntry) == 16, sizeof_SkSFNTHeader_TableDirectoryEntry_not_16);
static_assert(sizeof(SkSFNTHeader) == 12, "sizeof_SkSFNTHeader_not_12");
static_assert(sizeof(SkSFNTHeader::TableDirectoryEntry) == 16, "sizeof_SkSFNTHeader_TableDirectoryEntry_not_16");
#endif

View File

@ -51,6 +51,6 @@ struct SkTTCFHeader {
#pragma pack(pop)
SK_COMPILE_ASSERT(sizeof(SkTTCFHeader) == 12, sizeof_SkTTCFHeader_not_12);
static_assert(sizeof(SkTTCFHeader) == 12, "sizeof_SkTTCFHeader_not_12");
#endif

View File

@ -42,7 +42,7 @@ static const char* cap_map[] = {
"round", // kRound_Cap
"square" // kSquare_Cap
};
SK_COMPILE_ASSERT(SK_ARRAY_COUNT(cap_map) == SkPaint::kCapCount, missing_cap_map_entry);
static_assert(SK_ARRAY_COUNT(cap_map) == SkPaint::kCapCount, "missing_cap_map_entry");
static const char* svg_cap(SkPaint::Cap cap) {
SkASSERT(cap < SK_ARRAY_COUNT(cap_map));
@ -55,7 +55,7 @@ static const char* join_map[] = {
"round", // kRound_Join
"bevel" // kBevel_Join
};
SK_COMPILE_ASSERT(SK_ARRAY_COUNT(join_map) == SkPaint::kJoinCount, missing_join_map_entry);
static_assert(SK_ARRAY_COUNT(join_map) == SkPaint::kJoinCount, "missing_join_map_entry");
static const char* svg_join(SkPaint::Join join) {
SkASSERT(join < SK_ARRAY_COUNT(join_map));
@ -68,8 +68,8 @@ static const char* text_align_map[] = {
"middle", // kCenter_Align
"end" // kRight_Align
};
SK_COMPILE_ASSERT(SK_ARRAY_COUNT(text_align_map) == SkPaint::kAlignCount,
missing_text_align_map_entry);
static_assert(SK_ARRAY_COUNT(text_align_map) == SkPaint::kAlignCount,
"missing_text_align_map_entry");
static const char* svg_text_align(SkPaint::Align align) {
SkASSERT(align < SK_ARRAY_COUNT(text_align_map));
return text_align_map[align];

View File

@ -39,7 +39,7 @@ template <typename D, typename S> struct SkTOutOfRange_LT_MinD {
typedef S source_type;
static bool apply(S s) {
typedef typename SkTHasMoreDigits<S, D>::type precondition;
SK_COMPILE_ASSERT(precondition::value, SkTOutOfRange_LT_MinD__minS_gt_minD);
static_assert(precondition::value, "SkTOutOfRange_LT_MinD__minS_gt_minD");
return s < static_cast<S>((std::numeric_limits<D>::min)());
}
@ -62,7 +62,7 @@ template <typename D, typename S> struct SkTOutOfRange_GT_MaxD {
typedef S source_type;
static bool apply(S s) {
typedef typename SkTHasMoreDigits<S, D>::type precondition;
SK_COMPILE_ASSERT(precondition::value, SkTOutOfRange_GT_MaxD__maxS_lt_maxD);
static_assert(precondition::value, "SkTOutOfRange_GT_MaxD__maxS_lt_maxD");
return s > static_cast<S>((std::numeric_limits<D>::max)());
}
@ -200,8 +200,8 @@ template<typename D, typename S> struct SkTFitsIn {
/** Returns true if the integer source value 's' will fit in the integer destination type 'D'. */
template <typename D, typename S> inline bool SkTFitsIn(S s) {
SK_COMPILE_ASSERT(std::numeric_limits<S>::is_integer, SkTFitsIn_source_must_be_integer);
SK_COMPILE_ASSERT(std::numeric_limits<D>::is_integer, SkTFitsIn_destination_must_be_integer);
static_assert(std::numeric_limits<S>::is_integer, "SkTFitsIn_source_must_be_integer");
static_assert(std::numeric_limits<D>::is_integer, "SkTFitsIn_destination_must_be_integer");
return !sktfitsin::Private::SkTFitsIn<D, S>::type::OutOfRange(s);
}

View File

@ -10,7 +10,7 @@
#include "SkSurface.h"
#include "SkCGUtils.h"
#include "SkEvent.h"
SK_COMPILE_ASSERT(SK_SUPPORT_GPU, not_implemented_for_non_gpu_build);
static_assert(SK_SUPPORT_GPU, "not_implemented_for_non_gpu_build");
#include <OpenGL/gl.h>
//#define FORCE_REDRAW

View File

@ -16,7 +16,7 @@
#import "SkEventNotifier.h"
#define kINVAL_NSVIEW_EventType "inval-nsview"
SK_COMPILE_ASSERT(SK_SUPPORT_GPU, not_implemented_for_non_gpu_build);
static_assert(SK_SUPPORT_GPU, "not_implemented_for_non_gpu_build");
SkOSWindow::SkOSWindow(void* hWnd) : fHWND(hWnd) {
fInvalEventIsPending = false;

View File

@ -358,8 +358,8 @@ static const SkColor kExpectedPixels[] = {
0xffb07222, 0xff2e23f8, 0xfff089d9, 0xffb35738,
0xffa86022, 0xff3340fe, 0xff95fe71, 0xff6a71df
};
SK_COMPILE_ASSERT((kExpectedWidth * kExpectedHeight)
== SK_ARRAY_COUNT(kExpectedPixels), array_size_mismatch);
static_assert((kExpectedWidth * kExpectedHeight) == SK_ARRAY_COUNT(kExpectedPixels),
"array_size_mismatch");
DEF_TEST(WebP, reporter) {
const unsigned char encodedWebP[] = {

View File

@ -71,11 +71,12 @@ public:
kMaskFilter_DrawFilterFlag = 0x80000, // toggles on/off mask filters (e.g., blurs)
};
SK_COMPILE_ASSERT(!(kMaskFilter_DrawFilterFlag & SkPaint::kAllFlags), maskfilter_flag_must_be_greater);
SK_COMPILE_ASSERT(!(kHinting_DrawFilterFlag & SkPaint::kAllFlags),
hinting_flag_must_be_greater);
SK_COMPILE_ASSERT(!(kSlightHinting_DrawFilterFlag & SkPaint::kAllFlags),
slight_hinting_flag_must_be_greater);
static_assert(!(kMaskFilter_DrawFilterFlag & SkPaint::kAllFlags),
"maskfilter_flag_must_be_greater");
static_assert(!(kHinting_DrawFilterFlag & SkPaint::kAllFlags),
"hinting_flag_must_be_greater");
static_assert(!(kSlightHinting_DrawFilterFlag & SkPaint::kAllFlags),
"slight_hinting_flag_must_be_greater");
/**
* Called with each new SkPicture to render.