diff --git a/bench/GameBench.cpp b/bench/GameBench.cpp index 1df82dedb42a2..b0f7ee64a90cf 100644 --- a/bench/GameBench.cpp +++ b/bench/GameBench.cpp @@ -8,7 +8,7 @@ #include "bench/Benchmark.h" #include "include/core/SkBitmap.h" #include "include/core/SkCanvas.h" -#include "include/core/SkMatrix44.h" +#include "include/core/SkM44.h" #include "include/core/SkPaint.h" #include "include/core/SkShader.h" #include "include/core/SkString.h" @@ -368,7 +368,7 @@ class CanvasMatrixBench : public Benchmark { case kScale_Type: canvas->scale(1.0001f, 0.9999f); break; case k2x3_Type: canvas->concat(m); break; case k3x3_Type: canvas->concat(m); break; - case k4x4_Type: canvas->experimental_concat44(m4); break; + case k4x4_Type: canvas->concat44(m4); break; } } canvas->restore(); diff --git a/bench/Matrix44Bench.cpp b/bench/Matrix44Bench.cpp index e0419a7a7f86b..70323232f3e87 100644 --- a/bench/Matrix44Bench.cpp +++ b/bench/Matrix44Bench.cpp @@ -8,7 +8,7 @@ #include "bench/Benchmark.h" #include "include/core/SkMatrix44.h" #include "include/core/SkString.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "include/utils/SkRandom.h" class Matrix44Bench : public Benchmark { diff --git a/gm/3d.cpp b/gm/3d.cpp index cbc664f51ce76..0625042236db7 100644 --- a/gm/3d.cpp +++ b/gm/3d.cpp @@ -49,7 +49,7 @@ static void do_draw(SkCanvas* canvas, SkColor color) { SkM44 m = SkM44::Rotate({0, 1, 0}, SK_ScalarPI/6); - canvas->experimental_concat44(make_ctm(info, m, {300, 300})); + canvas->concat44(make_ctm(info, m, {300, 300})); canvas->translate(150, 150); SkPaint paint; diff --git a/gm/crbug_224618.cpp b/gm/crbug_224618.cpp index c07fa5e968195..de4f5160f0ce0 100644 --- a/gm/crbug_224618.cpp +++ b/gm/crbug_224618.cpp @@ -12,7 +12,7 @@ #include "include/core/SkMatrix44.h" #include "include/core/SkSurface.h" #include "include/effects/SkGradientShader.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "tools/timer/TimeUtils.h" static SkM44 rotate_axis_angle(SkScalar x, SkScalar y, SkScalar z, SkScalar radians) { @@ -101,7 +101,7 @@ class CrBug224618GM : public skiagm::GM { SkM44::Translate(-radius, -radius); // center content canvas->save(); - canvas->experimental_concat44(model); + canvas->concat44(model); SkPaint fillPaint; fillPaint.setAntiAlias(true); diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h index 9e66747e78af7..29c4a5f6448ce 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -13,6 +13,7 @@ #include "include/core/SkColor.h" #include "include/core/SkFontTypes.h" #include "include/core/SkImageInfo.h" +#include "include/core/SkM44.h" #include "include/core/SkMatrix.h" #include "include/core/SkPaint.h" #include "include/core/SkPoint.h" @@ -26,7 +27,6 @@ #include "include/core/SkTypes.h" #include "include/core/SkVertices.h" #include "include/private/SkDeque.h" -#include "include/private/SkM44.h" #include "include/private/SkMacros.h" #include @@ -44,7 +44,6 @@ class SkFont; class SkGlyphRunBuilder; class SkImage; class SkImageFilter; -class SkM44; class SkPaintFilterCanvas; class SkPath; class SkPicture; @@ -880,9 +879,17 @@ class SK_API SkCanvas { example: https://fiddle.skia.org/c/@Canvas_concat */ void concat(const SkMatrix& matrix); + void concat44(const SkM44&); + void concat44(const SkScalar[]); // column-major - void experimental_concat44(const SkM44&); - void experimental_concat44(const SkScalar[]); // column-major +#ifdef SK_SUPPORT_EXPERIMENTAL_CANVAS44 + void experimental_concat44(const SkM44& m) { + this->concat44(m); + } + void experimental_concat44(const SkScalar colMajor[]) { + this->concat44(colMajor); + } +#endif /** Replaces SkMatrix with matrix. Unlike concat(), any prior matrix state is overwritten. @@ -2508,12 +2515,21 @@ class SK_API SkCanvas { example: https://fiddle.skia.org/c/@Clip */ SkMatrix getTotalMatrix() const; + SkM44 getLocalToDevice() const; // entire matrix stack + void getLocalToDevice(SkScalar colMajor[16]) const; + +#ifdef SK_SUPPORT_EXPERIMENTAL_CANVAS44 + SkM44 experimental_getLocalToDevice() const { + return this->getLocalToDevice(); + } + void experimental_getLocalToDevice(SkScalar colMajor[16]) const { + this->getLocalToDevice(colMajor); + } +#endif - SkM44 experimental_getLocalToDevice() const; // entire matrix stack SkM44 experimental_getLocalToWorld() const; // up to but not including top-most camera SkM44 experimental_getLocalToCamera() const; // up to and including top-most camera - void experimental_getLocalToDevice(SkScalar colMajor[16]) const; void experimental_getLocalToWorld(SkScalar colMajor[16]) const; void experimental_getLocalToCamera(SkScalar colMajor[16]) const; diff --git a/include/core/SkM44.h b/include/core/SkM44.h new file mode 100644 index 0000000000000..7ba293c574c55 --- /dev/null +++ b/include/core/SkM44.h @@ -0,0 +1,393 @@ +/* + * Copyright 2020 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef SkM44_DEFINED +#define SkM44_DEFINED + +#include "include/core/SkMatrix.h" +#include "include/core/SkScalar.h" + +struct SkVec2 { + SkScalar x, y; + + bool operator==(const SkVec2 v) const { return x == v.x && y == v.y; } + bool operator!=(const SkVec2 v) const { return !(*this == v); } + + static SkScalar Dot(SkVec2 a, SkVec2 b) { return a.x * b.x + a.y * b.y; } + static SkScalar Cross(SkVec2 a, SkVec2 b) { return a.x * b.y - a.y * b.x; } + static SkVec2 Normalize(SkVec2 v) { return v * (1.0f / v.length()); } + + SkVec2 operator-() const { return {-x, -y}; } + SkVec2 operator+(SkVec2 v) const { return {x+v.x, y+v.y}; } + SkVec2 operator-(SkVec2 v) const { return {x-v.x, y-v.y}; } + + SkVec2 operator*(SkVec2 v) const { return {x*v.x, y*v.y}; } + friend SkVec2 operator*(SkVec2 v, SkScalar s) { return {v.x*s, v.y*s}; } + friend SkVec2 operator*(SkScalar s, SkVec2 v) { return {v.x*s, v.y*s}; } + + void operator+=(SkVec2 v) { *this = *this + v; } + void operator-=(SkVec2 v) { *this = *this - v; } + void operator*=(SkVec2 v) { *this = *this * v; } + void operator*=(SkScalar s) { *this = *this * s; } + + SkScalar lengthSquared() const { return Dot(*this, *this); } + SkScalar length() const { return SkScalarSqrt(this->lengthSquared()); } + + SkScalar dot(SkVec2 v) const { return Dot(*this, v); } + SkScalar cross(SkVec2 v) const { return Cross(*this, v); } + SkVec2 normalize() const { return Normalize(*this); } + + const float* ptr() const { return &x; } + float* ptr() { return &x; } +}; + +struct SkV3 { + float x, y, z; + + 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) { + return { a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x }; + } + static SkV3 Normalize(const SkV3& v) { return v * (1.0f / v.length()); } + + SkV3 operator-() const { return {-x, -y, -z}; } + SkV3 operator+(const SkV3& v) const { return { x + v.x, y + v.y, z + v.z }; } + SkV3 operator-(const SkV3& v) const { return { x - v.x, y - v.y, z - v.z }; } + + SkV3 operator*(const SkV3& v) const { + return { x*v.x, y*v.y, z*v.z }; + } + friend SkV3 operator*(const SkV3& v, SkScalar s) { + return { v.x*s, v.y*s, v.z*s }; + } + friend SkV3 operator*(SkScalar s, const SkV3& v) { return v*s; } + + SkScalar lengthSquared() const { return Dot(*this, *this); } + SkScalar length() const { return SkScalarSqrt(Dot(*this, *this)); } + + SkScalar dot(const SkV3& v) const { return Dot(*this, v); } + SkV3 cross(const SkV3& v) const { return Cross(*this, v); } + SkV3 normalize() const { return Normalize(*this); } + + const float* ptr() const { return &x; } + float* ptr() { return &x; } +}; + +struct SkV4 { + float x, y, z, w; + + 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 }; } + + SkV4 operator*(const SkV4& v) const { + return { x*v.x, y*v.y, z*v.z, w*v.w }; + } + friend SkV4 operator*(const SkV4& v, SkScalar s) { + return { v.x*s, v.y*s, v.z*s, v.w*s }; + } + friend SkV4 operator*(SkScalar s, const SkV4& v) { return v*s; } + + const float* ptr() const { return &x; } + float* ptr() { return &x; } +}; + +/** + * 4x4 matrix used by SkCanvas and other parts of Skia. + * + * Skia assumes a right-handed coordinate system: + * +X goes to the right + * +Y goes down + * +Z goes into the screen (away from the viewer) + */ +class SkM44 { +public: + SkM44(const SkM44& src) = default; + SkM44& operator=(const SkM44& src) = default; + + constexpr SkM44() + : fMat{1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1} + {} + + SkM44(const SkM44& a, const SkM44& b) { + this->setConcat(a, b); + } + + 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. + */ + SkM44(SkScalar m0, SkScalar m4, SkScalar m8, SkScalar m12, + SkScalar m1, SkScalar m5, SkScalar m9, SkScalar m13, + SkScalar m2, SkScalar m6, SkScalar m10, SkScalar m14, + SkScalar m3, SkScalar m7, SkScalar m11, SkScalar m15) + { + this->set44(m0, m4, m8, m12, + m1, m5, m9, m13, + m2, m6, m10, m14, + m3, m7, m11, m15); + } + + static SkM44 Rows(const SkV4& r0, const SkV4& r1, const SkV4& r2, const SkV4& r3) { + SkM44 m(kUninitialized_Constructor); + m.setRow(0, r0); + m.setRow(1, r1); + m.setRow(2, r2); + m.setRow(3, r3); + return m; + } + static SkM44 Cols(const SkV4& c0, const SkV4& c1, const SkV4& c2, const SkV4& c3) { + SkM44 m(kUninitialized_Constructor); + m.setCol(0, c0); + m.setCol(1, c1); + m.setCol(2, c2); + m.setCol(3, c3); + return m; + } + + static SkM44 Translate(SkScalar x, SkScalar y, SkScalar z = 0) { + return SkM44(1, 0, 0, x, + 0, 1, 0, y, + 0, 0, 1, z, + 0, 0, 0, 1); + } + + static SkM44 Scale(SkScalar x, SkScalar y, SkScalar z = 1) { + return SkM44(x, 0, 0, 0, + 0, y, 0, 0, + 0, 0, z, 0, + 0, 0, 0, 1); + } + + static SkM44 Rotate(SkV3 axis, SkScalar radians) { + SkM44 m(kUninitialized_Constructor); + m.setRotate(axis, radians); + return m; + } + + bool operator==(const SkM44& other) const; + bool operator!=(const SkM44& other) const { + return !(other == *this); + } + + void getColMajor(SkScalar v[]) const { + memcpy(v, fMat, sizeof(fMat)); + } + void getRowMajor(SkScalar v[]) const; + + SkM44& setColMajor(const SkScalar v[]) { + memcpy(fMat, v, sizeof(fMat)); + return *this; + } + SkM44& setRowMajor(const SkScalar v[]); + + /* Parameters in same order as constructor. + */ + SkM44& set44(SkScalar m0, SkScalar m4, SkScalar m8, SkScalar m12, + SkScalar m1, SkScalar m5, SkScalar m9, SkScalar m13, + SkScalar m2, SkScalar m6, SkScalar m10, SkScalar m14, + SkScalar m3, SkScalar m7, SkScalar m11, SkScalar m15) { + fMat[0] = m0; fMat[4] = m4; fMat[8] = m8; fMat[12] = m12; + fMat[1] = m1; fMat[5] = m5; fMat[9] = m9; fMat[13] = m13; + fMat[2] = m2; fMat[6] = m6; fMat[10] = m10; fMat[14] = m14; + fMat[3] = m3; fMat[7] = m7; fMat[11] = m11; fMat[15] = m15; + return *this; + } + + SkScalar rc(int r, int c) const { + SkASSERT(r >= 0 && r <= 3); + SkASSERT(c >= 0 && c <= 3); + return fMat[c*4 + r]; + } + void setRC(int r, int c, SkScalar value) { + SkASSERT(r >= 0 && r <= 3); + SkASSERT(c >= 0 && c <= 3); + fMat[c*4 + r] = value; + } + + SkV4 row(int i) const { + SkASSERT(i >= 0 && i <= 3); + return {fMat[i + 0], fMat[i + 4], fMat[i + 8], fMat[i + 12]}; + } + SkV4 col(int i) const { + SkASSERT(i >= 0 && i <= 3); + return {fMat[i*4 + 0], fMat[i*4 + 1], fMat[i*4 + 2], fMat[i*4 + 3]}; + } + + void setRow(int i, const SkV4& v) { + SkASSERT(i >= 0 && i <= 3); + fMat[i + 0] = v.x; + fMat[i + 4] = v.y; + fMat[i + 8] = v.z; + fMat[i + 12] = v.w; + } + void setCol(int i, const SkV4& v) { + SkASSERT(i >= 0 && i <= 3); + memcpy(&fMat[i*4], v.ptr(), sizeof(v)); + } + + SkM44& setIdentity() { + return this->set44(1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1); + } + + SkM44& setTranslate(SkScalar x, SkScalar y, SkScalar z = 0) { + return this->set44(1, 0, 0, x, + 0, 1, 0, y, + 0, 0, 1, z, + 0, 0, 0, 1); + } + + SkM44& setScale(SkScalar x, SkScalar y, SkScalar z = 1) { + return this->set44(x, 0, 0, 0, + 0, y, 0, 0, + 0, 0, z, 0, + 0, 0, 0, 1); + } + + /** + * Set this matrix to rotate about the specified unit-length axis vector, + * by an angle specified by its sin() and cos(). + * + * This does not attempt to verify that axis.length() == 1 or that the sin,cos values + * are correct. + */ + SkM44& setRotateUnitSinCos(SkV3 axis, SkScalar sinAngle, SkScalar cosAngle); + + /** + * Set this matrix to rotate about the specified unit-length axis vector, + * by an angle specified in radians. + * + * This does not attempt to verify that axis.length() == 1. + */ + SkM44& setRotateUnit(SkV3 axis, SkScalar radians) { + return this->setRotateUnitSinCos(axis, SkScalarSin(radians), SkScalarCos(radians)); + } + + /** + * Set this matrix to rotate about the specified axis vector, + * by an angle specified in radians. + * + * Note: axis is not assumed to be unit-length, so it will be normalized internally. + * If axis is already unit-length, call setRotateAboutUnitRadians() instead. + */ + SkM44& setRotate(SkV3 axis, SkScalar radians); + + SkM44& setConcat16(const SkM44& a, const SkScalar colMajor[16]); + + SkM44& setConcat(const SkM44& a, const SkM44& b) { + return this->setConcat16(a, b.fMat); + } + + friend SkM44 operator*(const SkM44& a, const SkM44& b) { + return SkM44(a, b); + } + + SkM44& preConcat16(const SkScalar colMajor[16]) { + return this->setConcat16(*this, colMajor); + } + + /** If this is invertible, return that in inverse and return true. If it is + * not invertible, return false and leave the inverse parameter unchanged. + */ + bool SK_WARN_UNUSED_RESULT invert(SkM44* inverse) const; + + SkM44 transpose() const; + + void dump() const; + + //////////// + + SkV4 map(float x, float y, float z, float w) const; + SkV4 operator*(const SkV4& v) const { + return this->map(v.x, v.y, v.z, v.w); + } + SkV3 operator*(SkV3 v) const { + auto v4 = this->map(v.x, v.y, v.z, 0); + return {v4.x, v4.y, v4.z}; + } + + ////////////////////// Converting to/from SkMatrix + + /* When converting from SkM44 to SkMatrix, the third row and + * column is dropped. When converting from SkMatrix to SkM44 + * the third row and column remain as identity: + * [ a b c ] [ a b 0 c ] + * [ d e f ] -> [ d e 0 f ] + * [ g h i ] [ 0 0 1 0 ] + * [ g h 0 i ] + */ + SkMatrix asM33() const { + return SkMatrix::MakeAll(fMat[0], fMat[4], fMat[12], + fMat[1], fMat[5], fMat[13], + fMat[3], fMat[7], fMat[15]); + } + + SkM44(const SkMatrix& src) + : SkM44(src[SkMatrix::kMScaleX], src[SkMatrix::kMSkewX], 0, src[SkMatrix::kMTransX], + src[SkMatrix::kMSkewY], src[SkMatrix::kMScaleY], 0, src[SkMatrix::kMTransY], + 0, 0, 1, 0, + src[SkMatrix::kMPersp0], src[SkMatrix::kMPersp1], 0, src[SkMatrix::kMPersp2]) + {} + + SkM44& operator=(const SkMatrix& src) { + *this = SkM44(src); + return *this; + } + + SkM44& preTranslate(SkScalar x, SkScalar y); + SkM44& preScale(SkScalar x, SkScalar y); + SkM44& preConcat(const SkMatrix&); + +private: + /* Stored in column-major. + * Indices + * 0 4 8 12 1 0 0 trans_x + * 1 5 9 13 e.g. 0 1 0 trans_y + * 2 6 10 14 0 0 1 trans_z + * 3 7 11 15 0 0 0 1 + */ + SkScalar fMat[16]; + + double determinant() const; + + friend class SkMatrixPriv; +}; + +SkM44 Sk3LookAt(const SkV3& eye, const SkV3& center, const SkV3& up); +SkM44 Sk3Perspective(float near, float far, float angle); + +#endif diff --git a/include/private/SkM44.h b/include/private/SkM44.h index 7ba293c574c55..5ceca48428565 100644 --- a/include/private/SkM44.h +++ b/include/private/SkM44.h @@ -5,389 +5,9 @@ * found in the LICENSE file. */ -#ifndef SkM44_DEFINED -#define SkM44_DEFINED +#ifndef SkM44_private_DEFINED +#define SkM44_private_DEFINED -#include "include/core/SkMatrix.h" -#include "include/core/SkScalar.h" - -struct SkVec2 { - SkScalar x, y; - - bool operator==(const SkVec2 v) const { return x == v.x && y == v.y; } - bool operator!=(const SkVec2 v) const { return !(*this == v); } - - static SkScalar Dot(SkVec2 a, SkVec2 b) { return a.x * b.x + a.y * b.y; } - static SkScalar Cross(SkVec2 a, SkVec2 b) { return a.x * b.y - a.y * b.x; } - static SkVec2 Normalize(SkVec2 v) { return v * (1.0f / v.length()); } - - SkVec2 operator-() const { return {-x, -y}; } - SkVec2 operator+(SkVec2 v) const { return {x+v.x, y+v.y}; } - SkVec2 operator-(SkVec2 v) const { return {x-v.x, y-v.y}; } - - SkVec2 operator*(SkVec2 v) const { return {x*v.x, y*v.y}; } - friend SkVec2 operator*(SkVec2 v, SkScalar s) { return {v.x*s, v.y*s}; } - friend SkVec2 operator*(SkScalar s, SkVec2 v) { return {v.x*s, v.y*s}; } - - void operator+=(SkVec2 v) { *this = *this + v; } - void operator-=(SkVec2 v) { *this = *this - v; } - void operator*=(SkVec2 v) { *this = *this * v; } - void operator*=(SkScalar s) { *this = *this * s; } - - SkScalar lengthSquared() const { return Dot(*this, *this); } - SkScalar length() const { return SkScalarSqrt(this->lengthSquared()); } - - SkScalar dot(SkVec2 v) const { return Dot(*this, v); } - SkScalar cross(SkVec2 v) const { return Cross(*this, v); } - SkVec2 normalize() const { return Normalize(*this); } - - const float* ptr() const { return &x; } - float* ptr() { return &x; } -}; - -struct SkV3 { - float x, y, z; - - 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) { - return { a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x }; - } - static SkV3 Normalize(const SkV3& v) { return v * (1.0f / v.length()); } - - SkV3 operator-() const { return {-x, -y, -z}; } - SkV3 operator+(const SkV3& v) const { return { x + v.x, y + v.y, z + v.z }; } - SkV3 operator-(const SkV3& v) const { return { x - v.x, y - v.y, z - v.z }; } - - SkV3 operator*(const SkV3& v) const { - return { x*v.x, y*v.y, z*v.z }; - } - friend SkV3 operator*(const SkV3& v, SkScalar s) { - return { v.x*s, v.y*s, v.z*s }; - } - friend SkV3 operator*(SkScalar s, const SkV3& v) { return v*s; } - - SkScalar lengthSquared() const { return Dot(*this, *this); } - SkScalar length() const { return SkScalarSqrt(Dot(*this, *this)); } - - SkScalar dot(const SkV3& v) const { return Dot(*this, v); } - SkV3 cross(const SkV3& v) const { return Cross(*this, v); } - SkV3 normalize() const { return Normalize(*this); } - - const float* ptr() const { return &x; } - float* ptr() { return &x; } -}; - -struct SkV4 { - float x, y, z, w; - - 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 }; } - - SkV4 operator*(const SkV4& v) const { - return { x*v.x, y*v.y, z*v.z, w*v.w }; - } - friend SkV4 operator*(const SkV4& v, SkScalar s) { - return { v.x*s, v.y*s, v.z*s, v.w*s }; - } - friend SkV4 operator*(SkScalar s, const SkV4& v) { return v*s; } - - const float* ptr() const { return &x; } - float* ptr() { return &x; } -}; - -/** - * 4x4 matrix used by SkCanvas and other parts of Skia. - * - * Skia assumes a right-handed coordinate system: - * +X goes to the right - * +Y goes down - * +Z goes into the screen (away from the viewer) - */ -class SkM44 { -public: - SkM44(const SkM44& src) = default; - SkM44& operator=(const SkM44& src) = default; - - constexpr SkM44() - : fMat{1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1} - {} - - SkM44(const SkM44& a, const SkM44& b) { - this->setConcat(a, b); - } - - 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. - */ - SkM44(SkScalar m0, SkScalar m4, SkScalar m8, SkScalar m12, - SkScalar m1, SkScalar m5, SkScalar m9, SkScalar m13, - SkScalar m2, SkScalar m6, SkScalar m10, SkScalar m14, - SkScalar m3, SkScalar m7, SkScalar m11, SkScalar m15) - { - this->set44(m0, m4, m8, m12, - m1, m5, m9, m13, - m2, m6, m10, m14, - m3, m7, m11, m15); - } - - static SkM44 Rows(const SkV4& r0, const SkV4& r1, const SkV4& r2, const SkV4& r3) { - SkM44 m(kUninitialized_Constructor); - m.setRow(0, r0); - m.setRow(1, r1); - m.setRow(2, r2); - m.setRow(3, r3); - return m; - } - static SkM44 Cols(const SkV4& c0, const SkV4& c1, const SkV4& c2, const SkV4& c3) { - SkM44 m(kUninitialized_Constructor); - m.setCol(0, c0); - m.setCol(1, c1); - m.setCol(2, c2); - m.setCol(3, c3); - return m; - } - - static SkM44 Translate(SkScalar x, SkScalar y, SkScalar z = 0) { - return SkM44(1, 0, 0, x, - 0, 1, 0, y, - 0, 0, 1, z, - 0, 0, 0, 1); - } - - static SkM44 Scale(SkScalar x, SkScalar y, SkScalar z = 1) { - return SkM44(x, 0, 0, 0, - 0, y, 0, 0, - 0, 0, z, 0, - 0, 0, 0, 1); - } - - static SkM44 Rotate(SkV3 axis, SkScalar radians) { - SkM44 m(kUninitialized_Constructor); - m.setRotate(axis, radians); - return m; - } - - bool operator==(const SkM44& other) const; - bool operator!=(const SkM44& other) const { - return !(other == *this); - } - - void getColMajor(SkScalar v[]) const { - memcpy(v, fMat, sizeof(fMat)); - } - void getRowMajor(SkScalar v[]) const; - - SkM44& setColMajor(const SkScalar v[]) { - memcpy(fMat, v, sizeof(fMat)); - return *this; - } - SkM44& setRowMajor(const SkScalar v[]); - - /* Parameters in same order as constructor. - */ - SkM44& set44(SkScalar m0, SkScalar m4, SkScalar m8, SkScalar m12, - SkScalar m1, SkScalar m5, SkScalar m9, SkScalar m13, - SkScalar m2, SkScalar m6, SkScalar m10, SkScalar m14, - SkScalar m3, SkScalar m7, SkScalar m11, SkScalar m15) { - fMat[0] = m0; fMat[4] = m4; fMat[8] = m8; fMat[12] = m12; - fMat[1] = m1; fMat[5] = m5; fMat[9] = m9; fMat[13] = m13; - fMat[2] = m2; fMat[6] = m6; fMat[10] = m10; fMat[14] = m14; - fMat[3] = m3; fMat[7] = m7; fMat[11] = m11; fMat[15] = m15; - return *this; - } - - SkScalar rc(int r, int c) const { - SkASSERT(r >= 0 && r <= 3); - SkASSERT(c >= 0 && c <= 3); - return fMat[c*4 + r]; - } - void setRC(int r, int c, SkScalar value) { - SkASSERT(r >= 0 && r <= 3); - SkASSERT(c >= 0 && c <= 3); - fMat[c*4 + r] = value; - } - - SkV4 row(int i) const { - SkASSERT(i >= 0 && i <= 3); - return {fMat[i + 0], fMat[i + 4], fMat[i + 8], fMat[i + 12]}; - } - SkV4 col(int i) const { - SkASSERT(i >= 0 && i <= 3); - return {fMat[i*4 + 0], fMat[i*4 + 1], fMat[i*4 + 2], fMat[i*4 + 3]}; - } - - void setRow(int i, const SkV4& v) { - SkASSERT(i >= 0 && i <= 3); - fMat[i + 0] = v.x; - fMat[i + 4] = v.y; - fMat[i + 8] = v.z; - fMat[i + 12] = v.w; - } - void setCol(int i, const SkV4& v) { - SkASSERT(i >= 0 && i <= 3); - memcpy(&fMat[i*4], v.ptr(), sizeof(v)); - } - - SkM44& setIdentity() { - return this->set44(1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1); - } - - SkM44& setTranslate(SkScalar x, SkScalar y, SkScalar z = 0) { - return this->set44(1, 0, 0, x, - 0, 1, 0, y, - 0, 0, 1, z, - 0, 0, 0, 1); - } - - SkM44& setScale(SkScalar x, SkScalar y, SkScalar z = 1) { - return this->set44(x, 0, 0, 0, - 0, y, 0, 0, - 0, 0, z, 0, - 0, 0, 0, 1); - } - - /** - * Set this matrix to rotate about the specified unit-length axis vector, - * by an angle specified by its sin() and cos(). - * - * This does not attempt to verify that axis.length() == 1 or that the sin,cos values - * are correct. - */ - SkM44& setRotateUnitSinCos(SkV3 axis, SkScalar sinAngle, SkScalar cosAngle); - - /** - * Set this matrix to rotate about the specified unit-length axis vector, - * by an angle specified in radians. - * - * This does not attempt to verify that axis.length() == 1. - */ - SkM44& setRotateUnit(SkV3 axis, SkScalar radians) { - return this->setRotateUnitSinCos(axis, SkScalarSin(radians), SkScalarCos(radians)); - } - - /** - * Set this matrix to rotate about the specified axis vector, - * by an angle specified in radians. - * - * Note: axis is not assumed to be unit-length, so it will be normalized internally. - * If axis is already unit-length, call setRotateAboutUnitRadians() instead. - */ - SkM44& setRotate(SkV3 axis, SkScalar radians); - - SkM44& setConcat16(const SkM44& a, const SkScalar colMajor[16]); - - SkM44& setConcat(const SkM44& a, const SkM44& b) { - return this->setConcat16(a, b.fMat); - } - - friend SkM44 operator*(const SkM44& a, const SkM44& b) { - return SkM44(a, b); - } - - SkM44& preConcat16(const SkScalar colMajor[16]) { - return this->setConcat16(*this, colMajor); - } - - /** If this is invertible, return that in inverse and return true. If it is - * not invertible, return false and leave the inverse parameter unchanged. - */ - bool SK_WARN_UNUSED_RESULT invert(SkM44* inverse) const; - - SkM44 transpose() const; - - void dump() const; - - //////////// - - SkV4 map(float x, float y, float z, float w) const; - SkV4 operator*(const SkV4& v) const { - return this->map(v.x, v.y, v.z, v.w); - } - SkV3 operator*(SkV3 v) const { - auto v4 = this->map(v.x, v.y, v.z, 0); - return {v4.x, v4.y, v4.z}; - } - - ////////////////////// Converting to/from SkMatrix - - /* When converting from SkM44 to SkMatrix, the third row and - * column is dropped. When converting from SkMatrix to SkM44 - * the third row and column remain as identity: - * [ a b c ] [ a b 0 c ] - * [ d e f ] -> [ d e 0 f ] - * [ g h i ] [ 0 0 1 0 ] - * [ g h 0 i ] - */ - SkMatrix asM33() const { - return SkMatrix::MakeAll(fMat[0], fMat[4], fMat[12], - fMat[1], fMat[5], fMat[13], - fMat[3], fMat[7], fMat[15]); - } - - SkM44(const SkMatrix& src) - : SkM44(src[SkMatrix::kMScaleX], src[SkMatrix::kMSkewX], 0, src[SkMatrix::kMTransX], - src[SkMatrix::kMSkewY], src[SkMatrix::kMScaleY], 0, src[SkMatrix::kMTransY], - 0, 0, 1, 0, - src[SkMatrix::kMPersp0], src[SkMatrix::kMPersp1], 0, src[SkMatrix::kMPersp2]) - {} - - SkM44& operator=(const SkMatrix& src) { - *this = SkM44(src); - return *this; - } - - SkM44& preTranslate(SkScalar x, SkScalar y); - SkM44& preScale(SkScalar x, SkScalar y); - SkM44& preConcat(const SkMatrix&); - -private: - /* Stored in column-major. - * Indices - * 0 4 8 12 1 0 0 trans_x - * 1 5 9 13 e.g. 0 1 0 trans_y - * 2 6 10 14 0 0 1 trans_z - * 3 7 11 15 0 0 0 1 - */ - SkScalar fMat[16]; - - double determinant() const; - - friend class SkMatrixPriv; -}; - -SkM44 Sk3LookAt(const SkV3& eye, const SkV3& center, const SkV3& up); -SkM44 Sk3Perspective(float near, float far, float angle); +#include "include/core/SkM44.h" #endif diff --git a/modules/skottie/src/SkottieValue.cpp b/modules/skottie/src/SkottieValue.cpp index ba833e78da6e8..5b12b5d3e4cd2 100644 --- a/modules/skottie/src/SkottieValue.cpp +++ b/modules/skottie/src/SkottieValue.cpp @@ -8,9 +8,9 @@ #include "modules/skottie/src/SkottieValue.h" #include "include/core/SkColor.h" +#include "include/core/SkM44.h" #include "include/core/SkPoint.h" #include "include/core/SkSize.h" -#include "include/private/SkM44.h" #include "include/private/SkNx.h" #include "modules/skottie/src/SkottieJson.h" #include "modules/skottie/src/SkottiePriv.h" diff --git a/modules/skottie/src/Transform.h b/modules/skottie/src/Transform.h index 0d1797e006b3a..c18ab77bc7897 100644 --- a/modules/skottie/src/Transform.h +++ b/modules/skottie/src/Transform.h @@ -8,9 +8,9 @@ #ifndef SkottieTransform_DEFINED #define SkottieTransform_DEFINED +#include "include/core/SkM44.h" #include "include/core/SkMatrix.h" #include "include/core/SkPoint.h" -#include "include/private/SkM44.h" #include "modules/skottie/src/Adapter.h" #include "modules/skottie/src/SkottieValue.h" #include "modules/sksg/include/SkSGTransform.h" diff --git a/samplecode/Sample3D.cpp b/samplecode/Sample3D.cpp index 0caa247a35a40..3ec67eb924198 100644 --- a/samplecode/Sample3D.cpp +++ b/samplecode/Sample3D.cpp @@ -6,9 +6,9 @@ */ #include "include/core/SkCanvas.h" +#include "include/core/SkM44.h" #include "include/core/SkPaint.h" #include "include/core/SkRRect.h" -#include "include/private/SkM44.h" #include "include/utils/SkRandom.h" #include "samplecode/Sample.h" #include "tools/Resources.h" @@ -261,7 +261,7 @@ class SampleCubeBase : public Sample3DView { virtual void drawContent(SkCanvas* canvas, SkColor, int index, bool drawFront) = 0; void setClickToWorld(SkCanvas* canvas, const SkM44& clickM) { - auto l2d = canvas->experimental_getLocalToDevice(); + auto l2d = canvas->getLocalToDevice(); fWorldToClick = inv(clickM) * l2d; fClickToWorld = inv(fWorldToClick); } @@ -270,7 +270,7 @@ class SampleCubeBase : public Sample3DView { if (!canvas->getGrContext() && !(fFlags & kCanRunOnCPU)) { return; } - SkM44 clickM = canvas->experimental_getLocalToDevice(); + SkM44 clickM = canvas->getLocalToDevice(); canvas->save(); canvas->translate(DX, DY); @@ -287,7 +287,7 @@ class SampleCubeBase : public Sample3DView { SkM44 trans = SkM44::Translate(200, 200, 0); // center of the rotation SkM44 m = fRotateAnimator.rotation() * fRotation * f.asM44(200); - canvas->experimental_concat44(trans * m * inv(trans)); + canvas->concat44(trans * m * inv(trans)); this->drawContent(canvas, f.fColor, index++, drawFront); } } @@ -414,7 +414,7 @@ class SampleBump3D : public SampleCubeBase { } void drawContent(SkCanvas* canvas, SkColor color, int index, bool drawFront) override { - if (!drawFront || !front(canvas->experimental_getLocalToDevice())) { + if (!drawFront || !front(canvas->getLocalToDevice())) { return; } @@ -473,7 +473,7 @@ class SampleSkottieCube : public SampleCubeBase { } void drawContent(SkCanvas* canvas, SkColor color, int index, bool drawFront) override { - if (!drawFront || !front(canvas->experimental_getLocalToDevice())) { + if (!drawFront || !front(canvas->getLocalToDevice())) { return; } diff --git a/samplecode/SampleClip.cpp b/samplecode/SampleClip.cpp index 90f2c7ffaa8ef..4f4ff250b2a07 100644 --- a/samplecode/SampleClip.cpp +++ b/samplecode/SampleClip.cpp @@ -527,7 +527,7 @@ class HalfPlaneView3 : public SampleCameraView { if (fShowUnclipped) { canvas->save(); - canvas->experimental_concat44(mx); + canvas->concat44(mx); paint.setAlphaf(0.33f); canvas->drawPath(fPath, paint); paint.setAlphaf(1.f); @@ -542,7 +542,7 @@ class HalfPlaneView3 : public SampleCameraView { planeColor = SK_ColorRED; } canvas->save(); - canvas->experimental_concat44(mx); + canvas->concat44(mx); canvas->drawPath(*path, paint); canvas->restore(); @@ -585,7 +585,7 @@ class HalfPlaneCoons : public SampleCameraView { SkPaint paint; canvas->save(); - canvas->experimental_concat44(this->get44({0, 0, 300, 300})); + canvas->concat44(this->get44({0, 0, 300, 300})); const SkPoint* tex = nullptr; const SkColor* col = nullptr; diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index b7a73c2604963..6e4d5346f12d7 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -737,7 +737,7 @@ void SkCanvas::doSave() { int SkCanvas::experimental_saveCamera(const SkM44& projection, const SkM44& camera) { // TODO: add a virtual for this, and update clients (e.g. chrome) int n = this->save(); - this->experimental_concat44(projection * camera); + this->concat44(projection * camera); fCameraStack.push_back(CameraRec(fMCRec, camera)); return n; } @@ -1507,20 +1507,20 @@ void SkCanvas::concat(const SkMatrix& matrix) { this->didConcat(matrix); } -void SkCanvas::experimental_concat44(const SkScalar m[16]) { +void SkCanvas::concat44(const SkScalar colMajor[16]) { this->checkForDeferredSave(); - fMCRec->fMatrix.preConcat16(m); + fMCRec->fMatrix.preConcat16(colMajor); fIsScaleTranslate = fMCRec->fMatrix.isScaleTranslate(); FOR_EACH_TOP_DEVICE(device->setGlobalCTM(fMCRec->fMatrix)); - this->didConcat44(m); + this->didConcat44(colMajor); } -void SkCanvas::experimental_concat44(const SkM44& m) { - this->experimental_concat44(SkMatrixPriv::M44ColMajor(m)); +void SkCanvas::concat44(const SkM44& m) { + this->concat44(SkMatrixPriv::M44ColMajor(m)); } void SkCanvas::internalSetMatrix(const SkMatrix& matrix) { @@ -1825,30 +1825,30 @@ SkMatrix SkCanvas::getTotalMatrix() const { return fMCRec->fMatrix; } -SkM44 SkCanvas::experimental_getLocalToDevice() const { +SkM44 SkCanvas::getLocalToDevice() const { return fMCRec->fMatrix; } SkM44 SkCanvas::experimental_getLocalToWorld() const { if (fCameraStack.empty()) { - return this->experimental_getLocalToDevice(); + return this->getLocalToDevice(); } else { const auto& top = fCameraStack.back(); - return top.fInvPostCamera * this->experimental_getLocalToDevice(); + return top.fInvPostCamera * this->getLocalToDevice(); } } SkM44 SkCanvas::experimental_getLocalToCamera() const { if (fCameraStack.empty()) { - return this->experimental_getLocalToDevice(); + return this->getLocalToDevice(); } else { const auto& top = fCameraStack.back(); - return top.fCamera * top.fInvPostCamera * this->experimental_getLocalToDevice(); + return top.fCamera * top.fInvPostCamera * this->getLocalToDevice(); } } -void SkCanvas::experimental_getLocalToDevice(SkScalar colMajor[16]) const { - this->experimental_getLocalToDevice().getColMajor(colMajor); +void SkCanvas::getLocalToDevice(SkScalar colMajor[16]) const { + this->getLocalToDevice().getColMajor(colMajor); } void SkCanvas::experimental_getLocalToWorld(SkScalar colMajor[16]) const { diff --git a/src/core/SkCanvasMatrix.h b/src/core/SkCanvasMatrix.h index bc25a638335f0..88d5bc808741a 100644 --- a/src/core/SkCanvasMatrix.h +++ b/src/core/SkCanvasMatrix.h @@ -9,7 +9,7 @@ #define SkCanvasMatrix_DEFINED #include "include/core/SkMatrix.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" class SkCanvasMatrix : public SkM44 { public: diff --git a/src/core/SkM44.cpp b/src/core/SkM44.cpp index d0a697424a076..a09019fed829e 100644 --- a/src/core/SkM44.cpp +++ b/src/core/SkM44.cpp @@ -6,7 +6,7 @@ */ #include "include/core/SkMatrix.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "include/private/SkVx.h" typedef skvx::Vec<4, float> sk4f; diff --git a/src/core/SkMatrixPriv.h b/src/core/SkMatrixPriv.h index 72e8739e2ffc7..e4b2d4e026e61 100644 --- a/src/core/SkMatrixPriv.h +++ b/src/core/SkMatrixPriv.h @@ -10,7 +10,7 @@ #include "include/core/SkFilterQuality.h" #include "include/core/SkMatrix.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "include/private/SkNx.h" #include "src/core/SkPointPriv.h" diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp index 8b152145d0749..a765bdf635ab2 100644 --- a/src/core/SkPicturePlayback.cpp +++ b/src/core/SkPicturePlayback.cpp @@ -177,7 +177,7 @@ void SkPicturePlayback::handleOp(SkReadBuffer* reader, case CONCAT44: { const SkScalar* colMaj = reader->skipT(16); BREAK_ON_READ_ERROR(reader); - canvas->experimental_concat44(colMaj); + canvas->concat44(colMaj); break; } case DRAW_ANNOTATION: { diff --git a/src/core/SkRecordDraw.cpp b/src/core/SkRecordDraw.cpp index 3d7b987b2396e..114eea8491d74 100644 --- a/src/core/SkRecordDraw.cpp +++ b/src/core/SkRecordDraw.cpp @@ -94,7 +94,7 @@ template <> void Draw::draw(const DrawBehind& r) { } DRAW(SetMatrix, setMatrix(SkMatrix::Concat(fInitialCTM, r.matrix))); -DRAW(Concat44, experimental_concat44(r.matrix)); +DRAW(Concat44, concat44(r.matrix)); DRAW(Concat, concat(r.matrix)); DRAW(Translate, translate(r.dx, r.dy)); DRAW(Scale, scale(r.sx, r.sy)); diff --git a/src/core/SkRecords.h b/src/core/SkRecords.h index e97a13543f83c..ac096c08dd7dc 100644 --- a/src/core/SkRecords.h +++ b/src/core/SkRecords.h @@ -13,6 +13,7 @@ #include "include/core/SkDrawable.h" #include "include/core/SkImage.h" #include "include/core/SkImageFilter.h" +#include "include/core/SkM44.h" #include "include/core/SkMatrix.h" #include "include/core/SkPath.h" #include "include/core/SkPicture.h" @@ -23,7 +24,6 @@ #include "include/core/SkString.h" #include "include/core/SkTextBlob.h" #include "include/core/SkVertices.h" -#include "include/private/SkM44.h" #include "src/core/SkDrawShadowInfo.h" namespace SkRecords { diff --git a/src/core/SkYUVMath.cpp b/src/core/SkYUVMath.cpp index fe5cc9cf50dda..a3450febac425 100644 --- a/src/core/SkYUVMath.cpp +++ b/src/core/SkYUVMath.cpp @@ -5,7 +5,7 @@ * found in the LICENSE file. */ -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "src/core/SkYUVMath.h" // in SkColorMatrix order (row-major) diff --git a/src/gpu/effects/generated/GrAARectEffect.h b/src/gpu/effects/generated/GrAARectEffect.h index d697e937b378d..42324b4c6dcdf 100644 --- a/src/gpu/effects/generated/GrAARectEffect.h +++ b/src/gpu/effects/generated/GrAARectEffect.h @@ -11,7 +11,7 @@ #ifndef GrAARectEffect_DEFINED #define GrAARectEffect_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "src/gpu/GrCoordTransform.h" #include "src/gpu/GrFragmentProcessor.h" diff --git a/src/gpu/effects/generated/GrAlphaThresholdFragmentProcessor.h b/src/gpu/effects/generated/GrAlphaThresholdFragmentProcessor.h index b7bcc8d2b4ff5..69da3a0552c42 100644 --- a/src/gpu/effects/generated/GrAlphaThresholdFragmentProcessor.h +++ b/src/gpu/effects/generated/GrAlphaThresholdFragmentProcessor.h @@ -11,7 +11,7 @@ #ifndef GrAlphaThresholdFragmentProcessor_DEFINED #define GrAlphaThresholdFragmentProcessor_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "src/gpu/GrCoordTransform.h" #include "src/gpu/GrFragmentProcessor.h" diff --git a/src/gpu/effects/generated/GrBlurredEdgeFragmentProcessor.h b/src/gpu/effects/generated/GrBlurredEdgeFragmentProcessor.h index 130666b40e997..188280327a925 100644 --- a/src/gpu/effects/generated/GrBlurredEdgeFragmentProcessor.h +++ b/src/gpu/effects/generated/GrBlurredEdgeFragmentProcessor.h @@ -11,7 +11,7 @@ #ifndef GrBlurredEdgeFragmentProcessor_DEFINED #define GrBlurredEdgeFragmentProcessor_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "src/gpu/GrCoordTransform.h" #include "src/gpu/GrFragmentProcessor.h" diff --git a/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.h b/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.h index bbd74d357c917..e3f2d5df61c22 100644 --- a/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.h +++ b/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.h @@ -11,7 +11,7 @@ #ifndef GrCircleBlurFragmentProcessor_DEFINED #define GrCircleBlurFragmentProcessor_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "src/gpu/GrCoordTransform.h" #include "src/gpu/GrFragmentProcessor.h" diff --git a/src/gpu/effects/generated/GrCircleEffect.h b/src/gpu/effects/generated/GrCircleEffect.h index 923b3aad28643..fb5d217937fa2 100644 --- a/src/gpu/effects/generated/GrCircleEffect.h +++ b/src/gpu/effects/generated/GrCircleEffect.h @@ -11,7 +11,7 @@ #ifndef GrCircleEffect_DEFINED #define GrCircleEffect_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "src/gpu/GrCoordTransform.h" #include "src/gpu/GrFragmentProcessor.h" diff --git a/src/gpu/effects/generated/GrClampFragmentProcessor.h b/src/gpu/effects/generated/GrClampFragmentProcessor.h index 1ea0f7ab986cb..61dc3a03d602e 100644 --- a/src/gpu/effects/generated/GrClampFragmentProcessor.h +++ b/src/gpu/effects/generated/GrClampFragmentProcessor.h @@ -11,7 +11,7 @@ #ifndef GrClampFragmentProcessor_DEFINED #define GrClampFragmentProcessor_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "src/gpu/GrCoordTransform.h" #include "src/gpu/GrFragmentProcessor.h" diff --git a/src/gpu/effects/generated/GrColorMatrixFragmentProcessor.h b/src/gpu/effects/generated/GrColorMatrixFragmentProcessor.h index c18a54744561e..3a153b3e6a3b9 100644 --- a/src/gpu/effects/generated/GrColorMatrixFragmentProcessor.h +++ b/src/gpu/effects/generated/GrColorMatrixFragmentProcessor.h @@ -11,7 +11,7 @@ #ifndef GrColorMatrixFragmentProcessor_DEFINED #define GrColorMatrixFragmentProcessor_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "src/gpu/GrCoordTransform.h" #include "src/gpu/GrFragmentProcessor.h" diff --git a/src/gpu/effects/generated/GrComposeLerpEffect.h b/src/gpu/effects/generated/GrComposeLerpEffect.h index b1ac89408f871..f08403addb054 100644 --- a/src/gpu/effects/generated/GrComposeLerpEffect.h +++ b/src/gpu/effects/generated/GrComposeLerpEffect.h @@ -11,7 +11,7 @@ #ifndef GrComposeLerpEffect_DEFINED #define GrComposeLerpEffect_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "src/gpu/GrCoordTransform.h" #include "src/gpu/GrFragmentProcessor.h" diff --git a/src/gpu/effects/generated/GrComposeLerpRedEffect.h b/src/gpu/effects/generated/GrComposeLerpRedEffect.h index 9f0c03a5736e6..dd9e65eaab449 100644 --- a/src/gpu/effects/generated/GrComposeLerpRedEffect.h +++ b/src/gpu/effects/generated/GrComposeLerpRedEffect.h @@ -11,7 +11,7 @@ #ifndef GrComposeLerpRedEffect_DEFINED #define GrComposeLerpRedEffect_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "src/gpu/GrCoordTransform.h" #include "src/gpu/GrFragmentProcessor.h" diff --git a/src/gpu/effects/generated/GrConfigConversionEffect.h b/src/gpu/effects/generated/GrConfigConversionEffect.h index b1da7c4419df7..5e4b3ceaca796 100644 --- a/src/gpu/effects/generated/GrConfigConversionEffect.h +++ b/src/gpu/effects/generated/GrConfigConversionEffect.h @@ -11,7 +11,7 @@ #ifndef GrConfigConversionEffect_DEFINED #define GrConfigConversionEffect_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "include/gpu/GrContext.h" #include "src/gpu/GrBitmapTextureMaker.h" diff --git a/src/gpu/effects/generated/GrConstColorProcessor.h b/src/gpu/effects/generated/GrConstColorProcessor.h index 2eed3e62c7fba..6d84f836cf264 100644 --- a/src/gpu/effects/generated/GrConstColorProcessor.h +++ b/src/gpu/effects/generated/GrConstColorProcessor.h @@ -11,7 +11,7 @@ #ifndef GrConstColorProcessor_DEFINED #define GrConstColorProcessor_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "src/gpu/GrCoordTransform.h" #include "src/gpu/GrFragmentProcessor.h" diff --git a/src/gpu/effects/generated/GrEllipseEffect.h b/src/gpu/effects/generated/GrEllipseEffect.h index 37241fb19f7e8..b87e538854315 100644 --- a/src/gpu/effects/generated/GrEllipseEffect.h +++ b/src/gpu/effects/generated/GrEllipseEffect.h @@ -11,7 +11,7 @@ #ifndef GrEllipseEffect_DEFINED #define GrEllipseEffect_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "src/gpu/GrShaderCaps.h" diff --git a/src/gpu/effects/generated/GrHSLToRGBFilterEffect.h b/src/gpu/effects/generated/GrHSLToRGBFilterEffect.h index 89c91e658004c..a86c4af046499 100644 --- a/src/gpu/effects/generated/GrHSLToRGBFilterEffect.h +++ b/src/gpu/effects/generated/GrHSLToRGBFilterEffect.h @@ -11,7 +11,7 @@ #ifndef GrHSLToRGBFilterEffect_DEFINED #define GrHSLToRGBFilterEffect_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "src/gpu/GrCoordTransform.h" #include "src/gpu/GrFragmentProcessor.h" diff --git a/src/gpu/effects/generated/GrLumaColorFilterEffect.h b/src/gpu/effects/generated/GrLumaColorFilterEffect.h index 546f25851365b..3ee5c06aede8f 100644 --- a/src/gpu/effects/generated/GrLumaColorFilterEffect.h +++ b/src/gpu/effects/generated/GrLumaColorFilterEffect.h @@ -11,7 +11,7 @@ #ifndef GrLumaColorFilterEffect_DEFINED #define GrLumaColorFilterEffect_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "src/gpu/GrCoordTransform.h" #include "src/gpu/GrFragmentProcessor.h" diff --git a/src/gpu/effects/generated/GrMagnifierEffect.h b/src/gpu/effects/generated/GrMagnifierEffect.h index 753a2e6cbbad4..dd099fc21e907 100644 --- a/src/gpu/effects/generated/GrMagnifierEffect.h +++ b/src/gpu/effects/generated/GrMagnifierEffect.h @@ -11,7 +11,7 @@ #ifndef GrMagnifierEffect_DEFINED #define GrMagnifierEffect_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "src/gpu/GrCoordTransform.h" #include "src/gpu/GrFragmentProcessor.h" diff --git a/src/gpu/effects/generated/GrMixerEffect.h b/src/gpu/effects/generated/GrMixerEffect.h index 464e4d79b718f..37cbb68cc33b7 100644 --- a/src/gpu/effects/generated/GrMixerEffect.h +++ b/src/gpu/effects/generated/GrMixerEffect.h @@ -11,7 +11,7 @@ #ifndef GrMixerEffect_DEFINED #define GrMixerEffect_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "src/gpu/GrCoordTransform.h" #include "src/gpu/GrFragmentProcessor.h" diff --git a/src/gpu/effects/generated/GrOverrideInputFragmentProcessor.h b/src/gpu/effects/generated/GrOverrideInputFragmentProcessor.h index 119a457278e97..d69c16ebbbe7b 100644 --- a/src/gpu/effects/generated/GrOverrideInputFragmentProcessor.h +++ b/src/gpu/effects/generated/GrOverrideInputFragmentProcessor.h @@ -11,7 +11,7 @@ #ifndef GrOverrideInputFragmentProcessor_DEFINED #define GrOverrideInputFragmentProcessor_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "src/gpu/GrCoordTransform.h" #include "src/gpu/GrFragmentProcessor.h" diff --git a/src/gpu/effects/generated/GrPremulInputFragmentProcessor.h b/src/gpu/effects/generated/GrPremulInputFragmentProcessor.h index d6310ebf72aa3..ae093ca6daf10 100644 --- a/src/gpu/effects/generated/GrPremulInputFragmentProcessor.h +++ b/src/gpu/effects/generated/GrPremulInputFragmentProcessor.h @@ -11,7 +11,7 @@ #ifndef GrPremulInputFragmentProcessor_DEFINED #define GrPremulInputFragmentProcessor_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "src/gpu/GrCoordTransform.h" #include "src/gpu/GrFragmentProcessor.h" diff --git a/src/gpu/effects/generated/GrRGBToHSLFilterEffect.h b/src/gpu/effects/generated/GrRGBToHSLFilterEffect.h index 924535d4fa8dd..e8e0bba75619b 100644 --- a/src/gpu/effects/generated/GrRGBToHSLFilterEffect.h +++ b/src/gpu/effects/generated/GrRGBToHSLFilterEffect.h @@ -11,7 +11,7 @@ #ifndef GrRGBToHSLFilterEffect_DEFINED #define GrRGBToHSLFilterEffect_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "src/gpu/GrCoordTransform.h" #include "src/gpu/GrFragmentProcessor.h" diff --git a/src/gpu/effects/generated/GrRRectBlurEffect.h b/src/gpu/effects/generated/GrRRectBlurEffect.h index 14dcd156fa5ad..287a2a78b5796 100644 --- a/src/gpu/effects/generated/GrRRectBlurEffect.h +++ b/src/gpu/effects/generated/GrRRectBlurEffect.h @@ -11,7 +11,7 @@ #ifndef GrRRectBlurEffect_DEFINED #define GrRRectBlurEffect_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "include/gpu/GrContext.h" #include "include/private/GrRecordingContext.h" diff --git a/src/gpu/effects/generated/GrRectBlurEffect.h b/src/gpu/effects/generated/GrRectBlurEffect.h index 51094e678967d..6a56d9d4434d8 100644 --- a/src/gpu/effects/generated/GrRectBlurEffect.h +++ b/src/gpu/effects/generated/GrRectBlurEffect.h @@ -11,7 +11,7 @@ #ifndef GrRectBlurEffect_DEFINED #define GrRectBlurEffect_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include #include "include/core/SkRect.h" diff --git a/src/gpu/glsl/GrGLSLProgramDataManager.cpp b/src/gpu/glsl/GrGLSLProgramDataManager.cpp index d73eebc9498d7..2421fe9d2f261 100644 --- a/src/gpu/glsl/GrGLSLProgramDataManager.cpp +++ b/src/gpu/glsl/GrGLSLProgramDataManager.cpp @@ -7,8 +7,8 @@ #include "src/gpu/glsl/GrGLSLProgramDataManager.h" +#include "include/core/SkM44.h" #include "include/core/SkMatrix.h" -#include "include/private/SkM44.h" #include "src/core/SkMatrixPriv.h" void GrGLSLProgramDataManager::setSkMatrix(UniformHandle u, const SkMatrix& matrix) const { diff --git a/src/gpu/gradients/generated/GrClampedGradientEffect.h b/src/gpu/gradients/generated/GrClampedGradientEffect.h index 3ab1889d5dff4..3e751606bc0eb 100644 --- a/src/gpu/gradients/generated/GrClampedGradientEffect.h +++ b/src/gpu/gradients/generated/GrClampedGradientEffect.h @@ -11,7 +11,7 @@ #ifndef GrClampedGradientEffect_DEFINED #define GrClampedGradientEffect_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "src/gpu/GrCoordTransform.h" #include "src/gpu/GrFragmentProcessor.h" diff --git a/src/gpu/gradients/generated/GrDualIntervalGradientColorizer.h b/src/gpu/gradients/generated/GrDualIntervalGradientColorizer.h index 209072da1e82c..e30297b7e64b2 100644 --- a/src/gpu/gradients/generated/GrDualIntervalGradientColorizer.h +++ b/src/gpu/gradients/generated/GrDualIntervalGradientColorizer.h @@ -11,7 +11,7 @@ #ifndef GrDualIntervalGradientColorizer_DEFINED #define GrDualIntervalGradientColorizer_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "src/gpu/GrCoordTransform.h" #include "src/gpu/GrFragmentProcessor.h" diff --git a/src/gpu/gradients/generated/GrLinearGradientLayout.h b/src/gpu/gradients/generated/GrLinearGradientLayout.h index 94945ab148d8b..6ecbeee850c9b 100644 --- a/src/gpu/gradients/generated/GrLinearGradientLayout.h +++ b/src/gpu/gradients/generated/GrLinearGradientLayout.h @@ -11,7 +11,7 @@ #ifndef GrLinearGradientLayout_DEFINED #define GrLinearGradientLayout_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "src/gpu/gradients/GrGradientShader.h" #include "src/shaders/gradients/SkLinearGradient.h" diff --git a/src/gpu/gradients/generated/GrRadialGradientLayout.h b/src/gpu/gradients/generated/GrRadialGradientLayout.h index 4cb01395a8914..44be21202e456 100644 --- a/src/gpu/gradients/generated/GrRadialGradientLayout.h +++ b/src/gpu/gradients/generated/GrRadialGradientLayout.h @@ -11,7 +11,7 @@ #ifndef GrRadialGradientLayout_DEFINED #define GrRadialGradientLayout_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "src/gpu/gradients/GrGradientShader.h" #include "src/shaders/gradients/SkRadialGradient.h" diff --git a/src/gpu/gradients/generated/GrSingleIntervalGradientColorizer.h b/src/gpu/gradients/generated/GrSingleIntervalGradientColorizer.h index d3bf1de66a1dd..2c808102c9d68 100644 --- a/src/gpu/gradients/generated/GrSingleIntervalGradientColorizer.h +++ b/src/gpu/gradients/generated/GrSingleIntervalGradientColorizer.h @@ -11,7 +11,7 @@ #ifndef GrSingleIntervalGradientColorizer_DEFINED #define GrSingleIntervalGradientColorizer_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "src/gpu/GrCoordTransform.h" #include "src/gpu/GrFragmentProcessor.h" diff --git a/src/gpu/gradients/generated/GrSweepGradientLayout.h b/src/gpu/gradients/generated/GrSweepGradientLayout.h index e86e7bdf3a700..ef7a2ea4918ac 100644 --- a/src/gpu/gradients/generated/GrSweepGradientLayout.h +++ b/src/gpu/gradients/generated/GrSweepGradientLayout.h @@ -11,7 +11,7 @@ #ifndef GrSweepGradientLayout_DEFINED #define GrSweepGradientLayout_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "src/gpu/gradients/GrGradientShader.h" #include "src/shaders/gradients/SkSweepGradient.h" diff --git a/src/gpu/gradients/generated/GrTextureGradientColorizer.h b/src/gpu/gradients/generated/GrTextureGradientColorizer.h index 1e373e0b4e7d7..0672b9fdf0d74 100644 --- a/src/gpu/gradients/generated/GrTextureGradientColorizer.h +++ b/src/gpu/gradients/generated/GrTextureGradientColorizer.h @@ -11,7 +11,7 @@ #ifndef GrTextureGradientColorizer_DEFINED #define GrTextureGradientColorizer_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "src/gpu/GrCoordTransform.h" #include "src/gpu/GrFragmentProcessor.h" diff --git a/src/gpu/gradients/generated/GrTiledGradientEffect.h b/src/gpu/gradients/generated/GrTiledGradientEffect.h index 02101579c476b..b74d59615bd1a 100644 --- a/src/gpu/gradients/generated/GrTiledGradientEffect.h +++ b/src/gpu/gradients/generated/GrTiledGradientEffect.h @@ -11,7 +11,7 @@ #ifndef GrTiledGradientEffect_DEFINED #define GrTiledGradientEffect_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "src/gpu/GrCoordTransform.h" #include "src/gpu/GrFragmentProcessor.h" diff --git a/src/gpu/gradients/generated/GrTwoPointConicalGradientLayout.h b/src/gpu/gradients/generated/GrTwoPointConicalGradientLayout.h index 09950884eca08..781f86b51231c 100644 --- a/src/gpu/gradients/generated/GrTwoPointConicalGradientLayout.h +++ b/src/gpu/gradients/generated/GrTwoPointConicalGradientLayout.h @@ -11,7 +11,7 @@ #ifndef GrTwoPointConicalGradientLayout_DEFINED #define GrTwoPointConicalGradientLayout_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "src/gpu/gradients/GrGradientShader.h" #include "src/shaders/gradients/SkTwoPointConicalGradient.h" diff --git a/src/gpu/gradients/generated/GrUnrolledBinaryGradientColorizer.h b/src/gpu/gradients/generated/GrUnrolledBinaryGradientColorizer.h index 312ae81da7be3..9c9ecea611fbd 100644 --- a/src/gpu/gradients/generated/GrUnrolledBinaryGradientColorizer.h +++ b/src/gpu/gradients/generated/GrUnrolledBinaryGradientColorizer.h @@ -11,7 +11,7 @@ #ifndef GrUnrolledBinaryGradientColorizer_DEFINED #define GrUnrolledBinaryGradientColorizer_DEFINED #include "include/core/SkTypes.h" -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "src/gpu/GrCoordTransform.h" #include "src/gpu/GrFragmentProcessor.h" diff --git a/src/sksl/SkSLHCodeGenerator.cpp b/src/sksl/SkSLHCodeGenerator.cpp index 3898c05258376..65db84a3fc830 100644 --- a/src/sksl/SkSLHCodeGenerator.cpp +++ b/src/sksl/SkSLHCodeGenerator.cpp @@ -349,7 +349,7 @@ bool HCodeGenerator::generateCode() { fFullName.c_str(), fFullName.c_str()); this->writef("#include \"include/core/SkTypes.h\"\n"); - this->writef("#include \"include/private/SkM44.h\"\n"); + this->writef("#include \"include/core/SkM44.h\"\n"); this->writeSection(HEADER_SECTION); this->writef("\n" "#include \"src/gpu/GrCoordTransform.h\"\n" diff --git a/src/utils/SkNWayCanvas.cpp b/src/utils/SkNWayCanvas.cpp index 3d3af614c883f..bdd9b72b5bf3b 100644 --- a/src/utils/SkNWayCanvas.cpp +++ b/src/utils/SkNWayCanvas.cpp @@ -95,7 +95,7 @@ void SkNWayCanvas::willRestore() { void SkNWayCanvas::didConcat44(const SkScalar m[16]) { Iter iter(fList); while (iter.next()) { - iter->experimental_concat44(m); + iter->concat44(m); } } diff --git a/tests/Matrix44Test.cpp b/tests/Matrix44Test.cpp index 3290e0e9b8b02..0ae286ef05440 100644 --- a/tests/Matrix44Test.cpp +++ b/tests/Matrix44Test.cpp @@ -5,9 +5,9 @@ * found in the LICENSE file. */ +#include "include/core/SkM44.h" #include "include/core/SkMatrix44.h" #include "include/core/SkPoint3.h" -#include "include/private/SkM44.h" #include "tests/Test.h" static bool nearly_equal_double(double a, double b) { diff --git a/tests/SkSLFPTest.cpp b/tests/SkSLFPTest.cpp index f98091fc249ed..a7b34f09a0317 100644 --- a/tests/SkSLFPTest.cpp +++ b/tests/SkSLFPTest.cpp @@ -94,7 +94,7 @@ DEF_TEST(SkSLFPHelloWorld, r) { "#ifndef GrTest_DEFINED\n" "#define GrTest_DEFINED\n" "#include \"include/core/SkTypes.h\"\n" - "#include \"include/private/SkM44.h\"\n\n" + "#include \"include/core/SkM44.h\"\n\n" "#include \"src/gpu/GrCoordTransform.h\"\n" "#include \"src/gpu/GrFragmentProcessor.h\"\n" "class GrTest : public GrFragmentProcessor {\n" diff --git a/tests/SkSLInterpreterTest.cpp b/tests/SkSLInterpreterTest.cpp index f2cf0bee1620d..040b2401185d6 100644 --- a/tests/SkSLInterpreterTest.cpp +++ b/tests/SkSLInterpreterTest.cpp @@ -5,7 +5,7 @@ * found in the LICENSE file. */ -#include "include/private/SkM44.h" +#include "include/core/SkM44.h" #include "src/sksl/SkSLByteCode.h" #include "src/sksl/SkSLCompiler.h" #include "src/sksl/SkSLExternalValue.h"