Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/gl/gl_angle_util_win.h" | 5 #include "ui/gl/gl_angle_util_win.h" |
| 6 | 6 |
| 7 #include "base/trace_event/trace_event.h" | 7 #include "base/trace_event/trace_event.h" |
| 8 #include "third_party/angle/include/EGL/egl.h" | 8 #include "third_party/angle/include/EGL/egl.h" |
| 9 #include "third_party/angle/include/EGL/eglext.h" | 9 #include "third_party/angle/include/EGL/eglext.h" |
| 10 #include "ui/gl/gl_surface_egl.h" | 10 #include "ui/gl/gl_surface_egl.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 return d3d11_device; | 75 return d3d11_device; |
| 76 } | 76 } |
| 77 | 77 |
| 78 base::win::ScopedComPtr<IDirect3DDevice9> QueryD3D9DeviceObjectFromANGLE() { | 78 base::win::ScopedComPtr<IDirect3DDevice9> QueryD3D9DeviceObjectFromANGLE() { |
| 79 base::win::ScopedComPtr<IDirect3DDevice9> d3d9_device; | 79 base::win::ScopedComPtr<IDirect3DDevice9> d3d9_device; |
| 80 d3d9_device = reinterpret_cast<IDirect3DDevice9*>( | 80 d3d9_device = reinterpret_cast<IDirect3DDevice9*>( |
| 81 QueryDeviceObjectFromANGLE(EGL_D3D9_DEVICE_ANGLE)); | 81 QueryDeviceObjectFromANGLE(EGL_D3D9_DEVICE_ANGLE)); |
| 82 return d3d9_device; | 82 return d3d9_device; |
| 83 } | 83 } |
| 84 | 84 |
| 85 base::win::ScopedComPtr<IDCompositionDevice2> QueryDirectCompositionDevice( | |
| 86 base::win::ScopedComPtr<ID3D11Device> d3d11_device) { | |
| 87 // Each D3D11 device will have a DirectComposition device stored in its | |
| 88 // private data under this GUID. | |
| 89 // {CF81D85A-8D30-4769-8509-B9D73898D870} | |
| 90 static const GUID kDirectCompositionGUID = { | |
| 91 0xcf81d85a, | |
| 92 0x8d30, | |
| 93 0x4769, | |
| 94 {0x85, 0x9, 0xb9, 0xd7, 0x38, 0x98, 0xd8, 0x70}}; | |
| 95 | |
| 96 base::win::ScopedComPtr<IDCompositionDevice2> dcomp_device; | |
| 97 if (!d3d11_device) | |
| 98 return dcomp_device; | |
| 99 | |
| 100 UINT data_size = sizeof(dcomp_device.get()); | |
| 101 HRESULT hr = d3d11_device->GetPrivateData(kDirectCompositionGUID, &data_size, | |
| 102 dcomp_device.ReceiveVoid()); | |
| 103 if (SUCCEEDED(hr) && dcomp_device) | |
| 104 return dcomp_device; | |
| 105 | |
|
sunnyps
2017/01/28 01:33:59
nit: can you comment under what conditions the fol
| |
| 106 HMODULE dcomp_module = ::GetModuleHandle(L"dcomp.dll"); | |
| 107 if (!dcomp_module) | |
| 108 return dcomp_device; | |
| 109 | |
| 110 typedef HRESULT(WINAPI * PFN_DCOMPOSITION_CREATE_DEVICE2)( | |
| 111 IUnknown * renderingDevice, REFIID iid, void** dcompositionDevice); | |
| 112 PFN_DCOMPOSITION_CREATE_DEVICE2 create_device_function = | |
| 113 reinterpret_cast<PFN_DCOMPOSITION_CREATE_DEVICE2>( | |
| 114 ::GetProcAddress(dcomp_module, "DCompositionCreateDevice2")); | |
| 115 if (!create_device_function) | |
| 116 return dcomp_device; | |
| 117 | |
| 118 base::win::ScopedComPtr<IDXGIDevice> dxgi_device; | |
| 119 d3d11_device.QueryInterface(dxgi_device.Receive()); | |
| 120 base::win::ScopedComPtr<IDCompositionDesktopDevice> desktop_device; | |
| 121 hr = create_device_function(dxgi_device.get(), | |
| 122 IID_PPV_ARGS(desktop_device.Receive())); | |
| 123 if (FAILED(hr)) | |
| 124 return dcomp_device; | |
| 125 | |
| 126 hr = desktop_device.QueryInterface(dcomp_device.Receive()); | |
| 127 CHECK(SUCCEEDED(hr)); | |
| 128 d3d11_device->SetPrivateDataInterface(kDirectCompositionGUID, | |
| 129 dcomp_device.get()); | |
| 130 | |
| 131 return dcomp_device; | |
| 132 } | |
| 133 | |
| 85 } // namespace gl | 134 } // namespace gl |
| OLD | NEW |