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

Unified Diff: ui/views/widget/native_widget_aura.cc

Issue 9960042: Refactor screen/monitor so that gfx::Screen returns monitor object. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 8 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/views/widget/native_widget_aura.cc
diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc
index 9de1e78968b415a06c6e9a71023fc9fb87d37e28..580d5906f1b7fc6d19b59385c9bb81554e578c6e 100644
--- a/ui/views/widget/native_widget_aura.cc
+++ b/ui/views/widget/native_widget_aura.cc
@@ -42,8 +42,7 @@
#endif
#if defined(ENABLE_DIP)
-#include "ui/aura/monitor.h"
-#include "ui/aura/monitor_manager.h"
+#include "ui/gfx/monitor.h"
#endif
namespace views {
@@ -842,9 +841,8 @@ void NativeWidgetAura::OnCaptureLost() {
void NativeWidgetAura::OnPaint(gfx::Canvas* canvas) {
#if defined(ENABLE_DIP)
- aura::Monitor* monitor = GetMonitor();
canvas->Save();
- float scale = monitor->GetDeviceScaleFactor();
+ float scale = GetMonitorScaleFactor();
canvas->sk_canvas()->scale(SkFloatToScalar(scale), SkFloatToScalar(scale));
#endif
delegate_->OnNativeWidgetPaint(canvas);
@@ -949,33 +947,34 @@ void NativeWidgetAura::SetInitialFocus() {
}
#if defined(ENABLE_DIP)
-aura::Monitor* NativeWidgetAura::GetMonitor() const {
- return aura::Env::GetInstance()->monitor_manager()->
- GetMonitorNearestWindow(window_);
+float NativeWidgetAura::GetMonitorScaleFactor() const {
+ gfx::Monitor monitor;
+ gfx::Screen::GetMonitorNearestWindow(window_, &monitor);
+ return monitor.device_scale_factor();
}
gfx::Point NativeWidgetAura::ConvertPointFromMonitor(
const gfx::Point& point) const {
- return point.Scale(1.0f / GetMonitor()->GetDeviceScaleFactor());
+ return point.Scale(1.0f / GetMonitorScaleFactor());
}
gfx::Size NativeWidgetAura::ConvertSizeFromMonitor(
const gfx::Size& size) const {
- return size.Scale(1.0f / GetMonitor()->GetDeviceScaleFactor());
+ return size.Scale(1.0f / GetMonitorScaleFactor());
}
gfx::Rect NativeWidgetAura::ConvertRectFromMonitor(
const gfx::Rect& rect) const {
- float scale = 1.0f / GetMonitor()->GetDeviceScaleFactor();
+ float scale = 1.0f / GetMonitorScaleFactor();
return gfx::Rect(rect.origin().Scale(scale), rect.size().Scale(scale));
}
gfx::Size NativeWidgetAura::ConvertSizeToMonitor(const gfx::Size& size) const {
- return size.Scale(GetMonitor()->GetDeviceScaleFactor());
+ return size.Scale(GetMonitorScaleFactor());
}
gfx::Rect NativeWidgetAura::ConvertRectToMonitor(const gfx::Rect& rect) const {
- float scale = GetMonitor()->GetDeviceScaleFactor();
+ float scale = GetMonitorScaleFactor();
return gfx::Rect(rect.origin().Scale(scale), rect.size().Scale(scale));
}
#endif

Powered by Google App Engine
This is Rietveld 408576698