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

Unified Diff: ui/gfx/color_profile_win.cc

Issue 293393008: gfx/ui/color_profile: add color profile cache on win (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/color_profile_win.cc
diff --git a/ui/gfx/color_profile_win.cc b/ui/gfx/color_profile_win.cc
index 43ea465795834f735a133d8cb9b8b79c80ea60e9..c4b26b4d226dedb9c0a2a284b53d56b8277b7418 100644
--- a/ui/gfx/color_profile_win.cc
+++ b/ui/gfx/color_profile_win.cc
@@ -4,12 +4,53 @@
#include "ui/gfx/color_profile.h"
+#include <map>
#include <windows.h>
#include "base/file_util.h"
+#include "base/synchronization/lock.h"
namespace gfx {
+class ColorProfileCache {
sky 2014/05/29 15:31:32 Add description.
+ public:
+ ColorProfileCache() {}
+
+ bool find(const std::wstring& device, std::vector<char>* profile) {
sky 2014/05/29 15:31:32 All your function names should be camelcase, eg Fi
+ base::AutoLock lock(lock_);
+ DeviceColorProfile::const_iterator it = cache_.find(device);
+ if (it == cache_.end())
+ return false;
+ *profile = it->second;
+ return true;
+ }
+
+ void insert(const std::wstring& device, const std::vector<char>& profile) {
+ base::AutoLock lock(lock_);
+ cache_[device] = profile;
+ }
+
+ bool erase(const std::wstring& device) {
+ base::AutoLock lock(lock_);
+ DeviceColorProfile::iterator it = cache_.find(device);
+ if (it == cache_.end())
+ return false;
+ cache_.erase(device);
+ return true;
+ }
+
+ void clear() {
+ base::AutoLock lock(lock_);
+ cache_.clear();
+ }
+
+ private:
+ typedef std::map<std::wstring, std::vector<char> > DeviceColorProfile;
+
+ DeviceColorProfile cache_;
+ base::Lock lock_;
+};
sky 2014/05/29 15:31:32 DISALLOW_COPY_AND_ASSIGN.
+
bool GetDisplayColorProfile(const gfx::Rect& bounds,
std::vector<char>* profile) {
if (bounds.IsEmpty())
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698