xref: /aosp_15_r20/external/skia/src/sksl/SkSLDefines.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2019 Google Inc.
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 #ifndef SKSL_DEFINES
9 #define SKSL_DEFINES
10 
11 #include <cstdint>
12 
13 #include "include/core/SkTypes.h"
14 #include "include/private/base/SkTArray.h"
15 
16 using SKSL_INT = int64_t;
17 using SKSL_FLOAT = float;
18 
19 namespace SkSL {
20 
21 class Expression;
22 class Statement;
23 
24 class ExpressionArray : public skia_private::STArray<2, std::unique_ptr<Expression>> {
25 public:
26     using STArray::STArray;
27 
28     /** Returns a new ExpressionArray containing a clone of every element. */
29     ExpressionArray clone() const;
30 };
31 
32 using StatementArray = skia_private::STArray<2, std::unique_ptr<Statement>>;
33 
34 // Functions larger than this (measured in IR nodes) will not be inlined. This growth factor
35 // accounts for the number of calls being inlined--i.e., a function called five times (that is, with
36 // five inlining opportunities) would be considered 5x larger than if it were called once. This
37 // default threshold value is arbitrary, but tends to work well in practice.
38 static constexpr int kDefaultInlineThreshold = 50;
39 
40 // A hard upper limit on the number of variable slots allowed in a function/global scope.
41 // This is an arbitrary limit, but is needed to prevent code generation from taking unbounded
42 // amounts of time or space.
43 static constexpr int kVariableSlotLimit = 100000;
44 
45 }  // namespace SkSL
46 
47 #endif
48