summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgirard@chromium.org <girard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-22 13:22:59 +0000
committergirard@chromium.org <girard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-22 13:22:59 +0000
commit40bd0e2dbb489669dedd5eaab25f1dee629e9b09 (patch)
tree54345cd9f0f2a56abcd72137e1cef2be7a051e66
parent8d33ef915d77c93f9a5a726a6861719ed8fd0732 (diff)
downloadchromium_src-40bd0e2dbb489669dedd5eaab25f1dee629e9b09.zip
chromium_src-40bd0e2dbb489669dedd5eaab25f1dee629e9b09.tar.gz
chromium_src-40bd0e2dbb489669dedd5eaab25f1dee629e9b09.tar.bz2
Disable win/ash on high dpi screens
BUG=321694 Review URL: https://codereview.chromium.org/79033002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@236762 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/toolbar/wrench_menu_model.cc6
-rw-r--r--ui/gfx/win/dpi.cc22
-rw-r--r--ui/gfx/win/dpi.h7
-rw-r--r--win8/metro_driver/display_properties.cc34
-rw-r--r--win8/metro_driver/metro_driver.gyp1
5 files changed, 66 insertions, 4 deletions
diff --git a/chrome/browser/ui/toolbar/wrench_menu_model.cc b/chrome/browser/ui/toolbar/wrench_menu_model.cc
index eea6eaa8..5715f4c 100644
--- a/chrome/browser/ui/toolbar/wrench_menu_model.cc
+++ b/chrome/browser/ui/toolbar/wrench_menu_model.cc
@@ -65,6 +65,7 @@
#include "chrome/browser/enumerate_modules_model_win.h"
#include "chrome/browser/ui/metro_pin_tab_helper_win.h"
#include "content/public/browser/gpu_data_manager.h"
+#include "ui/gfx/win/dpi.h"
#include "win8/util/win8_util.h"
#endif
@@ -544,7 +545,10 @@ void WrenchMenuModel::Build(bool is_new_menu) {
#if defined(USE_AURA)
if (base::win::GetVersion() >= base::win::VERSION_WIN8 &&
- content::GpuDataManager::GetInstance()->CanUseGpuBrowserCompositor()) {
+ content::GpuDataManager::GetInstance()->CanUseGpuBrowserCompositor() &&
+ gfx::win::GetUndocumentedDPIScale() == 1.0f &&
+ gfx::GetDPIScale() == 1.0 &&
+ gfx::GetModernUIScale() == 1.0f) {
if (browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) {
// Metro mode, add the 'Relaunch Chrome in desktop mode'.
AddSeparator(ui::NORMAL_SEPARATOR);
diff --git a/ui/gfx/win/dpi.cc b/ui/gfx/win/dpi.cc
index acd7ee3..33abdf6 100644
--- a/ui/gfx/win/dpi.cc
+++ b/ui/gfx/win/dpi.cc
@@ -36,10 +36,30 @@ float GetUnforcedDeviceScaleFactor() {
return static_cast<float>(gfx::GetDPI().width()) /
static_cast<float>(kDefaultDPIX);
}
+
+float GetModernUIScaleWrapper() {
+ float result = 1.0f;
+ typedef float(WINAPI *GetModernUIScalePtr)(VOID);
+ HMODULE lib = LoadLibraryA("metro_driver.dll");
+ if (lib) {
+ GetModernUIScalePtr func =
+ reinterpret_cast<GetModernUIScalePtr>(
+ GetProcAddress(lib, "GetModernUIScale"));
+ if (func)
+ result = func();
+ FreeLibrary(lib);
+ }
+ return result;
+}
+
} // namespace
namespace gfx {
+float GetModernUIScale() {
+ return GetModernUIScaleWrapper();
+}
+
void InitDeviceScaleFactor(float scale) {
DCHECK_NE(0.0f, scale);
g_device_scale_factor = scale;
@@ -163,7 +183,6 @@ double GetUndocumentedDPIScale() {
return scale;
}
-
double GetUndocumentedDPITouchScale() {
static double scale =
(base::win::GetVersion() < base::win::VERSION_WIN8_1) ?
@@ -171,6 +190,5 @@ double GetUndocumentedDPITouchScale() {
return scale;
}
-
} // namespace win
} // namespace gfx
diff --git a/ui/gfx/win/dpi.h b/ui/gfx/win/dpi.h
index 0193ac0..772944f 100644
--- a/ui/gfx/win/dpi.h
+++ b/ui/gfx/win/dpi.h
@@ -22,9 +22,14 @@ GFX_EXPORT void InitDeviceScaleFactor(float scale);
GFX_EXPORT Size GetDPI();
// Gets the scale factor of the display. For example, if the display DPI is
-// 96 then the scale factor is 1.0.
+// 96 then the scale factor is 1.0. Note that this is the "desktop" scale, which
+// may be differnt than GetModernUIScale().
GFX_EXPORT float GetDPIScale();
+// Gets the scale factor of the modern (metro) UI display. Returns 1.0 for
+// unscaled or "not running on win8+"
+GFX_EXPORT float GetModernUIScale();
+
// Tests to see if the command line flag "--high-dpi-support" is set.
GFX_EXPORT bool IsHighDPIEnabled();
diff --git a/win8/metro_driver/display_properties.cc b/win8/metro_driver/display_properties.cc
new file mode 100644
index 0000000..a7cf427
--- /dev/null
+++ b/win8/metro_driver/display_properties.cc
@@ -0,0 +1,34 @@
+// Copyright 2013 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 "stdafx.h"
+
+#include <windows.h>
+#include <wrl\implements.h>
+#include <wrl\wrappers\corewrappers.h>
+#include <windows.foundation.h>
+#include <windows.graphics.display.h>
+#include "base/win/scoped_com_initializer.h"
+#include "winrt_utils.h"
+
+#pragma comment(lib, "runtimeobject.lib")
+
+extern "C" {
+
+ __declspec(dllexport) float GetModernUIScale() {
+ base::win::ScopedCOMInitializer com_init;
+ Microsoft::WRL::ComPtr<
+ ABI::Windows::Graphics::Display::IDisplayPropertiesStatics>
+ display_properties;
+ if (SUCCEEDED(winrt_utils::CreateActivationFactory(
+ RuntimeClass_Windows_Graphics_Display_DisplayProperties,
+ display_properties.GetAddressOf()))) {
+ ABI::Windows::Graphics::Display::ResolutionScale resolution_scale;
+ if (SUCCEEDED(display_properties->get_ResolutionScale(&resolution_scale)))
+ return static_cast<float>(resolution_scale) / 100.0f;
+ }
+ return 1.0f;
+}
+
+}
diff --git a/win8/metro_driver/metro_driver.gyp b/win8/metro_driver/metro_driver.gyp
index c4797fb..33e7e48 100644
--- a/win8/metro_driver/metro_driver.gyp
+++ b/win8/metro_driver/metro_driver.gyp
@@ -64,6 +64,7 @@
'metro_driver_version_resources',
],
'sources': [
+ 'display_properties.cc',
'metro_driver.cc',
'metro_driver.h',
'stdafx.h',