2019-01-22 15:59:11 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2019 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SKSL_DEFINES
|
|
|
|
#define SKSL_DEFINES
|
2019-06-19 15:40:33 +00:00
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkTypes.h"
|
2021-03-04 19:30:25 +00:00
|
|
|
#include "include/private/SkTArray.h"
|
2019-01-22 15:59:11 +00:00
|
|
|
|
2020-12-11 20:00:07 +00:00
|
|
|
#if defined(SK_BUILD_FOR_IOS) && \
|
|
|
|
(!defined(__IPHONE_9_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_9_0)
|
2020-12-01 18:38:32 +00:00
|
|
|
#define SKSL_USE_THREAD_LOCAL 0
|
|
|
|
#else
|
|
|
|
#define SKSL_USE_THREAD_LOCAL 1
|
|
|
|
#endif
|
|
|
|
|
2020-12-29 14:47:20 +00:00
|
|
|
using SKSL_INT = int64_t;
|
2019-06-19 15:40:33 +00:00
|
|
|
using SKSL_FLOAT = float;
|
|
|
|
|
2021-02-02 23:35:09 +00:00
|
|
|
namespace SkSL {
|
2021-02-18 21:06:17 +00:00
|
|
|
|
2021-03-04 19:30:25 +00:00
|
|
|
class Expression;
|
|
|
|
class Statement;
|
|
|
|
|
|
|
|
using ComponentArray = SkSTArray<4, int8_t>; // for Swizzles
|
|
|
|
using ExpressionArray = SkSTArray<2, std::unique_ptr<Expression>>;
|
|
|
|
using StatementArray = SkSTArray<2, std::unique_ptr<Statement>>;
|
|
|
|
|
2021-02-02 23:35:09 +00:00
|
|
|
// Functions larger than this (measured in IR nodes) will not be inlined. This growth factor
|
|
|
|
// accounts for the number of calls being inlined--i.e., a function called five times (that is, with
|
|
|
|
// five inlining opportunities) would be considered 5x larger than if it were called once. This
|
|
|
|
// default threshold value is arbitrary, but tends to work well in practice.
|
|
|
|
static constexpr int kDefaultInlineThreshold = 50;
|
2021-02-18 21:06:17 +00:00
|
|
|
|
|
|
|
// The SwizzleComponent namespace is used both by the SkSL::Swizzle expression, and the DSL swizzle.
|
|
|
|
// This namespace is injected into SkSL::dsl so that `using namespace SkSL::dsl` enables DSL code
|
|
|
|
// like `Swizzle(var, X, Y, ONE)` to compile without any extra qualifications.
|
|
|
|
namespace SwizzleComponent {
|
|
|
|
|
|
|
|
enum Type : int8_t {
|
|
|
|
X = 0, Y = 1, Z = 2, W = 3,
|
|
|
|
R = 0, G = 1, B = 2, A = 3,
|
|
|
|
ZERO,
|
|
|
|
ONE
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace SwizzleComponent
|
|
|
|
} // namespace SkSL
|
2021-02-02 23:35:09 +00:00
|
|
|
|
2019-01-22 15:59:11 +00:00
|
|
|
#endif
|