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

Issue 1679393002: Multiple DPI Tracking for ScreenWin (Closed)

Created:
4 years, 10 months ago by robliao
Modified:
4 years, 6 months ago
Reviewers:
oshima, sky, scottmg
CC:
chromium-reviews, extensions-reviews_chromium.org, kalyank, tapted, tfarina, jam, sievers+watch_chromium.org, jbauman+watch_chromium.org, nona+watch_chromium.org, Matt Giuca, darin-cc_chromium.org, shuchen+watch_chromium.org, asvitkine+watch_chromium.org, piman+watch_chromium.org, chromium-apps-reviews_chromium.org, danakj+watch_chromium.org, James Su, yusukes+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Multiple DPI Tracking for ScreenWin In Windows 8.1 and above, a machine with multiple monitors can have a different DPI for each monitor. This means that we can no longer use global DPI scaling to convert between screen pixels and device-independent points. Additionally, top-level windows can span multiple monitors. Fortunately, the window is affine to a DPI, so within a window, a single DPI will apply. To begin to accommodate multiple-DPIs, these Windows scaling functions will now take an HWND to determine the DPI context and then perform the scale. Given that the DPI will be determined by gfx::Display in gfx::Screen, ScreenWin seems like an appropriate home for these now. All callers of the old functions have been directed to use the new functions. The visual behavior of Chrome should not change with this CL. BUG=426656, 501259

Patch Set 1 #

Total comments: 18

Patch Set 2 : CR Feedback #

Total comments: 2

Patch Set 3 : Add rect_util_unittests to GN #

Total comments: 26

Patch Set 4 : CR Feedback #

Patch Set 5 : One-liner Unit Test Update #

Patch Set 6 : CR Feedback #

Patch Set 7 : Fix comment. #

Total comments: 1

Patch Set 8 : Fix Indent #

Patch Set 9 : Rebase to b4da629 and a few equivalent comparison tweaks in rect_util #

Total comments: 24

Patch Set 10 : CR Feedback EXCEPT Filename Change #

Total comments: 4

Patch Set 11 : CR Feedback EXCEPT rect_util Rename #

Unified diffs Side-by-side diffs Delta from patch set Stats (+2458 lines, -132 lines) Patch
M chrome/browser/extensions/display_info_provider_win.cc View 3 chunks +4 lines, -5 lines 0 comments Download
M chrome/browser/ui/views/frame/browser_desktop_window_tree_host_win.cc View 1 2 3 4 5 6 7 8 2 chunks +3 lines, -2 lines 0 comments Download
M chrome/browser/ui/views/tabs/tab_strip.cc View 2 chunks +2 lines, -2 lines 0 comments Download
M chrome/browser/ui/views/tabs/window_finder_win.cc View 3 chunks +3 lines, -3 lines 0 comments Download
M components/metrics/ui/screen_info_metrics_provider.cc View 1 chunk +1 line, -0 lines 0 comments Download
M content/browser/renderer_host/input/web_input_event_builders_win.cc View 2 chunks +2 lines, -2 lines 0 comments Download
M content/browser/renderer_host/legacy_render_widget_host_win.cc View 2 chunks +2 lines, -2 lines 0 comments Download
M content/browser/renderer_host/render_widget_host_view_aura.cc View 3 chunks +3 lines, -4 lines 0 comments Download
M content/browser/renderer_host/render_widget_host_view_base.cc View 4 chunks +5 lines, -4 lines 0 comments Download
M content/child/npapi/webplugin_delegate_impl_win.cc View 2 chunks +5 lines, -3 lines 0 comments Download
M ui/app_list/views/apps_grid_view.cc View 2 chunks +3 lines, -2 lines 0 comments Download
M ui/base/ime/input_method_win.cc View 3 chunks +5 lines, -3 lines 0 comments Download
M ui/gfx/BUILD.gn View 1 2 2 chunks +3 lines, -0 lines 0 comments Download
M ui/gfx/gfx.gyp View 1 chunk +2 lines, -0 lines 0 comments Download
M ui/gfx/gfx_tests.gyp View 1 chunk +1 line, -0 lines 0 comments Download
M ui/gfx/screen_win.h View 1 2 3 4 chunks +78 lines, -0 lines 0 comments Download
M ui/gfx/screen_win.cc View 1 2 3 8 chunks +255 lines, -5 lines 0 comments Download
M ui/gfx/screen_win_unittest.cc View 1 2 3 4 5 6 7 8 15 chunks +1225 lines, -5 lines 0 comments Download
M ui/gfx/win/dpi.h View 2 chunks +1 line, -15 lines 0 comments Download
M ui/gfx/win/dpi.cc View 2 chunks +19 lines, -49 lines 0 comments Download
A ui/gfx/win/rect_util.h View 1 2 3 4 5 6 7 8 9 1 chunk +130 lines, -0 lines 0 comments Download
A ui/gfx/win/rect_util.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +255 lines, -0 lines 0 comments Download
A ui/gfx/win/rect_util_unittest.cc View 1 1 chunk +380 lines, -0 lines 0 comments Download
M ui/gfx/win/screen_win_display.h View 1 chunk +2 lines, -0 lines 0 comments Download
M ui/gfx/win/screen_win_display.cc View 1 2 chunks +37 lines, -6 lines 0 comments Download
M ui/views/controls/menu/menu_controller.cc View 2 chunks +2 lines, -2 lines 0 comments Download
M ui/views/corewm/tooltip_win.cc View 3 chunks +6 lines, -5 lines 0 comments Download
M ui/views/widget/desktop_aura/desktop_window_tree_host_win.h View 1 chunk +1 line, -0 lines 0 comments Download
M ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc View 9 chunks +19 lines, -10 lines 0 comments Download
M ui/views/win/hwnd_message_handler.cc View 2 chunks +2 lines, -3 lines 0 comments Download
M ui/views/win/hwnd_message_handler_delegate.h View 1 chunk +2 lines, -0 lines 0 comments Download

Messages

Total messages: 26 (6 generated)
robliao
Let's go ahead and get this show on the road!
4 years, 10 months ago (2016-02-09 19:26:14 UTC) #4
scottmg
I'm still working on rect_util, but generally looks good. https://codereview.chromium.org/1679393002/diff/1/ui/gfx/screen_win.cc File ui/gfx/screen_win.cc (right): https://codereview.chromium.org/1679393002/diff/1/ui/gfx/screen_win.cc#newcode62 ui/gfx/screen_win.cc:62: ...
4 years, 10 months ago (2016-02-09 20:21:36 UTC) #5
scottmg
https://codereview.chromium.org/1679393002/diff/1/ui/gfx/win/rect_util.cc File ui/gfx/win/rect_util.cc (right): https://codereview.chromium.org/1679393002/diff/1/ui/gfx/win/rect_util.cc#newcode184 ui/gfx/win/rect_util.cc:184: ref_scaled_rect = CanonicalizeTouchingEdge(ref_scaled_rect, orig_edge); (I'm still trying to figure ...
4 years, 10 months ago (2016-02-09 21:24:26 UTC) #6
robliao
Thanks for the comments! https://codereview.chromium.org/1679393002/diff/1/ui/gfx/screen_win.cc File ui/gfx/screen_win.cc (right): https://codereview.chromium.org/1679393002/diff/1/ui/gfx/screen_win.cc#newcode62 ui/gfx/screen_win.cc:62: // insufficent room to lay ...
4 years, 10 months ago (2016-02-10 22:50:04 UTC) #7
scottmg
non-owner lgtm insofar as I know what's going on :) https://codereview.chromium.org/1679393002/diff/1/ui/gfx/win/rect_util_unittest.cc File ui/gfx/win/rect_util_unittest.cc (right): https://codereview.chromium.org/1679393002/diff/1/ui/gfx/win/rect_util_unittest.cc#newcode320 ...
4 years, 10 months ago (2016-02-10 23:07:45 UTC) #8
robliao
oshima: Feel free to take a look. Thanks! https://codereview.chromium.org/1679393002/diff/20001/ui/gfx/BUILD.gn File ui/gfx/BUILD.gn (right): https://codereview.chromium.org/1679393002/diff/20001/ui/gfx/BUILD.gn#newcode226 ui/gfx/BUILD.gn:226: "win/rect_util.h", ...
4 years, 10 months ago (2016-02-11 19:05:40 UTC) #9
oshima
https://codereview.chromium.org/1679393002/diff/40001/ui/gfx/screen_win.cc File ui/gfx/screen_win.cc (right): https://codereview.chromium.org/1679393002/diff/40001/ui/gfx/screen_win.cc#newcode165 ui/gfx/screen_win.cc:165: DCHECK(g_screen_win_instance == nullptr); DCHECK(!g_screen_win_instance) is more common https://codereview.chromium.org/1679393002/diff/40001/ui/gfx/screen_win.cc#newcode338 ui/gfx/screen_win.cc:338: ...
4 years, 10 months ago (2016-02-11 22:59:58 UTC) #10
robliao
Thanks for the comments! https://codereview.chromium.org/1679393002/diff/40001/ui/gfx/screen_win.cc File ui/gfx/screen_win.cc (right): https://codereview.chromium.org/1679393002/diff/40001/ui/gfx/screen_win.cc#newcode165 ui/gfx/screen_win.cc:165: DCHECK(g_screen_win_instance == nullptr); On 2016/02/11 ...
4 years, 10 months ago (2016-02-12 01:52:53 UTC) #13
oshima
https://codereview.chromium.org/1679393002/diff/40001/ui/gfx/win/rect_util.cc File ui/gfx/win/rect_util.cc (right): https://codereview.chromium.org/1679393002/diff/40001/ui/gfx/win/rect_util.cc#newcode144 ui/gfx/win/rect_util.cc:144: InRange(ref.right(), test.x(), test.right()))) { On 2016/02/12 01:52:53, robliao wrote: ...
4 years, 10 months ago (2016-02-12 23:18:26 UTC) #14
robliao
https://codereview.chromium.org/1679393002/diff/40001/ui/gfx/win/rect_util.cc File ui/gfx/win/rect_util.cc (right): https://codereview.chromium.org/1679393002/diff/40001/ui/gfx/win/rect_util.cc#newcode144 ui/gfx/win/rect_util.cc:144: InRange(ref.right(), test.x(), test.right()))) { On 2016/02/12 23:18:26, oshima wrote: ...
4 years, 10 months ago (2016-02-13 01:27:49 UTC) #15
oshima
lgtm https://codereview.chromium.org/1679393002/diff/40001/ui/gfx/win/rect_util.cc File ui/gfx/win/rect_util.cc (right): https://codereview.chromium.org/1679393002/diff/40001/ui/gfx/win/rect_util.cc#newcode144 ui/gfx/win/rect_util.cc:144: InRange(ref.right(), test.x(), test.right()))) { On 2016/02/13 01:27:49, robliao ...
4 years, 10 months ago (2016-02-16 06:03:26 UTC) #16
robliao
sky: Please review ui/* in this CL. Thanks!
4 years, 10 months ago (2016-02-16 21:42:18 UTC) #18
sky
Here's some initial, mostly minor feedback. I need a bit of time to thoroughly understand ...
4 years, 10 months ago (2016-02-17 04:40:29 UTC) #19
sky
I don't understand the constraints of ScaleAndPositionRect enough to review it. Seem my questions below. ...
4 years, 10 months ago (2016-02-17 17:28:48 UTC) #20
robliao
Thanks for the comments! https://codereview.chromium.org/1679393002/diff/200001/ui/gfx/win/rect_util.cc File ui/gfx/win/rect_util.cc (right): https://codereview.chromium.org/1679393002/diff/200001/ui/gfx/win/rect_util.cc#newcode61 ui/gfx/win/rect_util.cc:61: return CoordinateRotateRectangle90(rect); On 2016/02/17 17:28:48, ...
4 years, 10 months ago (2016-02-18 00:34:40 UTC) #21
sky
https://codereview.chromium.org/1679393002/diff/200001/ui/gfx/win/rect_util.h File ui/gfx/win/rect_util.h (right): https://codereview.chromium.org/1679393002/diff/200001/ui/gfx/win/rect_util.h#newcode16 ui/gfx/win/rect_util.h:16: namespace win { On 2016/02/18 00:34:39, robliao wrote: > ...
4 years, 10 months ago (2016-02-18 17:02:58 UTC) #22
robliao
https://codereview.chromium.org/1679393002/diff/220001/ui/gfx/win/rect_util.cc File ui/gfx/win/rect_util.cc (right): https://codereview.chromium.org/1679393002/diff/220001/ui/gfx/win/rect_util.cc#newcode129 ui/gfx/win/rect_util.cc:129: int max_x = std::max(ref.x(), test.x()); On 2016/02/18 17:02:58, sky ...
4 years, 10 months ago (2016-02-19 00:26:29 UTC) #23
robliao
On 2016/02/19 00:26:29, robliao wrote: > https://codereview.chromium.org/1679393002/diff/220001/ui/gfx/win/rect_util.cc > File ui/gfx/win/rect_util.cc (right): > > https://codereview.chromium.org/1679393002/diff/220001/ui/gfx/win/rect_util.cc#newcode129 > ...
4 years, 10 months ago (2016-02-24 00:55:19 UTC) #24
sky
Thanks for the update! I'm glad to hear we can share code between the two ...
4 years, 10 months ago (2016-02-24 17:11:35 UTC) #25
robliao
4 years, 9 months ago (2016-03-16 19:31:59 UTC) #26
On 2016/02/24 17:11:35, sky wrote:
> Thanks for the update! I'm glad to hear we can share code between the
> two environments.
> 
> On Tue, Feb 23, 2016 at 4:55 PM,  <mailto:robliao@chromium.org> wrote:
> > On 2016/02/19 00:26:29, robliao wrote:
> >>
> >>
> https://codereview.chromium.org/1679393002/diff/220001/ui/gfx/win/rect_util.cc
> >> File ui/gfx/win/rect_util.cc (right):
> >>
> >>
> >
>
https://codereview.chromium.org/1679393002/diff/220001/ui/gfx/win/rect_util.c...
> >> ui/gfx/win/rect_util.cc:129: int max_x = std::max(ref.x(), test.x());
> >> On 2016/02/18 17:02:58, sky wrote:
> >> > I have a hard time reading this code because max_x implies the biggest
> >> > x-coordinate, but that's not what this is. It's the biggest left value.
> >> > How
> >> > about max_left and max_top? That better matches min_bottom and
> >> > min_right.
> >>
> >> sgtm. Done. As an aside, the original naming from gfx::Rect was rx, ry,
> >> rr,
> > rb,
> >> which I had renamed here to [min|max]_[rect property name]
> >>
> >>
> >>
> https://codereview.chromium.org/1679393002/diff/220001/ui/gfx/win/rect_util.h
> >> File ui/gfx/win/rect_util.h (right):
> >>
> >>
> >
>
https://codereview.chromium.org/1679393002/diff/220001/ui/gfx/win/rect_util.h...
> >> ui/gfx/win/rect_util.h:88: GFX_EXPORT gfx::Rect ScaleAndPositionRect(const
> >> gfx::Rect& ref_scaled_rect,
> >> On 2016/02/18 17:02:58, sky wrote:
> >> > Thanks for the comments. I think I understand what you're trying to do
> >> > here
> >> now.
> >> > Why can't you take the top/left corner of unscaled_rect, apply the scale
> >> > of
> >> ref
> >> > rect to get the origin of the resulting rect. For the size of the
> >> > resulting
> >> rect
> >> > scale the unscaled_rects size by unscaled_rect_scale_factor. Isn't this
> >> > effectively what this function wants to do?
> >>
> >> The sizing is straightforward. The positioning is tricky.
> >>
> >> To rephrase, the proposal above is to have (correct me if I'm wrong)...
> >> ScaledRectOrigin(unscaled_rect.origin(), ref_scale_factor)
> >>
> >> One of the fun parts about MultiDPI is that while the reference rectangle
> >> may
> >> have a scale factor of 1x, it can move between unscaled and scaled
> >> coordinate
> >> systems.
> >>
> >> Consider 3 monitors side-by-side:
> >> [Left 3x], [Middle 1x], [Right 1x]
> >> The left monitor will shrink when we go from unscaled to scaled. This
> >> means to
> >> place the middle monitor, we need to know the size of the left monitor and
> >> the
> >> scale factor. That's fine.
> >>
> >> However, to position the right monitor, we need to figure out how much the
> >> middle monitor moved from unscaled to scaled so that the right monitor can
> >> remain side-by-side in scaled. This means having the scale factor is
> > insufficent
> >> to place the right monitor. We need to have the unscaled and scaled
> >> origins of
> >> the middle monitor.
> >>
> >> So now we have
> >> ScaledRectOrigin(unscaled_rect.origin(), ref_scale_factor,
> >> ref_unscaled.origin(), ref_scaled.origin())
> >>
> >>
> >> The next case is case #2 in the comment.
> >> If we only consider the reference scale, then the unscaled_rect origin
> >> doesn't
> >> move. This means the bottom edge of the reference rectangle is no longer
> >> perpendicular to the left edge of unscaled_rect with sufficient scaling.
> >>
> >> This shows up in monitors that are aligned across the bottom:
> >>
> >> +------+
> >> | REF +----+
> >> | 1x | |
> >> | | 2x |
> >> +------+----+
> >>
> >> Since REF 1x basically doesn't change between unscaled and scaled
> >> coordinates,
> >> to maintain the bottom alignment of the unscaled_rect, we need to know how
> >> it
> >> was positioned along the reference rect.
> >>
> >> This led to the need to know the reference rect in both unscaled and
> >> scaled
> >> coordinates for positioning.
> >
> > To update the review, oshima and I met and here's a summary of the
> > discussion:
> > * ChromeOS in the past did not handle systems with more than 2 displays,
> > which
> > is why display layout hasn't really been a problem for CrOS.
> > * oshima is working on a similar change for ash for 3+ display support.
> > Inputs = Display Tree + Physical Pixels + Scale Factor
> > Output = DIP displays in the correct position and size
> > * The code today is able to generate this tree relationship anchored to the
> > primary display.
> >
> > oshima is going to land his change first. Then we'll need to perform some
> > refactoring to share the code since that code will initially live in ash.
> > After that, then the Windows code can consume the common layout code.
> >
> > oshima and robliao will also sync up tomorrow on the further mechanics of
> > landing this.
> >
> > https://codereview.chromium.org/1679393002/
> 
> -- 
> You received this message because you are subscribed to the Google Groups
> "Chromium-reviews" group.
> To unsubscribe from this group and stop receiving emails from it, send an
email
> to mailto:chromium-reviews+unsubscribe@chromium.org.
> 

A preview of what sharing code will look like is available here:
https://codereview.chromium.org/1813493002/

There are two additional changelists required that are not captured by the
preview:
1) Removing JSON dependencies from DisplayLayout and friends
2) Moving DisplayLayout and DisplayLayoutBuilder to ui/gfx/display

Powered by Google App Engine
This is Rietveld 408576698