A bunch of little SkMScalar-as-float build fixes.
Landing this before http://crrev.com/1169813006 so the test changes needed there are clearer. This just lets things build with floats, and is a no-op for doubles. No public API changes we didn't intend to already have... TBR=reed@google.com BUG=skia: Review URL: https://codereview.chromium.org/1173673003
This commit is contained in:
parent
1aca864904
commit
1831f990c3
@ -116,22 +116,22 @@ public:
|
|||||||
, fM0(SkMatrix44::kUninitialized_Constructor)
|
, fM0(SkMatrix44::kUninitialized_Constructor)
|
||||||
, fM1(SkMatrix44::kUninitialized_Constructor)
|
, fM1(SkMatrix44::kUninitialized_Constructor)
|
||||||
{
|
{
|
||||||
fM0.set(0, 0, -1.1);
|
fM0.setDouble(0, 0, -1.1);
|
||||||
fM0.set(0, 1, 2.1);
|
fM0.setDouble(0, 1, 2.1);
|
||||||
fM0.set(0, 2, -3.1);
|
fM0.setDouble(0, 2, -3.1);
|
||||||
fM0.set(0, 3, 4.1);
|
fM0.setDouble(0, 3, 4.1);
|
||||||
fM0.set(1, 0, 5.1);
|
fM0.setDouble(1, 0, 5.1);
|
||||||
fM0.set(1, 1, -6.1);
|
fM0.setDouble(1, 1, -6.1);
|
||||||
fM0.set(1, 2, 7.1);
|
fM0.setDouble(1, 2, 7.1);
|
||||||
fM0.set(1, 3, 8.1);
|
fM0.setDouble(1, 3, 8.1);
|
||||||
fM0.set(2, 0, -9.1);
|
fM0.setDouble(2, 0, -9.1);
|
||||||
fM0.set(2, 1, 10.1);
|
fM0.setDouble(2, 1, 10.1);
|
||||||
fM0.set(2, 2, 11.1);
|
fM0.setDouble(2, 2, 11.1);
|
||||||
fM0.set(2, 3, -12.1);
|
fM0.setDouble(2, 3, -12.1);
|
||||||
fM0.set(3, 0, -13.1);
|
fM0.setDouble(3, 0, -13.1);
|
||||||
fM0.set(3, 1, 14.1);
|
fM0.setDouble(3, 1, 14.1);
|
||||||
fM0.set(3, 2, -15.1);
|
fM0.setDouble(3, 2, -15.1);
|
||||||
fM0.set(3, 3, 16.1);
|
fM0.setDouble(3, 3, 16.1);
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
virtual void performTest() {
|
virtual void performTest() {
|
||||||
@ -151,18 +151,18 @@ public:
|
|||||||
, fM0(SkMatrix44::kIdentity_Constructor)
|
, fM0(SkMatrix44::kIdentity_Constructor)
|
||||||
, fM1(SkMatrix44::kUninitialized_Constructor)
|
, fM1(SkMatrix44::kUninitialized_Constructor)
|
||||||
{
|
{
|
||||||
fM0.set(0, 0, -1.1);
|
fM0.setDouble(0, 0, -1.1);
|
||||||
fM0.set(0, 1, 2.1);
|
fM0.setDouble(0, 1, 2.1);
|
||||||
fM0.set(0, 2, -3.1);
|
fM0.setDouble(0, 2, -3.1);
|
||||||
fM0.set(0, 3, 4.1);
|
fM0.setDouble(0, 3, 4.1);
|
||||||
fM0.set(1, 0, 5.1);
|
fM0.setDouble(1, 0, 5.1);
|
||||||
fM0.set(1, 1, -6.1);
|
fM0.setDouble(1, 1, -6.1);
|
||||||
fM0.set(1, 2, 7.1);
|
fM0.setDouble(1, 2, 7.1);
|
||||||
fM0.set(1, 3, 8.1);
|
fM0.setDouble(1, 3, 8.1);
|
||||||
fM0.set(2, 0, -9.1);
|
fM0.setDouble(2, 0, -9.1);
|
||||||
fM0.set(2, 1, 10.1);
|
fM0.setDouble(2, 1, 10.1);
|
||||||
fM0.set(2, 2, 11.1);
|
fM0.setDouble(2, 2, 11.1);
|
||||||
fM0.set(2, 3, -12.1);
|
fM0.setDouble(2, 3, -12.1);
|
||||||
// bottom row (perspective component) remains (0, 0, 0, 1).
|
// bottom row (perspective component) remains (0, 0, 0, 1).
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
@ -183,14 +183,14 @@ public:
|
|||||||
, fM0(SkMatrix44::kIdentity_Constructor)
|
, fM0(SkMatrix44::kIdentity_Constructor)
|
||||||
, fM1(SkMatrix44::kUninitialized_Constructor)
|
, fM1(SkMatrix44::kUninitialized_Constructor)
|
||||||
{
|
{
|
||||||
fM0.set(0, 0, -1.1);
|
fM0.setDouble(0, 0, -1.1);
|
||||||
fM0.set(0, 3, 4.1);
|
fM0.setDouble(0, 3, 4.1);
|
||||||
|
|
||||||
fM0.set(1, 1, -6.1);
|
fM0.setDouble(1, 1, -6.1);
|
||||||
fM0.set(1, 3, 8.1);
|
fM0.setDouble(1, 3, 8.1);
|
||||||
|
|
||||||
fM0.set(2, 2, 11.1);
|
fM0.setDouble(2, 2, 11.1);
|
||||||
fM0.set(2, 3, -12.1);
|
fM0.setDouble(2, 3, -12.1);
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
virtual void performTest() {
|
virtual void performTest() {
|
||||||
@ -210,9 +210,9 @@ public:
|
|||||||
, fM0(SkMatrix44::kIdentity_Constructor)
|
, fM0(SkMatrix44::kIdentity_Constructor)
|
||||||
, fM1(SkMatrix44::kUninitialized_Constructor)
|
, fM1(SkMatrix44::kUninitialized_Constructor)
|
||||||
{
|
{
|
||||||
fM0.set(0, 3, 4.1);
|
fM0.setDouble(0, 3, 4.1);
|
||||||
fM0.set(1, 3, 8.1);
|
fM0.setDouble(1, 3, 8.1);
|
||||||
fM0.set(2, 3, -12.1);
|
fM0.setDouble(2, 3, -12.1);
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
virtual void performTest() {
|
virtual void performTest() {
|
||||||
|
@ -91,6 +91,8 @@ static inline float sk_float_copysign(float x, float y) {
|
|||||||
#define sk_float_log(x) logf(x)
|
#define sk_float_log(x) logf(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define sk_float_round(x) sk_float_floor((x) + 0.5f)
|
||||||
|
|
||||||
// can't find log2f on android, but maybe that just a tool bug?
|
// can't find log2f on android, but maybe that just a tool bug?
|
||||||
#ifdef SK_BUILD_FOR_ANDROID
|
#ifdef SK_BUILD_FOR_ANDROID
|
||||||
static inline float sk_float_log2(float x) {
|
static inline float sk_float_log2(float x) {
|
||||||
|
@ -473,24 +473,24 @@ bool SkMatrix44::invert(SkMatrix44* inverse) const {
|
|||||||
double invYScale = 1 / fMat[1][1];
|
double invYScale = 1 / fMat[1][1];
|
||||||
double invZScale = 1 / fMat[2][2];
|
double invZScale = 1 / fMat[2][2];
|
||||||
|
|
||||||
inverse->fMat[0][0] = invXScale;
|
inverse->fMat[0][0] = SkDoubleToMScalar(invXScale);
|
||||||
inverse->fMat[0][1] = 0;
|
inverse->fMat[0][1] = 0;
|
||||||
inverse->fMat[0][2] = 0;
|
inverse->fMat[0][2] = 0;
|
||||||
inverse->fMat[0][3] = 0;
|
inverse->fMat[0][3] = 0;
|
||||||
|
|
||||||
inverse->fMat[1][0] = 0;
|
inverse->fMat[1][0] = 0;
|
||||||
inverse->fMat[1][1] = invYScale;
|
inverse->fMat[1][1] = SkDoubleToMScalar(invYScale);
|
||||||
inverse->fMat[1][2] = 0;
|
inverse->fMat[1][2] = 0;
|
||||||
inverse->fMat[1][3] = 0;
|
inverse->fMat[1][3] = 0;
|
||||||
|
|
||||||
inverse->fMat[2][0] = 0;
|
inverse->fMat[2][0] = 0;
|
||||||
inverse->fMat[2][1] = 0;
|
inverse->fMat[2][1] = 0;
|
||||||
inverse->fMat[2][2] = invZScale;
|
inverse->fMat[2][2] = SkDoubleToMScalar(invZScale);
|
||||||
inverse->fMat[2][3] = 0;
|
inverse->fMat[2][3] = 0;
|
||||||
|
|
||||||
inverse->fMat[3][0] = -fMat[3][0] * invXScale;
|
inverse->fMat[3][0] = SkDoubleToMScalar(-fMat[3][0] * invXScale);
|
||||||
inverse->fMat[3][1] = -fMat[3][1] * invYScale;
|
inverse->fMat[3][1] = SkDoubleToMScalar(-fMat[3][1] * invYScale);
|
||||||
inverse->fMat[3][2] = -fMat[3][2] * invZScale;
|
inverse->fMat[3][2] = SkDoubleToMScalar(-fMat[3][2] * invZScale);
|
||||||
inverse->fMat[3][3] = 1;
|
inverse->fMat[3][3] = 1;
|
||||||
|
|
||||||
inverse->setTypeMask(this->getType());
|
inverse->setTypeMask(this->getType());
|
||||||
|
@ -200,8 +200,8 @@ static void test_map2(skiatest::Reporter* reporter, const SkMatrix44& mat) {
|
|||||||
SkMScalar dstA[4], dstB[4];
|
SkMScalar dstA[4], dstB[4];
|
||||||
|
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
dstA[i] = 123456789;
|
dstA[i] = SkDoubleToMScalar(123456789);
|
||||||
dstB[i] = 987654321;
|
dstB[i] = SkDoubleToMScalar(987654321);
|
||||||
}
|
}
|
||||||
|
|
||||||
mat.map2(src2, 1, dstA);
|
mat.map2(src2, 1, dstA);
|
||||||
@ -532,29 +532,29 @@ static void test_3x3_conversion(skiatest::Reporter* reporter) {
|
|||||||
static void test_has_perspective(skiatest::Reporter* reporter) {
|
static void test_has_perspective(skiatest::Reporter* reporter) {
|
||||||
SkMatrix44 transform(SkMatrix44::kIdentity_Constructor);
|
SkMatrix44 transform(SkMatrix44::kIdentity_Constructor);
|
||||||
|
|
||||||
transform.set(3, 2, -0.1);
|
transform.setDouble(3, 2, -0.1);
|
||||||
REPORTER_ASSERT(reporter, transform.hasPerspective());
|
REPORTER_ASSERT(reporter, transform.hasPerspective());
|
||||||
|
|
||||||
transform.reset();
|
transform.reset();
|
||||||
REPORTER_ASSERT(reporter, !transform.hasPerspective());
|
REPORTER_ASSERT(reporter, !transform.hasPerspective());
|
||||||
|
|
||||||
transform.set(3, 0, -1.0);
|
transform.setDouble(3, 0, -1.0);
|
||||||
REPORTER_ASSERT(reporter, transform.hasPerspective());
|
REPORTER_ASSERT(reporter, transform.hasPerspective());
|
||||||
|
|
||||||
transform.reset();
|
transform.reset();
|
||||||
transform.set(3, 1, -1.0);
|
transform.setDouble(3, 1, -1.0);
|
||||||
REPORTER_ASSERT(reporter, transform.hasPerspective());
|
REPORTER_ASSERT(reporter, transform.hasPerspective());
|
||||||
|
|
||||||
transform.reset();
|
transform.reset();
|
||||||
transform.set(3, 2, -0.3);
|
transform.setDouble(3, 2, -0.3);
|
||||||
REPORTER_ASSERT(reporter, transform.hasPerspective());
|
REPORTER_ASSERT(reporter, transform.hasPerspective());
|
||||||
|
|
||||||
transform.reset();
|
transform.reset();
|
||||||
transform.set(3, 3, 0.5);
|
transform.setDouble(3, 3, 0.5);
|
||||||
REPORTER_ASSERT(reporter, transform.hasPerspective());
|
REPORTER_ASSERT(reporter, transform.hasPerspective());
|
||||||
|
|
||||||
transform.reset();
|
transform.reset();
|
||||||
transform.set(3, 3, 0.0);
|
transform.setDouble(3, 3, 0.0);
|
||||||
REPORTER_ASSERT(reporter, transform.hasPerspective());
|
REPORTER_ASSERT(reporter, transform.hasPerspective());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -757,13 +757,13 @@ static void test_preserves_2d_axis_alignment(skiatest::Reporter* reporter) {
|
|||||||
|
|
||||||
// Perspective cases.
|
// Perspective cases.
|
||||||
transform.setIdentity();
|
transform.setIdentity();
|
||||||
transform.set(3, 2, -0.1); // Perspective depth 10
|
transform.setDouble(3, 2, -0.1); // Perspective depth 10
|
||||||
transform2.setRotateDegreesAbout(0.0, 1.0, 0.0, 45.0);
|
transform2.setRotateDegreesAbout(0.0, 1.0, 0.0, 45.0);
|
||||||
transform.preConcat(transform2);
|
transform.preConcat(transform2);
|
||||||
test(false, reporter, transform);
|
test(false, reporter, transform);
|
||||||
|
|
||||||
transform.setIdentity();
|
transform.setIdentity();
|
||||||
transform.set(3, 2, -0.1); // Perspective depth 10
|
transform.setDouble(3, 2, -0.1); // Perspective depth 10
|
||||||
transform2.setRotateDegreesAbout(0.0, 0.0, 1.0, 90.0);
|
transform2.setRotateDegreesAbout(0.0, 0.0, 1.0, 90.0);
|
||||||
transform.preConcat(transform2);
|
transform.preConcat(transform2);
|
||||||
test(true, reporter, transform);
|
test(true, reporter, transform);
|
||||||
@ -819,10 +819,11 @@ DEF_TEST(Matrix44, reporter) {
|
|||||||
|
|
||||||
// test tiny-valued matrix inverse
|
// test tiny-valued matrix inverse
|
||||||
mat.reset();
|
mat.reset();
|
||||||
mat.setScale(1.0e-12, 1.0e-12, 1.0e-12);
|
auto v = SkDoubleToMScalar(1.0e-12);
|
||||||
|
mat.setScale(v,v,v);
|
||||||
rot.setRotateDegreesAbout(0, 0, -1, 90);
|
rot.setRotateDegreesAbout(0, 0, -1, 90);
|
||||||
mat.postConcat(rot);
|
mat.postConcat(rot);
|
||||||
mat.postTranslate(1.0e-12, 1.0e-12, 1.0e-12);
|
mat.postTranslate(v,v,v);
|
||||||
REPORTER_ASSERT(reporter, mat.invert(NULL));
|
REPORTER_ASSERT(reporter, mat.invert(NULL));
|
||||||
mat.invert(&inverse);
|
mat.invert(&inverse);
|
||||||
iden1.setConcat(mat, inverse);
|
iden1.setConcat(mat, inverse);
|
||||||
@ -830,10 +831,14 @@ DEF_TEST(Matrix44, reporter) {
|
|||||||
|
|
||||||
// test mixed-valued matrix inverse
|
// test mixed-valued matrix inverse
|
||||||
mat.reset();
|
mat.reset();
|
||||||
mat.setScale(1.0e-10, 3.0, 1.0e+10);
|
mat.setScale(SkDoubleToMScalar(1.0e-10),
|
||||||
|
SkDoubleToMScalar(3.0),
|
||||||
|
SkDoubleToMScalar(1.0e+10));
|
||||||
rot.setRotateDegreesAbout(0, 0, -1, 90);
|
rot.setRotateDegreesAbout(0, 0, -1, 90);
|
||||||
mat.postConcat(rot);
|
mat.postConcat(rot);
|
||||||
mat.postTranslate(1.0e+10, 3.0, 1.0e-10);
|
mat.postTranslate(SkDoubleToMScalar(1.0e+10),
|
||||||
|
SkDoubleToMScalar(3.0),
|
||||||
|
SkDoubleToMScalar(1.0e-10));
|
||||||
REPORTER_ASSERT(reporter, mat.invert(NULL));
|
REPORTER_ASSERT(reporter, mat.invert(NULL));
|
||||||
mat.invert(&inverse);
|
mat.invert(&inverse);
|
||||||
iden1.setConcat(mat, inverse);
|
iden1.setConcat(mat, inverse);
|
||||||
|
Loading…
Reference in New Issue
Block a user