Replace SK_ARRAY_COUNT with std::size() for skia/modules
* Changed one static_assert to SkASSERT in RangeSelector.cpp:42 Change-Id: I12815a8817816261bb30f5412432109ed46826fd Reviewed-on: https://skia-review.googlesource.com/c/skia/+/551892 Commit-Queue: Herb Derby <herb@google.com> Reviewed-by: John Stiles <johnstiles@google.com>
This commit is contained in:
parent
9d5ba0ea41
commit
45313d1ce3
@ -214,6 +214,6 @@ int register_androidkit_Canvas(JNIEnv* env) {
|
||||
|
||||
const auto clazz = env->FindClass("org/skia/androidkit/Canvas");
|
||||
return clazz
|
||||
? env->RegisterNatives(clazz, methods, SK_ARRAY_COUNT(methods))
|
||||
? env->RegisterNatives(clazz, methods, std::size(methods))
|
||||
: JNI_ERR;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ int register_androidkit_ColorFilter(JNIEnv* env) {
|
||||
|
||||
const auto clazz = env->FindClass("org/skia/androidkit/ColorFilter");
|
||||
return clazz
|
||||
? env->RegisterNatives(clazz, methods, SK_ARRAY_COUNT(methods))
|
||||
? env->RegisterNatives(clazz, methods, std::size(methods))
|
||||
: JNI_ERR;
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ int register_androidkit_MatrixColorFilter(JNIEnv* env) {
|
||||
|
||||
const auto clazz = env->FindClass("org/skia/androidkit/MatrixColorFilter");
|
||||
return clazz
|
||||
? env->RegisterNatives(clazz, methods, SK_ARRAY_COUNT(methods))
|
||||
? env->RegisterNatives(clazz, methods, std::size(methods))
|
||||
: JNI_ERR;
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ int register_androidkit_HSLAMatrixColorFilter(JNIEnv* env) {
|
||||
|
||||
const auto clazz = env->FindClass("org/skia/androidkit/HSLAMatrixColorFilter");
|
||||
return clazz
|
||||
? env->RegisterNatives(clazz, methods, SK_ARRAY_COUNT(methods))
|
||||
? env->RegisterNatives(clazz, methods, std::size(methods))
|
||||
: JNI_ERR;
|
||||
}
|
||||
|
||||
@ -81,6 +81,6 @@ int register_androidkit_ComposeColorFilter(JNIEnv* env) {
|
||||
|
||||
const auto clazz = env->FindClass("org/skia/androidkit/ComposeColorFilter");
|
||||
return clazz
|
||||
? env->RegisterNatives(clazz, methods, SK_ARRAY_COUNT(methods))
|
||||
? env->RegisterNatives(clazz, methods, std::size(methods))
|
||||
: JNI_ERR;
|
||||
}
|
||||
|
@ -35,6 +35,6 @@ int register_androidkit_Font(JNIEnv* env) {
|
||||
|
||||
const auto clazz = env->FindClass("org/skia/androidkit/Font");
|
||||
return clazz
|
||||
? env->RegisterNatives(clazz, methods, SK_ARRAY_COUNT(methods))
|
||||
? env->RegisterNatives(clazz, methods, std::size(methods))
|
||||
: JNI_ERR;
|
||||
}
|
||||
|
@ -85,6 +85,6 @@ int register_androidkit_FontChain(JNIEnv* env) {
|
||||
};
|
||||
|
||||
return clazz
|
||||
? env->RegisterNatives(clazz, methods, SK_ARRAY_COUNT(methods))
|
||||
? env->RegisterNatives(clazz, methods, std::size(methods))
|
||||
: JNI_ERR;
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ int register_androidkit_LinearGradient(JNIEnv* env) {
|
||||
|
||||
const auto clazz = env->FindClass("org/skia/androidkit/LinearGradient");
|
||||
return clazz
|
||||
? env->RegisterNatives(clazz, methods, SK_ARRAY_COUNT(methods))
|
||||
? env->RegisterNatives(clazz, methods, std::size(methods))
|
||||
: JNI_ERR;
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ int register_androidkit_RadialGradient(JNIEnv* env) {
|
||||
|
||||
const auto clazz = env->FindClass("org/skia/androidkit/RadialGradient");
|
||||
return clazz
|
||||
? env->RegisterNatives(clazz, methods, SK_ARRAY_COUNT(methods))
|
||||
? env->RegisterNatives(clazz, methods, std::size(methods))
|
||||
: JNI_ERR;
|
||||
}
|
||||
|
||||
@ -154,7 +154,7 @@ int register_androidkit_TwoPointConicalGradient(JNIEnv* env) {
|
||||
|
||||
const auto clazz = env->FindClass("org/skia/androidkit/TwoPointConicalGradient");
|
||||
return clazz
|
||||
? env->RegisterNatives(clazz, methods, SK_ARRAY_COUNT(methods))
|
||||
? env->RegisterNatives(clazz, methods, std::size(methods))
|
||||
: JNI_ERR;
|
||||
}
|
||||
|
||||
@ -165,6 +165,6 @@ int register_androidkit_SweepGradient(JNIEnv* env) {
|
||||
|
||||
const auto clazz = env->FindClass("org/skia/androidkit/SweepGradient");
|
||||
return clazz
|
||||
? env->RegisterNatives(clazz, methods, SK_ARRAY_COUNT(methods))
|
||||
? env->RegisterNatives(clazz, methods, std::size(methods))
|
||||
: JNI_ERR;
|
||||
}
|
||||
|
@ -75,6 +75,6 @@ int register_androidkit_Image(JNIEnv* env) {
|
||||
|
||||
const auto clazz = env->FindClass("org/skia/androidkit/Image");
|
||||
return clazz
|
||||
? env->RegisterNatives(clazz, methods, SK_ARRAY_COUNT(methods))
|
||||
? env->RegisterNatives(clazz, methods, std::size(methods))
|
||||
: JNI_ERR;
|
||||
}
|
||||
|
@ -75,6 +75,6 @@ int register_androidkit_ImageFilter(JNIEnv* env) {
|
||||
|
||||
const auto clazz = env->FindClass("org/skia/androidkit/ImageFilter");
|
||||
return clazz
|
||||
? env->RegisterNatives(clazz, methods, SK_ARRAY_COUNT(methods))
|
||||
? env->RegisterNatives(clazz, methods, std::size(methods))
|
||||
: JNI_ERR;
|
||||
}
|
||||
|
@ -123,6 +123,6 @@ int register_androidkit_Matrix(JNIEnv* env) {
|
||||
|
||||
const auto clazz = env->FindClass("org/skia/androidkit/Matrix");
|
||||
return clazz
|
||||
? env->RegisterNatives(clazz, methods, SK_ARRAY_COUNT(methods))
|
||||
? env->RegisterNatives(clazz, methods, std::size(methods))
|
||||
: JNI_ERR;
|
||||
}
|
||||
|
@ -122,6 +122,6 @@ int register_androidkit_Paint(JNIEnv* env) {
|
||||
|
||||
const auto clazz = env->FindClass("org/skia/androidkit/Paint");
|
||||
return clazz
|
||||
? env->RegisterNatives(clazz, methods, SK_ARRAY_COUNT(methods))
|
||||
? env->RegisterNatives(clazz, methods, std::size(methods))
|
||||
: JNI_ERR;
|
||||
}
|
||||
|
@ -23,6 +23,6 @@ int register_androidkit_Path(JNIEnv* env) {
|
||||
|
||||
const auto clazz = env->FindClass("org/skia/androidkit/Path");
|
||||
return clazz
|
||||
? env->RegisterNatives(clazz, methods, SK_ARRAY_COUNT(methods))
|
||||
? env->RegisterNatives(clazz, methods, std::size(methods))
|
||||
: JNI_ERR;
|
||||
}
|
||||
|
@ -103,6 +103,6 @@ int register_androidkit_PathBuilder(JNIEnv* env) {
|
||||
|
||||
const auto clazz = env->FindClass("org/skia/androidkit/PathBuilder");
|
||||
return clazz
|
||||
? env->RegisterNatives(clazz, methods, SK_ARRAY_COUNT(methods))
|
||||
? env->RegisterNatives(clazz, methods, std::size(methods))
|
||||
: JNI_ERR;
|
||||
}
|
||||
|
@ -78,6 +78,6 @@ int register_androidkit_RuntimeShaderBuilder(JNIEnv* env) {
|
||||
|
||||
const auto clazz = env->FindClass("org/skia/androidkit/RuntimeShaderBuilder");
|
||||
return clazz
|
||||
? env->RegisterNatives(clazz, methods, SK_ARRAY_COUNT(methods))
|
||||
? env->RegisterNatives(clazz, methods, std::size(methods))
|
||||
: JNI_ERR;
|
||||
}
|
||||
|
@ -23,6 +23,6 @@ int register_androidkit_Shader(JNIEnv* env) {
|
||||
|
||||
const auto clazz = env->FindClass("org/skia/androidkit/Shader");
|
||||
return clazz
|
||||
? env->RegisterNatives(clazz, methods, SK_ARRAY_COUNT(methods))
|
||||
? env->RegisterNatives(clazz, methods, std::size(methods))
|
||||
: JNI_ERR;
|
||||
}
|
||||
|
@ -86,6 +86,6 @@ int register_androidkit_SkottieAnimation(JNIEnv* env) {
|
||||
|
||||
const auto clazz = env->FindClass("org/skia/androidkit/SkottieAnimation");
|
||||
return clazz
|
||||
? env->RegisterNatives(clazz, methods, SK_ARRAY_COUNT(methods))
|
||||
? env->RegisterNatives(clazz, methods, std::size(methods))
|
||||
: JNI_ERR;
|
||||
}
|
||||
|
@ -268,6 +268,6 @@ int register_androidkit_Surface(JNIEnv* env) {
|
||||
|
||||
const auto clazz = env->FindClass("org/skia/androidkit/Surface");
|
||||
return clazz
|
||||
? env->RegisterNatives(clazz, methods, SK_ARRAY_COUNT(methods))
|
||||
? env->RegisterNatives(clazz, methods, std::size(methods))
|
||||
: JNI_ERR;
|
||||
}
|
||||
|
@ -46,6 +46,6 @@ int register_androidkit_Text(JNIEnv* env) {
|
||||
|
||||
const auto clazz = env->FindClass("org/skia/androidkit/Text");
|
||||
return clazz
|
||||
? env->RegisterNatives(clazz, methods, SK_ARRAY_COUNT(methods))
|
||||
? env->RegisterNatives(clazz, methods, std::size(methods))
|
||||
: JNI_ERR;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ private:
|
||||
{ "update #3", SK_ColorMAGENTA, SK_ColorCYAN , 150.f },
|
||||
};
|
||||
|
||||
SkASSERT(i - 1 < SK_ARRAY_COUNT(gTests));
|
||||
SkASSERT(i - 1 < std::size(gTests));
|
||||
const auto& tst = gTests[i - 1];
|
||||
|
||||
for (const auto& prop : fPropManager->getColorProps()) {
|
||||
|
@ -148,7 +148,7 @@ protected:
|
||||
};
|
||||
|
||||
if (uni == 'c') {
|
||||
fColorIndex = (fColorIndex + 1) % SK_ARRAY_COUNT(kColors);
|
||||
fColorIndex = (fColorIndex + 1) % std::size(kColors);
|
||||
for (const auto& prop : fColorProps) {
|
||||
fPropManager->setColor(prop, kColors[fColorIndex]);
|
||||
}
|
||||
|
@ -450,7 +450,7 @@ sk_sp<sksg::RenderNode> LayerBuilder::buildRenderTree(const AnimationBuilder& ab
|
||||
{ nullptr , 0 }, // 'ty': 14 -> light
|
||||
};
|
||||
|
||||
if (fType < 0 || static_cast<size_t>(fType) >= SK_ARRAY_COUNT(gLayerBuildInfo)) {
|
||||
if (fType < 0 || static_cast<size_t>(fType) >= std::size(gLayerBuildInfo)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -557,7 +557,7 @@ sk_sp<sksg::RenderNode> LayerBuilder::buildRenderTree(const AnimationBuilder& ab
|
||||
sksg::MaskEffect::Mode::kLumaInvert, // tt: 4
|
||||
};
|
||||
|
||||
if (matte_mode <= SK_ARRAY_COUNT(gMatteModes)) {
|
||||
if (matte_mode <= std::size(gMatteModes)) {
|
||||
// The current layer is masked with the previous layer *content*.
|
||||
layer = sksg::MaskEffect::Make(std::move(layer),
|
||||
prev_layer->fContentTree,
|
||||
|
@ -115,7 +115,7 @@ static SkBlendMode GetBlendMode(const skjson::ObjectValue& jobject,
|
||||
};
|
||||
|
||||
const size_t bm_index = ParseDefault<size_t>(jobject["bm"], 0);
|
||||
if (bm_index >= SK_ARRAY_COUNT(kBlendModeMap)) {
|
||||
if (bm_index >= std::size(kBlendModeMap)) {
|
||||
abuilder->log(Logger::Level::kWarning, &jobject, "Unsupported blend mode %zu\n", bm_index);
|
||||
return SkBlendMode::kSrcOver;
|
||||
}
|
||||
|
@ -55,10 +55,10 @@ private:
|
||||
{ fUR.x, fUR.y},
|
||||
{ fLR.x, fLR.y},
|
||||
{ fLL.x, fLL.y}};
|
||||
static_assert(SK_ARRAY_COUNT(src) == SK_ARRAY_COUNT(dst));
|
||||
static_assert(std::size(src) == std::size(dst));
|
||||
|
||||
SkMatrix m;
|
||||
if (m.setPolyToPoly(src, dst, SK_ARRAY_COUNT(src))) {
|
||||
if (m.setPolyToPoly(src, dst, std::size(src))) {
|
||||
fMatrixNode->setMatrix(m);
|
||||
}
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ private:
|
||||
};
|
||||
|
||||
const auto i = static_cast<size_t>(sel);
|
||||
SkASSERT(i < SK_ARRAY_COUNT(gCoeffs));
|
||||
SkASSERT(i < std::size(gCoeffs));
|
||||
|
||||
return gCoeffs[i];
|
||||
}
|
||||
|
@ -158,8 +158,8 @@ sk_sp<sksg::RenderNode> EffectBuilder::attachStyles(const skjson::ArrayValue& js
|
||||
|
||||
const auto style_type =
|
||||
ParseDefault<size_t>((*jstyle)["ty"], std::numeric_limits<size_t>::max());
|
||||
auto builder = style_type < SK_ARRAY_COUNT(gStyleBuilders) ? gStyleBuilders[style_type]
|
||||
: nullptr;
|
||||
auto builder = style_type < std::size(gStyleBuilders) ? gStyleBuilders[style_type]
|
||||
: nullptr;
|
||||
|
||||
if (!builder) {
|
||||
fBuilder->log(Logger::Level::kWarning, jstyle, "Unsupported layer style.");
|
||||
|
@ -216,8 +216,8 @@ sk_sp<SkRuntimeEffect> noise_effect() {
|
||||
gFractalTurbulentSharpSkSL
|
||||
};
|
||||
|
||||
static_assert(static_cast<size_t>(FILTER) < SK_ARRAY_COUNT(gFilters));
|
||||
static_assert(static_cast<size_t>(FRACTAL) < SK_ARRAY_COUNT(gFractals));
|
||||
static_assert(static_cast<size_t>(FILTER) < std::size(gFilters));
|
||||
static_assert(static_cast<size_t>(FRACTAL) < std::size(gFractals));
|
||||
|
||||
static const SkRuntimeEffect* effect =
|
||||
make_noise_effect(LOOPS,
|
||||
|
@ -55,7 +55,7 @@ private:
|
||||
};
|
||||
|
||||
const auto dim_index = SkTPin<size_t>(static_cast<size_t>(fDimensions),
|
||||
1, SK_ARRAY_COUNT(kDimensionsMap)) - 1;
|
||||
1, std::size(kDimensionsMap)) - 1;
|
||||
|
||||
const auto sigma = fBlurriness * kBlurSizeToSigma;
|
||||
|
||||
@ -68,7 +68,7 @@ private:
|
||||
};
|
||||
|
||||
const auto repeat_index = SkTPin<size_t>(static_cast<size_t>(fRepeatEdge),
|
||||
0, SK_ARRAY_COUNT(kRepeatEdgeMap) - 1);
|
||||
0, std::size(kRepeatEdgeMap) - 1);
|
||||
fBlur->setTileMode(kRepeatEdgeMap[repeat_index]);
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ protected:
|
||||
tile.y() + 2 * (tile.height() - phase_vec.fY) }};
|
||||
|
||||
auto mask_shader = SkGradientShader::MakeLinear(pts, colors, pos,
|
||||
SK_ARRAY_COUNT(colors),
|
||||
std::size(colors),
|
||||
SkTileMode::kRepeat);
|
||||
|
||||
// First drawing pass: in-place masked layer content.
|
||||
|
@ -75,7 +75,7 @@ protected:
|
||||
|
||||
fMaskShader = SkGradientShader::MakeSweep(fWipeCenter.x(), fWipeCenter.y(),
|
||||
grad_colors, grad_pos,
|
||||
SK_ARRAY_COUNT(grad_colors),
|
||||
std::size(grad_colors),
|
||||
SkTileMode::kClamp,
|
||||
a0, a1, 0, nullptr);
|
||||
|
||||
|
@ -87,7 +87,7 @@ private:
|
||||
{ 0, 0, 0, 0, 1}, // kFullOn
|
||||
{ 0, 0, 0, 0, 0}, // kFullOff
|
||||
};
|
||||
static_assert(SK_ARRAY_COUNT(gSourceCoeffs) == static_cast<size_t>(Source::kMax), "");
|
||||
static_assert(std::size(gSourceCoeffs) == static_cast<size_t>(Source::kMax), "");
|
||||
|
||||
auto coeffs = [](float src) {
|
||||
// Channel sources are encoded as Source enum values.
|
||||
|
@ -128,7 +128,7 @@ private:
|
||||
1 - df1 - df0, // fp3
|
||||
1,
|
||||
};
|
||||
static_assert(SK_ARRAY_COUNT(colors) == SK_ARRAY_COUNT(pos), "");
|
||||
static_assert(std::size(colors) == std::size(pos), "");
|
||||
|
||||
const auto center = SkPoint::Make(0.5f * this->layerSize().width(),
|
||||
0.5f * this->layerSize().height()),
|
||||
@ -141,7 +141,7 @@ private:
|
||||
};
|
||||
|
||||
return {
|
||||
SkGradientShader::MakeLinear(pts, colors, pos, SK_ARRAY_COUNT(colors),
|
||||
SkGradientShader::MakeLinear(pts, colors, pos, std::size(colors),
|
||||
SkTileMode::kRepeat),
|
||||
true
|
||||
};
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
};
|
||||
this->node()->setStrokeJoin(
|
||||
gJoins[std::min<size_t>(ParseDefault<size_t>(jpaint["lj"], 1) - 1,
|
||||
SK_ARRAY_COUNT(gJoins) - 1)]);
|
||||
std::size(gJoins) - 1)]);
|
||||
|
||||
static constexpr SkPaint::Cap gCaps[] = {
|
||||
SkPaint::kButt_Cap,
|
||||
@ -58,7 +58,7 @@ public:
|
||||
};
|
||||
this->node()->setStrokeCap(
|
||||
gCaps[std::min<size_t>(ParseDefault<size_t>(jpaint["lc"], 1) - 1,
|
||||
SK_ARRAY_COUNT(gCaps) - 1)]);
|
||||
std::size(gCaps) - 1)]);
|
||||
}
|
||||
|
||||
if (fShaderType == ShaderType::kColor) {
|
||||
|
@ -39,7 +39,7 @@ std::vector<sk_sp<sksg::GeometryNode>> ShapeBuilder::AttachMergeGeometryEffect(
|
||||
};
|
||||
|
||||
const auto mode = gModes[std::min<size_t>(ParseDefault<size_t>(jmerge["mm"], 1) - 1,
|
||||
SK_ARRAY_COUNT(gModes) - 1)];
|
||||
std::size(gModes) - 1)];
|
||||
|
||||
std::vector<sk_sp<sksg::GeometryNode>> merged;
|
||||
merged.push_back(ShapeBuilder::MergeGeometry(std::move(geos), mode));
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
};
|
||||
|
||||
const auto join = ParseDefault<int>(joffset["lj"], 1) - 1;
|
||||
this->node()->setJoin(gJoinMap[SkTPin<int>(join, 0, SK_ARRAY_COUNT(gJoinMap) - 1)]);
|
||||
this->node()->setJoin(gJoinMap[SkTPin<int>(join, 0, std::size(gJoinMap) - 1)]);
|
||||
|
||||
this->bind(abuilder, joffset["a" ], fAmount);
|
||||
this->bind(abuilder, joffset["ml"], fMiterLimit);
|
||||
|
@ -90,7 +90,7 @@ sk_sp<sksg::GeometryNode> ShapeBuilder::AttachPolystarGeometry(const skjson::Obj
|
||||
};
|
||||
|
||||
const auto type = ParseDefault<size_t>(jstar["sy"], 0) - 1;
|
||||
if (type >= SK_ARRAY_COUNT(gTypes)) {
|
||||
if (type >= std::size(gTypes)) {
|
||||
abuilder->log(Logger::Level::kError, &jstar, "Unknown polystar type.");
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ static constexpr GeometryEffectAttacherT gPaintGeometryAdjusters[] = {
|
||||
nullptr, // gradient fill
|
||||
ShapeBuilder::AdjustStrokeGeometry, // gradient stroke
|
||||
};
|
||||
static_assert(SK_ARRAY_COUNT(gPaintGeometryAdjusters) == SK_ARRAY_COUNT(gPaintAttachers), "");
|
||||
static_assert(std::size(gPaintGeometryAdjusters) == std::size(gPaintAttachers), "");
|
||||
|
||||
using DrawEffectAttacherT =
|
||||
std::vector<sk_sp<sksg::RenderNode>> (*)(const skjson::ObjectValue&,
|
||||
@ -126,7 +126,7 @@ const ShapeInfo* FindShapeInfo(const skjson::ObjectValue& jshape) {
|
||||
|
||||
const auto* info = bsearch(type->begin(),
|
||||
gShapeInfo,
|
||||
SK_ARRAY_COUNT(gShapeInfo),
|
||||
std::size(gShapeInfo),
|
||||
sizeof(ShapeInfo),
|
||||
[](const void* key, const void* info) {
|
||||
return strcmp(static_cast<const char*>(key),
|
||||
@ -210,7 +210,7 @@ sk_sp<sksg::RenderNode> AnimationBuilder::attachShape(const skjson::ArrayValue*
|
||||
jtransform = shape;
|
||||
break;
|
||||
case ShapeType::kGeometryEffect:
|
||||
SkASSERT(info->fAttacherIndex < SK_ARRAY_COUNT(gGeometryEffectAttachers));
|
||||
SkASSERT(info->fAttacherIndex < std::size(gGeometryEffectAttachers));
|
||||
ctx->fGeometryEffectStack->push_back(
|
||||
{ *shape, gGeometryEffectAttachers[info->fAttacherIndex] });
|
||||
break;
|
||||
@ -237,14 +237,14 @@ sk_sp<sksg::RenderNode> AnimationBuilder::attachShape(const skjson::ArrayValue*
|
||||
|
||||
switch (rec->fInfo.fShapeType) {
|
||||
case ShapeType::kGeometry: {
|
||||
SkASSERT(rec->fInfo.fAttacherIndex < SK_ARRAY_COUNT(gGeometryAttachers));
|
||||
SkASSERT(rec->fInfo.fAttacherIndex < std::size(gGeometryAttachers));
|
||||
if (auto geo = gGeometryAttachers[rec->fInfo.fAttacherIndex](rec->fJson, this)) {
|
||||
geos.push_back(std::move(geo));
|
||||
}
|
||||
} break;
|
||||
case ShapeType::kGeometryEffect: {
|
||||
// Apply the current effect and pop from the stack.
|
||||
SkASSERT(rec->fInfo.fAttacherIndex < SK_ARRAY_COUNT(gGeometryEffectAttachers));
|
||||
SkASSERT(rec->fInfo.fAttacherIndex < std::size(gGeometryEffectAttachers));
|
||||
if (!geos.empty()) {
|
||||
geos = gGeometryEffectAttachers[rec->fInfo.fAttacherIndex](rec->fJson,
|
||||
this,
|
||||
@ -268,7 +268,7 @@ sk_sp<sksg::RenderNode> AnimationBuilder::attachShape(const skjson::ArrayValue*
|
||||
}
|
||||
} break;
|
||||
case ShapeType::kPaint: {
|
||||
SkASSERT(rec->fInfo.fAttacherIndex < SK_ARRAY_COUNT(gPaintAttachers));
|
||||
SkASSERT(rec->fInfo.fAttacherIndex < std::size(gPaintAttachers));
|
||||
auto paint = gPaintAttachers[rec->fInfo.fAttacherIndex](rec->fJson, this);
|
||||
if (!paint || geos.empty() || rec->fSuppressed)
|
||||
break;
|
||||
@ -282,7 +282,7 @@ sk_sp<sksg::RenderNode> AnimationBuilder::attachShape(const skjson::ArrayValue*
|
||||
}
|
||||
|
||||
// Apply local paint geometry adjustments (e.g. dashing).
|
||||
SkASSERT(rec->fInfo.fAttacherIndex < SK_ARRAY_COUNT(gPaintGeometryAdjusters));
|
||||
SkASSERT(rec->fInfo.fAttacherIndex < std::size(gPaintGeometryAdjusters));
|
||||
if (const auto adjuster = gPaintGeometryAdjusters[rec->fInfo.fAttacherIndex]) {
|
||||
drawGeos = adjuster(rec->fJson, this, std::move(drawGeos));
|
||||
}
|
||||
@ -297,7 +297,7 @@ sk_sp<sksg::RenderNode> AnimationBuilder::attachShape(const skjson::ArrayValue*
|
||||
ctx->fCommittedAnimators = fCurrentAnimatorScope->size();
|
||||
} break;
|
||||
case ShapeType::kDrawEffect: {
|
||||
SkASSERT(rec->fInfo.fAttacherIndex < SK_ARRAY_COUNT(gDrawEffectAttachers));
|
||||
SkASSERT(rec->fInfo.fAttacherIndex < std::size(gDrawEffectAttachers));
|
||||
if (!draws.empty()) {
|
||||
draws = gDrawEffectAttachers[rec->fInfo.fAttacherIndex](rec->fJson,
|
||||
this,
|
||||
|
@ -81,7 +81,7 @@ std::vector<sk_sp<sksg::GeometryNode>> ShapeBuilder::AttachTrimGeometryEffect(
|
||||
} gModes[] = { Mode::kParallel, Mode::kSerial};
|
||||
|
||||
const auto mode = gModes[std::min<size_t>(ParseDefault<size_t>(jtrim["m"], 1) - 1,
|
||||
SK_ARRAY_COUNT(gModes) - 1)];
|
||||
std::size(gModes) - 1)];
|
||||
|
||||
std::vector<sk_sp<sksg::GeometryNode>> inputs;
|
||||
if (mode == Mode::kSerial) {
|
||||
|
@ -28,7 +28,7 @@ T ParseEnum(const TArray& arr, const skjson::Value& jenum,
|
||||
|
||||
const auto idx = ParseDefault<int>(jenum, 1);
|
||||
|
||||
if (idx > 0 && SkToSizeT(idx) <= SK_ARRAY_COUNT(arr)) {
|
||||
if (idx > 0 && SkToSizeT(idx) <= std::size(arr)) {
|
||||
return arr[idx - 1];
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ T ParseEnum(const TArray& arr, const skjson::Value& jenum,
|
||||
"Ignoring unknown range selector %s '%d'", warn_name, idx);
|
||||
}
|
||||
|
||||
static_assert(SK_ARRAY_COUNT(arr) > 0, "");
|
||||
SkASSERT(std::size(arr) > 0);
|
||||
return arr[0];
|
||||
}
|
||||
|
||||
@ -363,7 +363,7 @@ void RangeSelector::modulateCoverage(const TextAnimator::DomainMaps& maps,
|
||||
auto r0 = std::get<0>(range),
|
||||
len = std::max(std::get<1>(range) - r0, std::numeric_limits<float>::epsilon());
|
||||
|
||||
SkASSERT(static_cast<size_t>(fShape) < SK_ARRAY_COUNT(gShapeInfo));
|
||||
SkASSERT(static_cast<size_t>(fShape) < std::size(gShapeInfo));
|
||||
ShapeGenerator gen(gShapeInfo[static_cast<size_t>(fShape)], ease_lo, ease_hi);
|
||||
|
||||
if (fShape == Shape::kSquare) {
|
||||
|
@ -216,7 +216,7 @@ sk_sp<TextAdapter> TextAdapter::Make(const skjson::ObjectValue& jlayer,
|
||||
AnchorPointGrouping::kAll, // 'g': 4
|
||||
};
|
||||
const auto apg = jm
|
||||
? SkTPin<int>(ParseDefault<int>((*jm)["g"], 1), 1, SK_ARRAY_COUNT(gGroupingMap))
|
||||
? SkTPin<int>(ParseDefault<int>((*jm)["g"], 1), 1, std::size(gGroupingMap))
|
||||
: 1;
|
||||
|
||||
auto adapter = sk_sp<TextAdapter>(new TextAdapter(std::move(fontmgr),
|
||||
|
@ -46,7 +46,7 @@ bool Parse(const skjson::Value& jv, const internal::AnimationBuilder& abuilder,
|
||||
SkTextUtils::kCenter_Align // 'j': 2
|
||||
};
|
||||
v->fHAlign = gAlignMap[std::min<size_t>(ParseDefault<size_t>((*jtxt)["j"], 0),
|
||||
SK_ARRAY_COUNT(gAlignMap) - 1)];
|
||||
std::size(gAlignMap) - 1)];
|
||||
|
||||
// Optional text box size.
|
||||
if (const skjson::ArrayValue* jsz = (*jtxt)["sz"]) {
|
||||
@ -72,7 +72,7 @@ bool Parse(const skjson::Value& jv, const internal::AnimationBuilder& abuilder,
|
||||
// TODO: remove "sk_rs" support after migrating clients.
|
||||
v->fResize = gResizeMap[std::min(std::max(ParseDefault<size_t>((*jtxt)[ "rs"], 0),
|
||||
ParseDefault<size_t>((*jtxt)["sk_rs"], 0)),
|
||||
SK_ARRAY_COUNT(gResizeMap) - 1)];
|
||||
std::size(gResizeMap) - 1)];
|
||||
|
||||
// Optional min/max font size and line count (used when aute-resizing)
|
||||
v->fMinTextSize = ParseDefault<SkScalar>((*jtxt)["mf"], 0.0f);
|
||||
@ -100,7 +100,7 @@ bool Parse(const skjson::Value& jv, const internal::AnimationBuilder& abuilder,
|
||||
Shaper::Capitalization::kUpperCase, // 'ca': 1
|
||||
};
|
||||
v->fCapitalization = gCapMap[std::min<size_t>(ParseDefault<size_t>((*jtxt)["ca"], 0),
|
||||
SK_ARRAY_COUNT(gCapMap) - 1)];
|
||||
std::size(gCapMap) - 1)];
|
||||
|
||||
// In point mode, the text is baseline-aligned.
|
||||
v->fVAlign = v->fBox.isEmpty() ? Shaper::VAlign::kTopBaseline
|
||||
@ -114,7 +114,7 @@ bool Parse(const skjson::Value& jv, const internal::AnimationBuilder& abuilder,
|
||||
size_t vj;
|
||||
if (skottie::Parse((*jtxt)[ "vj"], &vj) ||
|
||||
skottie::Parse((*jtxt)["sk_vj"], &vj)) { // TODO: remove after migrating clients.
|
||||
if (vj < SK_ARRAY_COUNT(gVAlignMap)) {
|
||||
if (vj < std::size(gVAlignMap)) {
|
||||
v->fVAlign = gVAlignMap[vj];
|
||||
} else {
|
||||
// Legacy sk_vj values.
|
||||
@ -168,7 +168,7 @@ bool Parse(const skjson::Value& jv, const internal::AnimationBuilder& abuilder,
|
||||
SkPaint::kBevel_Join, // lj: 3
|
||||
};
|
||||
v->fStrokeJoin = gJoins[std::min<size_t>(ParseDefault<size_t>((*jtxt)["lj"], 1) - 1,
|
||||
SK_ARRAY_COUNT(gJoins) - 1)];
|
||||
std::size(gJoins) - 1)];
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -80,7 +80,7 @@ struct Timer {
|
||||
|
||||
static constexpr float kFontSize = 18;
|
||||
static const char* kTypefaces[3] = {"sans-serif", "serif", "monospace"};
|
||||
static constexpr size_t kTypefaceCount = SK_ARRAY_COUNT(kTypefaces);
|
||||
static constexpr size_t kTypefaceCount = std::size(kTypefaces);
|
||||
|
||||
static constexpr SkFontStyle::Weight kFontWeight = SkFontStyle::kNormal_Weight;
|
||||
static constexpr SkFontStyle::Width kFontWidth = SkFontStyle::kNormal_Width;
|
||||
|
@ -287,7 +287,7 @@ static sk_sp<SkData> decode_datauri(const char prefix[], const char uri[]) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* b64Data = encoding + SK_ARRAY_COUNT(kDataURIEncodingStr) - 1;
|
||||
const char* b64Data = encoding + std::size(kDataURIEncodingStr) - 1;
|
||||
size_t b64DataLen = strlen(b64Data);
|
||||
size_t dataLen;
|
||||
if (SkBase64::Decode(b64Data, b64DataLen, nullptr, &dataLen) != SkBase64::kNoError) {
|
||||
|
@ -141,7 +141,7 @@ private:
|
||||
|
||||
template <typename T, typename TArray>
|
||||
bool parseEnumMap(const TArray& arr, T* result) {
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(arr); ++i) {
|
||||
for (size_t i = 0; i < std::size(arr); ++i) {
|
||||
if (this->parseExpectedStringToken(std::get<0>(arr[i]))) {
|
||||
*result = std::get<1>(arr[i]);
|
||||
return true;
|
||||
|
@ -229,7 +229,7 @@ bool SkSVGAttributeParser::parseLengthUnitToken(SkSVGLength::Unit* unit) {
|
||||
{ "pc", SkSVGLength::Unit::kPC },
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(gUnitInfo); ++i) {
|
||||
for (size_t i = 0; i < std::size(gUnitInfo); ++i) {
|
||||
if (this->parseExpectedStringToken(gUnitInfo[i].fUnitName)) {
|
||||
*unit = gUnitInfo[i].fUnit;
|
||||
return true;
|
||||
@ -745,7 +745,7 @@ bool SkSVGAttributeParser::parse(SkSVGLineCap* cap) {
|
||||
};
|
||||
|
||||
bool parsedValue = false;
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(gCapInfo); ++i) {
|
||||
for (size_t i = 0; i < std::size(gCapInfo); ++i) {
|
||||
if (this->parseExpectedStringToken(gCapInfo[i].fName)) {
|
||||
*cap = SkSVGLineCap(gCapInfo[i].fType);
|
||||
parsedValue = true;
|
||||
@ -770,7 +770,7 @@ bool SkSVGAttributeParser::parse(SkSVGLineJoin* join) {
|
||||
};
|
||||
|
||||
bool parsedValue = false;
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(gJoinInfo); ++i) {
|
||||
for (size_t i = 0; i < std::size(gJoinInfo); ++i) {
|
||||
if (this->parseExpectedStringToken(gJoinInfo[i].fName)) {
|
||||
*join = SkSVGLineJoin(gJoinInfo[i].fType);
|
||||
parsedValue = true;
|
||||
@ -859,7 +859,7 @@ bool SkSVGAttributeParser::parse(SkSVGFillRule* fillRule) {
|
||||
};
|
||||
|
||||
bool parsedValue = false;
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(gFillRuleInfo); ++i) {
|
||||
for (size_t i = 0; i < std::size(gFillRuleInfo); ++i) {
|
||||
if (this->parseExpectedStringToken(gFillRuleInfo[i].fName)) {
|
||||
*fillRule = SkSVGFillRule(gFillRuleInfo[i].fType);
|
||||
parsedValue = true;
|
||||
|
@ -291,7 +291,7 @@ bool set_string_attribute(const sk_sp<SkSVGNode>& node, const char* name, const
|
||||
}
|
||||
|
||||
const int attrIndex = SkStrSearch(&gAttributeParseInfo[0].fKey,
|
||||
SkTo<int>(SK_ARRAY_COUNT(gAttributeParseInfo)),
|
||||
SkTo<int>(std::size(gAttributeParseInfo)),
|
||||
name, sizeof(gAttributeParseInfo[0]));
|
||||
if (attrIndex < 0) {
|
||||
#if defined(SK_VERBOSE_SVG_PARSING)
|
||||
@ -300,7 +300,7 @@ bool set_string_attribute(const sk_sp<SkSVGNode>& node, const char* name, const
|
||||
return false;
|
||||
}
|
||||
|
||||
SkASSERT(SkTo<size_t>(attrIndex) < SK_ARRAY_COUNT(gAttributeParseInfo));
|
||||
SkASSERT(SkTo<size_t>(attrIndex) < std::size(gAttributeParseInfo));
|
||||
const auto& attrInfo = gAttributeParseInfo[attrIndex].fValue;
|
||||
if (!attrInfo.fSetter(node, attrInfo.fAttr, value)) {
|
||||
#if defined(SK_VERBOSE_SVG_PARSING)
|
||||
@ -351,7 +351,7 @@ sk_sp<SkSVGNode> construct_svg_node(const SkDOM& dom, const ConstructionContext&
|
||||
}
|
||||
|
||||
const int tagIndex = SkStrSearch(&gTagFactories[0].fKey,
|
||||
SkTo<int>(SK_ARRAY_COUNT(gTagFactories)),
|
||||
SkTo<int>(std::size(gTagFactories)),
|
||||
elem, sizeof(gTagFactories[0]));
|
||||
if (tagIndex < 0) {
|
||||
#if defined(SK_VERBOSE_SVG_PARSING)
|
||||
@ -359,7 +359,7 @@ sk_sp<SkSVGNode> construct_svg_node(const SkDOM& dom, const ConstructionContext&
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
SkASSERT(SkTo<size_t>(tagIndex) < SK_ARRAY_COUNT(gTagFactories));
|
||||
SkASSERT(SkTo<size_t>(tagIndex) < std::size(gTagFactories));
|
||||
|
||||
return gTagFactories[tagIndex].fValue();
|
||||
};
|
||||
|
@ -109,7 +109,7 @@ bool SkSVGAttributeParser::parse(SkSVGSpreadMethod* spread) {
|
||||
};
|
||||
|
||||
bool parsedValue = false;
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(gSpreadInfo); ++i) {
|
||||
for (size_t i = 0; i < std::size(gSpreadInfo); ++i) {
|
||||
if (this->parseExpectedStringToken(gSpreadInfo[i].fName)) {
|
||||
*spread = SkSVGSpreadMethod(gSpreadInfo[i].fType);
|
||||
parsedValue = true;
|
||||
|
@ -162,8 +162,8 @@ SkMatrix SkSVGNode::ComputeViewboxMatrix(const SkRect& viewBox,
|
||||
const size_t x_coeff = par.fAlign >> 0 & 0x03,
|
||||
y_coeff = par.fAlign >> 2 & 0x03;
|
||||
|
||||
SkASSERT(x_coeff < SK_ARRAY_COUNT(gAlignCoeffs) &&
|
||||
y_coeff < SK_ARRAY_COUNT(gAlignCoeffs));
|
||||
SkASSERT(x_coeff < std::size(gAlignCoeffs) &&
|
||||
y_coeff < std::size(gAlignCoeffs));
|
||||
|
||||
const auto tx = -viewBox.x() * scale.x,
|
||||
ty = -viewBox.y() * scale.y,
|
||||
|
@ -56,7 +56,7 @@ private:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* b64Data = encoding + SK_ARRAY_COUNT(kDataURIEncodingStr) - 1;
|
||||
const char* b64Data = encoding + std::size(kDataURIEncodingStr) - 1;
|
||||
size_t b64DataLen = strlen(b64Data);
|
||||
size_t dataLen;
|
||||
if (SkBase64::Decode(b64Data, b64DataLen, nullptr, &dataLen) != SkBase64::kNoError) {
|
||||
|
Loading…
Reference in New Issue
Block a user