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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | ui/gfx/color_space.cc » ('j') | ui/gfx/color_space.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <vector>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h"
11 #include "build/build_config.h" 12 #include "build/build_config.h"
12 #include "ui/gfx/gfx_export.h" 13 #include "ui/gfx/gfx_export.h"
13 14
14 #if defined(OS_MACOSX) 15 #if defined(OS_MACOSX)
15 #include <CoreGraphics/CGColorSpace.h> 16 #include <CoreGraphics/CGColorSpace.h>
16 #endif 17 #endif
17 18
18 namespace gfx { 19 namespace gfx {
19 20
20 class GFX_EXPORT ColorSpace { 21 class GFX_EXPORT ColorSpace {
21 public: 22 public:
22 ColorSpace(); 23 ColorSpace();
23 ColorSpace(ColorSpace&& other); 24 ColorSpace(ColorSpace&& other);
24 ColorSpace(const ColorSpace& other); 25 ColorSpace(const ColorSpace& other);
25 ColorSpace& operator=(const ColorSpace& other); 26 ColorSpace& operator=(const ColorSpace& other);
26 ~ColorSpace(); 27 ~ColorSpace();
27 bool operator==(const ColorSpace& other) const; 28 bool operator==(const ColorSpace& other) const;
29 bool operator<(const ColorSpace& other) const;
28 30
29 // Returns the color profile of the monitor that can best represent color. 31 // Returns the color profile of the monitor that can best represent color.
30 // This profile should be used for creating content that does not know on 32 // This profile should be used for creating content that does not know on
31 // which monitor it will be displayed. 33 // which monitor it will be displayed.
32 static ColorSpace FromBestMonitor(); 34 static ColorSpace FromBestMonitor();
33 static ColorSpace FromICCProfile(const std::vector<char>& icc_profile); 35 static ColorSpace FromICCProfile(const std::vector<char>& icc_profile);
34 #if defined(OS_MACOSX) 36 #if defined(OS_MACOSX)
35 static ColorSpace FromCGColorSpace(CGColorSpaceRef cg_color_space); 37 static ColorSpace FromCGColorSpace(CGColorSpaceRef cg_color_space);
36 #endif 38 #endif
37 39
38 const std::vector<char>& GetICCProfile() const { return icc_profile_; } 40 const std::vector<char>& GetICCProfile() const;
39 41
40 #if defined(OS_WIN) 42 #if defined(OS_WIN)
41 // This will read monitor ICC profiles from disk and cache the results for the 43 // This will read monitor ICC profiles from disk and cache the results for the
42 // other functions to read. This should not be called on the UI or IO thread. 44 // other functions to read. This should not be called on the UI or IO thread.
43 static void UpdateCachedProfilesOnBackgroundThread(); 45 static void UpdateCachedProfilesOnBackgroundThread();
44 static bool CachedProfilesNeedUpdate(); 46 static bool CachedProfilesNeedUpdate();
45 #endif 47 #endif
46 48
47 static bool IsValidProfileLength(size_t length); 49 static bool IsValidProfileLength(size_t length);
48 50
49 private: 51 private:
50 std::vector<char> icc_profile_; 52 struct Key;
53 class GlobalData;
54 friend struct Key;
55 friend class GlobalData;
56 enum class Type {
57 UNDEFINED,
58 ICC_PROFILE,
59 };
60 Type type_ = Type::UNDEFINED;
61
62 // GlobalData stores large or expensive-to-compute data about a color space
63 // (e.g, ICC profile). This structure is shared by all identical ColorSpace
64 // objects in the process. It is lazily initialized for named color spaces.
65 mutable scoped_refptr<GlobalData> global_data_;
51 }; 66 };
52 67
53 } // namespace gfx 68 } // namespace gfx
54 69
55 #endif // UI_GFX_COLOR_SPACE_H_ 70 #endif // UI_GFX_COLOR_SPACE_H_
OLDNEW
« 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