Commit 29edde9c authored by Markus Handell's avatar Markus Handell Committed by Commit Bot

gfx::ColorSpace: Add getters

This change adds getters for currently stored primary ID, transfer
characteristics ID, matrix coefficient ID, and range ID. The change
also adds a test case for making sure they don't regress.

Bug: 1013590
Change-Id: I6da4d567591649e08a57e9bf8d6ed69f732bd26c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1950974
Commit-Queue: Markus Handell <handellm@google.com>
Reviewed-by: default avatarccameron <ccameron@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721803}
parent e6bf70c2
...@@ -514,6 +514,22 @@ sk_sp<SkColorSpace> ColorSpace::ToSkColorSpace() const { ...@@ -514,6 +514,22 @@ sk_sp<SkColorSpace> ColorSpace::ToSkColorSpace() const {
return sk_color_space; return sk_color_space;
} }
ColorSpace::PrimaryID ColorSpace::GetPrimaryID() const {
return primaries_;
}
ColorSpace::TransferID ColorSpace::GetTransferID() const {
return transfer_;
}
ColorSpace::MatrixID ColorSpace::GetMatrixID() const {
return matrix_;
}
ColorSpace::RangeID ColorSpace::GetRangeID() const {
return range_;
}
// static // static
void ColorSpace::GetPrimaryMatrix(PrimaryID primary_id, void ColorSpace::GetPrimaryMatrix(PrimaryID primary_id,
skcms_Matrix3x3* to_XYZD50) { skcms_Matrix3x3* to_XYZD50) {
......
...@@ -270,6 +270,21 @@ class COLOR_SPACE_EXPORT ColorSpace { ...@@ -270,6 +270,21 @@ class COLOR_SPACE_EXPORT ColorSpace {
void GetTransferMatrix(SkMatrix44* matrix) const; void GetTransferMatrix(SkMatrix44* matrix) const;
void GetRangeAdjustMatrix(SkMatrix44* matrix) const; void GetRangeAdjustMatrix(SkMatrix44* matrix) const;
// Returns the current primary ID.
// Note: if SetCustomPrimaries() has been used, the primary ID returned
// may have been set to PrimaryID::CUSTOM, or been coerced to another
// PrimaryID if it was very close.
PrimaryID GetPrimaryID() const;
// Returns the current transfer ID.
TransferID GetTransferID() const;
// Returns the current matrix ID.
MatrixID GetMatrixID() const;
// Returns the current range ID.
RangeID GetRangeID() const;
private: private:
static void GetPrimaryMatrix(PrimaryID, skcms_Matrix3x3* to_XYZD50); static void GetPrimaryMatrix(PrimaryID, skcms_Matrix3x3* to_XYZD50);
static bool GetTransferFunction(TransferID, skcms_TransferFunction* fn); static bool GetTransferFunction(TransferID, skcms_TransferFunction* fn);
......
...@@ -179,5 +179,15 @@ TEST(ColorSpace, MixedHDR10WithRec709) { ...@@ -179,5 +179,15 @@ TEST(ColorSpace, MixedHDR10WithRec709) {
EXPECT_EQ(color_space, expected_color_space); EXPECT_EQ(color_space, expected_color_space);
} }
TEST(ColorSpace, GetsPrimariesTransferMatrixAndRange) {
ColorSpace color_space(
ColorSpace::PrimaryID::BT709, ColorSpace::TransferID::BT709,
ColorSpace::MatrixID::BT709, ColorSpace::RangeID::LIMITED);
EXPECT_EQ(color_space.GetPrimaryID(), ColorSpace::PrimaryID::BT709);
EXPECT_EQ(color_space.GetTransferID(), ColorSpace::TransferID::BT709);
EXPECT_EQ(color_space.GetMatrixID(), ColorSpace::MatrixID::BT709);
EXPECT_EQ(color_space.GetRangeID(), ColorSpace::RangeID::LIMITED);
}
} // namespace } // namespace
} // namespace gfx } // namespace gfx
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment