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

Unified Diff: ui/gfx/color_space.cc

Issue 2738713003: color: Ensure that VideoResourceUpdater give consistent colors (Closed)
Patch Set: Rebase Created 3 years, 9 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
« no previous file with comments | « ui/gfx/color_space.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/color_space.cc
diff --git a/ui/gfx/color_space.cc b/ui/gfx/color_space.cc
index 45afbee4c0df3516d6ee4f7eb8bc346269f4e519..78141bde8a8b28cc436adc4ab52b4b61f350255c 100644
--- a/ui/gfx/color_space.cc
+++ b/ui/gfx/color_space.cc
@@ -5,6 +5,7 @@
#include "ui/gfx/color_space.h"
#include <map>
+#include <sstream>
#include "base/lazy_instance.h"
#include "base/synchronization/lock.h"
@@ -324,6 +325,48 @@ bool ColorSpace::operator<(const ColorSpace& other) const {
return false;
}
+std::string ColorSpace::ToString() const {
+ std::stringstream ss;
+ ss << "{primaries:";
+ if (primaries_ == PrimaryID::CUSTOM) {
+ ss << "[";
+ for (size_t i = 0; i < 3; ++i) {
+ ss << "[";
+ for (size_t j = 0; j < 3; ++j) {
+ ss << custom_primary_matrix_[3 * i + j];
+ ss << ",";
+ }
+ ss << "],";
+ }
+ ss << "]";
+ } else {
+ ss << static_cast<int>(primaries_);
+ }
+ ss << ", transfer:";
+ if (transfer_ == TransferID::CUSTOM) {
+ ss << "[";
+ for (size_t i = 0; i < 7; ++i)
+ ss << custom_transfer_params_[i];
+ ss << "]";
+ } else {
+ ss << static_cast<int>(transfer_);
+ }
+ ss << ", matrix:" << static_cast<int>(matrix_);
+ ss << ", range:" << static_cast<int>(range_);
+ ss << ", icc_profile_id:" << icc_profile_id_;
+ ss << "}";
+ return ss.str();
+}
+
+ColorSpace ColorSpace::GetAsFullRangeRGB() const {
+ ColorSpace result(*this);
+ if (!IsValid())
+ return result;
+ result.matrix_ = MatrixID::RGB;
+ result.range_ = RangeID::FULL;
+ return result;
+}
+
sk_sp<SkColorSpace> ColorSpace::ToSkColorSpace() const {
// If we got a specific SkColorSpace from the ICCProfile that this color space
// was created from, use that.
@@ -406,8 +449,18 @@ sk_sp<SkColorSpace> ColorSpace::ToNonlinearBlendedSkColorSpace() const {
}
bool ColorSpace::GetICCProfile(ICCProfile* icc_profile) const {
- if (!IsValid())
+ if (!IsValid()) {
+ DLOG(ERROR) << "Cannot fetch ICCProfile for invalid space.";
+ return false;
+ }
+ if (matrix_ != MatrixID::RGB) {
+ DLOG(ERROR) << "Not creating non-RGB ICCProfile";
return false;
+ }
+ if (range_ != RangeID::FULL) {
+ DLOG(ERROR) << "Not creating non-full-range ICCProfile";
+ return false;
+ }
// If this was created from an ICC profile, retrieve that exact profile.
ICCProfile result;
@@ -783,4 +836,8 @@ void ColorSpace::GetRangeAdjustMatrix(SkMatrix44* matrix) const {
}
}
+std::ostream& operator<<(std::ostream& out, const ColorSpace& color_space) {
+ return out << color_space.ToString();
+}
+
} // namespace gfx
« no previous file with comments | « ui/gfx/color_space.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698