Chromium Code Reviews| 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 <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 // Used to represet a color space for the purpose of color conversion. | |
|
dcheng
2016/07/25 13:42:26
Perhaps also note that this is designed to be safe
ccameron
2016/07/25 21:31:54
Put in both notes (in "higher-privilege" to "lower
| |
| 26 class GFX_EXPORT ColorSpace { | 24 class GFX_EXPORT ColorSpace { |
| 27 public: | 25 public: |
| 28 ColorSpace(); | 26 ColorSpace(); |
| 29 ColorSpace(ColorSpace&& other); | 27 static ColorSpace CreateSRGB(); |
| 30 ColorSpace(const ColorSpace& other); | 28 |
| 31 ColorSpace& operator=(const ColorSpace& other); | 29 // TODO: Remove these, and replace with more generic constructors. |
| 32 ~ColorSpace(); | 30 static ColorSpace CreateJpeg(); |
| 31 static ColorSpace CreateREC601(); | |
| 32 static ColorSpace CreateREC709(); | |
| 33 | |
| 33 bool operator==(const ColorSpace& other) const; | 34 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 | 35 |
| 56 private: | 36 private: |
| 57 struct Key; | 37 bool valid_ = false; |
| 58 class GlobalData; | 38 // This is used to look up the ICCProfile from which this ColorSpace was |
| 59 enum class Type { | 39 // created, if possible. |
| 60 UNDEFINED, | 40 uint64_t icc_profile_id_ = 0; |
| 61 ICC_PROFILE, | |
| 62 LAST = ICC_PROFILE | |
| 63 }; | |
| 64 Type type_ = Type::UNDEFINED; | |
| 65 | 41 |
| 66 // GlobalData stores large or expensive-to-compute data about a color space | 42 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>; | 43 friend struct IPC::ParamTraits<gfx::ColorSpace>; |
| 74 friend struct IPC::ParamTraits<gfx::ColorSpace::Type>; | |
| 75 }; | 44 }; |
| 76 | 45 |
| 77 } // namespace gfx | 46 } // namespace gfx |
| 78 | 47 |
| 79 #endif // UI_GFX_COLOR_SPACE_H_ | 48 #endif // UI_GFX_COLOR_SPACE_H_ |
| OLD | NEW |