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

Side by Side Diff: ui/gfx/icc_profile.h

Issue 2161293002: Color: Separate ICCProfile and ColorSpace structures (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Err, get the right stuff 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef UI_GFX_ICC_PROFILE_H_
6 #define UI_GFX_ICC_PROFILE_H_
7
8 #include <stdint.h>
9 #include <vector>
10
11 #include "ui/gfx/color_space.h"
12
13 #if defined(OS_MACOSX)
14 #include <CoreGraphics/CGColorSpace.h>
15 #endif
16
17 namespace gfx {
18
19 // Used to represent a full ICC profile, usually retrieved from a monitor. It
20 // can be lossily compressed into a ColorSpace object.
21 class GFX_EXPORT ICCProfile {
22 public:
23 ICCProfile();
24 ICCProfile(ICCProfile&& other);
dcheng 2016/07/25 13:42:26 I would probably default the move assignment opera
ccameron 2016/07/25 21:31:54 Done.
25 ICCProfile(const ICCProfile& other);
26 ICCProfile& operator=(const ICCProfile& other);
27 ~ICCProfile();
28 bool operator==(const ICCProfile& other) const;
29
30 // Returns the color profile of the monitor that can best represent color.
31 // This profile should be used for creating content that does not know on
32 // which monitor it will be displayed.
33 static ICCProfile FromBestMonitor();
34 #if defined(OS_MACOSX)
35 static ICCProfile FromCGColorSpace(CGColorSpaceRef cg_color_space);
36 #endif
37
38 // This will recover a ICCProfile from a compact ColorSpace representation.
39 // Internally, this will make an effort to create an identical ICCProfile
40 // to the one that created |color_space|, but this is not guaranteed.
41 static ICCProfile FromColorSpace(const gfx::ColorSpace& color_space);
42
43 // This will perform a potentially-lossy conversion to a more compact color
44 // space representation.
45 ColorSpace GetColorSpace() const;
46
47 const std::vector<char>& GetData() const;
48
49 #if defined(OS_WIN)
50 // This will read monitor ICC profiles from disk and cache the results for the
51 // other functions to read. This should not be called on the UI or IO thread.
52 static void UpdateCachedProfilesOnBackgroundThread();
53 static bool CachedProfilesNeedUpdate();
54 #endif
55
56 private:
57 static ICCProfile FromData(const std::vector<char>& icc_profile);
58 static bool IsValidProfileLength(size_t length);
59
60 bool valid_ = false;
61 std::vector<char> data_;
62
63 // This globally identifies this ICC profile. It is used to look up this ICC
64 // profile from a ColorSpace object created from it.
65 uint64_t id_ = 0;
66
67 // Hard-coded values for the supported non-monitor-ICC-based profiles that we
68 // support (for now).
69 static const uint64_t kSRGBId = 1;
70 static const uint64_t kJpegId = 2;
71 static const uint64_t kRec601Id = 3;
72 static const uint64_t kRec709Id = 4;
73
74 friend class ColorSpace;
75 friend struct IPC::ParamTraits<gfx::ICCProfile>;
76 };
77
78 } // namespace gfx
79
80 #endif // UI_GFX_ICC_PROFILE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698