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

Unified Diff: win8/metro_driver/direct3d_helper.cc

Issue 211863003: Second part of porting Chrome Ash to Windows 7 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: msg loop Created 6 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 side-by-side diff with in-line comments
Download patch
Index: win8/metro_driver/direct3d_helper.cc
diff --git a/win8/metro_driver/direct3d_helper.cc b/win8/metro_driver/direct3d_helper.cc
index 056e84b4cb999df0d9f2f7fbf60d543957158a4b..d0c30cf71219f1d024854e1c25f7f3b4b22291ab 100644
--- a/win8/metro_driver/direct3d_helper.cc
+++ b/win8/metro_driver/direct3d_helper.cc
@@ -7,7 +7,10 @@
#include "win8/metro_driver/winrt_utils.h"
#include "base/logging.h"
+#include "base/win/windows_version.h"
+#include <corewindow.h>
+#include <windows.applicationmodel.core.h>
#include <windows.graphics.display.h>
namespace {
@@ -83,9 +86,15 @@ void Direct3DHelper::CreateDeviceResources() {
}
void Direct3DHelper::CreateWindowSizeDependentResources() {
- CheckIfFailed(window_->get_Bounds(&window_bounds_));
- float window_width = ConvertDipsToPixels(window_bounds_.Width);
- float window_height = ConvertDipsToPixels(window_bounds_.Height);
+ float window_width = 0;
+ float window_height = 0;
+
+ if (base::win::GetVersion() >= base::win::VERSION_WIN8) {
+ // Windows 8 returns in DIPs.
+ CheckIfFailed(window_->get_Bounds(&window_bounds_));
+ window_width = ConvertDipsToPixels(window_width);
+ window_height = ConvertDipsToPixels(window_height);
+ }
// TODO(scottmg): Orientation.
@@ -116,12 +125,32 @@ void Direct3DHelper::CreateWindowSizeDependentResources() {
CheckIfFailed(dxgi_adapter->GetParent(
__uuidof(IDXGIFactory2), &dxgi_factory));
- CheckIfFailed(dxgi_factory->CreateSwapChainForCoreWindow(
- d3d_device_.Get(),
- reinterpret_cast<IUnknown*>(window_),
- &swap_chain_desc,
- nullptr,
- &swap_chain_));
+ if (base::win::GetVersion() >= base::win::VERSION_WIN8) {
+ // On Win8 we need the CoreWindow interface to create the Swapchain.
+ CheckIfFailed(dxgi_factory->CreateSwapChainForCoreWindow(
+ d3d_device_.Get(),
+ reinterpret_cast<IUnknown*>(window_),
+ &swap_chain_desc,
+ nullptr,
+ &swap_chain_));
+ } else {
+ // On Win7 we need the raw HWND to create the Swapchain.
+ mswr::ComPtr<ICoreWindowInterop> interop;
+ CheckIfFailed(window_->QueryInterface(interop.GetAddressOf()));
+ HWND window = NULL;
+ interop->get_WindowHandle(&window);
+
+ swap_chain_desc.Scaling = DXGI_SCALING_STRETCH;
+ swap_chain_desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
cpu_(ooo_6.6-7.5) 2014/03/26 19:22:53 the win8 scaling and swapeffect modes are not supp
+
+ CheckIfFailed(dxgi_factory->CreateSwapChainForHwnd(
+ d3d_device_.Get(),
+ window,
+ &swap_chain_desc,
+ nullptr,
+ nullptr,
+ &swap_chain_));
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698