| 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. This structure should |
| 21 // only be sent from higher-privilege processes to lower-privilege processes, |
| 22 // as parsing this structure is not secure. |
| 23 class GFX_EXPORT ICCProfile { |
| 24 public: |
| 25 ICCProfile(); |
| 26 ICCProfile(ICCProfile&& other); |
| 27 ICCProfile(const ICCProfile& other); |
| 28 ICCProfile& operator=(ICCProfile&& other); |
| 29 ICCProfile& operator=(const ICCProfile& other); |
| 30 ~ICCProfile(); |
| 31 bool operator==(const ICCProfile& other) const; |
| 32 |
| 33 // Returns the color profile of the monitor that can best represent color. |
| 34 // This profile should be used for creating content that does not know on |
| 35 // which monitor it will be displayed. |
| 36 static ICCProfile FromBestMonitor(); |
| 37 #if defined(OS_MACOSX) |
| 38 static ICCProfile FromCGColorSpace(CGColorSpaceRef cg_color_space); |
| 39 #endif |
| 40 |
| 41 // This will recover a ICCProfile from a compact ColorSpace representation. |
| 42 // Internally, this will make an effort to create an identical ICCProfile |
| 43 // to the one that created |color_space|, but this is not guaranteed. |
| 44 static ICCProfile FromColorSpace(const gfx::ColorSpace& color_space); |
| 45 |
| 46 // This will perform a potentially-lossy conversion to a more compact color |
| 47 // space representation. |
| 48 ColorSpace GetColorSpace() const; |
| 49 |
| 50 const std::vector<char>& GetData() const; |
| 51 |
| 52 #if defined(OS_WIN) |
| 53 // This will read monitor ICC profiles from disk and cache the results for the |
| 54 // other functions to read. This should not be called on the UI or IO thread. |
| 55 static void UpdateCachedProfilesOnBackgroundThread(); |
| 56 static bool CachedProfilesNeedUpdate(); |
| 57 #endif |
| 58 |
| 59 private: |
| 60 static ICCProfile FromData(const std::vector<char>& icc_profile); |
| 61 static bool IsValidProfileLength(size_t length); |
| 62 |
| 63 bool valid_ = false; |
| 64 std::vector<char> data_; |
| 65 |
| 66 // This globally identifies this ICC profile. It is used to look up this ICC |
| 67 // profile from a ColorSpace object created from it. |
| 68 uint64_t id_ = 0; |
| 69 |
| 70 // Hard-coded values for the supported non-monitor-ICC-based profiles that we |
| 71 // support (for now). |
| 72 static const uint64_t kSRGBId = 1; |
| 73 static const uint64_t kJpegId = 2; |
| 74 static const uint64_t kRec601Id = 3; |
| 75 static const uint64_t kRec709Id = 4; |
| 76 |
| 77 friend class ColorSpace; |
| 78 friend struct IPC::ParamTraits<gfx::ICCProfile>; |
| 79 }; |
| 80 |
| 81 } // namespace gfx |
| 82 |
| 83 #endif // UI_GFX_ICC_PROFILE_H_ |
| OLD | NEW |