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

Unified Diff: ui/gfx/icc_profile.cc

Issue 2502703002: Add more robust gfx::ColorSpace<->gfx::ICCProfile conversion (Closed)
Patch Set: Created 4 years, 1 month 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/icc_profile.cc
diff --git a/ui/gfx/icc_profile.cc b/ui/gfx/icc_profile.cc
index 118a071124a06c7c064c1f5f20bf596429affda3..cec7a0944125b1a8a2143e40e687ab2c929e42d5 100644
--- a/ui/gfx/icc_profile.cc
+++ b/ui/gfx/icc_profile.cc
@@ -43,18 +43,28 @@ ICCProfile& ICCProfile::operator=(const ICCProfile& other) = default;
ICCProfile::~ICCProfile() = default;
bool ICCProfile::operator==(const ICCProfile& other) const {
- return valid_ == other.valid_ && data_ == other.data_;
+ if (type_ != other.type_)
+ return false;
+ switch (type_) {
+ case Type::INVALID:
+ return true;
+ case Type::FROM_COLOR_SPACE:
+ return color_space_ == other.color_space_;
+ case Type::FROM_DATA:
+ return data_ == other.data_;
+ }
+ return false;
}
// static
ICCProfile ICCProfile::FromData(const char* data, size_t size) {
ICCProfile icc_profile;
if (IsValidProfileLength(size)) {
- icc_profile.valid_ = true;
+ icc_profile.type_ = Type::FROM_DATA;
icc_profile.data_.insert(icc_profile.data_.begin(), data, data + size);
+ } else {
+ return ICCProfile();
}
- if (!icc_profile.valid_)
- return icc_profile;
Cache& cache = g_cache.Get();
base::AutoLock lock(cache.lock);
@@ -105,8 +115,10 @@ const std::vector<char>& ICCProfile::GetData() const {
}
ColorSpace ICCProfile::GetColorSpace() const {
- if (!valid_)
+ if (type_ == Type::INVALID)
return gfx::ColorSpace();
+ if (type_ == Type::FROM_COLOR_SPACE)
+ return color_space_;
ColorSpace color_space(ColorSpace::PrimaryID::CUSTOM,
ColorSpace::TransferID::CUSTOM,

Powered by Google App Engine
This is Rietveld 408576698