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; | 20 static const size_t kMinProfileLength = 128; |
| 21 static const size_t kMaxProfileLength = 4 * 1024 * 1024; | 21 static const size_t kMaxProfileLength = 4 * 1024 * 1024; |
| 22 | 22 |
| 23 class GFX_EXPORT ColorProfile { | 23 class GFX_EXPORT ColorProfile { |
| 24 public: | 24 public: |
| 25 // On Windows, this reads a file from disk so it should not be run on the UI | 25 // Creates a color profile for the system's primary monitor. |
|
ccameron
2016/03/15 06:02:24
This should be a function called GetPrimaryDisplay
| |
| 26 // or IO thread. | |
| 27 ColorProfile(); | 26 ColorProfile(); |
| 28 ~ColorProfile(); | 27 ~ColorProfile(); |
| 29 | 28 |
| 30 const std::vector<char>& profile() const { return profile_; } | 29 const std::vector<char>& profile() const { return profile_; } |
| 31 | 30 |
| 32 private: | 31 private: |
| 33 std::vector<char> profile_; | 32 std::vector<char> profile_; |
| 34 | 33 |
| 35 DISALLOW_COPY_AND_ASSIGN(ColorProfile); | 34 DISALLOW_COPY_AND_ASSIGN(ColorProfile); |
| 36 }; | 35 }; |
| 37 | 36 |
| 38 inline bool InvalidColorProfileLength(size_t length) { | 37 inline bool InvalidColorProfileLength(size_t length) { |
| 39 return (length < kMinProfileLength) || (length > kMaxProfileLength); | 38 return (length < kMinProfileLength) || (length > kMaxProfileLength); |
| 40 } | 39 } |
| 41 | 40 |
| 42 // Return the color profile of the display nearest the screen bounds. On Win32, | 41 #if defined(OS_WIN) |
| 43 // this may read a file from disk so it should not be run on the UI/IO threads. | 42 // On Windows, color profile data is read from a file on disk, which may take an |
| 44 // If the given bounds are empty, or are off-screen, return false meaning there | 43 // arbitrarily long time to run. This function will update all displays' color |
| 45 // is no color profile associated with the bounds. Otherwise return true after | 44 // profiles. It should not be called on the UI or IO threads. The functions to |
| 45 // query color profiles will read the data cached by this function. | |
| 46 void GFX_EXPORT UpdateDisplayColorProfileCache(); | |
| 47 #endif | |
| 48 | |
| 49 // Return the color profile of the display nearest the screen bounds. If the | |
| 50 // given bounds are empty, or are off-screen, return false meaning there is no | |
| 51 // 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 | 52 // storing the display's color profile in |profile|, which will be empty if the |
| 47 // standard sRGB color profile should be assumed. | 53 // standard sRGB color profile should be assumed. |
| 48 GFX_EXPORT bool GetDisplayColorProfile(const gfx::Rect& bounds, | 54 GFX_EXPORT bool GetDisplayColorProfile(const gfx::Rect& bounds, |
| 49 std::vector<char>* profile); | 55 std::vector<char>* profile); |
| 50 #if defined(OS_MACOSX) | 56 #if defined(OS_MACOSX) |
|
ccameron
2016/03/15 06:02:24
Note that there is no reason why Mac should have a
Avi (use Gerrit)
2016/03/15 16:20:38
woot
| |
| 51 // Return the color profile of the native window. If the window is null, or has | 57 // 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 | 58 // 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 | 59 // 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. | 60 // |profile|, which will be empty if the sRGB color profile should be assumed. |
| 55 GFX_EXPORT bool GetDisplayColorProfile(gfx::NativeWindow window, | 61 GFX_EXPORT bool GetDisplayColorProfile(gfx::NativeWindow window, |
| 56 std::vector<char>* profile); | 62 std::vector<char>* profile); |
| 57 #endif | 63 #endif |
| 58 } // namespace gfx | 64 } // namespace gfx |
| 59 | 65 |
| 60 #endif // UI_GFX_COLOR_PROFILE_H_ | 66 #endif // UI_GFX_COLOR_PROFILE_H_ |
| OLD | NEW |