| OLD | NEW |
| (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); |
| 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 friend struct IPC::ParamTraits<gfx::ICCProfile>; |
| 68 }; |
| 69 |
| 70 } // namespace gfx |
| 71 |
| 72 #endif // UI_GFX_ICC_PROFILE_H_ |
| OLD | NEW |