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

Unified Diff: ui/gfx/color_space.h

Issue 2140803002: Color: Don't duplicate ICC profile data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporate review feedback Created 4 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 | « no previous file | ui/gfx/color_space.cc » ('j') | ui/gfx/color_space.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/color_space.h
diff --git a/ui/gfx/color_space.h b/ui/gfx/color_space.h
index 0129e7e1cb4282c8ac765a927293bf19455c0afd..44a85eb4a761a7d8457ef00635d0d01183430bd5 100644
--- a/ui/gfx/color_space.h
+++ b/ui/gfx/color_space.h
@@ -8,6 +8,7 @@
#include <vector>
#include "base/macros.h"
+#include "base/memory/ref_counted.h"
#include "build/build_config.h"
#include "ui/gfx/gfx_export.h"
@@ -25,6 +26,7 @@ class GFX_EXPORT ColorSpace {
ColorSpace& operator=(const ColorSpace& other);
~ColorSpace();
bool operator==(const ColorSpace& other) const;
+ bool operator<(const ColorSpace& other) const;
// Returns the color profile of the monitor that can best represent color.
// This profile should be used for creating content that does not know on
@@ -35,7 +37,7 @@ class GFX_EXPORT ColorSpace {
static ColorSpace FromCGColorSpace(CGColorSpaceRef cg_color_space);
#endif
- const std::vector<char>& GetICCProfile() const { return icc_profile_; }
+ const std::vector<char>& GetICCProfile() const;
#if defined(OS_WIN)
// This will read monitor ICC profiles from disk and cache the results for the
@@ -47,7 +49,20 @@ class GFX_EXPORT ColorSpace {
static bool IsValidProfileLength(size_t length);
private:
- std::vector<char> icc_profile_;
+ struct Key;
+ class GlobalData;
+ friend struct Key;
+ friend class GlobalData;
+ enum class Type {
+ UNDEFINED,
+ ICC_PROFILE,
+ };
+ Type type_ = Type::UNDEFINED;
+
+ // GlobalData stores large or expensive-to-compute data about a color space
+ // (e.g, ICC profile). This structure is shared by all identical ColorSpace
+ // objects in the process. It is lazily initialized for named color spaces.
+ mutable scoped_refptr<GlobalData> global_data_;
};
} // namespace gfx
« no previous file with comments | « no previous file | ui/gfx/color_space.cc » ('j') | ui/gfx/color_space.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698