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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 static const GUID kDirectCompositionGUID = { | 90 static const GUID kDirectCompositionGUID = { |
91 0xcf81d85a, | 91 0xcf81d85a, |
92 0x8d30, | 92 0x8d30, |
93 0x4769, | 93 0x4769, |
94 {0x85, 0x9, 0xb9, 0xd7, 0x38, 0x98, 0xd8, 0x70}}; | 94 {0x85, 0x9, 0xb9, 0xd7, 0x38, 0x98, 0xd8, 0x70}}; |
95 | 95 |
96 base::win::ScopedComPtr<IDCompositionDevice2> dcomp_device; | 96 base::win::ScopedComPtr<IDCompositionDevice2> dcomp_device; |
97 if (!d3d11_device) | 97 if (!d3d11_device) |
98 return dcomp_device; | 98 return dcomp_device; |
99 | 99 |
100 UINT data_size = sizeof(dcomp_device.get()); | 100 UINT data_size = sizeof(dcomp_device.Get()); |
101 HRESULT hr = d3d11_device->GetPrivateData(kDirectCompositionGUID, &data_size, | 101 HRESULT hr = d3d11_device->GetPrivateData(kDirectCompositionGUID, &data_size, |
102 dcomp_device.ReceiveVoid()); | 102 dcomp_device.ReceiveVoid()); |
103 if (SUCCEEDED(hr) && dcomp_device) | 103 if (SUCCEEDED(hr) && dcomp_device) |
104 return dcomp_device; | 104 return dcomp_device; |
105 | 105 |
106 // Allocate a new DirectComposition device if none currently exists. | 106 // Allocate a new DirectComposition device if none currently exists. |
107 HMODULE dcomp_module = ::GetModuleHandle(L"dcomp.dll"); | 107 HMODULE dcomp_module = ::GetModuleHandle(L"dcomp.dll"); |
108 if (!dcomp_module) | 108 if (!dcomp_module) |
109 return dcomp_device; | 109 return dcomp_device; |
110 | 110 |
111 using PFN_DCOMPOSITION_CREATE_DEVICE2 = HRESULT(WINAPI*)( | 111 using PFN_DCOMPOSITION_CREATE_DEVICE2 = HRESULT(WINAPI*)( |
112 IUnknown * renderingDevice, REFIID iid, void** dcompositionDevice); | 112 IUnknown * renderingDevice, REFIID iid, void** dcompositionDevice); |
113 PFN_DCOMPOSITION_CREATE_DEVICE2 create_device_function = | 113 PFN_DCOMPOSITION_CREATE_DEVICE2 create_device_function = |
114 reinterpret_cast<PFN_DCOMPOSITION_CREATE_DEVICE2>( | 114 reinterpret_cast<PFN_DCOMPOSITION_CREATE_DEVICE2>( |
115 ::GetProcAddress(dcomp_module, "DCompositionCreateDevice2")); | 115 ::GetProcAddress(dcomp_module, "DCompositionCreateDevice2")); |
116 if (!create_device_function) | 116 if (!create_device_function) |
117 return dcomp_device; | 117 return dcomp_device; |
118 | 118 |
119 base::win::ScopedComPtr<IDXGIDevice> dxgi_device; | 119 base::win::ScopedComPtr<IDXGIDevice> dxgi_device; |
120 d3d11_device.QueryInterface(dxgi_device.Receive()); | 120 d3d11_device.QueryInterface(dxgi_device.Receive()); |
121 base::win::ScopedComPtr<IDCompositionDesktopDevice> desktop_device; | 121 base::win::ScopedComPtr<IDCompositionDesktopDevice> desktop_device; |
122 hr = create_device_function(dxgi_device.get(), | 122 hr = create_device_function(dxgi_device.Get(), |
123 IID_PPV_ARGS(desktop_device.Receive())); | 123 IID_PPV_ARGS(desktop_device.Receive())); |
124 if (FAILED(hr)) | 124 if (FAILED(hr)) |
125 return dcomp_device; | 125 return dcomp_device; |
126 | 126 |
127 hr = desktop_device.QueryInterface(dcomp_device.Receive()); | 127 hr = desktop_device.QueryInterface(dcomp_device.Receive()); |
128 CHECK(SUCCEEDED(hr)); | 128 CHECK(SUCCEEDED(hr)); |
129 d3d11_device->SetPrivateDataInterface(kDirectCompositionGUID, | 129 d3d11_device->SetPrivateDataInterface(kDirectCompositionGUID, |
130 dcomp_device.get()); | 130 dcomp_device.Get()); |
131 | 131 |
132 return dcomp_device; | 132 return dcomp_device; |
133 } | 133 } |
134 | 134 |
135 } // namespace gl | 135 } // namespace gl |
OLD | NEW |