Roll src/third_party/WebKit b944946:201fd41 (svn 192400:192407)
[chromium-blink-merge.git] / ui / gfx / color_profile.h
blob8f3f1f62f61d484509b1d8934203e9db109ab050
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
3 // found in the LICENSE file.
5 #ifndef UI_GFX_COLOR_PROFILE_H_
6 #define UI_GFX_COLOR_PROFILE_H_
8 #include <vector>
10 #include "ui/gfx/geometry/rect.h"
11 #include "ui/gfx/gfx_export.h"
12 #include "ui/gfx/native_widget_types.h"
14 namespace gfx {
16 static const size_t kMinProfileLength = 128;
17 static const size_t kMaxProfileLength = 4 * 1024 * 1024;
19 class GFX_EXPORT ColorProfile {
20 public:
21 // On Windows, this reads a file from disk so it should not be run on the UI
22 // or IO thread.
23 ColorProfile();
24 ~ColorProfile();
26 const std::vector<char>& profile() const { return profile_; }
28 private:
29 std::vector<char> profile_;
31 DISALLOW_COPY_AND_ASSIGN(ColorProfile);
34 inline bool InvalidColorProfileLength(size_t length) {
35 return (length < kMinProfileLength) || (length > kMaxProfileLength);
38 // Return the color profile of the display nearest the screen bounds. On Win32,
39 // this may read a file from disk so it should not be run on the UI/IO threads.
40 // If the given bounds are empty, or are off-screen, return false meaning there
41 // is no color profile associated with the bounds. Otherwise return true after
42 // storing the display's color profile in |profile|, which will be empty if the
43 // standard sRGB color profile should be assumed.
44 GFX_EXPORT bool GetDisplayColorProfile(const gfx::Rect& bounds,
45 std::vector<char>* profile);
46 #if defined(OS_MACOSX)
47 // Return the color profile of the native window. If the window is null, or has
48 // empty bounds, return false meaning there is no color profile associated with
49 // the window. Otherwise return true after storing the window color profile in
50 // |profile|, which will be empty if the sRGB color profile should be assumed.
51 GFX_EXPORT bool GetDisplayColorProfile(gfx::NativeWindow window,
52 std::vector<char>* profile);
53 #endif
54 } // namespace gfx
56 #endif // UI_GFX_COLOR_PROFILE_H_