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

Unified Diff: ui/gfx/color_space.h

Issue 2161293002: Color: Separate ICCProfile and ColorSpace structures (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 | « ui/gfx/BUILD.gn ('k') | ui/gfx/color_space.cc » ('j') | no next file with comments »
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 164ca0037d29d611fb1cc6b409ddea98a1ba81ed..4e166e17f404f184f7dcb1ba38f1f98e32a67cd7 100644
--- a/ui/gfx/color_space.h
+++ b/ui/gfx/color_space.h
@@ -5,17 +5,12 @@
#ifndef UI_GFX_COLOR_SPACE_H_
#define UI_GFX_COLOR_SPACE_H_
-#include <vector>
+#include <stdint.h>
#include "base/macros.h"
-#include "base/memory/ref_counted.h"
#include "build/build_config.h"
#include "ui/gfx/gfx_export.h"
-#if defined(OS_MACOSX)
-#include <CoreGraphics/CGColorSpace.h>
-#endif
-
namespace IPC {
template <class P>
struct ParamTraits;
@@ -23,55 +18,31 @@ struct ParamTraits;
namespace gfx {
+class ICCProfile;
+
+// Used to represet a color space for the purpose of color conversion.
+// This is designed to be safe and compact enough to send over IPC
+// between any processes.
class GFX_EXPORT ColorSpace {
public:
ColorSpace();
- ColorSpace(ColorSpace&& other);
- ColorSpace(const ColorSpace& other);
- 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
- // which monitor it will be displayed.
- static ColorSpace FromBestMonitor();
- static ColorSpace FromICCProfile(const std::vector<char>& icc_profile);
-#if defined(OS_MACOSX)
- static ColorSpace FromCGColorSpace(CGColorSpaceRef cg_color_space);
-#endif
+ static ColorSpace CreateSRGB();
- const std::vector<char>& GetICCProfile() const;
+ // TODO: Remove these, and replace with more generic constructors.
+ static ColorSpace CreateJpeg();
+ static ColorSpace CreateREC601();
+ static ColorSpace CreateREC709();
-#if defined(OS_WIN)
- // This will read monitor ICC profiles from disk and cache the results for the
- // other functions to read. This should not be called on the UI or IO thread.
- static void UpdateCachedProfilesOnBackgroundThread();
- static bool CachedProfilesNeedUpdate();
-#endif
-
- static bool IsValidProfileLength(size_t length);
+ bool operator==(const ColorSpace& other) const;
private:
- struct Key;
- class GlobalData;
- enum class Type {
- UNDEFINED,
- ICC_PROFILE,
- LAST = 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_;
+ bool valid_ = false;
+ // This is used to look up the ICCProfile from which this ColorSpace was
+ // created, if possible.
+ uint64_t icc_profile_id_ = 0;
- friend struct Key;
- friend class GlobalData;
+ friend class ICCProfile;
friend struct IPC::ParamTraits<gfx::ColorSpace>;
- friend struct IPC::ParamTraits<gfx::ColorSpace::Type>;
};
} // namespace gfx
« no previous file with comments | « ui/gfx/BUILD.gn ('k') | ui/gfx/color_space.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698