| 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 "win8/metro_driver/direct3d_helper.h" | |
| 7 #include "win8/metro_driver/winrt_utils.h" | |
| 8 | |
| 9 #include "base/logging.h" | |
| 10 #include "base/win/windows_version.h" | |
| 11 | |
| 12 #include <corewindow.h> | 6 #include <corewindow.h> |
| 13 #include <windows.applicationmodel.core.h> | 7 #include <windows.applicationmodel.core.h> |
| 14 #include <windows.graphics.display.h> | 8 #include <windows.graphics.display.h> |
| 15 | 9 |
| 10 #include "win8/metro_driver/direct3d_helper.h" |
| 11 #include "base/logging.h" |
| 12 #include "base/win/windows_version.h" |
| 13 #include "ui/gfx/win/dpi.h" |
| 14 #include "win8/metro_driver/winrt_utils.h" |
| 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. |
| 24 float GetLogicalDpi() { | 28 float GetLogicalDpi() { |
| 25 mswr::ComPtr<wingfx::Display::IDisplayPropertiesStatics> display_properties; | 29 mswr::ComPtr<wingfx::Display::IDisplayPropertiesStatics> display_properties; |
| 26 CheckIfFailed(winrt_utils::CreateActivationFactory( | 30 CheckIfFailed(winrt_utils::CreateActivationFactory( |
| 27 RuntimeClass_Windows_Graphics_Display_DisplayProperties, | 31 RuntimeClass_Windows_Graphics_Display_DisplayProperties, |
| 28 display_properties.GetAddressOf())); | 32 display_properties.GetAddressOf())); |
| 29 float dpi = 0.0; | 33 float dpi = 0.0; |
| 30 CheckIfFailed(display_properties->get_LogicalDpi(&dpi)); | 34 CheckIfFailed(display_properties->get_LogicalDpi(&dpi)); |
| 31 return dpi; | 35 return dpi; |
| 32 } | 36 } |
| 33 | 37 |
| 34 float ConvertDipsToPixels(float dips) { | 38 float ConvertDipsToPixels(float dips) { |
| 35 static const float dips_per_inch = 96.f; | 39 return floor(dips * gfx::GetDPIScale() + 0.5f); |
| 36 float logical_dpi = GetLogicalDpi(); | |
| 37 return floor(dips * logical_dpi / dips_per_inch + 0.5f); | |
| 38 } | 40 } |
| 39 | 41 |
| 40 } | 42 } |
| 41 | 43 |
| 42 namespace metro_driver { | 44 namespace metro_driver { |
| 43 | 45 |
| 44 Direct3DHelper::Direct3DHelper() { | 46 Direct3DHelper::Direct3DHelper() { |
| 45 } | 47 } |
| 46 | 48 |
| 47 Direct3DHelper::~Direct3DHelper() { | 49 Direct3DHelper::~Direct3DHelper() { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 window, | 150 window, |
| 149 &swap_chain_desc, | 151 &swap_chain_desc, |
| 150 nullptr, | 152 nullptr, |
| 151 nullptr, | 153 nullptr, |
| 152 &swap_chain_)); | 154 &swap_chain_)); |
| 153 } | 155 } |
| 154 } | 156 } |
| 155 } | 157 } |
| 156 | 158 |
| 157 } // namespace metro_driver | 159 } // namespace metro_driver |
| OLD | NEW |