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