Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(522)

Side by Side Diff: ui/gfx/color_profile.h

Issue 2092533002: Clean up gfx::ColorProfile (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git cl try Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gfx/BUILD.gn ('k') | ui/gfx/color_profile.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
30 const std::vector<char>& profile() const { return profile_; } 28 const std::vector<char>& profile() const { return profile_; }
31 29
30 #if defined(OS_WIN)
31 // This will read color profile information from disk and cache the results
32 // for the other functions to read. This should not be called on the UI or IO
33 // thread.
34 static void UpdateCachedProfilesOnBackgroundThread();
35 static bool CachedProfilesNeedUpdate();
36 #endif
37
38 // Returns the color profile of the monitor that can best represent color.
39 // This profile should be used for creating content that does not know on
40 // which monitor it will be displayed.
41 static ColorProfile GetFromBestMonitor();
42
43 static bool IsValidProfileLength(size_t length);
44
32 private: 45 private:
33 std::vector<char> profile_; 46 std::vector<char> profile_;
34
35 DISALLOW_COPY_AND_ASSIGN(ColorProfile);
36 }; 47 };
37 48
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 49 } // namespace gfx
59 50
60 #endif // UI_GFX_COLOR_PROFILE_H_ 51 #endif // UI_GFX_COLOR_PROFILE_H_
OLDNEW
« no previous file with comments | « ui/gfx/BUILD.gn ('k') | ui/gfx/color_profile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698