Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkSLIntrinsicList.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2021 Google LLC.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
11
12using namespace skia_private;
13
14namespace SkSL {
15
17 #define SKSL_INTRINSIC(name) {#name, k_##name##_IntrinsicKind},
18 static const SkNoDestructor<IntrinsicMap> kAllIntrinsics(IntrinsicMap{
20 });
21 #undef SKSL_INTRINSIC
22
23 return *kAllIntrinsics;
24}
25
26IntrinsicKind FindIntrinsicKind(std::string_view functionName) {
27 if (skstd::starts_with(functionName, '$')) {
28 functionName.remove_prefix(1);
29 }
30
31 const IntrinsicMap& intrinsicMap = GetIntrinsicMap();
32 IntrinsicKind* kind = intrinsicMap.find(functionName);
33 return kind ? *kind : kNotIntrinsic;
34}
35
36} // namespace SkSL
V * find(const K &key) const
Definition SkTHash.h:479
const IntrinsicMap & GetIntrinsicMap()
@ SKSL_INTRINSIC_LIST
IntrinsicKind FindIntrinsicKind(std::string_view functionName)
constexpr bool starts_with(std::string_view str, std::string_view prefix)