summaryrefslogtreecommitdiffstats
path: root/gfx/win_util.cc
diff options
context:
space:
mode:
authorgeorgey@chromium.org <georgey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-06 22:56:47 +0000
committergeorgey@chromium.org <georgey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-06 22:56:47 +0000
commit5b3a7e96fdd94ef0a7f8d375e8b88babcfe5fcc4 (patch)
tree4ba52dd8f508efb0f6bc4e8bc06e28a4fb36eba3 /gfx/win_util.cc
parent0e6d874af53c7d08ad8a2eafd3e3e7ae8ba563af (diff)
downloadchromium_src-5b3a7e96fdd94ef0a7f8d375e8b88babcfe5fcc4.zip
chromium_src-5b3a7e96fdd94ef0a7f8d375e8b88babcfe5fcc4.tar.gz
chromium_src-5b3a7e96fdd94ef0a7f8d375e8b88babcfe5fcc4.tar.bz2
Fix gfx unit-tests so they do not crash on Windows, prior to Windows 7
Also fix failing Font test. TEST=unit tests BUG=46733 Review URL: http://codereview.chromium.org/3615001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61725 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gfx/win_util.cc')
-rw-r--r--gfx/win_util.cc63
1 files changed, 63 insertions, 0 deletions
diff --git a/gfx/win_util.cc b/gfx/win_util.cc
new file mode 100644
index 0000000..edd1a01
--- /dev/null
+++ b/gfx/win_util.cc
@@ -0,0 +1,63 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "gfx/win_util.h"
+
+#include <windows.h>
+
+#include "base/win_util.h"
+
+namespace {
+
+bool DynamicLibraryPresent(const wchar_t* lib_name) {
+ HINSTANCE lib = LoadLibrary(lib_name);
+ if (lib) {
+ FreeLibrary(lib);
+ return true;
+ }
+ return false;
+}
+
+} // namespace
+
+namespace gfx {
+
+// Returns true if Direct2d is available, false otherwise.
+bool Direct2dIsAvailable() {
+ static bool checked = false;
+ static bool available = false;
+
+ if (!checked) {
+ win_util::WinVersion version = win_util::GetWinVersion();
+ if (version < win_util::WINVERSION_VISTA)
+ available = false;
+ else if (version >= win_util::WINVERSION_WIN7)
+ available = true;
+ else
+ available = DynamicLibraryPresent(L"d2d1.dll");
+ checked = true;
+ }
+ return available;
+}
+
+// Returns true if DirectWrite is available, false otherwise.
+bool DirectWriteIsAvailable() {
+ static bool checked = false;
+ static bool available = false;
+
+ if (!checked) {
+ win_util::WinVersion version = win_util::GetWinVersion();
+ if (version < win_util::WINVERSION_VISTA)
+ available = false;
+ else if (version >= win_util::WINVERSION_WIN7)
+ available = true;
+ else
+ available = DynamicLibraryPresent(L"dwrite.dll");
+ checked = true;
+ }
+ return available;
+}
+
+} // namespace gfx
+