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

Unified Diff: ui/gfx/icc_profile.cc

Issue 2229953003: Support for custom primaries (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: test updated Created 4 years, 4 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/icc_profile.h ('k') | ui/gfx/ipc/color/gfx_param_traits.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/icc_profile.cc
diff --git a/ui/gfx/icc_profile.cc b/ui/gfx/icc_profile.cc
index 9fbbdd0358121f75ef03f43623fa4a218eac51ae..f293cda2162efe0d2fd93009e6de15adacebfca0 100644
--- a/ui/gfx/icc_profile.cc
+++ b/ui/gfx/icc_profile.cc
@@ -9,6 +9,7 @@
#include "base/containers/mru_cache.h"
#include "base/lazy_instance.h"
#include "base/synchronization/lock.h"
+#include "ui/gfx/color_transform.h"
namespace gfx {
@@ -90,8 +91,9 @@ ICCProfile ICCProfile::FromColorSpace(const gfx::ColorSpace& color_space) {
base::AutoLock lock(cache.lock);
auto found = cache.id_to_icc_profile_mru.Get(color_space.icc_profile_id_);
- if (found != cache.id_to_icc_profile_mru.end())
+ if (found != cache.id_to_icc_profile_mru.end()) {
return found->second;
+ }
}
// TODO(ccameron): Support constructing ICC profiles from arbitrary ColorSpace
// objects.
@@ -117,6 +119,50 @@ ColorSpace ICCProfile::GetColorSpace() const {
if (found == cache.id_to_icc_profile_mru.end())
cache.id_to_icc_profile_mru.Put(id_, *this);
}
+
+ ColorSpace unity_colorspace(
+ ColorSpace::PrimaryID::CUSTOM, ColorSpace::TransferID::LINEAR,
+ ColorSpace::MatrixID::RGB, ColorSpace::RangeID::FULL);
+ unity_colorspace.custom_primary_matrix_[0] = 1.0f;
+ unity_colorspace.custom_primary_matrix_[1] = 0.0f;
+ unity_colorspace.custom_primary_matrix_[2] = 0.0f;
+ unity_colorspace.custom_primary_matrix_[3] = 0.0f;
+
+ unity_colorspace.custom_primary_matrix_[4] = 0.0f;
+ unity_colorspace.custom_primary_matrix_[5] = 1.0f;
+ unity_colorspace.custom_primary_matrix_[6] = 0.0f;
+ unity_colorspace.custom_primary_matrix_[7] = 0.0f;
+
+ unity_colorspace.custom_primary_matrix_[8] = 0.0f;
+ unity_colorspace.custom_primary_matrix_[9] = 0.0f;
+ unity_colorspace.custom_primary_matrix_[10] = 1.0f;
+ unity_colorspace.custom_primary_matrix_[11] = 0.0f;
+
+ // This will look up and use the ICC profile.
+ std::unique_ptr<ColorTransform> transform(ColorTransform::NewColorTransform(
+ color_space, unity_colorspace, ColorTransform::Intent::INTENT_ABSOLUTE));
+
+ ColorTransform::TriStim tmp[4];
+ tmp[0].set_x(1.0f);
+ tmp[1].set_y(1.0f);
+ tmp[2].set_z(1.0f);
+ transform->transform(tmp, arraysize(tmp));
+
+ color_space.custom_primary_matrix_[0] = tmp[0].x() - tmp[3].x();
+ color_space.custom_primary_matrix_[1] = tmp[1].x() - tmp[3].x();
+ color_space.custom_primary_matrix_[2] = tmp[2].x() - tmp[3].x();
+ color_space.custom_primary_matrix_[3] = tmp[3].x();
+
+ color_space.custom_primary_matrix_[4] = tmp[0].y() - tmp[3].y();
+ color_space.custom_primary_matrix_[5] = tmp[1].y() - tmp[3].y();
+ color_space.custom_primary_matrix_[6] = tmp[2].y() - tmp[3].y();
+ color_space.custom_primary_matrix_[7] = tmp[3].y();
+
+ color_space.custom_primary_matrix_[8] = tmp[0].z() - tmp[3].z();
+ color_space.custom_primary_matrix_[9] = tmp[1].z() - tmp[3].z();
+ color_space.custom_primary_matrix_[10] = tmp[2].z() - tmp[3].z();
+ color_space.custom_primary_matrix_[11] = tmp[3].z();
+
return color_space;
}
« no previous file with comments | « ui/gfx/icc_profile.h ('k') | ui/gfx/ipc/color/gfx_param_traits.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698