1/*
2 * Copyright 2017 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_CPP
9#define SKSL_CPP
10
11// functions used by CPP programs created by skslc
12
13#include <cmath>
14#include "include/core/SkPoint.h"
15#include "include/core/SkRect.h"
16
17using std::abs;
18
19struct Float4 {
20 Float4(float x, float y, float z, float w)
21 : fX(x)
22 , fY(y)
23 , fZ(z)
24 , fW(w) {}
25
26 operator SkRect() const {
27 return SkRect::MakeLTRB(fX, fY, fZ, fW);
28 }
29
30private:
31 float fX;
32 float fY;
33 float fZ;
34 float fW;
35};
36
37// macros to make sk_Caps.<cap name> work from C++ code
38#define sk_Caps (*args.fShaderCaps)
39
40#define floatIs32Bits floatIs32Bits()
41
42// functions to make GLSL constructors work from C++ code
43inline SkPoint float2(float xy) { return SkPoint::Make(xy, xy); }
44
45inline SkPoint float2(float x, float y) { return SkPoint::Make(x, y); }
46
47inline Float4 float4(float xyzw) { return Float4(xyzw, xyzw, xyzw, xyzw); }
48
49inline Float4 float4(float x, float y, float z, float w) { return Float4(x, y, z, w); }
50
51#define half2 float2
52
53#define half3 float3
54
55#define half4 float4
56
57#endif
58