OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "gfx/win_util.h" | 5 #include "gfx/win_util.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/win_util.h" | 9 #include "base/win/windows_version.h" |
10 | 10 |
11 namespace { | 11 namespace { |
12 | 12 |
13 bool DynamicLibraryPresent(const wchar_t* lib_name) { | 13 bool DynamicLibraryPresent(const wchar_t* lib_name) { |
14 HINSTANCE lib = LoadLibrary(lib_name); | 14 HINSTANCE lib = LoadLibrary(lib_name); |
15 if (lib) { | 15 if (lib) { |
16 FreeLibrary(lib); | 16 FreeLibrary(lib); |
17 return true; | 17 return true; |
18 } | 18 } |
19 return false; | 19 return false; |
20 } | 20 } |
21 | 21 |
22 } // namespace | 22 } // namespace |
23 | 23 |
24 namespace gfx { | 24 namespace gfx { |
25 | 25 |
26 // Returns true if Direct2d is available, false otherwise. | 26 // Returns true if Direct2d is available, false otherwise. |
27 bool Direct2dIsAvailable() { | 27 bool Direct2dIsAvailable() { |
28 static bool checked = false; | 28 static bool checked = false; |
29 static bool available = false; | 29 static bool available = false; |
30 | 30 |
31 if (!checked) { | 31 if (!checked) { |
32 win_util::WinVersion version = win_util::GetWinVersion(); | 32 base::win::Version version = base::win::GetVersion(); |
33 if (version < win_util::WINVERSION_VISTA) | 33 if (version < base::win::VERSION_VISTA) |
34 available = false; | 34 available = false; |
35 else if (version >= win_util::WINVERSION_WIN7) | 35 else if (version >= base::win::VERSION_WIN7) |
36 available = true; | 36 available = true; |
37 else | 37 else |
38 available = DynamicLibraryPresent(L"d2d1.dll"); | 38 available = DynamicLibraryPresent(L"d2d1.dll"); |
39 checked = true; | 39 checked = true; |
40 } | 40 } |
41 return available; | 41 return available; |
42 } | 42 } |
43 | 43 |
44 // Returns true if DirectWrite is available, false otherwise. | 44 // Returns true if DirectWrite is available, false otherwise. |
45 bool DirectWriteIsAvailable() { | 45 bool DirectWriteIsAvailable() { |
46 static bool checked = false; | 46 static bool checked = false; |
47 static bool available = false; | 47 static bool available = false; |
48 | 48 |
49 if (!checked) { | 49 if (!checked) { |
50 win_util::WinVersion version = win_util::GetWinVersion(); | 50 base::win::Version version = base::win::GetVersion(); |
51 if (version < win_util::WINVERSION_VISTA) | 51 if (version < base::win::VERSION_VISTA) |
52 available = false; | 52 available = false; |
53 else if (version >= win_util::WINVERSION_WIN7) | 53 else if (version >= base::win::VERSION_WIN7) |
54 available = true; | 54 available = true; |
55 else | 55 else |
56 available = DynamicLibraryPresent(L"dwrite.dll"); | 56 available = DynamicLibraryPresent(L"dwrite.dll"); |
57 checked = true; | 57 checked = true; |
58 } | 58 } |
59 return available; | 59 return available; |
60 } | 60 } |
61 | 61 |
62 } // namespace gfx | 62 } // namespace gfx |
63 | 63 |
OLD | NEW |