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

Side by Side 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: Add parts to resource provider 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_GFX_COLOR_SPACE_H_ 5 #ifndef UI_GFX_COLOR_SPACE_H_
6 #define UI_GFX_COLOR_SPACE_H_ 6 #define UI_GFX_COLOR_SPACE_H_
7 7
8 #include <vector> 8 #include <stdint.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h"
12 #include "build/build_config.h" 11 #include "build/build_config.h"
13 #include "ui/gfx/gfx_export.h" 12 #include "ui/gfx/gfx_export.h"
14 13
15 #if defined(OS_MACOSX)
16 #include <CoreGraphics/CGColorSpace.h>
17 #endif
18
19 namespace IPC { 14 namespace IPC {
20 template <class P> 15 template <class P>
21 struct ParamTraits; 16 struct ParamTraits;
22 } // namespace IPC 17 } // namespace IPC
23 18
24 namespace gfx { 19 namespace gfx {
25 20
21 class ICCProfile;
22
23 enum class ColorTransferFunction { UNSUPPORTED, LAST = UNSUPPORTED };
24
25 // Used to represet a color space for the purpose of color conversion.
enne (OOO) 2016/07/21 22:22:53 typo
26 class GFX_EXPORT ColorSpace { 26 class GFX_EXPORT ColorSpace {
27 public: 27 public:
28 ColorSpace(); 28 ColorSpace();
29 ColorSpace(ColorSpace&& other);
30 ColorSpace(const ColorSpace& other);
31 ColorSpace& operator=(const ColorSpace& other);
32 ~ColorSpace();
33 bool operator==(const ColorSpace& other) const; 29 bool operator==(const ColorSpace& other) const;
34 bool operator<(const ColorSpace& other) const;
35
36 // Returns the color profile of the monitor that can best represent color.
37 // This profile should be used for creating content that does not know on
38 // which monitor it will be displayed.
39 static ColorSpace FromBestMonitor();
40 static ColorSpace FromICCProfile(const std::vector<char>& icc_profile);
41 #if defined(OS_MACOSX)
42 static ColorSpace FromCGColorSpace(CGColorSpaceRef cg_color_space);
43 #endif
44
45 const std::vector<char>& GetICCProfile() const;
46
47 #if defined(OS_WIN)
48 // This will read monitor ICC profiles from disk and cache the results for the
49 // other functions to read. This should not be called on the UI or IO thread.
50 static void UpdateCachedProfilesOnBackgroundThread();
51 static bool CachedProfilesNeedUpdate();
52 #endif
53
54 static bool IsValidProfileLength(size_t length);
55 30
56 private: 31 private:
57 struct Key; 32 bool valid_ = false;
58 class GlobalData; 33 ColorTransferFunction transfer_function_ = ColorTransferFunction::UNSUPPORTED;
59 enum class Type { 34 // 3x4 affine transformation matrix in row-major order.
60 UNDEFINED, 35 float xyz_d50_matrix_[12];
61 ICC_PROFILE, 36 // This is used to look up the ICCProfile from which this ColorSpace was
62 LAST = ICC_PROFILE 37 // created, if possible.
63 }; 38 uint64_t icc_profile_id_ = 0;
64 Type type_ = Type::UNDEFINED;
65 39
66 // GlobalData stores large or expensive-to-compute data about a color space 40 friend class ICCProfile;
67 // (e.g, ICC profile). This structure is shared by all identical ColorSpace
68 // objects in the process. It is lazily initialized for named color spaces.
69 mutable scoped_refptr<GlobalData> global_data_;
70
71 friend struct Key;
72 friend class GlobalData;
73 friend struct IPC::ParamTraits<gfx::ColorSpace>; 41 friend struct IPC::ParamTraits<gfx::ColorSpace>;
74 friend struct IPC::ParamTraits<gfx::ColorSpace::Type>;
75 }; 42 };
76 43
77 } // namespace gfx 44 } // namespace gfx
78 45
79 #endif // UI_GFX_COLOR_SPACE_H_ 46 #endif // UI_GFX_COLOR_SPACE_H_
OLDNEW
« no previous file with comments | « ui/gfx/BUILD.gn ('k') | ui/gfx/color_space.cc » ('j') | ui/gfx/icc_profile.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698