OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/gfx/screen.h" | 5 #include "ui/gfx/screen.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 namespace { | 9 namespace { |
10 | 10 |
11 MONITORINFO GetMonitorInfoForMonitor(HMONITOR monitor) { | 11 MONITORINFO GetMonitorInfoForMonitor(HMONITOR monitor) { |
12 MONITORINFO monitor_info = { 0 }; | 12 MONITORINFO monitor_info = { 0 }; |
13 monitor_info.cbSize = sizeof(monitor_info); | 13 monitor_info.cbSize = sizeof(monitor_info); |
14 GetMonitorInfo(monitor, &monitor_info); | 14 GetMonitorInfo(monitor, &monitor_info); |
15 return monitor_info; | 15 return monitor_info; |
16 } | 16 } |
17 | 17 |
18 } // namespace | 18 } // namespace |
19 | 19 |
20 namespace gfx { | 20 namespace gfx { |
21 | 21 |
22 // static | 22 // static |
| 23 HDC Screen::compatible_dc_ = NULL; |
| 24 |
| 25 // static |
23 gfx::Point Screen::GetCursorScreenPoint() { | 26 gfx::Point Screen::GetCursorScreenPoint() { |
24 POINT pt; | 27 POINT pt; |
25 GetCursorPos(&pt); | 28 GetCursorPos(&pt); |
26 return gfx::Point(pt); | 29 return gfx::Point(pt); |
27 } | 30 } |
28 | 31 |
29 // static | 32 // static |
30 gfx::Rect Screen::GetMonitorWorkAreaNearestWindow(gfx::NativeWindow window) { | 33 gfx::Rect Screen::GetMonitorWorkAreaNearestWindow(gfx::NativeWindow window) { |
31 MONITORINFO monitor_info; | 34 MONITORINFO monitor_info; |
32 monitor_info.cbSize = sizeof(monitor_info); | 35 monitor_info.cbSize = sizeof(monitor_info); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 gfx::Size Screen::GetPrimaryMonitorSize() { | 98 gfx::Size Screen::GetPrimaryMonitorSize() { |
96 return gfx::Size(GetSystemMetrics(SM_CXSCREEN), | 99 return gfx::Size(GetSystemMetrics(SM_CXSCREEN), |
97 GetSystemMetrics(SM_CYSCREEN)); | 100 GetSystemMetrics(SM_CYSCREEN)); |
98 } | 101 } |
99 | 102 |
100 // static | 103 // static |
101 int Screen::GetNumMonitors() { | 104 int Screen::GetNumMonitors() { |
102 return GetSystemMetrics(SM_CMONITORS); | 105 return GetSystemMetrics(SM_CMONITORS); |
103 } | 106 } |
104 | 107 |
| 108 // static |
| 109 HDC Screen::GetCompatibleDC() { |
| 110 if (!compatible_dc_) |
| 111 compatible_dc_ = CreateCompatibleDC(NULL); |
| 112 return compatible_dc_; |
| 113 } |
| 114 |
| 115 // static |
| 116 void Screen::ReleaseCompatibleDC() { |
| 117 if (compatible_dc_) { |
| 118 DeleteDC(compatible_dc_); |
| 119 compatible_dc_ = NULL; |
| 120 } |
| 121 } |
| 122 |
105 } // namespace gfx | 123 } // namespace gfx |
OLD | NEW |