| OLD | NEW |
| 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" | |
| 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) | 14 #if defined(OS_MACOSX) |
| 16 #include <CoreGraphics/CGColorSpace.h> | 15 #include <CoreGraphics/CGColorSpace.h> |
| 17 #endif | 16 #endif |
| 18 | 17 |
| 19 namespace gfx { | 18 namespace gfx { |
| 20 | 19 |
| 21 class GFX_EXPORT ColorSpace { | 20 class GFX_EXPORT ColorSpace { |
| 22 public: | 21 public: |
| 23 ColorSpace(); | 22 ColorSpace(); |
| 24 ColorSpace(ColorSpace&& other); | 23 ColorSpace(ColorSpace&& other); |
| 25 ColorSpace(const ColorSpace& other); | 24 ColorSpace(const ColorSpace& other); |
| 26 ColorSpace& operator=(const ColorSpace& other); | 25 ColorSpace& operator=(const ColorSpace& other); |
| 27 ~ColorSpace(); | 26 ~ColorSpace(); |
| 28 bool operator==(const ColorSpace& other) const; | 27 bool operator==(const ColorSpace& other) const; |
| 29 bool operator<(const ColorSpace& other) const; | |
| 30 | 28 |
| 31 // Returns the color profile of the monitor that can best represent color. | 29 // Returns the color profile of the monitor that can best represent color. |
| 32 // This profile should be used for creating content that does not know on | 30 // This profile should be used for creating content that does not know on |
| 33 // which monitor it will be displayed. | 31 // which monitor it will be displayed. |
| 34 static ColorSpace FromBestMonitor(); | 32 static ColorSpace FromBestMonitor(); |
| 35 static ColorSpace FromICCProfile(const std::vector<char>& icc_profile); | 33 static ColorSpace FromICCProfile(const std::vector<char>& icc_profile); |
| 36 #if defined(OS_MACOSX) | 34 #if defined(OS_MACOSX) |
| 37 static ColorSpace FromCGColorSpace(CGColorSpaceRef cg_color_space); | 35 static ColorSpace FromCGColorSpace(CGColorSpaceRef cg_color_space); |
| 38 #endif | 36 #endif |
| 39 | 37 |
| 40 const std::vector<char>& GetICCProfile() const; | 38 const std::vector<char>& GetICCProfile() const { return icc_profile_; } |
| 41 | 39 |
| 42 #if defined(OS_WIN) | 40 #if defined(OS_WIN) |
| 43 // This will read monitor ICC profiles from disk and cache the results for the | 41 // This will read monitor ICC profiles from disk and cache the results for the |
| 44 // other functions to read. This should not be called on the UI or IO thread. | 42 // other functions to read. This should not be called on the UI or IO thread. |
| 45 static void UpdateCachedProfilesOnBackgroundThread(); | 43 static void UpdateCachedProfilesOnBackgroundThread(); |
| 46 static bool CachedProfilesNeedUpdate(); | 44 static bool CachedProfilesNeedUpdate(); |
| 47 #endif | 45 #endif |
| 48 | 46 |
| 49 static bool IsValidProfileLength(size_t length); | 47 static bool IsValidProfileLength(size_t length); |
| 50 | 48 |
| 51 private: | 49 private: |
| 52 struct Key; | 50 std::vector<char> icc_profile_; |
| 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_; | |
| 66 }; | 51 }; |
| 67 | 52 |
| 68 } // namespace gfx | 53 } // namespace gfx |
| 69 | 54 |
| 70 #endif // UI_GFX_COLOR_SPACE_H_ | 55 #endif // UI_GFX_COLOR_SPACE_H_ |
| OLD | NEW |