OLD | NEW |
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 "stdafx.h" | 5 #include "stdafx.h" |
6 #include <corewindow.h> | 6 #include <corewindow.h> |
7 #include <windows.applicationmodel.core.h> | 7 #include <windows.applicationmodel.core.h> |
8 #include <windows.graphics.display.h> | 8 #include <windows.graphics.display.h> |
9 | 9 |
10 #include "win8/metro_driver/direct3d_helper.h" | 10 #include "win8/metro_driver/direct3d_helper.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/win/windows_version.h" | 12 #include "base/win/windows_version.h" |
13 #include "ui/gfx/win/dpi.h" | 13 #include "ui/gfx/win/dpi.h" |
14 #include "win8/metro_driver/winrt_utils.h" | 14 #include "win8/metro_driver/winrt_utils.h" |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 void CheckIfFailed(HRESULT hr) { | 18 void CheckIfFailed(HRESULT hr) { |
19 DCHECK(!FAILED(hr)); | 19 DCHECK(!FAILED(hr)); |
20 if (FAILED(hr)) | 20 if (FAILED(hr)) |
21 DVLOG(0) << "Direct3D call failed, hr = " << hr; | 21 DVLOG(0) << "Direct3D call failed, hr = " << hr; |
22 } | 22 } |
23 | 23 |
24 // TODO(ananta) | |
25 // This function does not return the correct value as the IDisplayProperties | |
26 // interface does not work correctly in Windows 8 in metro mode. Needs | |
27 // more investigation. | |
28 float GetLogicalDpi() { | |
29 mswr::ComPtr<wingfx::Display::IDisplayPropertiesStatics> display_properties; | |
30 CheckIfFailed(winrt_utils::CreateActivationFactory( | |
31 RuntimeClass_Windows_Graphics_Display_DisplayProperties, | |
32 display_properties.GetAddressOf())); | |
33 float dpi = 0.0; | |
34 CheckIfFailed(display_properties->get_LogicalDpi(&dpi)); | |
35 return dpi; | |
36 } | |
37 | |
38 float ConvertDipsToPixels(float dips) { | 24 float ConvertDipsToPixels(float dips) { |
39 return floor(dips * gfx::GetDPIScale() + 0.5f); | 25 return floor(dips * gfx::GetDPIScale() + 0.5f); |
40 } | 26 } |
41 | 27 |
42 } | 28 } |
43 | 29 |
44 namespace metro_driver { | 30 namespace metro_driver { |
45 | 31 |
46 Direct3DHelper::Direct3DHelper() { | 32 Direct3DHelper::Direct3DHelper() { |
47 } | 33 } |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 // Prevent DXGI from monitoring an application message queue and thus | 141 // Prevent DXGI from monitoring an application message queue and thus |
156 // attempt mode changes. For e.g. Alt + Enter by default causes | 142 // attempt mode changes. For e.g. Alt + Enter by default causes |
157 // DXGI to attempt to take the window fullscreen. | 143 // DXGI to attempt to take the window fullscreen. |
158 CheckIfFailed(dxgi_factory->MakeWindowAssociation( | 144 CheckIfFailed(dxgi_factory->MakeWindowAssociation( |
159 window, DXGI_MWA_NO_WINDOW_CHANGES)); | 145 window, DXGI_MWA_NO_WINDOW_CHANGES)); |
160 } | 146 } |
161 } | 147 } |
162 } | 148 } |
163 | 149 |
164 } // namespace metro_driver | 150 } // namespace metro_driver |
OLD | NEW |