summaryrefslogtreecommitdiffstats
path: root/ui/base
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-27 16:56:06 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-27 16:56:06 +0000
commit4ffa789e031a7f0c8345e56a3c0813cb148176b4 (patch)
treee80237b500780d6bfb663353121655c3ec0beb2c /ui/base
parentfc91f92efc008ec9efac09814f37b66cb580cbf5 (diff)
downloadchromium_src-4ffa789e031a7f0c8345e56a3c0813cb148176b4.zip
chromium_src-4ffa789e031a7f0c8345e56a3c0813cb148176b4.tar.gz
chromium_src-4ffa789e031a7f0c8345e56a3c0813cb148176b4.tar.bz2
Remove last dependencies on ui/base from ui/gfx
BUG=103304 R=sky@chromium.org Review URL: https://codereview.chromium.org/23498059 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225722 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base')
-rw-r--r--ui/base/resource/resource_bundle.cc2
-rw-r--r--ui/base/win/dpi_setup.cc26
-rw-r--r--ui/base/win/dpi_setup.h22
-rw-r--r--ui/base/win/foreground_helper.h1
4 files changed, 51 insertions, 0 deletions
diff --git a/ui/base/resource/resource_bundle.cc b/ui/base/resource/resource_bundle.cc
index 8d2815d..761aab8 100644
--- a/ui/base/resource/resource_bundle.cc
+++ b/ui/base/resource/resource_bundle.cc
@@ -41,6 +41,7 @@
#endif
#if defined(OS_WIN)
+#include "ui/base/win/dpi_setup.h"
#include "ui/gfx/win/dpi.h"
#endif
@@ -562,6 +563,7 @@ void ResourceBundle::InitSharedInstance(Delegate* delegate) {
if (base::mac::IsOSLionOrLater())
supported_scale_factors.push_back(SCALE_FACTOR_200P);
#elif defined(OS_WIN)
+ ui::win::InitDeviceScaleFactor();
// Have high-DPI resources for 140% and 180% scaling on Windows based on
// default scaling for Metro mode. Round to nearest supported scale in
// all cases.
diff --git a/ui/base/win/dpi_setup.cc b/ui/base/win/dpi_setup.cc
new file mode 100644
index 0000000..b80b8126
--- /dev/null
+++ b/ui/base/win/dpi_setup.cc
@@ -0,0 +1,26 @@
+// Copyright (c) 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 "ui/base/win/dpi_setup.h"
+
+#include "ui/base/layout.h"
+#include "ui/gfx/display.h"
+#include "ui/gfx/win/dpi.h"
+
+namespace ui {
+namespace win {
+
+void InitDeviceScaleFactor() {
+ float scale = 1.0f;
+ if (gfx::IsHighDPIEnabled()) {
+ float scale = gfx::Display::HasForceDeviceScaleFactor() ?
+ gfx::Display::GetForcedDeviceScaleFactor() : gfx::GetDPIScale();
+ // Quantize to nearest supported scale factor.
+ scale = ui::GetImageScale(ui::GetSupportedScaleFactor(scale));
+ }
+ gfx::InitDeviceScaleFactor(scale);
+}
+
+} // namespace win
+} // namespace ui
diff --git a/ui/base/win/dpi_setup.h b/ui/base/win/dpi_setup.h
new file mode 100644
index 0000000..a885849
--- /dev/null
+++ b/ui/base/win/dpi_setup.h
@@ -0,0 +1,22 @@
+// Copyright (c) 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.
+
+#ifndef UI_BASE_WIN_DPI_SETUP_H_
+#define UI_BASE_WIN_DPI_SETUP_H_
+
+#include "ui/base/ui_export.h"
+
+namespace ui {
+namespace win {
+
+// Initializes the device scale factor. If support is enabled, this will set
+// the best available scale based on the screen's pixel density. This can be
+// affected (overridden) by --force-device-scale-factor=x
+// This function can be called only once for the lifetime of a process.
+UI_EXPORT void InitDeviceScaleFactor();
+
+} // namespace win
+} // namespace ui
+
+#endif // UI_BASE_WIN_DPI_SETUP_H_
diff --git a/ui/base/win/foreground_helper.h b/ui/base/win/foreground_helper.h
index e8101a0..a2d9ea2 100644
--- a/ui/base/win/foreground_helper.h
+++ b/ui/base/win/foreground_helper.h
@@ -6,6 +6,7 @@
#define UI_BASE_WIN_FOREGROUND_HELPER_H_
#include "base/logging.h"
+#include "ui/base/ui_export.h"
#include "ui/gfx/win/window_impl.h"
namespace ui {