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

Side by Side Diff: ui/display/screen.cc

Issue 2747143005: Revert of Add display::GetDisplayNearestView (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « ui/display/screen.h ('k') | ui/display/screen_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/display/screen.h" 5 #include "ui/display/screen.h"
6 6
7 #include "ui/display/display.h" 7 #include "ui/display/display.h"
8 #include "ui/gfx/geometry/rect.h" 8 #include "ui/gfx/geometry/rect.h"
9 9
10 namespace display { 10 namespace display {
(...skipping 16 matching lines...) Expand all
27 g_screen = CreateNativeScreen(); 27 g_screen = CreateNativeScreen();
28 #endif 28 #endif
29 return g_screen; 29 return g_screen;
30 } 30 }
31 31
32 // static 32 // static
33 void Screen::SetScreenInstance(Screen* instance) { 33 void Screen::SetScreenInstance(Screen* instance) {
34 g_screen = instance; 34 g_screen = instance;
35 } 35 }
36 36
37 Display Screen::GetDisplayNearestView(gfx::NativeView view) const {
38 return GetDisplayNearestWindow(GetWindowForView(view));
39 }
40
41 gfx::Rect Screen::ScreenToDIPRectInWindow(gfx::NativeView view, 37 gfx::Rect Screen::ScreenToDIPRectInWindow(gfx::NativeView view,
42 const gfx::Rect& screen_rect) const { 38 const gfx::Rect& screen_rect) const {
43 float scale = GetDisplayNearestView(view).device_scale_factor(); 39 float scale = GetDisplayNearestWindow(view).device_scale_factor();
44 return ScaleToEnclosingRect(screen_rect, 1.0f / scale); 40 return ScaleToEnclosingRect(screen_rect, 1.0f / scale);
45 } 41 }
46 42
47 gfx::Rect Screen::DIPToScreenRectInWindow(gfx::NativeView view, 43 gfx::Rect Screen::DIPToScreenRectInWindow(gfx::NativeView view,
48 const gfx::Rect& dip_rect) const { 44 const gfx::Rect& dip_rect) const {
49 float scale = GetDisplayNearestView(view).device_scale_factor(); 45 float scale = GetDisplayNearestWindow(view).device_scale_factor();
50 return ScaleToEnclosingRect(dip_rect, scale); 46 return ScaleToEnclosingRect(dip_rect, scale);
51 } 47 }
52 48
53 bool Screen::GetDisplayWithDisplayId(int64_t display_id, 49 bool Screen::GetDisplayWithDisplayId(int64_t display_id,
54 Display* display) const { 50 Display* display) const {
55 for (const Display& display_in_list : GetAllDisplays()) { 51 for (const Display& display_in_list : GetAllDisplays()) {
56 if (display_in_list.id() == display_id) { 52 if (display_in_list.id() == display_id) {
57 *display = display_in_list; 53 *display = display_in_list;
58 return true; 54 return true;
59 } 55 }
60 } 56 }
61 return false; 57 return false;
62 } 58 }
63 59
64 } // namespace display 60 } // namespace display
OLDNEW
« no previous file with comments | « ui/display/screen.h ('k') | ui/display/screen_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698