Replace SK_ARRAY_COUNT with std::size() for skia/bench
Change-Id: I63ce1643364c6d2dd50e3622d66c64bdb3091418 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/550704 Reviewed-by: John Stiles <johnstiles@google.com> Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
parent
0f1738dea7
commit
e25c114f94
@ -52,10 +52,10 @@ static void makebm(SkBitmap* bm, int w, int h) {
|
||||
|
||||
SkPaint paint;
|
||||
|
||||
paint.setShader(SkGradientShader::MakeLinear(kPts0, kColors0, kPos, SK_ARRAY_COUNT(kColors0),
|
||||
paint.setShader(SkGradientShader::MakeLinear(kPts0, kColors0, kPos, std::size(kColors0),
|
||||
SkTileMode::kClamp));
|
||||
canvas.drawPaint(paint);
|
||||
paint.setShader(SkGradientShader::MakeLinear(kPts1, kColors1, kPos, SK_ARRAY_COUNT(kColors1),
|
||||
paint.setShader(SkGradientShader::MakeLinear(kPts1, kColors1, kPos, std::size(kColors1),
|
||||
SkTileMode::kClamp));
|
||||
canvas.drawPaint(paint);
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ public:
|
||||
|
||||
static const char* LineTypeName(LineType lt) {
|
||||
static const char* gNames[] = { "hori", "vert", "diag" };
|
||||
static_assert(kLineTypeCount == SK_ARRAY_COUNT(gNames), "names_wrong_size");
|
||||
static_assert(kLineTypeCount == std::size(gNames), "names_wrong_size");
|
||||
return gNames[lt];
|
||||
}
|
||||
|
||||
@ -319,7 +319,7 @@ public:
|
||||
// deliberately pick intervals that won't be caught by asPoints(), so
|
||||
// we can test the filterPath code-path.
|
||||
const SkScalar intervals[] = { 20, 10, 10, 10 };
|
||||
fPathEffect = SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 0);
|
||||
fPathEffect = SkDashPathEffect::Make(intervals, std::size(intervals), 0);
|
||||
|
||||
SkScalar cx = 640 / 2; // center X
|
||||
SkScalar cy = 480 / 2; // center Y
|
||||
@ -439,7 +439,7 @@ private:
|
||||
|
||||
static const SkScalar gDots[] = { SK_Scalar1, SK_Scalar1 };
|
||||
|
||||
#define PARAM(array) array, SK_ARRAY_COUNT(array)
|
||||
#define PARAM(array) array, std::size(array)
|
||||
|
||||
DEF_BENCH( return new DashBench(PARAM(gDots), 0); )
|
||||
DEF_BENCH( return new DashBench(PARAM(gDots), 1); )
|
||||
|
@ -120,7 +120,7 @@ protected:
|
||||
for (int hashBits = 6; hashBits <= 12; hashBits += 1) {
|
||||
int hashMask = ((1 << hashBits) - 1);
|
||||
for (int limit = 32; limit <= 1024; limit <<= 1) {
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) {
|
||||
for (size_t i = 0; i < std::size(gRec); ++i) {
|
||||
int collisions = 0;
|
||||
int glyphs = 0;
|
||||
const uint16_t* array = gUniqueGlyphIDs;
|
||||
@ -169,7 +169,7 @@ protected:
|
||||
|
||||
void onDelayedSetup() override {
|
||||
fFont.setSize(32);
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(fGlyphs); ++i) {
|
||||
for (size_t i = 0; i < std::size(fGlyphs); ++i) {
|
||||
fGlyphs[i] = i;
|
||||
}
|
||||
}
|
||||
@ -178,11 +178,11 @@ protected:
|
||||
SkPath path;
|
||||
for (int loop = 0; loop < loops; ++loop) {
|
||||
if (fOneAtATime) {
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(fGlyphs); ++i) {
|
||||
for (size_t i = 0; i < std::size(fGlyphs); ++i) {
|
||||
fFont.getPath(fGlyphs[i], &path);
|
||||
}
|
||||
} else {
|
||||
fFont.getPaths(fGlyphs, SK_ARRAY_COUNT(fGlyphs),
|
||||
fFont.getPaths(fGlyphs, std::size(fGlyphs),
|
||||
[](const SkPath* src, const SkMatrix& mx, void* ctx) {
|
||||
if (src) {
|
||||
src->transform(mx, static_cast<SkPath*>(ctx));
|
||||
|
@ -52,7 +52,7 @@ protected:
|
||||
const SkScalar min = -100;
|
||||
const SkScalar max = 100;
|
||||
SkRandom rand;
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(fRects); ++i) {
|
||||
for (size_t i = 0; i < std::size(fRects); ++i) {
|
||||
SkScalar x = rand.nextRangeScalar(min, max);
|
||||
SkScalar y = rand.nextRangeScalar(min, max);
|
||||
SkScalar w = rand.nextRangeScalar(min, max);
|
||||
@ -70,7 +70,7 @@ protected:
|
||||
void onDraw(int loops, SkCanvas* canvas) override {
|
||||
for (int outer = 0; outer < loops; ++outer) {
|
||||
int count = 0;
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(fRects); ++i) {
|
||||
for (size_t i = 0; i < std::size(fRects); ++i) {
|
||||
SkRect r = fRects[0];
|
||||
count += r.intersect(fRects[i]);
|
||||
}
|
||||
@ -88,7 +88,7 @@ protected:
|
||||
for (int outer = 0; outer < loops; ++outer) {
|
||||
int count = 0;
|
||||
SkRect r;
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(fRects); ++i) {
|
||||
for (size_t i = 0; i < std::size(fRects); ++i) {
|
||||
count += r.intersect(fRects[0], fRects[i]);
|
||||
}
|
||||
this->virtualCallToFoilOptimizers(count);
|
||||
@ -104,7 +104,7 @@ protected:
|
||||
void onDraw(int loops, SkCanvas* canvas) override {
|
||||
for (int outer = 0; outer < loops; ++outer) {
|
||||
int count = 0;
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(fRects); ++i) {
|
||||
for (size_t i = 0; i < std::size(fRects); ++i) {
|
||||
count += SkRect::Intersects(fRects[0], fRects[i]);
|
||||
}
|
||||
this->virtualCallToFoilOptimizers(count);
|
||||
@ -119,7 +119,7 @@ public:
|
||||
protected:
|
||||
void onDraw(int loops, SkCanvas* canvas) override {
|
||||
for (int outer = 0; outer < loops; ++outer) {
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(fRects); ++i) {
|
||||
for (size_t i = 0; i < std::size(fRects); ++i) {
|
||||
fRects[i].sort();
|
||||
}
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ protected:
|
||||
SkColorSetARGB(alpha, gray, gray, gray),
|
||||
SK_ColorWHITE };
|
||||
paint.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr,
|
||||
SK_ARRAY_COUNT(colors),
|
||||
std::size(colors),
|
||||
SkTileMode::kClamp));
|
||||
canvas->drawRect(r, paint);
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ public:
|
||||
}
|
||||
void makePath(SkPath* path) override {
|
||||
SkRandom rand;
|
||||
int size = SK_ARRAY_COUNT(points);
|
||||
int size = std::size(points);
|
||||
int hSize = size / 2;
|
||||
for (int i = 0; i < kMaxPathSize; ++i) {
|
||||
int xTrans = 10 + 40 * (i%(kMaxPathSize/2));
|
||||
@ -119,7 +119,7 @@ public:
|
||||
}
|
||||
void makePath(SkPath* path) override {
|
||||
SkRandom rand;
|
||||
int size = SK_ARRAY_COUNT(points);
|
||||
int size = std::size(points);
|
||||
int hSize = size / 2;
|
||||
for (int i = 0; i < kMaxPathSize; ++i) {
|
||||
int xTrans = 10 + 40 * (i%(kMaxPathSize/2));
|
||||
@ -152,7 +152,7 @@ public:
|
||||
void makePath(SkPath* path) override {
|
||||
SkRandom rand;
|
||||
SkRandom randWeight;
|
||||
int size = SK_ARRAY_COUNT(points);
|
||||
int size = std::size(points);
|
||||
int hSize = size / 2;
|
||||
for (int i = 0; i < kMaxPathSize; ++i) {
|
||||
int xTrans = 10 + 40 * (i%(kMaxPathSize/2));
|
||||
@ -187,7 +187,7 @@ public:
|
||||
}
|
||||
void makePath(SkPath* path) override {
|
||||
SkRandom rand;
|
||||
int size = SK_ARRAY_COUNT(points);
|
||||
int size = std::size(points);
|
||||
int hSize = size / 2;
|
||||
for (int i = 0; i < kMaxPathSize; ++i) {
|
||||
int xTrans = 10 + 40 * (i%(kMaxPathSize/2));
|
||||
|
@ -60,7 +60,7 @@ private:
|
||||
SK_ColorBLACK, SK_ColorGREEN, SK_ColorCYAN,
|
||||
SK_ColorRED, 0, SK_ColorBLUE, SK_ColorWHITE
|
||||
};
|
||||
paint.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors),
|
||||
paint.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, std::size(colors),
|
||||
SkTileMode::kClamp));
|
||||
surf->getCanvas()->drawPaint(paint);
|
||||
fImage = surf->makeImageSnapshot(); // shader->makeImage()
|
||||
@ -90,7 +90,7 @@ protected:
|
||||
SkTableColorFilter::Make(table3),
|
||||
};
|
||||
|
||||
this->doPreDraw(colorFilters, SK_ARRAY_COUNT(colorFilters));
|
||||
this->doPreDraw(colorFilters, std::size(colorFilters));
|
||||
}
|
||||
|
||||
private:
|
||||
@ -128,7 +128,7 @@ protected:
|
||||
make_brightness(-0.1f),
|
||||
};
|
||||
|
||||
this->doPreDraw(colorFilters, SK_ARRAY_COUNT(colorFilters));
|
||||
this->doPreDraw(colorFilters, std::size(colorFilters));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -210,7 +210,7 @@ struct PDFShaderBench : public Benchmark {
|
||||
SK_ColorWHITE, SK_ColorBLACK,
|
||||
};
|
||||
fShader = SkGradientShader::MakeLinear(
|
||||
pts, colors, nullptr, SK_ARRAY_COUNT(colors),
|
||||
pts, colors, nullptr, std::size(colors),
|
||||
SkTileMode::kClamp);
|
||||
}
|
||||
void onDraw(int loops, SkCanvas*) final {
|
||||
@ -372,7 +372,7 @@ void big_pdf_test(SkDocument* doc, const SkBitmap& background) {
|
||||
SkCanvas* canvas = nullptr;
|
||||
float x = 36;
|
||||
float y = 36;
|
||||
constexpr size_t kLineCount = SK_ARRAY_COUNT(kText);
|
||||
constexpr size_t kLineCount = std::size(kText);
|
||||
constexpr int kLoopCount = 200;
|
||||
SkFont font;
|
||||
SkPaint paint;
|
||||
|
@ -78,7 +78,7 @@ public:
|
||||
};
|
||||
const SkPoint pts[] = { { 200.f / 4.f, 0.f }, { 3.f * 200.f / 4, 200.f } };
|
||||
|
||||
return SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors),
|
||||
return SkGradientShader::MakeLinear(pts, colors, nullptr, std::size(colors),
|
||||
SkTileMode::kMirror);
|
||||
}
|
||||
|
||||
|
@ -228,7 +228,7 @@ protected:
|
||||
SkScalar gSizes[] = {
|
||||
SkIntToScalar(7), 0
|
||||
};
|
||||
size_t sizes = SK_ARRAY_COUNT(gSizes);
|
||||
size_t sizes = std::size(gSizes);
|
||||
|
||||
if (FLAGS_strokeWidth >= 0) {
|
||||
gSizes[0] = (SkScalar)FLAGS_strokeWidth;
|
||||
@ -279,7 +279,7 @@ protected:
|
||||
SkScalar gSizes[] = {
|
||||
SkIntToScalar(13), SkIntToScalar(24)
|
||||
};
|
||||
size_t sizes = SK_ARRAY_COUNT(gSizes);
|
||||
size_t sizes = std::size(gSizes);
|
||||
|
||||
if (FLAGS_strokeWidth >= 0) {
|
||||
gSizes[0] = (SkScalar)FLAGS_strokeWidth;
|
||||
|
@ -75,7 +75,7 @@ struct Sk4fGradientBench : public Benchmark {
|
||||
b = a + dcdx,
|
||||
c = b + dcdx,
|
||||
d = c + dcdx;
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(fDevice); i += 4) {
|
||||
for (size_t i = 0; i < std::size(fDevice); i += 4) {
|
||||
skvx::cast<uint8_t>(a).store(fDevice + i + 0);
|
||||
skvx::cast<uint8_t>(b).store(fDevice + i + 1);
|
||||
skvx::cast<uint8_t>(c).store(fDevice + i + 2);
|
||||
|
@ -580,4 +580,4 @@ TigerPath kTigerPaths[] = {
|
||||
{36.856f,98.898f}}},
|
||||
};
|
||||
|
||||
int kNumTigerPaths = (int)SK_ARRAY_COUNT(kTigerPaths);
|
||||
int kNumTigerPaths = (int)std::size(kTigerPaths);
|
||||
|
@ -298,19 +298,19 @@ private:
|
||||
const char* fName;
|
||||
};
|
||||
|
||||
DEF_BENCH(return new UtfToGlyph(SkTextEncoding::kUTF32, ctext, SK_ARRAY_COUNT(ctext),
|
||||
DEF_BENCH(return new UtfToGlyph(SkTextEncoding::kUTF32, ctext, std::size(ctext),
|
||||
"SkTypefaceUTF32ToGlyphCN");)
|
||||
DEF_BENCH(return new UtfToGlyph(SkTextEncoding::kUTF16, ctext, SK_ARRAY_COUNT(ctext),
|
||||
DEF_BENCH(return new UtfToGlyph(SkTextEncoding::kUTF16, ctext, std::size(ctext),
|
||||
"SkTypefaceUTF16ToGlyphCN");)
|
||||
DEF_BENCH(return new UtfToGlyph(SkTextEncoding::kUTF8, ctext, SK_ARRAY_COUNT(ctext),
|
||||
DEF_BENCH(return new UtfToGlyph(SkTextEncoding::kUTF8, ctext, std::size(ctext),
|
||||
"SkTypefaceUTF8ToGlyphCN");)
|
||||
|
||||
|
||||
DEF_BENCH(return new UtfToGlyph(SkTextEncoding::kUTF32, atext, SK_ARRAY_COUNT(atext),
|
||||
DEF_BENCH(return new UtfToGlyph(SkTextEncoding::kUTF32, atext, std::size(atext),
|
||||
"SkTypefaceUTF32ToGlyphAscii");)
|
||||
DEF_BENCH(return new UtfToGlyph(SkTextEncoding::kUTF16, atext, SK_ARRAY_COUNT(atext),
|
||||
DEF_BENCH(return new UtfToGlyph(SkTextEncoding::kUTF16, atext, std::size(atext),
|
||||
"SkTypefaceUTF16ToGlyphAscii");)
|
||||
DEF_BENCH(return new UtfToGlyph(SkTextEncoding::kUTF8, atext, SK_ARRAY_COUNT(atext),
|
||||
DEF_BENCH(return new UtfToGlyph(SkTextEncoding::kUTF8, atext, std::size(atext),
|
||||
"SkTypefaceUTF8ToGlyphAscii");)
|
||||
|
||||
|
||||
|
@ -1125,7 +1125,7 @@ public:
|
||||
continue;
|
||||
}
|
||||
|
||||
while (fCurrentSampleSize < (int) SK_ARRAY_COUNT(sampleSizes)) {
|
||||
while (fCurrentSampleSize < (int) std::size(sampleSizes)) {
|
||||
int sampleSize = sampleSizes[fCurrentSampleSize];
|
||||
fCurrentSampleSize++;
|
||||
if (10 * sampleSize > std::min(codec->getInfo().width(), codec->getInfo().height())) {
|
||||
@ -1165,7 +1165,7 @@ public:
|
||||
}
|
||||
|
||||
while (fCurrentColorType < fColorTypes.count()) {
|
||||
while (fCurrentSampleSize < (int) SK_ARRAY_COUNT(brdSampleSizes)) {
|
||||
while (fCurrentSampleSize < (int) std::size(brdSampleSizes)) {
|
||||
while (fCurrentSubsetType <= kLastSingle_SubsetType) {
|
||||
|
||||
sk_sp<SkData> encoded(SkData::MakeFromFileName(path.c_str()));
|
||||
|
Loading…
Reference in New Issue
Block a user