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/SkTArray.h"
15 
16 #if defined(SK_BUILD_FOR_IOS) && \
17         (!defined(__IPHONE_9_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_9_0)
18 #define SKSL_USE_THREAD_LOCAL 0
19 #else
20 #define SKSL_USE_THREAD_LOCAL 1
21 #endif
22 
23 using SKSL_INT = int64_t;
24 using SKSL_FLOAT = float;
25 
26 namespace SkSL {
27 
28 class Expression;
29 class Statement;
30 
31 using ComponentArray = SkSTArray<4, int8_t>; // for Swizzles
32 using ExpressionArray = SkSTArray<2, std::unique_ptr<Expression>>;
33 using StatementArray = SkSTArray<2, std::unique_ptr<Statement>>;
34 
35 // Functions larger than this (measured in IR nodes) will not be inlined. This growth factor
36 // accounts for the number of calls being inlined--i.e., a function called five times (that is, with
37 // five inlining opportunities) would be considered 5x larger than if it were called once. This
38 // default threshold value is arbitrary, but tends to work well in practice.
39 static constexpr int kDefaultInlineThreshold = 50;
40 
41 // The SwizzleComponent namespace is used both by the SkSL::Swizzle expression, and the DSL swizzle.
42 // This namespace is injected into SkSL::dsl so that `using namespace SkSL::dsl` enables DSL code
43 // like `Swizzle(var, X, Y, ONE)` to compile without any extra qualifications.
44 namespace SwizzleComponent {
45 
46 enum Type : int8_t {
47     X = 0, Y = 1, Z = 2, W = 3,
48     R = 0, G = 1, B = 2, A = 3,
49     ZERO,
50     ONE
51 };
52 
53 }  // namespace SwizzleComponent
54 }  // namespace SkSL
55 
56 #endif
57