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

Unified Diff: ui/gfx/screen.cc

Issue 1426933002: Refactor Windows DPI Point, Rect, and Size for Multiple Monitor DPI Awareness (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make DisplayWin Standalone Created 4 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
« no previous file with comments | « ui/gfx/screen.h ('k') | ui/gfx/screen_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/screen.cc
diff --git a/ui/gfx/screen.cc b/ui/gfx/screen.cc
index 06ec78ec885b8fee107c72375e4df8174c46c934..e32d5f86a12a4b9f2fed7e3e4f00d8f412d8930d 100644
--- a/ui/gfx/screen.cc
+++ b/ui/gfx/screen.cc
@@ -2,8 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/logging.h"
#include "ui/gfx/screen.h"
+
+#include "base/logging.h"
+#include "ui/gfx/geometry/point.h"
+#include "ui/gfx/geometry/size.h"
#include "ui/gfx/screen_type_delegate.h"
namespace gfx {
@@ -55,4 +58,18 @@ Screen* Screen::GetNativeScreen() {
return g_screen_[SCREEN_TYPE_NATIVE];
}
+gfx::Rect Screen::ScreenToDIPRectInWindow(NativeView view,
+ const gfx::Rect& screen_rect) const {
+ float scale = GetDisplayNearestWindow(view).device_scale_factor();
+ return gfx::Rect(gfx::ScaleToFlooredPoint(screen_rect.origin(), 1.0f / scale),
+ gfx::ScaleToCeiledSize(screen_rect.size(), 1.0f / scale));
+}
+
+gfx::Rect Screen::DIPToScreenRectInWindow(NativeView view,
+ const gfx::Rect& dip_rect) const {
+ float scale = GetDisplayNearestWindow(view).device_scale_factor();
+ return gfx::Rect(gfx::ScaleToFlooredPoint(dip_rect.origin(), scale),
+ gfx::ScaleToCeiledSize(dip_rect.size(), scale));
+}
+
} // namespace gfx
« no previous file with comments | « ui/gfx/screen.h ('k') | ui/gfx/screen_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698