Reland "Replace SK_ARRAY_COUNT with std::size() all the rest"

This is a reland of commit f838f6f62f

Original change's description:
> Replace SK_ARRAY_COUNT with std::size() all the rest
>
> Added changes to IWYU_mapping.imp to allow std::size. This
> requires multiple entries because std::size can be defined from
> any number of files. Please see the following for reference:
> https://en.cppreference.com/w/cpp/iterator/size
>
> Please check that I got all the includes from the documented list.
>
> Change-Id: I8346834ea7f37128f2dc50f238af0665a1fcfd8d
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/550696
> Reviewed-by: John Stiles <johnstiles@google.com>
> Reviewed-by: Kevin Lubick <kjlubick@google.com>
> Commit-Queue: Herb Derby <herb@google.com>

Change-Id: I4c50340ac2a970de479da57d7d1b55bbf267b617
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/555004
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
This commit is contained in:
Herb Derby 2022-06-16 14:50:33 -04:00 committed by SkCQ
parent b8c26f8bfe
commit afe25662ee
44 changed files with 130 additions and 112 deletions

View File

@ -371,7 +371,7 @@ static void find_culprit() {
#if !defined(SK_BUILD_FOR_ANDROID)
void* stack[128];
int count = backtrace(stack, SK_ARRAY_COUNT(stack));
int count = backtrace(stack, std::size(stack));
char** symbols = backtrace_symbols(stack, count);
info("\nStack trace:\n");
for (int i = 0; i < count; i++) {

View File

@ -1261,7 +1261,7 @@ Result SkottieSrc::draw(GrDirectContext*, SkCanvas* canvas) const {
// frame progression. The film strip will still be in order left-to-right,
// top-down, just not drawn in that order.
static constexpr int frameOrder[] = { 4, 0, 3, 1, 2 };
static_assert(SK_ARRAY_COUNT(frameOrder) == kTileCount, "");
static_assert(std::size(frameOrder) == kTileCount, "");
for (int i = 0; i < kTileCount; ++i) {
const SkScalar y = frameOrder[i] * kTileSize;

View File

@ -110,7 +110,7 @@ static sk_sp<SkColorFilter> make_fuzz_colorfilter(Fuzz* fuzz, int depth) {
}
case 3: {
float array[20];
fuzz->nextN(array, SK_ARRAY_COUNT(array));
fuzz->nextN(array, std::size(array));
return SkColorFilters::Matrix(array);
}
case 4: {
@ -132,7 +132,7 @@ static sk_sp<SkColorFilter> make_fuzz_colorfilter(Fuzz* fuzz, int depth) {
return SkLumaColorFilter::Make();
case 7: {
uint8_t table[256];
fuzz->nextN(table, SK_ARRAY_COUNT(table));
fuzz->nextN(table, std::size(table));
return SkTableColorFilter::Make(table);
}
case 8: {
@ -140,10 +140,10 @@ static sk_sp<SkColorFilter> make_fuzz_colorfilter(Fuzz* fuzz, int depth) {
uint8_t tableR[256];
uint8_t tableG[256];
uint8_t tableB[256];
fuzz->nextN(tableA, SK_ARRAY_COUNT(tableA));
fuzz->nextN(tableR, SK_ARRAY_COUNT(tableR));
fuzz->nextN(tableG, SK_ARRAY_COUNT(tableG));
fuzz->nextN(tableB, SK_ARRAY_COUNT(tableB));
fuzz->nextN(tableA, std::size(tableA));
fuzz->nextN(tableR, std::size(tableR));
fuzz->nextN(tableG, std::size(tableG));
fuzz->nextN(tableB, std::size(tableB));
return SkTableColorFilter::MakeARGB(tableA, tableR, tableG, tableB);
}
default:
@ -395,7 +395,7 @@ static sk_sp<SkPathEffect> make_fuzz_patheffect(Fuzz* fuzz, int depth) {
fuzz->next(&phase);
SkScalar intervals[20];
int count;
fuzz->nextRange(&count, 0, (int)SK_ARRAY_COUNT(intervals));
fuzz->nextRange(&count, 0, (int)std::size(intervals));
fuzz->nextN(intervals, count);
return SkDashPathEffect::Make(intervals, count, phase);
}
@ -900,7 +900,7 @@ static SkTDArray<uint8_t> make_fuzz_text(Fuzz* fuzz, const SkFont& font, SkTextE
{0x0400, 0x0500},
};
int32_t count = 0;
for (size_t i = 0; i < SK_ARRAY_COUNT(ranges); ++i) {
for (size_t i = 0; i < std::size(ranges); ++i) {
count += (ranges[i][1] - ranges[i][0]);
}
constexpr int kMaxLength = kMaxGlyphCount;
@ -910,7 +910,7 @@ static SkTDArray<uint8_t> make_fuzz_text(Fuzz* fuzz, const SkFont& font, SkTextE
for (int j = 0; j < length; ++j) {
int32_t value;
fuzz->nextRange(&value, 0, count - 1);
for (size_t i = 0; i < SK_ARRAY_COUNT(ranges); ++i) {
for (size_t i = 0; i < std::size(ranges); ++i) {
if (value + ranges[i][0] < ranges[i][1]) {
buffer[j] = value + ranges[i][0];
break;

View File

@ -46,7 +46,7 @@ static void add_white(Fuzz* fuzz, SkString* atom) {
fuzz->nextRange(&reps, 0, 2);
for (uint8_t rep = 0; rep < reps; ++rep) {
uint8_t index;
fuzz->nextRange(&index, 0, (int) SK_ARRAY_COUNT(gWhiteSpace) - 1);
fuzz->nextRange(&index, 0, (int) std::size(gWhiteSpace) - 1);
if (gWhiteSpace[index]) {
atom->append(&gWhiteSpace[index], 1);
}
@ -76,7 +76,7 @@ static void add_comma(Fuzz* fuzz, SkString* atom) {
SkString MakeRandomParsePathPiece(Fuzz* fuzz) {
SkString atom;
uint8_t legalIndex;
fuzz->nextRange(&legalIndex, 0, (int) SK_ARRAY_COUNT(gLegal) - 1);
fuzz->nextRange(&legalIndex, 0, (int) std::size(gLegal) - 1);
const Legal& legal = gLegal[legalIndex];
gEasy ? atom.append("\n") : add_white(fuzz, &atom);
bool b;

View File

@ -6,7 +6,7 @@
*/
static bool find_sk(CType from, SKType* to) {
for (size_t i = 0; i < SK_ARRAY_COUNT(CTypeSkTypeMap); ++i) {
for (size_t i = 0; i < std::size(CTypeSkTypeMap); ++i) {
if (CTypeSkTypeMap[i].fC == from) {
if (to) {
*to = CTypeSkTypeMap[i].fSK;
@ -18,7 +18,7 @@ static bool find_sk(CType from, SKType* to) {
}
static bool find_c(SKType from, CType* to) {
for (size_t i = 0; i < SK_ARRAY_COUNT(CTypeSkTypeMap); ++i) {
for (size_t i = 0; i < std::size(CTypeSkTypeMap); ++i) {
if (CTypeSkTypeMap[i].fSK == from) {
if (to) {
*to = CTypeSkTypeMap[i].fC;

View File

@ -27,7 +27,7 @@ const struct {
};
static bool from_c_tilemode(sk_shader_tilemode_t cMode, SkTileMode* skMode) {
for (size_t i = 0; i < SK_ARRAY_COUNT(gTileModeMap); ++i) {
for (size_t i = 0; i < std::size(gTileModeMap); ++i) {
if (cMode == gTileModeMap[i].fC) {
if (skMode) {
*skMode = gTileModeMap[i].fSK;
@ -158,7 +158,7 @@ const struct {
};
static bool find_blurstyle(sk_blurstyle_t csrc, SkBlurStyle* dst) {
for (size_t i = 0; i < SK_ARRAY_COUNT(gBlurStylePairs); ++i) {
for (size_t i = 0; i < std::size(gBlurStylePairs); ++i) {
if (gBlurStylePairs[i].fC == csrc) {
if (dst) {
*dst = gBlurStylePairs[i].fSk;

View File

@ -11,6 +11,8 @@
#include "include/c/sk_colorspace.h"
#include "include/c/sk_imageinfo.h"
#include <array> // for std::size
const struct {
sk_colortype_t fC;
SkColorType fSK;
@ -34,7 +36,7 @@ const struct {
};
static bool from_c_colortype(sk_colortype_t cCT, SkColorType* skCT) {
for (size_t i = 0; i < SK_ARRAY_COUNT(gColorTypeMap); ++i) {
for (size_t i = 0; i < std::size(gColorTypeMap); ++i) {
if (gColorTypeMap[i].fC == cCT) {
if (skCT) {
*skCT = gColorTypeMap[i].fSK;
@ -46,7 +48,7 @@ static bool from_c_colortype(sk_colortype_t cCT, SkColorType* skCT) {
}
static bool to_c_colortype(SkColorType skCT, sk_colortype_t* cCT) {
for (size_t i = 0; i < SK_ARRAY_COUNT(gColorTypeMap); ++i) {
for (size_t i = 0; i < std::size(gColorTypeMap); ++i) {
if (gColorTypeMap[i].fSK == skCT) {
if (cCT) {
*cCT = gColorTypeMap[i].fC;
@ -58,7 +60,7 @@ static bool to_c_colortype(SkColorType skCT, sk_colortype_t* cCT) {
}
static bool from_c_alphatype(sk_alphatype_t cAT, SkAlphaType* skAT) {
for (size_t i = 0; i < SK_ARRAY_COUNT(gAlphaTypeMap); ++i) {
for (size_t i = 0; i < std::size(gAlphaTypeMap); ++i) {
if (gAlphaTypeMap[i].fC == cAT) {
if (skAT) {
*skAT = gAlphaTypeMap[i].fSK;
@ -70,7 +72,7 @@ static bool from_c_alphatype(sk_alphatype_t cAT, SkAlphaType* skAT) {
}
static bool to_c_alphatype(SkAlphaType skAT, sk_alphatype_t* cAT) {
for (size_t i = 0; i < SK_ARRAY_COUNT(gAlphaTypeMap); ++i) {
for (size_t i = 0; i < std::size(gAlphaTypeMap); ++i) {
if (gAlphaTypeMap[i].fSK == skAT) {
if (cAT) {
*cAT = gAlphaTypeMap[i].fC;

View File

@ -37,7 +37,7 @@ const struct {
static bool from_c_pixelgeometry(sk_pixelgeometry_t cGeom, SkPixelGeometry* skGeom) {
for (size_t i = 0; i < SK_ARRAY_COUNT(gPixelGeometryMap); ++i) {
for (size_t i = 0; i < std::size(gPixelGeometryMap); ++i) {
if (gPixelGeometryMap[i].fC == cGeom) {
if (skGeom) {
*skGeom = gPixelGeometryMap[i].fSK;
@ -63,7 +63,7 @@ const struct {
};
static bool from_c_path_direction(sk_path_direction_t cdir, SkPathDirection* dir) {
for (size_t i = 0; i < SK_ARRAY_COUNT(gPathDirMap); ++i) {
for (size_t i = 0; i < std::size(gPathDirMap); ++i) {
if (gPathDirMap[i].fC == cdir) {
if (dir) {
*dir = gPathDirMap[i].fSk;

View File

@ -1785,7 +1785,7 @@ void LightingEffect::ImplBase::emitCode(EmitArgs& args) {
SkString sobelFuncName = fragBuilder->getMangledFunctionName("sobel");
fragBuilder->emitFunction(SkSLType::kHalf,
sobelFuncName.c_str(),
{gSobelArgs, SK_ARRAY_COUNT(gSobelArgs)},
{gSobelArgs, std::size(gSobelArgs)},
"return (-a + b - 2.0 * c + 2.0 * d -e + f) * scale;");
const GrShaderVar gPointToNormalArgs[] = {
GrShaderVar("x", SkSLType::kHalf),
@ -1795,7 +1795,7 @@ void LightingEffect::ImplBase::emitCode(EmitArgs& args) {
SkString pointToNormalName = fragBuilder->getMangledFunctionName("pointToNormal");
fragBuilder->emitFunction(SkSLType::kHalf3,
pointToNormalName.c_str(),
{gPointToNormalArgs, SK_ARRAY_COUNT(gPointToNormalArgs)},
{gPointToNormalArgs, std::size(gPointToNormalArgs)},
"return normalize(half3(-x * scale, -y * scale, 1));");
const GrShaderVar gInteriorNormalArgs[] = {
@ -1808,7 +1808,7 @@ void LightingEffect::ImplBase::emitCode(EmitArgs& args) {
SkString normalName = fragBuilder->getMangledFunctionName("normal");
fragBuilder->emitFunction(SkSLType::kHalf3,
normalName.c_str(),
{gInteriorNormalArgs, SK_ARRAY_COUNT(gInteriorNormalArgs)},
{gInteriorNormalArgs, std::size(gInteriorNormalArgs)},
normalBody.c_str());
fragBuilder->codeAppendf("float2 coord = %s;", args.fSampleCoord);
@ -1872,7 +1872,7 @@ void DiffuseLightingEffect::Impl::emitLightFunc(const GrFragmentProcessor* owner
*funcName = fragBuilder->getMangledFunctionName("light");
fragBuilder->emitFunction(SkSLType::kHalf4,
funcName->c_str(),
{gLightArgs, SK_ARRAY_COUNT(gLightArgs)},
{gLightArgs, std::size(gLightArgs)},
lightBody.c_str());
}
@ -1979,7 +1979,7 @@ void SpecularLightingEffect::Impl::emitLightFunc(const GrFragmentProcessor* owne
*funcName = fragBuilder->getMangledFunctionName("light");
fragBuilder->emitFunction(SkSLType::kHalf4,
funcName->c_str(),
{gLightArgs, SK_ARRAY_COUNT(gLightArgs)},
{gLightArgs, std::size(gLightArgs)},
lightBody.c_str());
}
@ -2119,7 +2119,7 @@ void GpuSpotLight::emitLightColor(const GrFragmentProcessor* owner,
fLightColorFunc = fragBuilder->getMangledFunctionName("lightColor");
fragBuilder->emitFunction(SkSLType::kHalf3,
fLightColorFunc.c_str(),
{gLightColorArgs, SK_ARRAY_COUNT(gLightColorArgs)},
{gLightColorArgs, std::size(gLightColorArgs)},
lightColorBody.c_str());
fragBuilder->codeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight);

View File

@ -77,7 +77,7 @@ private:
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
inline static constexpr int kMaxKernelWidth = kMaxKernelRadius + 1;
inline static const constexpr int kMaxKernelWidth = kMaxKernelRadius + 1;
SkV2 fOffsetsAndKernel[kMaxKernelWidth];
int fRadius;

View File

@ -74,7 +74,7 @@ namespace SkVMInterpreterTypes {
Slot* r = few_regs;
if (nregs > (int)SK_ARRAY_COUNT(few_regs)) {
if (nregs > (int)std::size(few_regs)) {
// Annoyingly we can't trust that malloc() or new will work with Slot because
// the skvx::Vec types may have alignment greater than what they provide.
// We'll overallocate one extra register so we can align manually.
@ -272,7 +272,7 @@ namespace SkVMInterpreterTypes {
16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63 };
static_assert(K <= SK_ARRAY_COUNT(iota), "");
static_assert(K <= std::size(iota), "");
r[d].i32 = n - I32::Load(iota);
} break;

View File

@ -100,7 +100,7 @@ int SkIntersections::insert(double one, double two, const SkDPoint& pt) {
fT[0][index] = one;
fT[1][index] = two;
++fUsed;
SkASSERT(fUsed <= SK_ARRAY_COUNT(fPt));
SkASSERT(fUsed <= std::size(fPt));
return index;
}

View File

@ -200,7 +200,7 @@ public:
}
void setMax(int max) {
SkASSERT(max <= (int) SK_ARRAY_COUNT(fPt));
SkASSERT(max <= (int) std::size(fPt));
fMax = max;
}

View File

@ -208,10 +208,10 @@ bool SkOpEdgeBuilder::walk() {
if (SkChopQuadAtMaxCurvature(pointsPtr, pair) == 1) {
goto addOneQuad;
}
if (!SkScalarsAreFinite(&pair[0].fX, SK_ARRAY_COUNT(pair) * 2)) {
if (!SkScalarsAreFinite(&pair[0].fX, std::size(pair) * 2)) {
return false;
}
for (unsigned index = 0; index < SK_ARRAY_COUNT(pair); ++index) {
for (unsigned index = 0; index < std::size(pair); ++index) {
pair[index] = force_small_to_zero(pair[index]);
}
SkPoint cStorage[2][2];
@ -269,7 +269,7 @@ bool SkOpEdgeBuilder::walk() {
fContourBuilder.addCubic(pointsPtr);
break;
}
SkASSERT(breaks <= (int) SK_ARRAY_COUNT(splitT));
SkASSERT(breaks <= (int) std::size(splitT));
struct Splitsville {
double fT[2];
SkPoint fPts[4];
@ -277,7 +277,7 @@ bool SkOpEdgeBuilder::walk() {
SkPath::Verb fVerb;
bool fCanAdd;
} splits[4];
SkASSERT(SK_ARRAY_COUNT(splits) == SK_ARRAY_COUNT(splitT) + 1);
SkASSERT(std::size(splits) == std::size(splitT) + 1);
SkTQSort(splitT, splitT + breaks);
for (int index = 0; index <= breaks; ++index) {
Splitsville* split = &splits[index];
@ -306,7 +306,7 @@ bool SkOpEdgeBuilder::walk() {
split->fPts[0] = splits[prior].fPts[0];
}
int next = index;
int breakLimit = std::min(breaks, (int) SK_ARRAY_COUNT(splits) - 1);
int breakLimit = std::min(breaks, (int) std::size(splits) - 1);
while (next < breakLimit && !splits[next + 1].fCanAdd) {
++next;
}

View File

@ -564,7 +564,7 @@ void SkOpGlobalState::debugAddToGlobalCoinDicts() {
#if DEBUG_T_SECT_LOOP_COUNT
void SkOpGlobalState::debugAddLoopCount(SkIntersections* i, const SkIntersectionHelper& wt,
const SkIntersectionHelper& wn) {
for (int index = 0; index < (int) SK_ARRAY_COUNT(fDebugLoopCount); ++index) {
for (int index = 0; index < (int) std::size(fDebugLoopCount); ++index) {
SkIntersections::DebugLoop looper = (SkIntersections::DebugLoop) index;
if (fDebugLoopCount[index] >= i->debugLoopCount(looper)) {
continue;
@ -584,7 +584,7 @@ void SkOpGlobalState::debugAddLoopCount(SkIntersections* i, const SkIntersection
}
void SkOpGlobalState::debugDoYourWorst(SkOpGlobalState* local) {
for (int index = 0; index < (int) SK_ARRAY_COUNT(fDebugLoopCount); ++index) {
for (int index = 0; index < (int) std::size(fDebugLoopCount); ++index) {
if (fDebugLoopCount[index] >= local->fDebugLoopCount[index]) {
continue;
}
@ -627,7 +627,7 @@ static void dump_curve(SkPath::Verb verb, const SkPoint& pts, float weight) {
void SkOpGlobalState::debugLoopReport() {
const char* loops[] = { "iterations", "coinChecks", "perpCalcs" };
SkDebugf("\n");
for (int index = 0; index < (int) SK_ARRAY_COUNT(fDebugLoopCount); ++index) {
for (int index = 0; index < (int) std::size(fDebugLoopCount); ++index) {
SkDebugf("%s: %d\n", loops[index], fDebugLoopCount[index]);
dump_curve(fDebugWorstVerb[index * 2], fDebugWorstPts[index * 2 * 4],
fDebugWorstWeight[index * 2]);

View File

@ -1084,7 +1084,7 @@ int SkTSect::linesIntersect(SkTSpan* span,
if (thisRayI.used() > 1) {
int ptMatches = 0;
for (int tIndex = 0; tIndex < thisRayI.used(); ++tIndex) {
for (int lIndex = 0; lIndex < (int) SK_ARRAY_COUNT(thisLine.fPts); ++lIndex) {
for (int lIndex = 0; lIndex < (int) std::size(thisLine.fPts); ++lIndex) {
ptMatches += thisRayI.pt(tIndex).approximatelyEqual(thisLine.fPts[lIndex]);
}
}
@ -1095,7 +1095,7 @@ int SkTSect::linesIntersect(SkTSpan* span,
if (oppRayI.used() > 1) {
int ptMatches = 0;
for (int oIndex = 0; oIndex < oppRayI.used(); ++oIndex) {
for (int lIndex = 0; lIndex < (int) SK_ARRAY_COUNT(oppLine.fPts); ++lIndex) {
for (int lIndex = 0; lIndex < (int) std::size(oppLine.fPts); ++lIndex) {
ptMatches += oppRayI.pt(oIndex).approximatelyEqual(oppLine.fPts[lIndex]);
}
}

View File

@ -114,7 +114,7 @@ static void do_deflated_alpha(const SkPixmap& pm, SkPDFDocument* doc, SkPDFIndir
const uint32_t* stop = ptr + pm.height() * pm.width();
uint8_t byteBuffer[4092];
uint8_t* bufferStop = byteBuffer + SK_ARRAY_COUNT(byteBuffer);
uint8_t* bufferStop = byteBuffer + std::size(byteBuffer);
uint8_t* dst = byteBuffer;
while (ptr != stop) {
*dst++ = 0xFF & ((*ptr++) >> SK_BGRA_A32_SHIFT);
@ -162,8 +162,8 @@ static void do_deflated_image(const SkPixmap& pm,
SkASSERT(pm.colorType() == kBGRA_8888_SkColorType);
SkASSERT(pm.rowBytes() == (size_t)pm.width() * 4);
uint8_t byteBuffer[3072];
static_assert(SK_ARRAY_COUNT(byteBuffer) % 3 == 0, "");
uint8_t* bufferStop = byteBuffer + SK_ARRAY_COUNT(byteBuffer);
static_assert(std::size(byteBuffer) % 3 == 0, "");
uint8_t* bufferStop = byteBuffer + std::size(byteBuffer);
uint8_t* dst = byteBuffer;
for (int y = 0; y < pm.height(); ++y) {
const SkColor* src = pm.addr32(0, y);

View File

@ -29,7 +29,7 @@ static char* get_resource_name(char dst[kMaxResourceNameLength], SkPDFResourceTy
'X', // kXObject
'F' // kFont
};
SkASSERT((unsigned)type < SK_ARRAY_COUNT(kResourceTypePrefixes));
SkASSERT((unsigned)type < std::size(kResourceTypePrefixes));
dst[0] = kResourceTypePrefixes[(unsigned)type];
return SkStrAppendS32(dst + 1, key);
}
@ -49,7 +49,7 @@ static const char* resource_name(SkPDFResourceType type) {
"XObject",
"Font"
};
SkASSERT((unsigned)type < SK_ARRAY_COUNT(kResourceTypeNames));
SkASSERT((unsigned)type < std::size(kResourceTypeNames));
return kResourceTypeNames[(unsigned)type];
}
@ -74,7 +74,7 @@ static void add_subdict(const std::vector<SkPDFIndirectReference>& resourceList,
static std::unique_ptr<SkPDFArray> make_proc_set() {
auto procSets = SkPDFMakeArray();
static const char kProcs[][7] = { "PDF", "Text", "ImageB", "ImageC", "ImageI"};
procSets->reserve(SK_ARRAY_COUNT(kProcs));
procSets->reserve(std::size(kProcs));
for (const char* proc : kProcs) {
procSets->appendName(proc);
}

View File

@ -411,7 +411,7 @@ static SkFontStyle skfontstyle_from_fcpattern(FcPattern* pattern) {
{ FC_WEIGHT_EXTRABLACK, SkFS::kExtraBlack_Weight },
};
SkScalar weight = map_ranges(get_int(pattern, FC_WEIGHT, FC_WEIGHT_REGULAR),
weightRanges, SK_ARRAY_COUNT(weightRanges));
weightRanges, std::size(weightRanges));
static constexpr MapRanges widthRanges[] = {
{ FC_WIDTH_ULTRACONDENSED, SkFS::kUltraCondensed_Width },
@ -425,7 +425,7 @@ static SkFontStyle skfontstyle_from_fcpattern(FcPattern* pattern) {
{ FC_WIDTH_ULTRAEXPANDED, SkFS::kUltraExpanded_Width },
};
SkScalar width = map_ranges(get_int(pattern, FC_WIDTH, FC_WIDTH_NORMAL),
widthRanges, SK_ARRAY_COUNT(widthRanges));
widthRanges, std::size(widthRanges));
SkFS::Slant slant = SkFS::kUpright_Slant;
switch (get_int(pattern, FC_SLANT, FC_SLANT_ROMAN)) {
@ -455,7 +455,7 @@ static void fcpattern_from_skfontstyle(SkFontStyle style, FcPattern* pattern) {
{ SkFS::kBlack_Weight, FC_WEIGHT_BLACK },
{ SkFS::kExtraBlack_Weight, FC_WEIGHT_EXTRABLACK },
};
int weight = map_ranges(style.weight(), weightRanges, SK_ARRAY_COUNT(weightRanges));
int weight = map_ranges(style.weight(), weightRanges, std::size(weightRanges));
static constexpr MapRanges widthRanges[] = {
{ SkFS::kUltraCondensed_Width, FC_WIDTH_ULTRACONDENSED },
@ -468,7 +468,7 @@ static void fcpattern_from_skfontstyle(SkFontStyle style, FcPattern* pattern) {
{ SkFS::kExtraExpanded_Width, FC_WIDTH_EXTRAEXPANDED },
{ SkFS::kUltraExpanded_Width, FC_WIDTH_ULTRAEXPANDED },
};
int width = map_ranges(style.width(), widthRanges, SK_ARRAY_COUNT(widthRanges));
int width = map_ranges(style.width(), widthRanges, std::size(widthRanges));
int slant = FC_SLANT_ROMAN;
switch (style.slant()) {

View File

@ -2151,7 +2151,7 @@ bool SkTypeface_FreeType::Scanner::scanFont(
{ "ultraheavy", SkFontStyle::kExtraBlack_Weight },
{ "ultralight", SkFontStyle::kExtraLight_Weight },
};
int const index = SkStrLCSearch(&commonWeights[0].name, SK_ARRAY_COUNT(commonWeights),
int const index = SkStrLCSearch(&commonWeights[0].name, std::size(commonWeights),
psFontInfo.weight, sizeof(commonWeights[0]));
if (index >= 0) {
weight = commonWeights[index].weight;

View File

@ -1718,7 +1718,7 @@ std::unique_ptr<SkAdvancedTypefaceMetrics> LogFontTypeface::onGetAdvancedMetrics
// This probably isn't very good with an italic font.
min_width = SHRT_MAX;
info->fStemV = 0;
for (size_t i = 0; i < SK_ARRAY_COUNT(stem_chars); i++) {
for (size_t i = 0; i < std::size(stem_chars); i++) {
ABC abcWidths;
if (GetCharABCWidths(hdc, stem_chars[i], stem_chars[i], &abcWidths)) {
int16_t width = abcWidths.abcB;
@ -1735,7 +1735,7 @@ std::unique_ptr<SkAdvancedTypefaceMetrics> LogFontTypeface::onGetAdvancedMetrics
//Placeholder representation of a Base64 encoded GUID from create_unique_font_name.
#define BASE64_GUID_ID "XXXXXXXXXXXXXXXXXXXXXXXX"
//Length of GUID representation from create_id, including nullptr terminator.
#define BASE64_GUID_ID_LEN SK_ARRAY_COUNT(BASE64_GUID_ID)
#define BASE64_GUID_ID_LEN std::size(BASE64_GUID_ID)
static_assert(BASE64_GUID_ID_LEN < LF_FACESIZE, "GUID_longer_than_facesize");
@ -1805,7 +1805,7 @@ static sk_sp<SkTypeface> create_from_stream(std::unique_ptr<SkStreamAsset> strea
// Create a unique and unpredictable font name.
// Avoids collisions and access from CSS.
char familyName[BASE64_GUID_ID_LEN];
const int familyNameSize = SK_ARRAY_COUNT(familyName);
const int familyNameSize = std::size(familyName);
if (FAILED(create_unique_font_name(familyName, familyNameSize))) {
return nullptr;
}
@ -1839,7 +1839,7 @@ std::unique_ptr<SkStreamAsset> LogFontTypeface::onOpenStream(int* ttcIndex) cons
std::unique_ptr<SkStreamAsset> stream;
DWORD tables[2] = {kTTCTag, 0};
for (size_t i = 0; i < SK_ARRAY_COUNT(tables); i++) {
for (size_t i = 0; i < std::size(tables); i++) {
DWORD bufferSize = GetFontData(hdc, tables[i], 0, nullptr, 0);
if (bufferSize == GDI_ERROR) {
call_ensure_accessible(lf);

View File

@ -562,7 +562,7 @@ static char const * const gSystemFontUseStrings[] = {
sk_sp<SkFontMgr> SkFontMgr_New_Android(const SkFontMgr_Android_CustomFonts* custom) {
if (custom) {
SkASSERT(0 <= custom->fSystemFontUse);
SkASSERT(custom->fSystemFontUse < SK_ARRAY_COUNT(gSystemFontUseStrings));
SkASSERT(custom->fSystemFontUse < std::size(gSystemFontUseStrings));
SkDEBUGF("SystemFontUse: %s BasePath: %s Fonts: %s FallbackFonts: %s\n",
gSystemFontUseStrings[custom->fSystemFontUse],
custom->fBasePath,

View File

@ -169,7 +169,7 @@ SkFontMgr_Custom::SkFontMgr_Custom(const SystemFontLoader& loader) : fDefaultFam
static const char* defaultNames[] = {
"Arial", "Verdana", "Times New Roman", "Droid Sans", nullptr
};
for (size_t i = 0; i < SK_ARRAY_COUNT(defaultNames); ++i) {
for (size_t i = 0; i < std::size(defaultNames); ++i) {
sk_sp<SkFontStyleSet_Custom> set(this->onMatchFamily(defaultNames[i]));
if (nullptr == set) {
continue;

View File

@ -220,7 +220,7 @@ static SkWeakReturn is_weak(FcPattern* pattern, const char object[], int id) {
// However, there appears to be no way to match/sort without it.
SkAutoFcConfig config;
FcFontSet* fontSets[1] = { fontSet };
SkAutoFcPattern match(FcFontSetMatch(config, fontSets, SK_ARRAY_COUNT(fontSets),
SkAutoFcPattern match(FcFontSetMatch(config, fontSets, std::size(fontSets),
minimal, &result));
FcLangSet* matchLangSet;
@ -321,7 +321,7 @@ static SkFontStyle skfontstyle_from_fcpattern(FcPattern* pattern) {
{ FC_WEIGHT_EXTRABLACK, SkFS::kExtraBlack_Weight },
};
SkScalar weight = map_ranges(get_int(pattern, FC_WEIGHT, FC_WEIGHT_REGULAR),
weightRanges, SK_ARRAY_COUNT(weightRanges));
weightRanges, std::size(weightRanges));
static constexpr MapRanges widthRanges[] = {
{ FC_WIDTH_ULTRACONDENSED, SkFS::kUltraCondensed_Width },
@ -335,7 +335,7 @@ static SkFontStyle skfontstyle_from_fcpattern(FcPattern* pattern) {
{ FC_WIDTH_ULTRAEXPANDED, SkFS::kUltraExpanded_Width },
};
SkScalar width = map_ranges(get_int(pattern, FC_WIDTH, FC_WIDTH_NORMAL),
widthRanges, SK_ARRAY_COUNT(widthRanges));
widthRanges, std::size(widthRanges));
SkFS::Slant slant = SkFS::kUpright_Slant;
switch (get_int(pattern, FC_SLANT, FC_SLANT_ROMAN)) {
@ -368,7 +368,7 @@ static void fcpattern_from_skfontstyle(SkFontStyle style, FcPattern* pattern) {
{ SkFS::kBlack_Weight, FC_WEIGHT_BLACK },
{ SkFS::kExtraBlack_Weight, FC_WEIGHT_EXTRABLACK },
};
int weight = map_ranges(style.weight(), weightRanges, SK_ARRAY_COUNT(weightRanges));
int weight = map_ranges(style.weight(), weightRanges, std::size(weightRanges));
static constexpr MapRanges widthRanges[] = {
{ SkFS::kUltraCondensed_Width, FC_WIDTH_ULTRACONDENSED },
@ -381,7 +381,7 @@ static void fcpattern_from_skfontstyle(SkFontStyle style, FcPattern* pattern) {
{ SkFS::kExtraExpanded_Width, FC_WIDTH_EXTRAEXPANDED },
{ SkFS::kUltraExpanded_Width, FC_WIDTH_ULTRAEXPANDED },
};
int width = map_ranges(style.width(), widthRanges, SK_ARRAY_COUNT(widthRanges));
int width = map_ranges(style.width(), widthRanges, std::size(widthRanges));
int slant = FC_SLANT_ROMAN;
switch (style.slant()) {
@ -620,7 +620,7 @@ class SkFontMgr_fontconfig : public SkFontMgr {
FcResult result;
FcFontSet* fontSets[1] = { fFontSet };
return FcFontSetMatch(fFontMgr->fFC,
fontSets, SK_ARRAY_COUNT(fontSets),
fontSets, std::size(fontSets),
pattern, &result);
}());
@ -649,7 +649,7 @@ class SkFontMgr_fontconfig : public SkFontMgr {
SkTDArray<size_t> sizes;
static const FcSetName fcNameSet[] = { FcSetSystem, FcSetApplication };
for (int setIndex = 0; setIndex < (int)SK_ARRAY_COUNT(fcNameSet); ++setIndex) {
for (int setIndex = 0; setIndex < (int)std::size(fcNameSet); ++setIndex) {
// Return value of FcConfigGetFonts must not be destroyed.
FcFontSet* allFonts(FcConfigGetFonts(fcconfig, fcNameSet[setIndex]));
if (nullptr == allFonts) {
@ -851,7 +851,7 @@ protected:
// The patterns are exactly the same except for the FC_FILE.
// It should be possible to collapse these patterns by normalizing.
static const FcSetName fcNameSet[] = { FcSetSystem, FcSetApplication };
for (int setIndex = 0; setIndex < (int)SK_ARRAY_COUNT(fcNameSet); ++setIndex) {
for (int setIndex = 0; setIndex < (int)std::size(fcNameSet); ++setIndex) {
// Return value of FcConfigGetFonts must not be destroyed.
FcFontSet* allFonts(FcConfigGetFonts(fFC, fcNameSet[setIndex]));
if (nullptr == allFonts) {

View File

@ -216,7 +216,7 @@ static const char* map_css_names(const char* name) {
{ "monospace", "Courier" }
};
for (size_t i = 0; i < SK_ARRAY_COUNT(gPairs); i++) {
for (size_t i = 0; i < std::size(gPairs); i++) {
if (strcmp(name, gPairs[i].fFrom) == 0) {
return gPairs[i].fTo;
}

View File

@ -343,7 +343,7 @@ CGFloat SkCTFontCTWeightForCSSWeight(int fontstyleWeight) {
}
});
static constexpr Interpolator nativeInterpolator(
nativeWeightMappings, SK_ARRAY_COUNT(nativeWeightMappings));
nativeWeightMappings, std::size(nativeWeightMappings));
return nativeInterpolator.map(fontstyleWeight);
}
@ -374,9 +374,9 @@ static int ct_weight_to_fontstyle(CGFloat cgWeight, bool fromDataProvider) {
}
});
static constexpr Interpolator nativeInterpolator(
nativeWeightMappings, SK_ARRAY_COUNT(nativeWeightMappings));
nativeWeightMappings, std::size(nativeWeightMappings));
static constexpr Interpolator dataProviderInterpolator(
dataProviderWeightMappings, SK_ARRAY_COUNT(dataProviderWeightMappings));
dataProviderWeightMappings, std::size(dataProviderWeightMappings));
return fromDataProvider ? dataProviderInterpolator.map(cgWeight)
: nativeInterpolator.map(cgWeight);
@ -392,7 +392,7 @@ CGFloat SkCTFontCTWidthForCSSWidth(int fontstyleWidth) {
{ 0, -0.5 },
{ 10, 0.5 },
};
static constexpr Interpolator interpolator(widthMappings, SK_ARRAY_COUNT(widthMappings));
static constexpr Interpolator interpolator(widthMappings, std::size(widthMappings));
return interpolator.map(fontstyleWidth);
}
@ -406,7 +406,7 @@ static int ct_width_to_fontstyle(CGFloat cgWidth) {
{ -0.5, 0 },
{ 0.5, 10 },
};
static constexpr Interpolator interpolator(widthMappings, SK_ARRAY_COUNT(widthMappings));
static constexpr Interpolator interpolator(widthMappings, std::size(widthMappings));
return interpolator.map(cgWidth);
}

View File

@ -574,7 +574,7 @@ bool SkOTTableName::Iterator::next(SkOTTableName::Iterator::Record& record) {
// Handle format 0 languages, translating them into BCP 47.
const BCP47FromLanguageId target = { languageID, "" };
int languageIndex = SkTSearch<BCP47FromLanguageId, BCP47FromLanguageIdLess>(
BCP47FromLanguageID, SK_ARRAY_COUNT(BCP47FromLanguageID), target, sizeof(target));
BCP47FromLanguageID, std::size(BCP47FromLanguageID), target, sizeof(target));
if (languageIndex >= 0) {
record.language = BCP47FromLanguageID[languageIndex].bcp47;
return true;

View File

@ -191,7 +191,7 @@ sk_sp<SkOTUtils::LocalizedStrings_NameTable>
SkOTUtils::LocalizedStrings_NameTable::MakeForFamilyNames(const SkTypeface& typeface) {
return Make(typeface,
SkOTUtils::LocalizedStrings_NameTable::familyNameTypes,
SK_ARRAY_COUNT(SkOTUtils::LocalizedStrings_NameTable::familyNameTypes));
std::size(SkOTUtils::LocalizedStrings_NameTable::familyNameTypes));
}
bool SkOTUtils::LocalizedStrings_NameTable::next(SkTypeface::LocalizedString* localizedString) {

View File

@ -803,11 +803,11 @@ void GrPerlinNoise2Effect::Impl::emitCode(EmitArgs& args) {
SkString noiseFuncName = fragBuilder->getMangledFunctionName("noiseFuncName");
if (pne.stitchTiles()) {
fragBuilder->emitFunction(SkSLType::kHalf, noiseFuncName.c_str(),
{gPerlinNoiseStitchArgs, SK_ARRAY_COUNT(gPerlinNoiseStitchArgs)},
{gPerlinNoiseStitchArgs, std::size(gPerlinNoiseStitchArgs)},
noiseCode.c_str());
} else {
fragBuilder->emitFunction(SkSLType::kHalf, noiseFuncName.c_str(),
{gPerlinNoiseArgs, SK_ARRAY_COUNT(gPerlinNoiseArgs)},
{gPerlinNoiseArgs, std::size(gPerlinNoiseArgs)},
noiseCode.c_str());
}

View File

@ -52,7 +52,7 @@ std::string Mangler::uniqueName(std::string_view baseName, SymbolTable* symbolTa
// This code is a performance hotspot. Assemble the string manually to save a few cycles.
char uniqueName[256];
uniqueName[0] = '_';
char* uniqueNameEnd = uniqueName + SK_ARRAY_COUNT(uniqueName);
char* uniqueNameEnd = uniqueName + std::size(uniqueName);
for (;;) {
// _123
char* endPtr = SkStrAppendS32(uniqueName + 1, fCounter++);

View File

@ -1341,7 +1341,7 @@ Value SkVMGenerator::writeIntrinsicCall(const FunctionCall& c) {
const size_t nargs = c.arguments().size();
const size_t kMaxArgs = 3; // eg: clamp, mix, smoothstep
Value args[kMaxArgs];
SkASSERT(nargs >= 1 && nargs <= SK_ARRAY_COUNT(args));
SkASSERT(nargs >= 1 && nargs <= std::size(args));
// All other intrinsics have at most three args, and those can all be evaluated up front:
for (size_t i = 0; i < nargs; ++i) {
@ -2118,13 +2118,13 @@ skvm::Color ProgramToSkVM(const Program& program,
switch (param->modifiers().fLayout.fBuiltin) {
case SK_MAIN_COORDS_BUILTIN:
SkASSERT(param->type().slotCount() == 2);
SkASSERT((argSlots + 2) <= SK_ARRAY_COUNT(args));
SkASSERT((argSlots + 2) <= std::size(args));
args[argSlots++] = local.x.id;
args[argSlots++] = local.y.id;
break;
case SK_INPUT_COLOR_BUILTIN:
SkASSERT(param->type().slotCount() == 4);
SkASSERT((argSlots + 4) <= SK_ARRAY_COUNT(args));
SkASSERT((argSlots + 4) <= std::size(args));
args[argSlots++] = inputColor.r.id;
args[argSlots++] = inputColor.g.id;
args[argSlots++] = inputColor.b.id;
@ -2132,7 +2132,7 @@ skvm::Color ProgramToSkVM(const Program& program,
break;
case SK_DEST_COLOR_BUILTIN:
SkASSERT(param->type().slotCount() == 4);
SkASSERT((argSlots + 4) <= SK_ARRAY_COUNT(args));
SkASSERT((argSlots + 4) <= std::size(args));
args[argSlots++] = destColor.r.id;
args[argSlots++] = destColor.g.id;
args[argSlots++] = destColor.b.id;
@ -2143,7 +2143,7 @@ skvm::Color ProgramToSkVM(const Program& program,
return {};
}
}
SkASSERT(argSlots <= SK_ARRAY_COUNT(args));
SkASSERT(argSlots <= std::size(args));
// Make sure that the SkVMDebugTrace starts from a clean slate.
if (debugTrace) {

View File

@ -755,7 +755,7 @@ static std::unique_ptr<Expression> optimize_intrinsic_call(const Context& contex
}
double dmat[16];
std::copy(mat, mat + SK_ARRAY_COUNT(mat), dmat);
std::copy(mat, mat + std::size(mat), dmat);
return assemble_compound(context, arguments[0]->fPosition, returnType, dmat);
}
// 8.7 : Vector Relational Functions

View File

@ -129,7 +129,7 @@ static bool check_parameters(const Context& context,
m.fLayout.fBuiltin = SK_MAIN_COORDS_BUILTIN;
modifiersChanged = true;
} else if (typeIsValidForColor(type) &&
builtinColorIndex < SK_ARRAY_COUNT(kBuiltinColorIDs)) {
builtinColorIndex < std::size(kBuiltinColorIDs)) {
m.fLayout.fBuiltin = kBuiltinColorIDs[builtinColorIndex++];
modifiersChanged = true;
}

View File

@ -78,7 +78,7 @@ std::string SkVMDebugTrace::slotValueToString(int slotIndex, double value) const
}
default: {
char buffer[32];
snprintf(buffer, SK_ARRAY_COUNT(buffer), "%.8g", value);
snprintf(buffer, std::size(buffer), "%.8g", value);
return buffer;
}
}
@ -253,7 +253,7 @@ void SkVMDebugTrace::writeTrace(SkWStream* w) const {
json.appendS32((int)trace.op);
// Skip trailing zeros in the data (since most ops only use one value).
int lastDataIdx = SK_ARRAY_COUNT(trace.data) - 1;
int lastDataIdx = std::size(trace.data) - 1;
while (lastDataIdx >= 0 && !trace.data[lastDataIdx]) {
--lastDataIdx;
}
@ -367,7 +367,7 @@ bool SkVMDebugTrace::readTrace(SkStream* r) {
fTraceInfo.push_back(SkVMTraceInfo{});
SkVMTraceInfo& info = fTraceInfo.back();
if (!element || element->size() < 1 || element->size() > (1 + SK_ARRAY_COUNT(info.data))) {
if (!element || element->size() < 1 || element->size() > (1 + std::size(info.data))) {
return false;
}
const skjson::NumberValue* opVal = (*element)[0];

View File

@ -130,10 +130,10 @@ static const char* cap_map[] = {
"round", // kRound_Cap
"square" // kSquare_Cap
};
static_assert(SK_ARRAY_COUNT(cap_map) == SkPaint::kCapCount, "missing_cap_map_entry");
static_assert(std::size(cap_map) == SkPaint::kCapCount, "missing_cap_map_entry");
static const char* svg_cap(SkPaint::Cap cap) {
SkASSERT(cap < SK_ARRAY_COUNT(cap_map));
SkASSERT(static_cast<size_t>(cap) < std::size(cap_map));
return cap_map[cap];
}
@ -143,10 +143,10 @@ static const char* join_map[] = {
"round", // kRound_Join
"bevel" // kBevel_Join
};
static_assert(SK_ARRAY_COUNT(join_map) == SkPaint::kJoinCount, "missing_join_map_entry");
static_assert(std::size(join_map) == SkPaint::kJoinCount, "missing_join_map_entry");
static const char* svg_join(SkPaint::Join join) {
SkASSERT(join < SK_ARRAY_COUNT(join_map));
SkASSERT(join < std::size(join_map));
return join_map[join];
}

View File

@ -22,6 +22,7 @@
#include <algorithm>
#include <cmath>
#include <iterator>
#include <utility>
static inline int is_even(int x) {
@ -288,7 +289,7 @@ public:
pts[2].set(x1 - fNormal.fX, y1 - fNormal.fY); // lineTo
pts[3].set(x0 - fNormal.fX, y0 - fNormal.fY); // lineTo
path->addPoly(pts, SK_ARRAY_COUNT(pts), false);
path->addPoly(pts, std::size(pts), false);
}
private:

View File

@ -289,7 +289,7 @@ static inline float pow10(int32_t exp) {
1.e+025f, 1.e+026f, 1.e+027f, 1.e+028f, 1.e+029f, 1.e+030f, 1.e+031f
};
static constexpr int32_t k_exp_offset = SK_ARRAY_COUNT(g_pow10_table) / 2;
static constexpr int32_t k_exp_offset = std::size(g_pow10_table) / 2;
// We only support negative exponents for now.
SkASSERT(exp <= 0);

View File

@ -7,6 +7,7 @@
#include "include/utils/SkParse.h"
#include <iterator> // for std::size
#include <stdlib.h>
#include <string.h>
@ -248,12 +249,12 @@ bool SkParse::FindBool(const char str[], bool* value)
static const char* gYes[] = { "yes", "1", "true" };
static const char* gNo[] = { "no", "0", "false" };
if (lookup_str(str, gYes, SK_ARRAY_COUNT(gYes)))
if (lookup_str(str, gYes, std::size(gYes)))
{
if (value) *value = true;
return true;
}
else if (lookup_str(str, gNo, SK_ARRAY_COUNT(gNo)))
else if (lookup_str(str, gNo, std::size(gNo)))
{
if (value) *value = false;
return true;

View File

@ -229,7 +229,7 @@ SkCTFontSmoothBehavior SkCTFontGetSmoothBehavior() {
colorspace.get(), kBitmapInfoRGB));
SkUniqueCFRef<CFDataRef> data(CFDataCreateWithBytesNoCopy(
kCFAllocatorDefault, kSpiderSymbol_ttf, SK_ARRAY_COUNT(kSpiderSymbol_ttf),
kCFAllocatorDefault, kSpiderSymbol_ttf, std::size(kSpiderSymbol_ttf),
kCFAllocatorNull));
SkUniqueCFRef<CTFontDescriptorRef> desc(
CTFontManagerCreateFontDescriptorFromData(data.get()));
@ -298,7 +298,7 @@ SkCTFontWeightMapping& SkCTFontGetNSFontWeightMapping() {
SK_KIT_FONT_WEIGHT_PREFIX "FontWeightHeavy",
SK_KIT_FONT_WEIGHT_PREFIX "FontWeightBlack",
};
static_assert(SK_ARRAY_COUNT(nsFontWeightNames) == 9, "");
static_assert(std::size(nsFontWeightNames) == 9, "");
static CGFloat nsFontWeights[11];
static const CGFloat (*selectedNSFontWeights)[11] = &defaultNSFontWeights;
@ -330,7 +330,7 @@ SkCTFontWeightMapping& SkCTFontGetDataFontWeightMapping() {
static CGFloat dataFontWeights[11];
static SkOnce once;
once([&] {
constexpr size_t dataSize = SK_ARRAY_COUNT(kSpiderSymbol_ttf);
constexpr size_t dataSize = std::size(kSpiderSymbol_ttf);
sk_sp<SkData> data = SkData::MakeWithCopy(kSpiderSymbol_ttf, dataSize);
const SkSFNTHeader* sfntHeader = reinterpret_cast<const SkSFNTHeader*>(data->data());
const SkSFNTHeader::TableDirectoryEntry* tableEntry =

View File

@ -393,7 +393,7 @@ static HGLRC create_gl_context(HDC dc, const SkWGLExtensions& extensions,
SK_WGL_CONTEXT_PROFILE_MASK, SK_WGL_CONTEXT_CORE_PROFILE_BIT,
0,
};
for (size_t v = 0; v < SK_ARRAY_COUNT(kCoreGLVersions) / 2; ++v) {
for (size_t v = 0; v < std::size(kCoreGLVersions) / 2; ++v) {
coreProfileAttribs[1] = kCoreGLVersions[2 * v];
coreProfileAttribs[3] = kCoreGLVersions[2 * v + 1];
glrc = extensions.createContextAttribs(dc, shareContext, coreProfileAttribs);
@ -432,7 +432,7 @@ HGLRC SkCreateWGLContext(HDC dc, int msaaSampleCount, bool deepColor,
int pixelFormatsToTry[] = { -1, -1 };
get_pixel_formats_to_try(dc, extensions, true, msaaSampleCount, deepColor, pixelFormatsToTry);
for (size_t f = 0;
!set && -1 != pixelFormatsToTry[f] && f < SK_ARRAY_COUNT(pixelFormatsToTry);
!set && -1 != pixelFormatsToTry[f] && f < std::size(pixelFormatsToTry);
++f) {
PIXELFORMATDESCRIPTOR pfd;
DescribePixelFormat(dc, pixelFormatsToTry[f], sizeof(pfd), &pfd);

View File

@ -41,7 +41,7 @@ void SkXMLParserError::getErrorString(SkString* str) const
SkASSERT(str);
SkString temp;
if (fCode != kNoError) {
if ((unsigned)fCode < SK_ARRAY_COUNT(gErrorStrings))
if ((unsigned)fCode < std::size(gErrorStrings))
temp.set(gErrorStrings[fCode - 1]);
temp.append(fNoun);
} else

View File

@ -95,7 +95,7 @@ static const char* escape_char(char c, char storage[2]) {
};
const char** array = gEscapeChars;
for (unsigned i = 0; i < SK_ARRAY_COUNT(gEscapeChars); i++) {
for (unsigned i = 0; i < std::size(gEscapeChars); i++) {
if (array[i][0] == c) {
return &array[i][1];
}

View File

@ -63,7 +63,7 @@
//Placeholder representation of a GUID from createId.
#define L_GUID_ID L"XXXXXXXXsXXXXsXXXXsXXXXsXXXXXXXXXXXX"
//Length of GUID representation from createId, including nullptr terminator.
#define GUID_ID_LEN SK_ARRAY_COUNT(L_GUID_ID)
#define GUID_ID_LEN std::size(L_GUID_ID)
/**
Formats a GUID and places it into buffer.
@ -170,8 +170,8 @@ HRESULT SkXPSDevice::createXpsThumbnail(IXpsOMPage* page,
SkTScopedComPtr<IOpcPartUri> partUri;
constexpr size_t size = std::max(
SK_ARRAY_COUNT(L"/Documents/1/Metadata/.png") + sk_digits_in<decltype(pageNum)>(),
SK_ARRAY_COUNT(L"/Metadata/" L_GUID_ID L".png"));
std::size(L"/Documents/1/Metadata/.png") + sk_digits_in<decltype(pageNum)>(),
std::size(L"/Metadata/" L_GUID_ID L".png"));
wchar_t buffer[size];
if (pageNum > 0) {
swprintf_s(buffer, size, L"/Documents/1/Metadata/%u.png", pageNum);
@ -196,7 +196,7 @@ HRESULT SkXPSDevice::createXpsThumbnail(IXpsOMPage* page,
HRESULT SkXPSDevice::createXpsPage(const XPS_SIZE& pageSize,
IXpsOMPage** page) {
constexpr size_t size =
SK_ARRAY_COUNT(L"/Documents/1/Pages/.fpage")
std::size(L"/Documents/1/Pages/.fpage")
+ sk_digits_in<decltype(fCurrentPage)>();
wchar_t buffer[size];
swprintf_s(buffer, size, L"/Documents/1/Pages/%u.fpage",
@ -638,7 +638,7 @@ HRESULT SkXPSDevice::createXpsImageBrush(
"Could not create stream from png data.");
const size_t size =
SK_ARRAY_COUNT(L"/Documents/1/Resources/Images/" L_GUID_ID L".png");
std::size(L"/Documents/1/Resources/Images/" L_GUID_ID L".png");
wchar_t buffer[size];
wchar_t id[GUID_ID_LEN];
HR(this->createId(id, GUID_ID_LEN));
@ -1238,7 +1238,7 @@ void SkXPSDevice::internalDrawRect(const SkRect& r,
{ r.fRight, r.fTop },
};
if (!xpsTransformsPath && transformRect) {
this->localToDevice().mapPoints(points, SK_ARRAY_COUNT(points));
this->localToDevice().mapPoints(points, std::size(points));
}
HRV(this->createXpsQuad(points, stroke, fill, &rectFigure));
}
@ -1758,7 +1758,7 @@ HRESULT SkXPSDevice::CreateTypefaceUse(const SkFont& font,
"Could not create font stream.");
const size_t size =
SK_ARRAY_COUNT(L"/Resources/Fonts/" L_GUID_ID L".odttf");
std::size(L"/Resources/Fonts/" L_GUID_ID L".odttf");
wchar_t buffer[size];
wchar_t id[GUID_ID_LEN];
HR(this->createId(id, GUID_ID_LEN));

View File

@ -22,6 +22,20 @@
{ include: ["<__iterator/access.h>", "private", "<iterator>", "public"] },
{ include: ["<__iterator/distance.h>", "private", "<iterator>", "public"] },
{ include: ["<__iterator/size.h>", "private", "<array>", "public"] },
{ include: ["<__iterator/size.h>", "private", "<deque>", "public"] },
{ include: ["<__iterator/size.h>", "private", "<forward_list>", "public"] },
{ include: ["<__iterator/size.h>", "private", "<iterator>", "public"] },
{ include: ["<__iterator/size.h>", "private", "<list>", "public"] },
{ include: ["<__iterator/size.h>", "private", "<map>", "public"] },
{ include: ["<__iterator/size.h>", "private", "<regex>", "public"] },
{ include: ["<__iterator/size.h>", "private", "<set>", "public"] },
{ include: ["<__iterator/size.h>", "private", "<string>", "public"] },
{ include: ["<__iterator/size.h>", "private", "<string_view>", "public"] },
{ include: ["<__iterator/size.h>", "private", "<unordered_map>", "public"] },
{ include: ["<__iterator/size.h>", "private", "<unordered_set>", "public"] },
{ include: ["<__iterator/size.h>", "private", "<vector>", "public"] },
{ include: ["<__locale>", "private", "<locale>", "public"] },
{ include: ["<__memory/shared_ptr.h>", "private", "<memory>", "public"] },