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

Unified Diff: ui/display/win/color_profile_reader.h

Issue 2959423003: color: Read all displays' color profiles on Windows (Closed)
Patch Set: Remove unused Initialize method Created 3 years, 5 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/display/BUILD.gn ('k') | ui/display/win/color_profile_reader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/display/win/color_profile_reader.h
diff --git a/ui/display/win/color_profile_reader.h b/ui/display/win/color_profile_reader.h
new file mode 100644
index 0000000000000000000000000000000000000000..0d1e2b4807a4d43d0a530d3ff8a88814de6da046
--- /dev/null
+++ b/ui/display/win/color_profile_reader.h
@@ -0,0 +1,70 @@
+// Copyright 2017 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.
+
+#ifndef UI_DISPLAY_WIN_COLOR_PROFILE_READER_H_
+#define UI_DISPLAY_WIN_COLOR_PROFILE_READER_H_
+
+#include "base/callback.h"
+#include "base/memory/weak_ptr.h"
+#include "base/strings/string16.h"
+#include "ui/display/display_export.h"
+#include "ui/gfx/color_space.h"
+
+#include <map>
+#include <string>
+
+namespace display {
+namespace win {
+
+// Monitor ICC profiles are stored in the filesystem, and a blocking read from
+// file is required to read them. This is expensive and shouldn't be done on the
+// main thread, so this class manages asynchronously doing these readings and
+// calling back into its client when the profiles are noticed to have changed.
+class DISPLAY_EXPORT ColorProfileReader {
+ public:
+ class Client {
+ public:
+ virtual void OnColorProfilesChanged() = 0;
+ };
+
+ ColorProfileReader(Client* client);
+ ~ColorProfileReader();
+
+ // Check to see if the screen profile filenames have changed. If so, spawn a
+ // task to update them. When the task has completed, this will call the
+ // client's OnColorProfileReaderChanged on the main thread.
+ void UpdateIfNeeded();
+
+ // Look up the color space for a given device name. If the device's color
+ // profile has not yet been read, this will return sRGB (which is what the
+ // file on disk will say most of the time).
+ const gfx::ColorSpace& GetDisplayColorSpace(int64_t id) const;
+
+ private:
+ typedef std::map<base::string16, base::string16> DeviceToPathMap;
+ typedef std::map<base::string16, std::string> DeviceToDataMap;
+
+ // Enumerate displays and return a map to their ICC profile path.
+ static DeviceToPathMap BuildDeviceToPathMap();
+
+ // Do the actual reading from the filesystem. This needs to be run off of the
+ // main thread.
+ static DeviceToDataMap ReadProfilesOnBackgroundThread(
+ DeviceToPathMap new_device_to_path_map);
+
+ // Called on the main thread when the read has completed.
+ void ReadProfilesCompleted(DeviceToDataMap device_to_data_map);
+
+ Client* const client_ = nullptr;
+ bool update_in_flight_ = false;
+ DeviceToPathMap device_to_path_map_;
+ std::map<int64_t, gfx::ColorSpace> display_id_to_color_space_map_;
+ const gfx::ColorSpace default_color_space_ = gfx::ColorSpace::CreateSRGB();
+ base::WeakPtrFactory<ColorProfileReader> weak_factory_;
+};
+
+} // namespace win
+} // namespace display
+
+#endif // UI_DISPLAY_WIN_COLOR_PROFILE_READER_H_
« no previous file with comments | « ui/display/BUILD.gn ('k') | ui/display/win/color_profile_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698