Debian Codegraph @

src/sksl/SkSLIntrinsicList.cpp

raw
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
8 #include "src/base/SkNoDestructor.h"
9 #include "src/base/SkStringView.h"
10 #include "src/sksl/SkSLIntrinsicList.h"
11
12 using namespace skia_private;
13
14 namespace SkSL {
15
16 const IntrinsicMap& GetIntrinsicMap() {
17 #define SKSL_INTRINSIC(name) {#name, k_##name##_IntrinsicKind},
18 static const SkNoDestructor<IntrinsicMap> kAllIntrinsics(IntrinsicMap{
19 SKSL_INTRINSIC_LIST
20 });
21 #undef SKSL_INTRINSIC
22
23 return *kAllIntrinsics;
24 }
25
26 IntrinsicKind 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