2021-01-07 15:57:27 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2020 Google LLC
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SKSL_DSL_CORE
|
|
|
|
#define SKSL_DSL_CORE
|
|
|
|
|
2022-03-18 20:40:58 +00:00
|
|
|
#include "include/private/SkSLDefines.h"
|
2021-04-09 19:33:53 +00:00
|
|
|
#include "include/private/SkSLProgramKind.h"
|
2021-02-09 20:22:57 +00:00
|
|
|
#include "include/private/SkTArray.h"
|
2021-03-04 19:30:25 +00:00
|
|
|
#include "include/sksl/DSLCase.h"
|
|
|
|
#include "include/sksl/DSLExpression.h"
|
|
|
|
#include "include/sksl/DSLStatement.h"
|
|
|
|
#include "include/sksl/DSLVar.h"
|
2022-03-18 20:40:58 +00:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include <string_view>
|
|
|
|
#include <utility>
|
2021-01-07 15:57:27 +00:00
|
|
|
|
|
|
|
namespace SkSL {
|
|
|
|
|
|
|
|
class Compiler;
|
2022-03-18 20:40:58 +00:00
|
|
|
class ErrorReporter;
|
2022-04-08 15:37:08 +00:00
|
|
|
class Position;
|
2021-06-15 13:17:05 +00:00
|
|
|
struct Program;
|
2021-05-18 14:12:58 +00:00
|
|
|
struct ProgramSettings;
|
2021-01-07 15:57:27 +00:00
|
|
|
|
|
|
|
namespace dsl {
|
|
|
|
|
2022-03-18 20:40:58 +00:00
|
|
|
class DSLField;
|
2022-03-28 13:55:27 +00:00
|
|
|
class DSLModifiers;
|
2022-03-18 20:40:58 +00:00
|
|
|
|
2021-02-18 21:06:17 +00:00
|
|
|
// When users import the DSL namespace via `using namespace SkSL::dsl`, we want the SwizzleComponent
|
|
|
|
// Type enum to come into scope as well, so `Swizzle(var, X, Y, ONE)` can work as expected.
|
|
|
|
// `namespace SkSL::SwizzleComponent` contains only an `enum Type`; this `using namespace` directive
|
|
|
|
// shouldn't pollute the SkSL::dsl namespace with anything else.
|
|
|
|
using namespace SkSL::SwizzleComponent;
|
|
|
|
|
2021-01-07 15:57:27 +00:00
|
|
|
/**
|
|
|
|
* Starts DSL output on the current thread using the specified compiler. This must be called
|
2021-01-08 16:42:25 +00:00
|
|
|
* prior to any other DSL functions.
|
2021-01-07 15:57:27 +00:00
|
|
|
*/
|
2021-05-18 14:12:58 +00:00
|
|
|
void Start(SkSL::Compiler* compiler, SkSL::ProgramKind kind = SkSL::ProgramKind::kFragment);
|
|
|
|
|
|
|
|
void Start(SkSL::Compiler* compiler, SkSL::ProgramKind kind, const SkSL::ProgramSettings& settings);
|
2021-01-07 15:57:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Signals the end of DSL output. This must be called sometime between a call to Start() and the
|
|
|
|
* termination of the thread.
|
|
|
|
*/
|
|
|
|
void End();
|
|
|
|
|
2021-06-15 13:17:05 +00:00
|
|
|
/**
|
2021-07-16 13:53:53 +00:00
|
|
|
* Returns all global elements (functions and global variables) as a self-contained Program. The
|
|
|
|
* optional source string is retained as the program's source. DSL programs do not normally have
|
|
|
|
* sources, but when a DSL program is produced from parsed program text (as in DSLParser), it may be
|
2022-02-01 20:31:57 +00:00
|
|
|
* important to retain it so that any std::string_views derived from it remain valid.
|
2021-06-15 13:17:05 +00:00
|
|
|
*/
|
2022-02-02 21:51:18 +00:00
|
|
|
std::unique_ptr<SkSL::Program> ReleaseProgram(std::unique_ptr<std::string> source = nullptr);
|
2021-06-15 13:17:05 +00:00
|
|
|
|
2021-08-05 18:53:02 +00:00
|
|
|
/**
|
2021-08-13 21:29:51 +00:00
|
|
|
* Returns the ErrorReporter which will be notified of any errors that occur during DSL calls. The
|
|
|
|
* default error reporter aborts on any error.
|
2021-08-05 18:53:02 +00:00
|
|
|
*/
|
2021-08-13 21:29:51 +00:00
|
|
|
ErrorReporter& GetErrorReporter();
|
2021-08-05 18:53:02 +00:00
|
|
|
|
2021-01-26 17:00:25 +00:00
|
|
|
/**
|
2021-08-13 21:29:51 +00:00
|
|
|
* Installs an ErrorReporter which will be notified of any errors that occur during DSL calls.
|
2021-01-26 17:00:25 +00:00
|
|
|
*/
|
2021-08-13 21:29:51 +00:00
|
|
|
void SetErrorReporter(ErrorReporter* errorReporter);
|
2021-01-26 17:00:25 +00:00
|
|
|
|
Broke DSLVar into separate subclasses
Previously, DSLVar represented local, global, and parameter variables.
This splits it into three separate subclasses.
In addition to just being a cleaner API in general, this also addresses
an issue we ran into with the upcoming DSLParser: previously, a global
DSLVar's storage was not set correctly until DeclareGlobal was called,
so an AddToSymbolTable call prior to DeclareGlobal would create the
SkSL variable with the wrong storage, causing spurious errors on
global-only modifiers. But holding off on the AddToSymbolTable tends to
break constructs like "int x = 0, y = x", so improving the API seemed
like the best way to address it.
Now that we have greater type safety around variables, we can
potentially avoid having to call AddToSymbolTable for DSLVar and
DSLGlobalVar altogether, since we know they are both supposed to end up
in the symbol table, but that isn't something I want to change in this
CL.
Change-Id: I5f390a7384ce0af6a2131d84f97fc5e5b318063f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/428576
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-07-15 14:35:54 +00:00
|
|
|
DSLGlobalVar sk_FragColor();
|
2021-01-28 15:02:43 +00:00
|
|
|
|
Broke DSLVar into separate subclasses
Previously, DSLVar represented local, global, and parameter variables.
This splits it into three separate subclasses.
In addition to just being a cleaner API in general, this also addresses
an issue we ran into with the upcoming DSLParser: previously, a global
DSLVar's storage was not set correctly until DeclareGlobal was called,
so an AddToSymbolTable call prior to DeclareGlobal would create the
SkSL variable with the wrong storage, causing spurious errors on
global-only modifiers. But holding off on the AddToSymbolTable tends to
break constructs like "int x = 0, y = x", so improving the API seemed
like the best way to address it.
Now that we have greater type safety around variables, we can
potentially avoid having to call AddToSymbolTable for DSLVar and
DSLGlobalVar altogether, since we know they are both supposed to end up
in the symbol table, but that isn't something I want to change in this
CL.
Change-Id: I5f390a7384ce0af6a2131d84f97fc5e5b318063f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/428576
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-07-15 14:35:54 +00:00
|
|
|
DSLGlobalVar sk_FragCoord();
|
2021-01-28 15:02:43 +00:00
|
|
|
|
2021-07-09 19:35:23 +00:00
|
|
|
DSLExpression sk_Position();
|
|
|
|
|
2021-09-03 15:10:54 +00:00
|
|
|
/**
|
|
|
|
* #extension <name> : enable
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
void AddExtension(std::string_view name, Position pos = {});
|
2021-09-03 15:10:54 +00:00
|
|
|
|
2021-02-05 19:22:32 +00:00
|
|
|
/**
|
|
|
|
* break;
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLStatement Break(Position pos = {});
|
2021-02-05 19:22:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* continue;
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLStatement Continue(Position pos = {});
|
2021-02-05 19:22:32 +00:00
|
|
|
|
2021-09-03 10:33:47 +00:00
|
|
|
/**
|
|
|
|
* Adds a modifiers declaration to the current program.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
void Declare(const DSLModifiers& modifiers, Position pos = {});
|
2021-09-03 10:33:47 +00:00
|
|
|
|
2021-01-22 20:18:25 +00:00
|
|
|
/**
|
2021-06-15 13:17:05 +00:00
|
|
|
* Creates a local variable declaration statement.
|
2021-01-22 20:18:25 +00:00
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLStatement Declare(DSLVar& var, Position pos = {});
|
2021-04-30 17:14:24 +00:00
|
|
|
|
2021-07-19 16:55:52 +00:00
|
|
|
/**
|
|
|
|
* Creates a local variable declaration statement containing multiple variables.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLStatement Declare(SkTArray<DSLVar>& vars, Position pos = {});
|
2021-07-19 16:55:52 +00:00
|
|
|
|
2021-04-30 17:14:24 +00:00
|
|
|
/**
|
|
|
|
* Declares a global variable.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
void Declare(DSLGlobalVar& var, Position pos = {});
|
2021-01-22 20:18:25 +00:00
|
|
|
|
2021-07-19 16:55:52 +00:00
|
|
|
/**
|
|
|
|
* Declares a set of global variables.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
void Declare(SkTArray<DSLGlobalVar>& vars, Position pos = {});
|
2021-07-19 16:55:52 +00:00
|
|
|
|
2021-02-09 20:22:57 +00:00
|
|
|
/**
|
|
|
|
* default: statements
|
|
|
|
*/
|
|
|
|
template<class... Statements>
|
|
|
|
DSLCase Default(Statements... statements) {
|
|
|
|
return DSLCase(DSLExpression(), std::move(statements)...);
|
|
|
|
}
|
|
|
|
|
2021-02-05 19:22:32 +00:00
|
|
|
/**
|
|
|
|
* discard;
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLStatement Discard(Position pos = {});
|
2021-02-05 19:22:32 +00:00
|
|
|
|
2021-01-22 20:18:25 +00:00
|
|
|
/**
|
|
|
|
* do stmt; while (test);
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLStatement Do(DSLStatement stmt, DSLExpression test, Position pos = {});
|
2021-01-22 20:18:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* for (initializer; test; next) stmt;
|
|
|
|
*/
|
|
|
|
DSLStatement For(DSLStatement initializer, DSLExpression test, DSLExpression next,
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLStatement stmt, Position pos = {});
|
2021-01-22 20:18:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* if (test) ifTrue; [else ifFalse;]
|
|
|
|
*/
|
2021-02-26 01:50:32 +00:00
|
|
|
DSLStatement If(DSLExpression test, DSLStatement ifTrue, DSLStatement ifFalse = DSLStatement(),
|
2022-04-08 15:37:08 +00:00
|
|
|
Position pos = {});
|
2021-01-22 20:18:25 +00:00
|
|
|
|
2022-02-01 20:31:57 +00:00
|
|
|
DSLGlobalVar InterfaceBlock(const DSLModifiers& modifiers, std::string_view typeName,
|
|
|
|
SkTArray<DSLField> fields, std::string_view varName = "",
|
2022-04-08 15:37:08 +00:00
|
|
|
int arraySize = 0, Position pos = {});
|
2021-07-08 14:38:43 +00:00
|
|
|
|
2021-01-28 15:02:43 +00:00
|
|
|
/**
|
|
|
|
* return [value];
|
|
|
|
*/
|
2021-08-12 15:41:59 +00:00
|
|
|
DSLStatement Return(DSLExpression value = DSLExpression(),
|
2022-04-08 15:37:08 +00:00
|
|
|
Position pos = {});
|
2021-02-26 01:50:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* test ? ifTrue : ifFalse
|
|
|
|
*/
|
|
|
|
DSLExpression Select(DSLExpression test, DSLExpression ifTrue, DSLExpression ifFalse,
|
2022-04-08 15:37:08 +00:00
|
|
|
Position = {});
|
2021-01-28 15:02:43 +00:00
|
|
|
|
2021-04-30 16:44:00 +00:00
|
|
|
DSLStatement StaticIf(DSLExpression test, DSLStatement ifTrue,
|
2021-08-12 15:41:59 +00:00
|
|
|
DSLStatement ifFalse = DSLStatement(),
|
2022-04-08 15:37:08 +00:00
|
|
|
Position pos = {});
|
2021-04-30 16:44:00 +00:00
|
|
|
|
2021-09-22 19:15:54 +00:00
|
|
|
// Internal use only
|
|
|
|
DSLPossibleStatement PossibleStaticSwitch(DSLExpression value, SkTArray<DSLCase> cases);
|
|
|
|
|
|
|
|
DSLStatement StaticSwitch(DSLExpression value, SkTArray<DSLCase> cases,
|
2022-04-08 15:37:08 +00:00
|
|
|
Position pos = {});
|
2021-04-30 16:44:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @switch (value) { cases }
|
|
|
|
*/
|
|
|
|
template<class... Cases>
|
|
|
|
DSLPossibleStatement StaticSwitch(DSLExpression value, Cases... cases) {
|
|
|
|
SkTArray<DSLCase> caseArray;
|
|
|
|
caseArray.reserve_back(sizeof...(cases));
|
|
|
|
(caseArray.push_back(std::move(cases)), ...);
|
2021-09-22 19:15:54 +00:00
|
|
|
return PossibleStaticSwitch(std::move(value), std::move(caseArray));
|
2021-04-30 16:44:00 +00:00
|
|
|
}
|
|
|
|
|
2021-09-22 19:15:54 +00:00
|
|
|
// Internal use only
|
|
|
|
DSLPossibleStatement PossibleSwitch(DSLExpression value, SkTArray<DSLCase> cases);
|
|
|
|
|
|
|
|
DSLStatement Switch(DSLExpression value, SkTArray<DSLCase> cases,
|
2022-04-08 15:37:08 +00:00
|
|
|
Position pos = {});
|
2021-03-04 19:30:25 +00:00
|
|
|
|
2021-02-09 20:22:57 +00:00
|
|
|
/**
|
|
|
|
* switch (value) { cases }
|
|
|
|
*/
|
|
|
|
template<class... Cases>
|
2021-02-26 01:50:32 +00:00
|
|
|
DSLPossibleStatement Switch(DSLExpression value, Cases... cases) {
|
2021-04-30 16:44:00 +00:00
|
|
|
SkTArray<DSLCase> caseArray;
|
|
|
|
caseArray.reserve_back(sizeof...(cases));
|
|
|
|
(caseArray.push_back(std::move(cases)), ...);
|
2021-09-22 19:15:54 +00:00
|
|
|
return PossibleSwitch(std::move(value), std::move(caseArray));
|
2021-02-09 20:22:57 +00:00
|
|
|
}
|
|
|
|
|
2021-01-22 20:18:25 +00:00
|
|
|
/**
|
|
|
|
* while (test) stmt;
|
|
|
|
*/
|
2021-08-12 15:41:59 +00:00
|
|
|
DSLStatement While(DSLExpression test, DSLStatement stmt,
|
2022-04-08 15:37:08 +00:00
|
|
|
Position pos = {});
|
2021-01-07 15:57:27 +00:00
|
|
|
|
2021-02-18 21:06:17 +00:00
|
|
|
/**
|
|
|
|
* expression.xyz1
|
|
|
|
*/
|
2021-02-26 01:50:32 +00:00
|
|
|
DSLExpression Swizzle(DSLExpression base,
|
|
|
|
SkSL::SwizzleComponent::Type a,
|
2022-04-20 18:55:03 +00:00
|
|
|
Position pos = {},
|
|
|
|
Position maskPos = {});
|
2021-01-26 19:31:29 +00:00
|
|
|
|
2021-02-18 21:06:17 +00:00
|
|
|
DSLExpression Swizzle(DSLExpression base,
|
|
|
|
SkSL::SwizzleComponent::Type a,
|
2021-02-26 01:50:32 +00:00
|
|
|
SkSL::SwizzleComponent::Type b,
|
2022-04-20 18:55:03 +00:00
|
|
|
Position pos = {},
|
|
|
|
Position maskPos = {});
|
2021-01-26 19:31:29 +00:00
|
|
|
|
2021-02-18 21:06:17 +00:00
|
|
|
DSLExpression Swizzle(DSLExpression base,
|
|
|
|
SkSL::SwizzleComponent::Type a,
|
|
|
|
SkSL::SwizzleComponent::Type b,
|
2021-02-26 01:50:32 +00:00
|
|
|
SkSL::SwizzleComponent::Type c,
|
2022-04-20 18:55:03 +00:00
|
|
|
Position pos = {},
|
|
|
|
Position maskPos = {});
|
2021-01-26 19:31:29 +00:00
|
|
|
|
2021-02-18 21:06:17 +00:00
|
|
|
DSLExpression Swizzle(DSLExpression base,
|
|
|
|
SkSL::SwizzleComponent::Type a,
|
|
|
|
SkSL::SwizzleComponent::Type b,
|
|
|
|
SkSL::SwizzleComponent::Type c,
|
2021-02-26 01:50:32 +00:00
|
|
|
SkSL::SwizzleComponent::Type d,
|
2022-04-20 18:55:03 +00:00
|
|
|
Position pos = {},
|
|
|
|
Position maskPos = {});
|
2021-01-26 19:31:29 +00:00
|
|
|
|
2021-01-07 15:57:27 +00:00
|
|
|
/**
|
2021-01-26 17:00:25 +00:00
|
|
|
* Returns the absolute value of x. If x is a vector, operates componentwise.
|
2021-01-07 15:57:27 +00:00
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Abs(DSLExpression x, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if all of the components of boolean vector x are true.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression All(DSLExpression x, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if any of the components of boolean vector x are true.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Any(DSLExpression x, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
2021-04-26 13:36:07 +00:00
|
|
|
/**
|
|
|
|
* Returns the arctangent of y over x. Operates componentwise on vectors.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Atan(DSLExpression y_over_x, Position pos = {});
|
|
|
|
DSLExpression Atan(DSLExpression y, DSLExpression x, Position pos = {});
|
2021-04-26 13:36:07 +00:00
|
|
|
|
2021-01-26 17:00:25 +00:00
|
|
|
/**
|
|
|
|
* Returns x rounded towards positive infinity. If x is a vector, operates componentwise.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Ceil(DSLExpression x, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns x clamped to between min and max. If x is a vector, operates componentwise.
|
|
|
|
*/
|
2021-02-26 01:50:32 +00:00
|
|
|
DSLExpression Clamp(DSLExpression x, DSLExpression min, DSLExpression max,
|
2022-04-08 15:37:08 +00:00
|
|
|
Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the cosine of x. If x is a vector, operates componentwise.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Cos(DSLExpression x, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the cross product of x and y.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Cross(DSLExpression x, DSLExpression y, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns x converted from radians to degrees. If x is a vector, operates componentwise.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Degrees(DSLExpression x, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the distance between x and y.
|
|
|
|
*/
|
2021-08-12 15:41:59 +00:00
|
|
|
DSLExpression Distance(DSLExpression x, DSLExpression y,
|
2022-04-08 15:37:08 +00:00
|
|
|
Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the dot product of x and y.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Dot(DSLExpression x, DSLExpression y, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a boolean vector indicating whether components of x are equal to the corresponding
|
|
|
|
* components of y.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Equal(DSLExpression x, DSLExpression y, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns e^x. If x is a vector, operates componentwise.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Exp(DSLExpression x, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns 2^x. If x is a vector, operates componentwise.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Exp2(DSLExpression x, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If dot(i, nref) >= 0, returns n, otherwise returns -n.
|
|
|
|
*/
|
2021-02-26 01:50:32 +00:00
|
|
|
DSLExpression Faceforward(DSLExpression n, DSLExpression i, DSLExpression nref,
|
2022-04-08 15:37:08 +00:00
|
|
|
Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns x rounded towards negative infinity. If x is a vector, operates componentwise.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Floor(DSLExpression x, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the fractional part of x. If x is a vector, operates componentwise.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Fract(DSLExpression x, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a boolean vector indicating whether components of x are greater than the corresponding
|
|
|
|
* components of y.
|
|
|
|
*/
|
2021-08-12 15:41:59 +00:00
|
|
|
DSLExpression GreaterThan(DSLExpression x, DSLExpression y,
|
2022-04-08 15:37:08 +00:00
|
|
|
Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a boolean vector indicating whether components of x are greater than or equal to the
|
|
|
|
* corresponding components of y.
|
|
|
|
*/
|
2021-08-12 15:41:59 +00:00
|
|
|
DSLExpression GreaterThanEqual(DSLExpression x, DSLExpression y,
|
2022-04-08 15:37:08 +00:00
|
|
|
Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the 1/sqrt(x). If x is a vector, operates componentwise.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Inversesqrt(DSLExpression x, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the inverse of the matrix x.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Inverse(DSLExpression x, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the length of the vector x.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Length(DSLExpression x, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a boolean vector indicating whether components of x are less than the corresponding
|
|
|
|
* components of y.
|
|
|
|
*/
|
2021-08-12 15:41:59 +00:00
|
|
|
DSLExpression LessThan(DSLExpression x, DSLExpression y,
|
2022-04-08 15:37:08 +00:00
|
|
|
Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a boolean vector indicating whether components of x are less than or equal to the
|
|
|
|
* corresponding components of y.
|
|
|
|
*/
|
2021-08-12 15:41:59 +00:00
|
|
|
DSLExpression LessThanEqual(DSLExpression x, DSLExpression y,
|
2022-04-08 15:37:08 +00:00
|
|
|
Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the log base e of x. If x is a vector, operates componentwise.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Log(DSLExpression x, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the log base 2 of x. If x is a vector, operates componentwise.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Log2(DSLExpression x, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the larger (closer to positive infinity) of x and y. If x is a vector, operates
|
|
|
|
* componentwise. y may be either a vector of the same dimensions as x, or a scalar.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Max(DSLExpression x, DSLExpression y, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the smaller (closer to negative infinity) of x and y. If x is a vector, operates
|
|
|
|
* componentwise. y may be either a vector of the same dimensions as x, or a scalar.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Min(DSLExpression x, DSLExpression y, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a linear intepolation between x and y at position a, where a=0 results in x and a=1
|
|
|
|
* results in y. If x and y are vectors, operates componentwise. a may be either a vector of the
|
|
|
|
* same dimensions as x and y, or a scalar.
|
|
|
|
*/
|
2021-02-26 01:50:32 +00:00
|
|
|
DSLExpression Mix(DSLExpression x, DSLExpression y, DSLExpression a,
|
2022-04-08 15:37:08 +00:00
|
|
|
Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns x modulo y. If x is a vector, operates componentwise. y may be either a vector of the
|
|
|
|
* same dimensions as x, or a scalar.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Mod(DSLExpression x, DSLExpression y, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the vector x normalized to a length of 1.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Normalize(DSLExpression x, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a boolean vector indicating whether components of x are not equal to the corresponding
|
|
|
|
* components of y.
|
|
|
|
*/
|
2021-08-12 15:41:59 +00:00
|
|
|
DSLExpression NotEqual(DSLExpression x, DSLExpression y,
|
2022-04-08 15:37:08 +00:00
|
|
|
Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns x raised to the power y. If x is a vector, operates componentwise. y may be either a
|
|
|
|
* vector of the same dimensions as x, or a scalar.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Pow(DSLExpression x, DSLExpression y, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns x converted from degrees to radians. If x is a vector, operates componentwise.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Radians(DSLExpression x, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns i reflected from a surface with normal n.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Reflect(DSLExpression i, DSLExpression n, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns i refracted across a surface with normal n and ratio of indices of refraction eta.
|
|
|
|
*/
|
2021-02-26 01:50:32 +00:00
|
|
|
DSLExpression Refract(DSLExpression i, DSLExpression n, DSLExpression eta,
|
2022-04-08 15:37:08 +00:00
|
|
|
Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
2021-09-08 21:50:09 +00:00
|
|
|
/**
|
|
|
|
* Returns x, rounded to the nearest integer. If x is a vector, operates componentwise.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Round(DSLExpression x, Position pos = {});
|
2021-09-08 21:50:09 +00:00
|
|
|
|
2021-01-26 17:00:25 +00:00
|
|
|
/**
|
|
|
|
* Returns x clamped to the range [0, 1]. If x is a vector, operates componentwise.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Saturate(DSLExpression x, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns -1, 0, or 1 depending on whether x is negative, zero, or positive, respectively. If x is
|
|
|
|
* a vector, operates componentwise.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Sign(DSLExpression x, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the sine of x. If x is a vector, operates componentwise.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Sin(DSLExpression x, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a smooth interpolation between 0 (at x=edge1) and 1 (at x=edge2). If x is a vector,
|
|
|
|
* operates componentwise. edge1 and edge2 may either be both vectors of the same dimensions as x or
|
|
|
|
* scalars.
|
|
|
|
*/
|
2021-02-26 01:50:32 +00:00
|
|
|
DSLExpression Smoothstep(DSLExpression edge1, DSLExpression edge2, DSLExpression x,
|
2022-04-08 15:37:08 +00:00
|
|
|
Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the square root of x. If x is a vector, operates componentwise.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Sqrt(DSLExpression x, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns 0 if x < edge or 1 if x >= edge. If x is a vector, operates componentwise. edge may be
|
|
|
|
* either a vector of the same dimensions as x, or a scalar.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Step(DSLExpression edge, DSLExpression x, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the tangent of x. If x is a vector, operates componentwise.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Tan(DSLExpression x, Position pos = {});
|
2021-01-26 17:00:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns x converted from premultipled to unpremultiplied alpha.
|
|
|
|
*/
|
2022-04-08 15:37:08 +00:00
|
|
|
DSLExpression Unpremul(DSLExpression x, Position pos = {});
|
2021-01-07 15:57:27 +00:00
|
|
|
|
|
|
|
} // namespace dsl
|
|
|
|
|
|
|
|
} // namespace SkSL
|
|
|
|
|
|
|
|
#endif
|