SkMatrix44 clarifications and clean-ups
Fixed row/col major bug and added comments to the
header.
Made SkMatrix::I() thread safe using constexpr.
Added a test set3x3RowMajorf().
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2098583002
Review-Url: https://codereview.chromium.org/2098583002
diff --git a/src/core/SkColorSpace.cpp b/src/core/SkColorSpace.cpp
index 95c38f2..3f93f16 100644
--- a/src/core/SkColorSpace.cpp
+++ b/src/core/SkColorSpace.cpp
@@ -142,7 +142,7 @@
case kSRGB_Named: {
sRGBOnce([] {
SkMatrix44 srgbToxyzD50(SkMatrix44::kUninitialized_Constructor);
- srgbToxyzD50.set3x3ColMajorf(gSRGB_toXYZD50);
+ srgbToxyzD50.set3x3RowMajorf(gSRGB_toXYZD50);
sRGB = new SkColorSpace_Base(kSRGB_GammaNamed, srgbToxyzD50, kSRGB_Named);
});
return sk_ref_sp(sRGB);
@@ -150,7 +150,7 @@
case kAdobeRGB_Named: {
adobeRGBOnce([] {
SkMatrix44 adobergbToxyzD50(SkMatrix44::kUninitialized_Constructor);
- adobergbToxyzD50.set3x3ColMajorf(gAdobeRGB_toXYZD50);
+ adobergbToxyzD50.set3x3RowMajorf(gAdobeRGB_toXYZD50);
adobeRGB = new SkColorSpace_Base(k2Dot2Curve_GammaNamed, adobergbToxyzD50,
kAdobeRGB_Named);
});
@@ -897,7 +897,7 @@
return_null("Need valid rgb tags for XYZ space");
}
SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor);
- mat.set3x3ColMajorf(toXYZ);
+ mat.set3x3RowMajorf(toXYZ);
// It is not uncommon to see missing or empty gamma tags. This indicates
// that we should use unit gamma.
diff --git a/src/core/SkMatrix44.cpp b/src/core/SkMatrix44.cpp
index 56c2e8a..83c1adc 100644
--- a/src/core/SkMatrix44.cpp
+++ b/src/core/SkMatrix44.cpp
@@ -186,7 +186,7 @@
///////////////////////////////////////////////////////////////////////////////
const SkMatrix44& SkMatrix44::I() {
- static const SkMatrix44 gIdentity44(kIdentity_Constructor);
+ static constexpr SkMatrix44 gIdentity44(kIdentity_Constructor);
return gIdentity44;
}
@@ -220,7 +220,7 @@
this->dirtyTypeMask();
}
-void SkMatrix44::set3x3ColMajorf(const float src[]) {
+void SkMatrix44::set3x3RowMajorf(const float src[]) {
fMat[0][0] = src[0]; fMat[0][1] = src[3]; fMat[0][2] = src[6]; fMat[0][3] = 0;
fMat[1][0] = src[1]; fMat[1][1] = src[4]; fMat[1][2] = src[7]; fMat[1][3] = 0;
fMat[2][0] = src[2]; fMat[2][1] = src[5]; fMat[2][2] = src[8]; fMat[2][3] = 0;