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

Unified Diff: ui/gfx/color_space_win.cc

Issue 2106303002: Color: Rename gfx::ColorProfile to gfx::ColorSpace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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_mac.mm ('k') | ui/gfx/gfx.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/color_space_win.cc
diff --git a/ui/gfx/color_space_win.cc b/ui/gfx/color_space_win.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e9db49fc0d5731bd4b46828a84eb8cc230172585
--- /dev/null
+++ b/ui/gfx/color_space_win.cc
@@ -0,0 +1,68 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/gfx/color_space.h"
+
+#include <windows.h>
+#include <stddef.h>
+#include <map>
+
+#include "base/files/file_util.h"
+#include "base/lazy_instance.h"
+#include "base/macros.h"
+#include "base/synchronization/lock.h"
+
+namespace gfx {
+
+namespace {
+
+void ReadBestMonitorICCProfile(std::vector<char>* profile) {
+ HDC screen_dc = GetDC(NULL);
+ DWORD path_len = MAX_PATH;
+ WCHAR path[MAX_PATH + 1];
+
+ BOOL result = GetICMProfile(screen_dc, &path_len, path);
+ ReleaseDC(NULL, screen_dc);
+ if (!result)
+ return;
+ std::string profile_data;
+ if (!base::ReadFileToString(base::FilePath(path), &profile_data))
+ return;
+ size_t length = profile_data.size();
+ if (!ColorSpace::IsValidProfileLength(length))
+ return;
+ profile->assign(profile_data.data(), profile_data.data() + length);
+}
+
+base::LazyInstance<base::Lock> g_best_monitor_color_space_lock =
+ LAZY_INSTANCE_INITIALIZER;
+base::LazyInstance<gfx::ColorSpace> g_best_monitor_color_space =
+ LAZY_INSTANCE_INITIALIZER;
+bool g_has_initialized_best_monitor_color_space = false;
+
+} // namespace
+
+// static
+ColorSpace ColorSpace::FromBestMonitor() {
+ base::AutoLock lock(g_best_monitor_color_space_lock.Get());
+ return g_best_monitor_color_space.Get();
+}
+
+// static
+bool ColorSpace::CachedProfilesNeedUpdate() {
+ base::AutoLock lock(g_best_monitor_color_space_lock.Get());
+ return !g_has_initialized_best_monitor_color_space;
+}
+
+// static
+void ColorSpace::UpdateCachedProfilesOnBackgroundThread() {
+ std::vector<char> icc_profile;
+ ReadBestMonitorICCProfile(&icc_profile);
+
+ base::AutoLock lock(g_best_monitor_color_space_lock.Get());
+ g_best_monitor_color_space.Get().icc_profile_ = icc_profile;
+ g_has_initialized_best_monitor_color_space = true;
+}
+
+} // namespace gfx
« no previous file with comments | « ui/gfx/color_space_mac.mm ('k') | ui/gfx/gfx.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698