31template <
typename T,
typename TArray>
33 const AnimationBuilder* abuilder,
const char* warn_name) {
35 const auto idx = ParseDefault<int>(jenum, 1);
45 "Ignoring unknown range selector %s '%d'", warn_name, idx);
52template <RangeSelector::Units>
56struct UnitTraits<RangeSelector::Units::kPercentage> {
57 static constexpr auto Defaults() {
58 return std::make_tuple<float, float, float>(0, 100, 0);
61 static auto Resolve(
float s,
float e,
float o,
size_t domain_size) {
62 return std::make_tuple(domain_size * (
s + o) / 100,
63 domain_size * (
e + o) / 100);
68struct UnitTraits<RangeSelector::Units::kIndex> {
69 static constexpr auto Defaults() {
74 static auto Resolve(
float s,
float e,
float o,
size_t domain_size) {
75 return std::make_tuple(
s + o,
e + o);
79class CoverageProcessor {
81 CoverageProcessor(
const TextAnimator::DomainMaps& maps,
89 fProc = &CoverageProcessor::add_proc;
96 fMap = &maps.fNonWhitespaceMap;
99 fMap = &maps.fWordsMap;
102 fMap = &maps.fLinesMap;
110 fProc = &CoverageProcessor::domain_map_proc;
111 fDomainSize = fMap->size();
115 size_t size()
const {
return fDomainSize; }
117 void operator()(
float amount,
size_t offset,
size_t count)
const {
123 void add_proc(
float amount,
size_t offset,
size_t count)
const {
124 if (!amount || !
count)
return;
127 dst->coverage = SkTPin<float>(
dst->coverage + amount, -1, 1);
132 void domain_map_proc(
float amount,
size_t offset,
size_t count)
const {
137 const auto& span = (*fMap)[
i];
138 (this->*fMappedProc)(amount, span.fOffset, span.fCount);
142 using ProcT = void(CoverageProcessor::*)(
float amount,
size_t offset,
size_t count)
const;
146 fMappedProc =
nullptr;
207struct ShapeGenerator {
212 ShapeGenerator(
const ShapeInfo& sinfo,
float ease_lo,
float ease_hi)
219 float operator()(
float t)
const {
228static constexpr ShapeInfo gShapeInfo[] = {
229 { {0 ,0 }, {1 ,1}, 0 , 1 , 0.0f },
232 { {0 ,0 }, {1 ,1}, 0 , 1 , 0.5f },
233 { {0 ,.5f}, {.5f,1}, 0 , 1 , 0.5f },
234 { {.5f,0 }, {.5f,1}, 0 , 1 , 0.5f },
247 kRange_SelectorType = 0,
248 kExpression_SelectorType = 1,
254 const auto type = ParseDefault<int>((*jrange)[
"t"], kRange_SelectorType);
255 if (
type != kRange_SelectorType) {
257 "Ignoring unsupported selector type '%d'",
type);
262 static constexpr Units gUnitMap[] = {
267 static constexpr Domain gDomainMap[] = {
274 static constexpr Mode gModeMap[] = {
278 static constexpr Shape gShapeMap[] = {
288 new RangeSelector(ParseEnum<Units> (gUnitMap , (*jrange)[
"r" ], abuilder,
"units" ),
289 ParseEnum<Domain>(gDomainMap, (*jrange)[
"b" ], abuilder,
"domain"),
290 ParseEnum<Mode> (gModeMap , (*jrange)[
"m" ], abuilder,
"mode" ),
291 ParseEnum<Shape> (gShapeMap , (*jrange)[
"sh"], abuilder,
"shape" )));
293 acontainer->
bind(*abuilder, (*jrange)[
"s" ], &selector->fStart );
294 acontainer->
bind(*abuilder, (*jrange)[
"e" ], &selector->fEnd );
295 acontainer->
bind(*abuilder, (*jrange)[
"o" ], &selector->fOffset);
296 acontainer->
bind(*abuilder, (*jrange)[
"a" ], &selector->fAmount);
297 acontainer->
bind(*abuilder, (*jrange)[
"ne"], &selector->fEaseLo);
298 acontainer->
bind(*abuilder, (*jrange)[
"xe"], &selector->fEaseHi);
302 acontainer->
bind(*abuilder, (*jrange)[
"sm" ], &selector->fSmoothness);
308RangeSelector::RangeSelector(Units u, Domain
d,
Mode m,
Shape sh)
317 std::tie(fStart, fEnd, fOffset) = UnitTraits<Units::kPercentage>::Defaults();
320 std::tie(fStart, fEnd, fOffset) = UnitTraits<Units::kIndex >::Defaults();
325std::tuple<float, float> RangeSelector::resolve(
size_t len)
const {
333 std::tie(f_i0, f_i1) = resolver(fStart, fEnd, fOffset,
len);
338 return std::make_tuple(f_i0, f_i1);
357 const CoverageProcessor coverage_proc(maps, fDomain, fMode, mbuf);
358 if (coverage_proc.size() == 0) {
363 const auto amount = SkTPin<float>(fAmount / 100, -1, 1),
364 ease_lo = SkTPin<float>(fEaseLo / 100, -1, 1),
365 ease_hi = SkTPin<float>(fEaseHi / 100, -1, 1);
368 const auto range = this->resolve(coverage_proc.size());
373 ShapeGenerator
gen(gShapeInfo[
static_cast<size_t>(fShape)], ease_lo, ease_hi);
382 const auto smoothness = SkTPin<float>(fSmoothness / 100, 0, 1);
384 r0 -= smoothness / 2;
387 gen.crs += smoothness /
len;
391 const auto dt = 1 /
len;
392 auto t = (0.5f - r0) /
len;
394 for (
size_t i = 0;
i < coverage_proc.size(); ++
i, t += dt) {
395 coverage_proc(amount *
gen(t),
i, 1);
constexpr float SK_FloatInfinity
static constexpr float sk_ieee_float_divide(float numer, float denom)
constexpr float SK_FloatNegativeInfinity
void swap(sk_sp< T > &a, sk_sp< T > &b)
constexpr size_t SkToSizeT(S x)
float computeYFromX(float x) const
bool bind(const AnimationBuilder &, const skjson::ObjectValue *, T *)
void log(Logger::Level, const skjson::Value *, const char fmt[],...) const SK_PRINTF_LIKE(4
static sk_sp< RangeSelector > Make(const skjson::ObjectValue *, const AnimationBuilder *, AnimatablePropertyContainer *)
void modulateCoverage(const TextAnimator::DomainMaps &, TextAnimator::ModulatorBuffer &) const
std::vector< DomainSpan > DomainMap
std::vector< AnimatedPropsModulator > ModulatorBuffer
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
static float max(float r, float g, float b)
static float min(float r, float g, float b)
static FunctionPtr Resolve(Thread *thread, Zone *zone, const GrowableArray< const Instance * > &caller_arguments, const Class &receiver_class, const String &name, const Array &descriptor)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
const myers::Point & get< 1 >(const myers::Segment &s)
const myers::Point & get< 0 >(const myers::Segment &s)