Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(589)

Unified Diff: ui/base/win/dpi.cc

Issue 11953054: Fix high-DPI on Windows to make use of DIP scaling in WebKit. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove experimental changes to resource handling. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/base/win/dpi.cc
diff --git a/ui/base/win/dpi.cc b/ui/base/win/dpi.cc
index c9982924bd5ad0139f07313bb0478ecbf930f8ae..2a2e61a1d65a79f9bb9ca54c99825b5ba75d28cf 100644
--- a/ui/base/win/dpi.cc
+++ b/ui/base/win/dpi.cc
@@ -7,12 +7,25 @@
#include <windows.h>
#include "base/win/scoped_hdc.h"
+#include "ui/gfx/display.h"
+#include "ui/gfx/point_conversions.h"
+#include "ui/gfx/rect_conversions.h"
+#include "ui/gfx/size_conversions.h"
namespace {
int kDefaultDPIX = 96;
int kDefaultDPIY = 96;
+
+float GetDeviceScaleFactorImpl() {
+#if defined(ENABLE_HIDPI)
+ return gfx::Display::GetForcedDeviceScaleFactor();
+#else
+ return 1.0f;
+#endif
+}
+
} // namespace
namespace ui {
@@ -52,4 +65,33 @@ void EnableHighDPISupport() {
set_process_dpi_aware_func();
}
+namespace win {
+
+gfx::Point ScreenToDIPPoint(const gfx::Point& pixel_point) {
+ return gfx::ToFlooredPoint(
+ gfx::ScalePoint(pixel_point, 1.0f / GetDeviceScaleFactorImpl()));
+}
+
+gfx::Rect ScreenToDIPRect(const gfx::Rect& pixel_bounds) {
+ return gfx::ToFlooredRectDeprecated(
pkotwicz 2013/01/23 19:39:23 Nit: Add TODO to use gfx::ToNearestRect().
kevers 2013/01/23 21:37:00 Based on description of method, ToNearestRect migh
+ gfx::ScaleRect(pixel_bounds, 1.0f / GetDeviceScaleFactorImpl()));
+}
+
+gfx::Rect DIPToScreenRect(const gfx::Rect& dip_bounds) {
+ return gfx::ToFlooredRectDeprecated(
+ gfx::ScaleRect(dip_bounds, GetDeviceScaleFactorImpl()));
+}
+
+gfx::Size ScreenToDIPSize(const gfx::Size& size_in_pixels) {
+ return gfx::ToFlooredSize(
+ gfx::ScaleSize(size_in_pixels, 1.0f / GetDeviceScaleFactorImpl()));
+}
+
+gfx::Size DIPToScreenSize(const gfx::Size& dip_size) {
+ return gfx::ToFlooredSize(
+ gfx::ScaleSize(dip_size, GetDeviceScaleFactorImpl()));
+}
+
+} // namespace win
+
} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698