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_PROFILE_H_ | 5 #ifndef UI_GFX_COLOR_PROFILE_H_ |
| 6 #define UI_GFX_COLOR_PROFILE_H_ | 6 #define UI_GFX_COLOR_PROFILE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "ui/gfx/geometry/rect.h" | 14 #include "ui/gfx/geometry/rect.h" |
| 15 #include "ui/gfx/gfx_export.h" | 15 #include "ui/gfx/gfx_export.h" |
| 16 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
| 17 | 17 |
| 18 namespace gfx { | 18 namespace gfx { |
| 19 | 19 |
| 20 static const size_t kMinProfileLength = 128; | |
| 21 static const size_t kMaxProfileLength = 4 * 1024 * 1024; | |
| 22 | |
| 23 class GFX_EXPORT ColorProfile { | 20 class GFX_EXPORT ColorProfile { |
| 24 public: | 21 public: |
| 25 // On Windows, this reads a file from disk so it should not be run on the UI | |
| 26 // or IO thread. | |
| 27 ColorProfile(); | 22 ColorProfile(); |
| 23 ColorProfile(ColorProfile&& other); | |
| 24 ColorProfile(const ColorProfile& other); | |
| 25 ColorProfile& operator=(const ColorProfile& other); | |
| 28 ~ColorProfile(); | 26 ~ColorProfile(); |
| 29 | 27 |
| 28 #if defined(OS_WIN) | |
| 29 // This will read color profile information from disk and cache the results | |
| 30 // for the other functions to read. This should not be called on the UI or IO | |
| 31 // thread. | |
| 32 static void UpdateCachedProfilesOnBackgroundThread(); | |
| 33 #endif | |
| 34 | |
| 35 // Returns the color profile of the monitor that can best represent color. | |
| 36 // This profile should be used for creating content that does not know on | |
| 37 // which monitor it will be displayed. | |
| 38 static ColorProfile GetFromDeepestMonitor(); | |
|
enne (OOO)
2016/06/22 21:44:24
What does "deepest" in this context mean?
ccameron
2016/06/22 22:33:31
The name came from the NSDisplay API (I think deep
| |
| 39 | |
| 30 const std::vector<char>& profile() const { return profile_; } | 40 const std::vector<char>& profile() const { return profile_; } |
| 31 | 41 |
| 32 private: | 42 private: |
| 43 static bool InvalidColorProfileLength(size_t length); | |
| 33 std::vector<char> profile_; | 44 std::vector<char> profile_; |
| 34 | |
| 35 DISALLOW_COPY_AND_ASSIGN(ColorProfile); | |
| 36 }; | 45 }; |
| 37 | 46 |
| 38 inline bool InvalidColorProfileLength(size_t length) { | |
| 39 return (length < kMinProfileLength) || (length > kMaxProfileLength); | |
| 40 } | |
| 41 | |
| 42 // Return the color profile of the display nearest the screen bounds. On Win32, | |
| 43 // this may read a file from disk so it should not be run on the UI/IO threads. | |
| 44 // If the given bounds are empty, or are off-screen, return false meaning there | |
| 45 // is no color profile associated with the bounds. Otherwise return true after | |
| 46 // storing the display's color profile in |profile|, which will be empty if the | |
| 47 // standard sRGB color profile should be assumed. | |
| 48 GFX_EXPORT bool GetDisplayColorProfile(const gfx::Rect& bounds, | |
| 49 std::vector<char>* profile); | |
| 50 #if defined(OS_MACOSX) | |
| 51 // Return the color profile of the native window. If the window is null, or has | |
| 52 // empty bounds, return false meaning there is no color profile associated with | |
| 53 // the window. Otherwise return true after storing the window color profile in | |
| 54 // |profile|, which will be empty if the sRGB color profile should be assumed. | |
| 55 GFX_EXPORT bool GetDisplayColorProfile(gfx::NativeWindow window, | |
| 56 std::vector<char>* profile); | |
| 57 #endif | |
| 58 } // namespace gfx | 47 } // namespace gfx |
| 59 | 48 |
| 60 #endif // UI_GFX_COLOR_PROFILE_H_ | 49 #endif // UI_GFX_COLOR_PROFILE_H_ |
| OLD | NEW |