Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(503)

Unified Diff: ui/gfx/color_space.cc

Issue 2652503002: Use SkICC in gfx::ICCProfile and gfx::ColorSpace (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/gfx/color_space.cc
diff --git a/ui/gfx/color_space.cc b/ui/gfx/color_space.cc
index 2bf317bcecb7ec8db177ad8da6c18507680c4e6a..820ec5edf14d3c6a7b845724152e2c7ae7b7f910 100644
--- a/ui/gfx/color_space.cc
+++ b/ui/gfx/color_space.cc
@@ -41,6 +41,7 @@ ColorSpace::MatrixID ColorSpace::MatrixIDFromInt(int matrix_id) {
}
ColorSpace::ColorSpace() {
+ memset(custom_transfer_params_, 0, sizeof(custom_transfer_params_));
memset(custom_primary_matrix_, 0, sizeof(custom_primary_matrix_));
}
@@ -52,8 +53,8 @@ ColorSpace::ColorSpace(PrimaryID primaries,
transfer_(transfer),
matrix_(matrix),
range_(range) {
+ memset(custom_transfer_params_, 0, sizeof(custom_transfer_params_));
memset(custom_primary_matrix_, 0, sizeof(custom_primary_matrix_));
- // TODO: Set profile_id_
}
ColorSpace::ColorSpace(int primaries, int transfer, int matrix, RangeID range)
@@ -61,8 +62,8 @@ ColorSpace::ColorSpace(int primaries, int transfer, int matrix, RangeID range)
transfer_(TransferIDFromInt(transfer)),
matrix_(MatrixIDFromInt(matrix)),
range_(range) {
+ memset(custom_transfer_params_, 0, sizeof(custom_transfer_params_));
memset(custom_primary_matrix_, 0, sizeof(custom_primary_matrix_));
- // TODO: Set profile_id_
}
ColorSpace::ColorSpace(const ColorSpace& other)
@@ -72,6 +73,8 @@ ColorSpace::ColorSpace(const ColorSpace& other)
range_(other.range_),
icc_profile_id_(other.icc_profile_id_),
sk_color_space_(other.sk_color_space_) {
+ memcpy(custom_transfer_params_, other.custom_transfer_params_,
+ sizeof(custom_transfer_params_));
memcpy(custom_primary_matrix_, other.custom_primary_matrix_,
sizeof(custom_primary_matrix_));
}
@@ -124,6 +127,10 @@ bool ColorSpace::operator==(const ColorSpace& other) const {
memcmp(custom_primary_matrix_, other.custom_primary_matrix_,
sizeof(custom_primary_matrix_)))
return false;
+ if (transfer_ == TransferID::CUSTOM &&
+ memcmp(custom_transfer_params_, other.custom_transfer_params_,
+ sizeof(custom_transfer_params_)))
+ return false;
return true;
}
@@ -162,6 +169,15 @@ bool ColorSpace::operator<(const ColorSpace& other) const {
if (primary_result > 0)
return false;
}
+ if (transfer_ == TransferID::CUSTOM) {
+ int transfer_result =
+ memcmp(custom_transfer_params_, other.custom_transfer_params_,
+ sizeof(custom_transfer_params_));
+ if (transfer_result < 0)
+ return true;
+ if (transfer_result > 0)
+ return false;
+ }
return false;
}
@@ -180,4 +196,28 @@ ColorSpace ColorSpace::FromSkColorSpace(
return icc_profile.GetColorSpace();
}
+bool ColorSpace::GetPrimaryMatrix(SkMatrix44* to_XYZD50) const {
+ if (primaries_ == PrimaryID::CUSTOM) {
+ to_XYZD50->set3x3RowMajorf(custom_primary_matrix_);
+ return true;
+ }
+ // TODO(ccameron): Merge with primary look-up in ColorTransform.
+ return false;
+}
+
+bool ColorSpace::GetTransferFunction(SkColorSpaceTransferFn* fn) const {
+ if (transfer_ == TransferID::CUSTOM) {
+ fn->fA = custom_transfer_params_[0];
+ fn->fB = custom_transfer_params_[1];
+ fn->fC = custom_transfer_params_[2];
+ fn->fD = custom_transfer_params_[3];
+ fn->fE = custom_transfer_params_[4];
+ fn->fF = custom_transfer_params_[5];
+ fn->fG = custom_transfer_params_[6];
+ return true;
+ }
+ // TODO(ccameron): Add transfer look-up for non-CUSTOM transfer functions.
+ return false;
+}
+
} // namespace gfx
« no previous file with comments | « ui/gfx/color_space.h ('k') | ui/gfx/color_transform.cc » ('j') | ui/gfx/color_transform.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698