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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/gfx/win/screen_win_display.h"
6
7 #include "ui/gfx/geometry/insets.h"
8 #include "ui/gfx/win/display_info.h"
9 #include "ui/gfx/win/rect_util.h"
10
11 namespace gfx {
12 namespace win {
13
14 ScreenWinDisplay::ScreenWinDisplay() = default;
15
16 ScreenWinDisplay::ScreenWinDisplay(const DisplayInfo& display_info)
17 : display_(display_info.id()),
18 pixel_bounds_(display_info.screen_rect()) {
19 float scale_factor = display_info.device_scale_factor();
20 display_.set_device_scale_factor(scale_factor);
21 display_.set_work_area(
22 gfx::ScaleToEnclosedRect(display_info.screen_work_rect(),
23 1.0f / scale_factor));
24 display_.set_bounds(gfx::ScaleToEnclosedRect(display_info.screen_rect(),
25 1.0f / scale_factor));
26 }
27
28 ScreenWinDisplay::ScreenWinDisplay(const ScreenWinDisplay& ref,
29 const DisplayInfo& display_info)
30 : display_(display_info.id()),
31 pixel_bounds_(display_info.screen_rect()) {
32 float scale_factor = display_info.device_scale_factor();
33 display_.set_device_scale_factor(scale_factor);
34 const gfx::Insets pixel_insets =
35 display_info.screen_rect().InsetsFrom(display_info.screen_work_rect());
36 const gfx::Insets scaled_insets = pixel_insets.Scale(1.0f / scale_factor,
37 1.0f / scale_factor);
38 const gfx::Rect scaled_bounds =
39 gfx::win::ScaleAndPositionRect(ref.display_.bounds(),
40 ref.physical_bounds(),
41 display_info.screen_rect(),
42 scale_factor);
43 display_.set_bounds(scaled_bounds);
44 gfx::Rect scaled_work_area(scaled_bounds);
45 scaled_work_area.Inset(scaled_insets);
46 display_.set_work_area(scaled_work_area);
47 }
48
49 const Display& ScreenWinDisplay::display() const {
50 return display_;
51 }
52
53 const Rect& ScreenWinDisplay::physical_bounds() const {
54 return pixel_bounds_;
55 }
56
57 } // namespace win
58 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698