e9d172af84
Bug: skia: Change-Id: Ic3b18f82c1ab940637fb26dec1cf376dd859b35d Reviewed-on: https://skia-review.googlesource.com/73720 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
61 lines
1.2 KiB
C++
61 lines
1.2 KiB
C++
/*
|
|
* Copyright 2017 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#ifndef SKSL_CPP
|
|
#define SKSL_CPP
|
|
|
|
// functions used by CPP programs created by skslc
|
|
|
|
#include <cmath>
|
|
#include "SkPoint.h"
|
|
|
|
using std::abs;
|
|
|
|
struct Float4 {
|
|
Float4(float x, float y, float z, float w)
|
|
: fX(x)
|
|
, fY(y)
|
|
, fZ(z)
|
|
, fW(w) {}
|
|
|
|
operator SkRect() const {
|
|
return SkRect::MakeLTRB(fX, fY, fZ, fW);
|
|
}
|
|
|
|
operator GrColor4f() const {
|
|
return GrColor4f(fX, fY, fZ, fW);
|
|
}
|
|
|
|
private:
|
|
float fX;
|
|
float fY;
|
|
float fZ;
|
|
float fW;
|
|
};
|
|
|
|
// macros to make sk_Caps.<cap name> work from C++ code
|
|
#define sk_Caps (*args.fShaderCaps)
|
|
|
|
#define floatIs32Bits floatIs32Bits()
|
|
|
|
// functions to make GLSL constructors work from C++ code
|
|
inline SkPoint float2(float xy) { return SkPoint::Make(xy, xy); }
|
|
|
|
inline SkPoint float2(float x, float y) { return SkPoint::Make(x, y); }
|
|
|
|
inline Float4 float4(float xyzw) { return Float4(xyzw, xyzw, xyzw, xyzw); }
|
|
|
|
inline Float4 float4(float x, float y, float z, float w) { return Float4(x, y, z, w); }
|
|
|
|
#define half2 float2
|
|
|
|
#define half3 float3
|
|
|
|
#define half4 float4
|
|
|
|
#endif
|