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

Side by Side Diff: win8/metro_driver/direct3d_helper.cc

Issue 300003002: Use the win32 device scale factor in Chrome ASH on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed include Created 6 years, 7 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 | Annotate | Revision Log
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 "stdafx.h" 5 #include "stdafx.h"
6 #include "win8/metro_driver/direct3d_helper.h" 6 #include "win8/metro_driver/direct3d_helper.h"
7 #include "win8/metro_driver/winrt_utils.h" 7 #include "win8/metro_driver/winrt_utils.h"
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/win/windows_version.h" 10 #include "base/win/windows_version.h"
11 11
12 #include <corewindow.h> 12 #include <corewindow.h>
13 #include <windows.applicationmodel.core.h> 13 #include <windows.applicationmodel.core.h>
14 #include <windows.graphics.display.h> 14 #include <windows.graphics.display.h>
15 15
16 #include "ui/gfx/win/dpi.h"
17
16 namespace { 18 namespace {
17 19
18 void CheckIfFailed(HRESULT hr) { 20 void CheckIfFailed(HRESULT hr) {
19 DCHECK(!FAILED(hr)); 21 DCHECK(!FAILED(hr));
20 if (FAILED(hr)) 22 if (FAILED(hr))
21 DVLOG(0) << "Direct3D call failed, hr = " << hr; 23 DVLOG(0) << "Direct3D call failed, hr = " << hr;
22 } 24 }
23 25
26 // TODO(ananta)
27 // This function does not return the correct value as the IDisplayProperties
28 // interface does not work correctly in Windows 8 in metro mode. Needs
29 // more investigation.
24 float GetLogicalDpi() { 30 float GetLogicalDpi() {
25 mswr::ComPtr<wingfx::Display::IDisplayPropertiesStatics> display_properties; 31 mswr::ComPtr<wingfx::Display::IDisplayPropertiesStatics> display_properties;
26 CheckIfFailed(winrt_utils::CreateActivationFactory( 32 CheckIfFailed(winrt_utils::CreateActivationFactory(
27 RuntimeClass_Windows_Graphics_Display_DisplayProperties, 33 RuntimeClass_Windows_Graphics_Display_DisplayProperties,
28 display_properties.GetAddressOf())); 34 display_properties.GetAddressOf()));
29 float dpi = 0.0; 35 float dpi = 0.0;
30 CheckIfFailed(display_properties->get_LogicalDpi(&dpi)); 36 CheckIfFailed(display_properties->get_LogicalDpi(&dpi));
31 return dpi; 37 return dpi;
32 } 38 }
33 39
34 float ConvertDipsToPixels(float dips) { 40 float ConvertDipsToPixels(float dips) {
35 static const float dips_per_inch = 96.f; 41 return floor(dips * gfx::GetDPIScale() + 0.5f);
36 float logical_dpi = GetLogicalDpi();
37 return floor(dips * logical_dpi / dips_per_inch + 0.5f);
38 } 42 }
39 43
40 } 44 }
41 45
42 namespace metro_driver { 46 namespace metro_driver {
43 47
44 Direct3DHelper::Direct3DHelper() { 48 Direct3DHelper::Direct3DHelper() {
45 } 49 }
46 50
47 Direct3DHelper::~Direct3DHelper() { 51 Direct3DHelper::~Direct3DHelper() {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 window, 152 window,
149 &swap_chain_desc, 153 &swap_chain_desc,
150 nullptr, 154 nullptr,
151 nullptr, 155 nullptr,
152 &swap_chain_)); 156 &swap_chain_));
153 } 157 }
154 } 158 }
155 } 159 }
156 160
157 } // namespace metro_driver 161 } // namespace metro_driver
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698