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

Unified Diff: ui/gfx/win/screen_win_display.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: Fixed Other Unit Tests - Moved Inner Classes Outside 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
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

Powered by Google App Engine
This is Rietveld 408576698