use SkM44 internally
Today we use SkM44 in canvas, and SkMatrix44 in sksl (and colormatrix). This CL tries to move core to use a single type. SkMatrix44 has callers in android and chrome, is loaded with double/float variants in its API. I am suggesting moving to a private, clean-start, API for internal use. SkM44 is much faster, and has a leaner API. If eventually we can migrate clients to a shared impl/api, great. For now, I want to have one we are free to optimize/use as we see fit without worrying about changing client results. Change-Id: Id782ac1cc8b8d7f6621970e44e1f9729964d2a94 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/265299 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
f9aea7f7e5
commit
295cdf8775
@ -358,7 +358,7 @@ protected:
|
||||
if (fType == k3x3_Type) {
|
||||
m[7] = 0.0001f;
|
||||
}
|
||||
SkMatrix44 m4(m);
|
||||
SkM44 m4(m);
|
||||
|
||||
for (int i = 0; i < loops; ++i) {
|
||||
canvas->save();
|
||||
|
@ -8,9 +8,9 @@
|
||||
#ifndef SkM44_DEFINED
|
||||
#define SkM44_DEFINED
|
||||
|
||||
#include "include/core/SkMatrix.h"
|
||||
#include "include/core/SkScalar.h"
|
||||
|
||||
class SkMatrix;
|
||||
class SkMatrix44;
|
||||
|
||||
struct SkV3 {
|
||||
@ -19,6 +19,7 @@ struct SkV3 {
|
||||
bool operator==(const SkV3& v) const {
|
||||
return x == v.x && y == v.y && z == v.z;
|
||||
}
|
||||
bool operator!=(const SkV3& v) const { return !(*this == v); }
|
||||
|
||||
static SkScalar Dot(const SkV3& a, const SkV3& b) { return a.x*b.x + a.y*b.y + a.z*b.z; }
|
||||
static SkV3 Cross(const SkV3& a, const SkV3& b) {
|
||||
@ -47,6 +48,14 @@ struct SkV4 {
|
||||
bool operator==(const SkV4& v) const {
|
||||
return x == v.x && y == v.y && z == v.z && w == v.w;
|
||||
}
|
||||
bool operator!=(const SkV4& v) const { return !(*this == v); }
|
||||
|
||||
SkV4 operator-() const { return {-x, -y, -z, -w}; }
|
||||
SkV4 operator+(const SkV4& v) const { return { x + v.x, y + v.y, z + v.z, w + v.w }; }
|
||||
SkV4 operator-(const SkV4& v) const { return { x - v.x, y - v.y, z - v.z, w - v.w }; }
|
||||
|
||||
const float* vec() const { return &x; }
|
||||
float* vec() { return &x; }
|
||||
};
|
||||
|
||||
class SkM44 {
|
||||
@ -68,9 +77,18 @@ public:
|
||||
enum Uninitialized_Constructor {
|
||||
kUninitialized_Constructor
|
||||
};
|
||||
|
||||
SkM44(Uninitialized_Constructor) {}
|
||||
|
||||
enum NaN_Constructor {
|
||||
kNaN_Constructor
|
||||
};
|
||||
SkM44(NaN_Constructor)
|
||||
: fMat{SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN,
|
||||
SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN,
|
||||
SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN,
|
||||
SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN}
|
||||
{}
|
||||
|
||||
/**
|
||||
* Parameters are treated as row-major.
|
||||
*/
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
class SkArenaAlloc;
|
||||
class SkColorSpace;
|
||||
class SkMatrix;
|
||||
class SkPaint;
|
||||
class SkRasterPipeline;
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#ifndef SkImageFilterTypes_DEFINED
|
||||
#define SkImageFilterTypes_DEFINED
|
||||
|
||||
#include "include/core/SkMatrix.h"
|
||||
#include "src/core/SkSpecialImage.h"
|
||||
#include "src/core/SkSpecialSurface.h"
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
#include "src/core/SkYUVMath.h"
|
||||
|
||||
// in SkColorMatrix order (row-major)
|
||||
@ -106,29 +106,34 @@ void SkColorMatrix_YUV2RGB(SkYUVColorSpace cs, float m[20]) {
|
||||
// | 3x3 tg |
|
||||
// | tb |
|
||||
// | 0 0 0 1 |
|
||||
static void colormatrix_to_matrix44(const float src[20], SkMatrix44* dst) {
|
||||
for (int r = 0; r < 3; ++r) {
|
||||
for (int c = 0; c < 3; ++c) {
|
||||
dst->set(r, c, src[r*5 + c]);
|
||||
}
|
||||
dst->set(r, 3, src[r*5 + 4]);
|
||||
}
|
||||
dst->set(3, 0, 0);
|
||||
dst->set(3, 1, 0);
|
||||
dst->set(3, 2, 0);
|
||||
dst->set(3, 3, 1);
|
||||
static void colormatrix_to_matrix44(const float src[20], SkM44* dst) {
|
||||
*dst = SkM44(src[ 0], src[ 1], src[ 2], src[ 4],
|
||||
src[ 5], src[ 6], src[ 7], src[ 9],
|
||||
src[10], src[11], src[12], src[14],
|
||||
0, 0, 0, 1);
|
||||
}
|
||||
|
||||
// input: ignore the bottom row
|
||||
// output: inject identity row/column for alpha
|
||||
static void matrix44_to_colormatrix(const SkMatrix44& src, float dst[20]) {
|
||||
for (int r = 0; r < 3; ++r) {
|
||||
for (int c = 0; c < 3; ++c) {
|
||||
dst[r*5 + c] = src.get(r, c);
|
||||
}
|
||||
dst[r*5 + 3] = 0; // scale alpha
|
||||
dst[r*5 + 4] = src.get(r, 3); // translate
|
||||
}
|
||||
static void matrix44_to_colormatrix(const SkM44& src, float dst[20]) {
|
||||
dst[0] = src.atColMajor(0);
|
||||
dst[1] = src.atColMajor(4);
|
||||
dst[2] = src.atColMajor(8);
|
||||
dst[3] = 0;
|
||||
dst[4] = src.atColMajor(12); // tx
|
||||
|
||||
dst[5] = src.atColMajor(1);
|
||||
dst[6] = src.atColMajor(5);
|
||||
dst[7] = src.atColMajor(9);
|
||||
dst[8] = 0;
|
||||
dst[9] = src.atColMajor(13); // ty
|
||||
|
||||
dst[10] = src.atColMajor(2);
|
||||
dst[11] = src.atColMajor(6);
|
||||
dst[12] = src.atColMajor(10);
|
||||
dst[13] = 0;
|
||||
dst[14] = src.atColMajor(14); // tz
|
||||
|
||||
dst[15] = dst[16] = dst[17] = dst[19] = 0;
|
||||
dst[18] = 1;
|
||||
}
|
||||
@ -206,7 +211,7 @@ void SkColorMatrix_DumpYUVMatrixTables() {
|
||||
float m[20];
|
||||
make_rgb_to_yuv_matrix(m, gCoeff[(unsigned)cs]);
|
||||
dump(m, cs, true);
|
||||
SkMatrix44 m44, im44;
|
||||
SkM44 m44, im44;
|
||||
colormatrix_to_matrix44(m, &m44);
|
||||
float im[20];
|
||||
#ifdef SK_DEBUG
|
||||
|
@ -5,8 +5,8 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
layout(ctype=SkMatrix44, tracked) in uniform half4x4 m;
|
||||
layout(ctype=SkVector4, tracked) in uniform half4 v;
|
||||
layout(ctype=SkM44, tracked) in uniform half4x4 m;
|
||||
layout(ctype=SkV4, tracked) in uniform half4 v;
|
||||
layout(key) in bool unpremulInput;
|
||||
layout(key) in bool clampRGBOutput;
|
||||
layout(key) in bool premulOutput;
|
||||
@ -45,11 +45,8 @@ void main() {
|
||||
color.fB = input.fB;
|
||||
color.fA = input.fA;
|
||||
}
|
||||
m.mapScalars(color.vec());
|
||||
color.fR += v.fData[0];
|
||||
color.fG += v.fData[1];
|
||||
color.fB += v.fData[2];
|
||||
color.fA += v.fData[3];
|
||||
auto v4 = m.map(color.fR, color.fG, color.fB, color.fA) + v;
|
||||
color = {v4.x, v4.y, v4.z, v4.w};
|
||||
color.fA = SkTPin(color.fA, 0.f, 1.f);
|
||||
if (clampRGBOutput) {
|
||||
color.fR = SkTPin(color.fR, 0.f, 1.f);
|
||||
@ -66,14 +63,13 @@ void main() {
|
||||
|
||||
@make {
|
||||
static std::unique_ptr<GrFragmentProcessor> Make(const float matrix[20], bool unpremulInput, bool clampRGBOutput, bool premulOutput) {
|
||||
SkMatrix44 m44;
|
||||
m44.set4x4(
|
||||
matrix[0], matrix[5], matrix[10], matrix[15],
|
||||
matrix[1], matrix[6], matrix[11], matrix[16],
|
||||
matrix[2], matrix[7], matrix[12], matrix[17],
|
||||
matrix[3], matrix[8], matrix[13], matrix[18]
|
||||
SkM44 m44(
|
||||
matrix[0], matrix[5], matrix[10], matrix[15],
|
||||
matrix[1], matrix[6], matrix[11], matrix[16],
|
||||
matrix[2], matrix[7], matrix[12], matrix[17],
|
||||
matrix[3], matrix[8], matrix[13], matrix[18]
|
||||
);
|
||||
auto v4 = SkVector4(matrix[4], matrix[9], matrix[14], matrix[19]);
|
||||
SkV4 v4 = {matrix[4], matrix[9], matrix[14], matrix[19]};
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrColorMatrixFragmentProcessor(m44, v4, unpremulInput, clampRGBOutput, premulOutput));
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrAARectEffect_DEFINED
|
||||
#define GrAARectEffect_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include "src/gpu/GrCoordTransform.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrAlphaThresholdFragmentProcessor_DEFINED
|
||||
#define GrAlphaThresholdFragmentProcessor_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include "src/gpu/GrCoordTransform.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrBlurredEdgeFragmentProcessor_DEFINED
|
||||
#define GrBlurredEdgeFragmentProcessor_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include "src/gpu/GrCoordTransform.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrCircleBlurFragmentProcessor_DEFINED
|
||||
#define GrCircleBlurFragmentProcessor_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include "src/gpu/GrCoordTransform.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrCircleEffect_DEFINED
|
||||
#define GrCircleEffect_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include "src/gpu/GrCoordTransform.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrClampFragmentProcessor_DEFINED
|
||||
#define GrClampFragmentProcessor_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include "src/gpu/GrCoordTransform.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
|
@ -55,20 +55,20 @@ private:
|
||||
const GrFragmentProcessor& _proc) override {
|
||||
const GrColorMatrixFragmentProcessor& _outer = _proc.cast<GrColorMatrixFragmentProcessor>();
|
||||
{
|
||||
const SkMatrix44& mValue = _outer.m;
|
||||
const SkM44& mValue = _outer.m;
|
||||
if (mPrev != (mValue)) {
|
||||
mPrev = mValue;
|
||||
pdman.setSkMatrix44(mVar, mValue);
|
||||
pdman.setSkM44(mVar, mValue);
|
||||
}
|
||||
const SkVector4& vValue = _outer.v;
|
||||
const SkV4& vValue = _outer.v;
|
||||
if (vPrev != (vValue)) {
|
||||
vPrev = vValue;
|
||||
pdman.set4fv(vVar, 1, vValue.fData);
|
||||
pdman.set4fv(vVar, 1, vValue.vec());
|
||||
}
|
||||
}
|
||||
}
|
||||
SkMatrix44 mPrev = SkMatrix44(SkMatrix44::kNaN_Constructor);
|
||||
SkVector4 vPrev = SkVector4(SK_FloatNaN, SK_FloatNaN, SK_FloatNaN, SK_FloatNaN);
|
||||
SkM44 mPrev = SkM44(SkM44::kNaN_Constructor);
|
||||
SkV4 vPrev = SkV4{SK_FloatNaN, SK_FloatNaN, SK_FloatNaN, SK_FloatNaN};
|
||||
UniformHandle mVar;
|
||||
UniformHandle vVar;
|
||||
};
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrColorMatrixFragmentProcessor_DEFINED
|
||||
#define GrColorMatrixFragmentProcessor_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include "src/gpu/GrCoordTransform.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
@ -27,11 +27,8 @@ public:
|
||||
color.fB = input.fB;
|
||||
color.fA = input.fA;
|
||||
}
|
||||
m.mapScalars(color.vec());
|
||||
color.fR += v.fData[0];
|
||||
color.fG += v.fData[1];
|
||||
color.fB += v.fData[2];
|
||||
color.fA += v.fData[3];
|
||||
auto v4 = m.map(color.fR, color.fG, color.fB, color.fA) + v;
|
||||
color = {v4.x, v4.y, v4.z, v4.w};
|
||||
color.fA = SkTPin(color.fA, 0.f, 1.f);
|
||||
if (clampRGBOutput) {
|
||||
color.fR = SkTPin(color.fR, 0.f, 1.f);
|
||||
@ -47,26 +44,25 @@ public:
|
||||
|
||||
static std::unique_ptr<GrFragmentProcessor> Make(const float matrix[20], bool unpremulInput,
|
||||
bool clampRGBOutput, bool premulOutput) {
|
||||
SkMatrix44 m44;
|
||||
m44.set4x4(matrix[0], matrix[5], matrix[10], matrix[15], matrix[1], matrix[6], matrix[11],
|
||||
matrix[16], matrix[2], matrix[7], matrix[12], matrix[17], matrix[3], matrix[8],
|
||||
matrix[13], matrix[18]);
|
||||
auto v4 = SkVector4(matrix[4], matrix[9], matrix[14], matrix[19]);
|
||||
SkM44 m44(matrix[0], matrix[5], matrix[10], matrix[15], matrix[1], matrix[6], matrix[11],
|
||||
matrix[16], matrix[2], matrix[7], matrix[12], matrix[17], matrix[3], matrix[8],
|
||||
matrix[13], matrix[18]);
|
||||
SkV4 v4 = {matrix[4], matrix[9], matrix[14], matrix[19]};
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrColorMatrixFragmentProcessor(
|
||||
m44, v4, unpremulInput, clampRGBOutput, premulOutput));
|
||||
}
|
||||
GrColorMatrixFragmentProcessor(const GrColorMatrixFragmentProcessor& src);
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override;
|
||||
const char* name() const override { return "ColorMatrixFragmentProcessor"; }
|
||||
SkMatrix44 m;
|
||||
SkVector4 v;
|
||||
SkM44 m;
|
||||
SkV4 v;
|
||||
bool unpremulInput;
|
||||
bool clampRGBOutput;
|
||||
bool premulOutput;
|
||||
|
||||
private:
|
||||
GrColorMatrixFragmentProcessor(SkMatrix44 m, SkVector4 v, bool unpremulInput,
|
||||
bool clampRGBOutput, bool premulOutput)
|
||||
GrColorMatrixFragmentProcessor(SkM44 m, SkV4 v, bool unpremulInput, bool clampRGBOutput,
|
||||
bool premulOutput)
|
||||
: INHERITED(kGrColorMatrixFragmentProcessor_ClassID,
|
||||
(OptimizationFlags)kConstantOutputForConstantInput_OptimizationFlag)
|
||||
, m(m)
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrComposeLerpEffect_DEFINED
|
||||
#define GrComposeLerpEffect_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include "src/gpu/GrCoordTransform.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrComposeLerpRedEffect_DEFINED
|
||||
#define GrComposeLerpRedEffect_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include "src/gpu/GrCoordTransform.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrConfigConversionEffect_DEFINED
|
||||
#define GrConfigConversionEffect_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include "include/gpu/GrContext.h"
|
||||
#include "src/gpu/GrClip.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrConstColorProcessor_DEFINED
|
||||
#define GrConstColorProcessor_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include "src/gpu/GrCoordTransform.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrEllipseEffect_DEFINED
|
||||
#define GrEllipseEffect_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include "src/gpu/GrShaderCaps.h"
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrHSLToRGBFilterEffect_DEFINED
|
||||
#define GrHSLToRGBFilterEffect_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include "src/gpu/GrCoordTransform.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrLumaColorFilterEffect_DEFINED
|
||||
#define GrLumaColorFilterEffect_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include "src/gpu/GrCoordTransform.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrMagnifierEffect_DEFINED
|
||||
#define GrMagnifierEffect_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include "src/gpu/GrCoordTransform.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrMixerEffect_DEFINED
|
||||
#define GrMixerEffect_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include "src/gpu/GrCoordTransform.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrOverrideInputFragmentProcessor_DEFINED
|
||||
#define GrOverrideInputFragmentProcessor_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include "src/gpu/GrCoordTransform.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrPremulInputFragmentProcessor_DEFINED
|
||||
#define GrPremulInputFragmentProcessor_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include "src/gpu/GrCoordTransform.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrRGBToHSLFilterEffect_DEFINED
|
||||
#define GrRGBToHSLFilterEffect_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include "src/gpu/GrCoordTransform.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrRRectBlurEffect_DEFINED
|
||||
#define GrRRectBlurEffect_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include "include/gpu/GrContext.h"
|
||||
#include "include/private/GrRecordingContext.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrRectBlurEffect_DEFINED
|
||||
#define GrRectBlurEffect_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include <cmath>
|
||||
#include "include/core/SkRect.h"
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "src/gpu/glsl/GrGLSLProgramDataManager.h"
|
||||
|
||||
#include "include/core/SkMatrix.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
void GrGLSLProgramDataManager::setSkMatrix(UniformHandle u, const SkMatrix& matrix) const {
|
||||
float mt[] = {
|
||||
@ -25,8 +25,6 @@ void GrGLSLProgramDataManager::setSkMatrix(UniformHandle u, const SkMatrix& matr
|
||||
this->setMatrix3f(u, mt);
|
||||
}
|
||||
|
||||
void GrGLSLProgramDataManager::setSkMatrix44(UniformHandle u, const SkMatrix44& matrix) const {
|
||||
float mt[16];
|
||||
matrix.asColMajorf(mt);
|
||||
this->setMatrix4f(u, mt);
|
||||
void GrGLSLProgramDataManager::setSkM44(UniformHandle u, const SkM44& matrix) const {
|
||||
this->setMatrix4f(u, matrix.asColMajor());
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "src/gpu/GrResourceHandle.h"
|
||||
|
||||
class SkMatrix;
|
||||
class SkMatrix44;
|
||||
class SkM44;
|
||||
|
||||
/** Manages the resources used by a shader program.
|
||||
* The resources are objects the program uses to communicate with the
|
||||
@ -56,7 +56,7 @@ public:
|
||||
// convenience method for uploading a SkMatrix to a 3x3 matrix uniform
|
||||
void setSkMatrix(UniformHandle, const SkMatrix&) const;
|
||||
// convenience method for uploading a SkMatrix to a 4x4 matrix uniform
|
||||
void setSkMatrix44(UniformHandle, const SkMatrix44&) const;
|
||||
void setSkM44(UniformHandle, const SkM44&) const;
|
||||
|
||||
// for nvpr only
|
||||
GR_DEFINE_RESOURCE_HANDLE_CLASS(VaryingHandle);
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrClampedGradientEffect_DEFINED
|
||||
#define GrClampedGradientEffect_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include "src/gpu/GrCoordTransform.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrDualIntervalGradientColorizer_DEFINED
|
||||
#define GrDualIntervalGradientColorizer_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include "src/gpu/GrCoordTransform.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrLinearGradientLayout_DEFINED
|
||||
#define GrLinearGradientLayout_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include "src/gpu/gradients/GrGradientShader.h"
|
||||
#include "src/shaders/gradients/SkLinearGradient.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrRadialGradientLayout_DEFINED
|
||||
#define GrRadialGradientLayout_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include "src/gpu/gradients/GrGradientShader.h"
|
||||
#include "src/shaders/gradients/SkRadialGradient.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrSingleIntervalGradientColorizer_DEFINED
|
||||
#define GrSingleIntervalGradientColorizer_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include "src/gpu/GrCoordTransform.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrSweepGradientLayout_DEFINED
|
||||
#define GrSweepGradientLayout_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include "src/gpu/gradients/GrGradientShader.h"
|
||||
#include "src/shaders/gradients/SkSweepGradient.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrTextureGradientColorizer_DEFINED
|
||||
#define GrTextureGradientColorizer_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include "src/gpu/GrCoordTransform.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrTiledGradientEffect_DEFINED
|
||||
#define GrTiledGradientEffect_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include "src/gpu/GrCoordTransform.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrTwoPointConicalGradientLayout_DEFINED
|
||||
#define GrTwoPointConicalGradientLayout_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include "src/gpu/gradients/GrGradientShader.h"
|
||||
#include "src/shaders/gradients/SkTwoPointConicalGradient.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef GrUnrolledBinaryGradientColorizer_DEFINED
|
||||
#define GrUnrolledBinaryGradientColorizer_DEFINED
|
||||
#include "include/core/SkTypes.h"
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/private/SkM44.h"
|
||||
|
||||
#include "src/gpu/GrCoordTransform.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
|
@ -208,11 +208,11 @@ void CPPCodeGenerator::writeRuntimeValue(const Type& type, const Layout& layout,
|
||||
fFormatArgs.push_back(cppCode + ".fB");
|
||||
fFormatArgs.push_back(cppCode + ".fA");
|
||||
break;
|
||||
case Layout::CType::kSkVector4:
|
||||
fFormatArgs.push_back(cppCode + ".fData[0]");
|
||||
fFormatArgs.push_back(cppCode + ".fData[1]");
|
||||
fFormatArgs.push_back(cppCode + ".fData[2]");
|
||||
fFormatArgs.push_back(cppCode + ".fData[3]");
|
||||
case Layout::CType::kSkV4:
|
||||
fFormatArgs.push_back(cppCode + ".x");
|
||||
fFormatArgs.push_back(cppCode + ".y");
|
||||
fFormatArgs.push_back(cppCode + ".z");
|
||||
fFormatArgs.push_back(cppCode + ".w");
|
||||
break;
|
||||
case Layout::CType::kSkRect: // fall through
|
||||
case Layout::CType::kDefault:
|
||||
|
@ -161,9 +161,9 @@ static const std::vector<UniformCTypeMapper>& get_mappers() {
|
||||
"${pdman}.set4fv(${uniform}, 1, ${var}.vec())", // to gpu
|
||||
"{SK_FloatNaN, SK_FloatNaN, SK_FloatNaN, SK_FloatNaN}"), // default value
|
||||
|
||||
REGISTER(Layout::CType::kSkVector4, { "half4", "float4", "double4" },
|
||||
"${pdman}.set4fv(${uniform}, 1, ${var}.fData)", // to gpu
|
||||
"SkVector4(SK_FloatNaN, SK_FloatNaN, SK_FloatNaN, SK_FloatNaN)", // default value
|
||||
REGISTER(Layout::CType::kSkV4, { "half4", "float4", "double4" },
|
||||
"${pdman}.set4fv(${uniform}, 1, ${var}.vec())", // to gpu
|
||||
"SkV4{SK_FloatNaN, SK_FloatNaN, SK_FloatNaN, SK_FloatNaN}", // default value
|
||||
"${oldVar} != (${newVar})"), // dirty check
|
||||
|
||||
REGISTER(Layout::CType::kSkPoint, { "half2", "float2", "double2" } ,
|
||||
@ -179,9 +179,9 @@ static const std::vector<UniformCTypeMapper>& get_mappers() {
|
||||
"SkMatrix::MakeScale(SK_FloatNaN)", // default value
|
||||
"!${oldVar}.cheapEqualTo(${newVar})"), // dirty check
|
||||
|
||||
REGISTER(Layout::CType::kSkMatrix44, { "half4x4", "float4x4", "double4x4" },
|
||||
"${pdman}.setSkMatrix44(${uniform}, ${var})", // to gpu
|
||||
"SkMatrix44(SkMatrix44::kNaN_Constructor)", // default value
|
||||
REGISTER(Layout::CType::kSkM44, { "half4x4", "float4x4", "double4x4" },
|
||||
"${pdman}.setSkM44(${uniform}, ${var})", // to gpu
|
||||
"SkM44(SkM44::kNaN_Constructor)", // default value
|
||||
"${oldVar} != (${newVar})"), // dirty check
|
||||
|
||||
REGISTER(Layout::CType::kFloat, { "half", "float", "double" },
|
||||
|
@ -64,7 +64,7 @@ Layout::CType HCodeGenerator::ParameterCType(const Context& context, const Type&
|
||||
} else if (type == *context.fFloat3x3_Type || type == *context.fHalf3x3_Type) {
|
||||
return Layout::CType::kSkMatrix;
|
||||
} else if (type == *context.fFloat4x4_Type || type == *context.fHalf4x4_Type) {
|
||||
return Layout::CType::kSkMatrix44;
|
||||
return Layout::CType::kSkM44;
|
||||
} else if (type.kind() == Type::kSampler_Kind) {
|
||||
return Layout::CType::kGrSurfaceProxy;
|
||||
} else if (type == *context.fFragmentProcessor_Type) {
|
||||
@ -347,7 +347,7 @@ bool HCodeGenerator::generateCode() {
|
||||
fFullName.c_str(),
|
||||
fFullName.c_str());
|
||||
this->writef("#include \"include/core/SkTypes.h\"\n");
|
||||
this->writef("#include \"include/core/SkMatrix44.h\"\n");
|
||||
this->writef("#include \"include/private/SkM44.h\"\n");
|
||||
this->writeSection(HEADER_SECTION);
|
||||
this->writef("\n"
|
||||
"#include \"src/gpu/GrCoordTransform.h\"\n"
|
||||
|
@ -90,11 +90,11 @@ void Parser::InitLayoutMap() {
|
||||
TOKEN(TRACKED, "tracked");
|
||||
TOKEN(CTYPE, "ctype");
|
||||
TOKEN(SKPMCOLOR4F, "SkPMColor4f");
|
||||
TOKEN(SKVECTOR4, "SkVector4");
|
||||
TOKEN(SKV4, "SkV4");
|
||||
TOKEN(SKRECT, "SkRect");
|
||||
TOKEN(SKIRECT, "SkIRect");
|
||||
TOKEN(SKPMCOLOR, "SkPMColor");
|
||||
TOKEN(SKMATRIX44, "SkMatrix44");
|
||||
TOKEN(SKM44, "SkM44");
|
||||
TOKEN(BOOL, "bool");
|
||||
TOKEN(INT, "int");
|
||||
TOKEN(FLOAT, "float");
|
||||
@ -730,8 +730,8 @@ Layout::CType Parser::layoutCType() {
|
||||
switch (found->second) {
|
||||
case LayoutToken::SKPMCOLOR4F:
|
||||
return Layout::CType::kSkPMColor4f;
|
||||
case LayoutToken::SKVECTOR4:
|
||||
return Layout::CType::kSkVector4;
|
||||
case LayoutToken::SKV4:
|
||||
return Layout::CType::kSkV4;
|
||||
case LayoutToken::SKRECT:
|
||||
return Layout::CType::kSkRect;
|
||||
case LayoutToken::SKIRECT:
|
||||
@ -744,8 +744,8 @@ Layout::CType Parser::layoutCType() {
|
||||
return Layout::CType::kInt32;
|
||||
case LayoutToken::FLOAT:
|
||||
return Layout::CType::kFloat;
|
||||
case LayoutToken::SKMATRIX44:
|
||||
return Layout::CType::kSkMatrix44;
|
||||
case LayoutToken::SKM44:
|
||||
return Layout::CType::kSkM44;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -73,11 +73,11 @@ public:
|
||||
TRACKED,
|
||||
CTYPE,
|
||||
SKPMCOLOR4F,
|
||||
SKVECTOR4,
|
||||
SKV4,
|
||||
SKRECT,
|
||||
SKIRECT,
|
||||
SKPMCOLOR,
|
||||
SKMATRIX44,
|
||||
SKM44,
|
||||
BOOL,
|
||||
INT,
|
||||
FLOAT,
|
||||
|
@ -90,11 +90,11 @@ struct Layout {
|
||||
kSkIRect,
|
||||
kSkPMColor4f,
|
||||
kSkPMColor,
|
||||
kSkVector4,
|
||||
kSkV4,
|
||||
kSkPoint,
|
||||
kSkIPoint,
|
||||
kSkMatrix,
|
||||
kSkMatrix44,
|
||||
kSkM44,
|
||||
kGrSurfaceProxy,
|
||||
kGrFragmentProcessor,
|
||||
};
|
||||
@ -167,16 +167,16 @@ struct Layout {
|
||||
return "SkPMColor4f";
|
||||
case CType::kSkPMColor:
|
||||
return "SkPMColor";
|
||||
case CType::kSkVector4:
|
||||
return "SkVector4";
|
||||
case CType::kSkV4:
|
||||
return "SkV4";
|
||||
case CType::kSkPoint:
|
||||
return "SkPoint";
|
||||
case CType::kSkIPoint:
|
||||
return "SkIPoint";
|
||||
case CType::kSkMatrix:
|
||||
return "SkMatrix";
|
||||
case CType::kSkMatrix44:
|
||||
return "SkMatrix44";
|
||||
case CType::kSkM44:
|
||||
return "SkM44";
|
||||
case CType::kGrSurfaceProxy:
|
||||
return "sk_sp<GrSurfaceProxy>";
|
||||
case CType::kGrFragmentProcessor:
|
||||
|
@ -94,7 +94,7 @@ DEF_TEST(SkSLFPHelloWorld, r) {
|
||||
"#ifndef GrTest_DEFINED\n"
|
||||
"#define GrTest_DEFINED\n"
|
||||
"#include \"include/core/SkTypes.h\"\n"
|
||||
"#include \"include/core/SkMatrix44.h\"\n\n"
|
||||
"#include \"include/private/SkM44.h\"\n\n"
|
||||
"#include \"src/gpu/GrCoordTransform.h\"\n"
|
||||
"#include \"src/gpu/GrFragmentProcessor.h\"\n"
|
||||
"class GrTest : public GrFragmentProcessor {\n"
|
||||
|
@ -5,8 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "include/core/SkMatrix44.h"
|
||||
#include "include/core/SkPoint3.h"
|
||||
#include "include/private/SkM44.h"
|
||||
#include "src/sksl/SkSLByteCode.h"
|
||||
#include "src/sksl/SkSLCompiler.h"
|
||||
#include "src/sksl/SkSLExternalValue.h"
|
||||
@ -369,12 +368,14 @@ DEF_TEST(SkSLInterpreterMatrix, r) {
|
||||
|
||||
// M*M
|
||||
{
|
||||
SkMatrix44 m;
|
||||
m.setColMajorf(in);
|
||||
SkMatrix44 m2;
|
||||
SkM44 m;
|
||||
m.setColMajor(in);
|
||||
SkM44 m2;
|
||||
float in2[16];
|
||||
for (int i = 0; i < 16; ++i) {
|
||||
m2.set(i % 4, i / 4, (i + 4) % 16);
|
||||
in2[i] = (i + 4) % 16;
|
||||
}
|
||||
m2.setColMajor(in2);
|
||||
m.setConcat(m, m2);
|
||||
// Rearrange the columns on the RHS so we detect left-hand/right-hand errors
|
||||
test(r, "float4x4 main(float4x4 m) { return m * float4x4(m[1], m[2], m[3], m[0]); }",
|
||||
@ -860,9 +861,9 @@ DEF_TEST(SkSLInterpreterMix, r) {
|
||||
|
||||
DEF_TEST(SkSLInterpreterCross, r) {
|
||||
float args[] = { 1.0f, 4.0f, -6.0f, -2.0f, 7.0f, -3.0f };
|
||||
SkPoint3 cross = SkPoint3::CrossProduct(SkPoint3::Make(args[0], args[1], args[2]),
|
||||
SkPoint3::Make(args[3], args[4], args[5]));
|
||||
float expected[] = { cross.fX, cross.fY, cross.fZ };
|
||||
SkV3 cross = SkV3::Cross({args[0], args[1], args[2]},
|
||||
{args[3], args[4], args[5]});
|
||||
float expected[] = { cross.x, cross.y, cross.z };
|
||||
test(r, "float3 main(float3 x, float3 y) { return cross(x, y); }", args, expected);
|
||||
}
|
||||
|
||||
@ -885,12 +886,11 @@ DEF_TEST(SkSLInterpreterInverse, r) {
|
||||
}
|
||||
{
|
||||
float args[16], expt[16];
|
||||
SkMatrix44 m;
|
||||
// just some crazy thing that is invertible
|
||||
m.set4x4(1, 2, 3, 4, 1, 2, 0, 3, 1, 0, 1, 4, 1, 3, 2, 0);
|
||||
m.asColMajorf(args);
|
||||
SkM44 m = {1, 2, 3, 4, 1, 2, 0, 3, 1, 0, 1, 4, 1, 3, 2, 0};
|
||||
m.getColMajor(args);
|
||||
SkAssertResult(m.invert(&m));
|
||||
m.asColMajorf(expt);
|
||||
m.getColMajor(expt);
|
||||
test(r, "float4x4 main(float4x4 m) { return inverse(m); }", args, expt, false);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user