Index: ui/gfx/color_space.cc |
diff --git a/ui/gfx/color_space.cc b/ui/gfx/color_space.cc |
index 8bb9bddca8882614957505d47eceb70e18d15af9..8e62ef0f411eb2430029a9d582ca1641b2d2c598 100644 |
--- a/ui/gfx/color_space.cc |
+++ b/ui/gfx/color_space.cc |
@@ -8,6 +8,7 @@ |
#include "base/lazy_instance.h" |
#include "base/synchronization/lock.h" |
+#include "third_party/skia/include/core/SkColorSpace.h" |
#include "ui/gfx/icc_profile.h" |
namespace gfx { |
@@ -60,7 +61,9 @@ ColorSpace ColorSpace::CreateREC709() { |
bool ColorSpace::operator==(const ColorSpace& other) const { |
return primaries_ == other.primaries_ && transfer_ == other.transfer_ && |
- matrix_ == other.matrix_ && range_ == other.range_; |
+ matrix_ == other.matrix_ && range_ == other.range_ && |
+ !memcmp(custom_primary_matrix_, other.custom_primary_matrix_, |
hubbe
2016/09/19 19:21:27
We should only do this if primaries_ == CUSTOM I t
ccameron
2016/09/19 22:23:15
Done.
|
+ sizeof(custom_primary_matrix_)); |
} |
bool ColorSpace::operator!=(const ColorSpace& other) const { |
@@ -83,12 +86,26 @@ bool ColorSpace::operator<(const ColorSpace& other) const { |
if (range_ < other.range_) |
return true; |
if (range_ > other.range_) |
+ return false; |
+ int primary_result = |
+ memcmp(custom_primary_matrix_, other.custom_primary_matrix_, |
+ sizeof(custom_primary_matrix_)); |
+ if (primary_result < 0) |
return true; |
- |
- // TODO(hubbe): For "CUSTOM" primaries or tranfer functions, compare their |
- // coefficients here |
+ if (primary_result > 0) |
+ return false; |
return false; |
} |
+sk_sp<SkColorSpace> ColorSpace::ToSkColorSpace() const { |
+ // TODO(crbug.com/634102): Make this conversion more robust. |
+ std::vector<char> icc_data = |
+ gfx::ICCProfile::FromColorSpace(*this).GetData(); |
hubbe
2016/09/19 19:21:27
1) Shouldn't we implement FromColorSpace() first?
ccameron
2016/09/19 22:23:15
This is to un-block work on rasterization, and ras
hubbe
2016/09/19 22:53:19
Then maybe remove the DCHECK and tell callers to e
|
+ sk_sp<SkColorSpace> result = |
+ SkColorSpace::NewICC(icc_data.data(), icc_data.size()); |
+ DCHECK(result); |
+ return result; |
+} |
+ |
} // namespace gfx |