Index: ui/gfx/win/screen_win_display.cc |
diff --git a/ui/gfx/win/screen_win_display.cc b/ui/gfx/win/screen_win_display.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c4795eb26e381a992c9e01a741a70b176603db91 |
--- /dev/null |
+++ b/ui/gfx/win/screen_win_display.cc |
@@ -0,0 +1,58 @@ |
+// Copyright 2016 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/gfx/win/screen_win_display.h" |
+ |
+#include "ui/gfx/geometry/insets.h" |
+#include "ui/gfx/win/display_info.h" |
+#include "ui/gfx/win/rect_util.h" |
+ |
+namespace gfx { |
+namespace win { |
+ |
+ScreenWinDisplay::ScreenWinDisplay() = default; |
+ |
+ScreenWinDisplay::ScreenWinDisplay(const DisplayInfo& display_info) |
+ : display_(display_info.id()), |
+ pixel_bounds_(display_info.screen_rect()) { |
+ float scale_factor = display_info.device_scale_factor(); |
+ display_.set_device_scale_factor(scale_factor); |
+ display_.set_work_area( |
+ gfx::ScaleToEnclosedRect(display_info.screen_work_rect(), |
+ 1.0f / scale_factor)); |
+ display_.set_bounds(gfx::ScaleToEnclosedRect(display_info.screen_rect(), |
+ 1.0f / scale_factor)); |
+} |
+ |
+ScreenWinDisplay::ScreenWinDisplay(const ScreenWinDisplay& ref, |
+ const DisplayInfo& display_info) |
+ : display_(display_info.id()), |
+ pixel_bounds_(display_info.screen_rect()) { |
+ float scale_factor = display_info.device_scale_factor(); |
+ display_.set_device_scale_factor(scale_factor); |
+ const gfx::Insets pixel_insets = |
+ display_info.screen_rect().InsetsFrom(display_info.screen_work_rect()); |
+ const gfx::Insets scaled_insets = pixel_insets.Scale(1.0f / scale_factor, |
+ 1.0f / scale_factor); |
+ const gfx::Rect scaled_bounds = |
+ gfx::win::ScaleAndPositionRect(ref.display_.bounds(), |
+ ref.physical_bounds(), |
+ display_info.screen_rect(), |
+ scale_factor); |
+ display_.set_bounds(scaled_bounds); |
+ gfx::Rect scaled_work_area(scaled_bounds); |
+ scaled_work_area.Inset(scaled_insets); |
+ display_.set_work_area(scaled_work_area); |
+} |
+ |
+const Display& ScreenWinDisplay::display() const { |
+ return display_; |
+} |
+ |
+const Rect& ScreenWinDisplay::physical_bounds() const { |
+ return pixel_bounds_; |
+} |
+ |
+} // namespace win |
+} // namespace gfx |