| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/gl/gl_angle_util_win.h" |
| 6 |
| 7 #include "base/trace_event/trace_event.h" |
| 8 #include "third_party/angle/include/EGL/egl.h" |
| 9 #include "third_party/angle/include/EGL/eglext.h" |
| 10 #include "ui/gl/gl_surface_egl.h" |
| 11 |
| 12 namespace gl { |
| 13 |
| 14 void* QueryDeviceObjectFromANGLE(int object_type) { |
| 15 EGLDisplay egl_display = nullptr; |
| 16 intptr_t egl_device = 0; |
| 17 intptr_t device = 0; |
| 18 |
| 19 { |
| 20 TRACE_EVENT0("gpu", "QueryDeviceObjectFromANGLE. GetHardwareDisplay"); |
| 21 egl_display = gl::GLSurfaceEGL::GetHardwareDisplay(); |
| 22 } |
| 23 |
| 24 if (!gl::GLSurfaceEGL::HasEGLExtension("EGL_EXT_device_query")) |
| 25 return nullptr; |
| 26 |
| 27 PFNEGLQUERYDISPLAYATTRIBEXTPROC QueryDisplayAttribEXT = nullptr; |
| 28 |
| 29 { |
| 30 TRACE_EVENT0("gpu", "QueryDeviceObjectFromANGLE. eglGetProcAddress"); |
| 31 |
| 32 QueryDisplayAttribEXT = reinterpret_cast<PFNEGLQUERYDISPLAYATTRIBEXTPROC>( |
| 33 eglGetProcAddress("eglQueryDisplayAttribEXT")); |
| 34 |
| 35 if (!QueryDisplayAttribEXT) |
| 36 return nullptr; |
| 37 } |
| 38 |
| 39 PFNEGLQUERYDEVICEATTRIBEXTPROC QueryDeviceAttribEXT = nullptr; |
| 40 |
| 41 { |
| 42 TRACE_EVENT0("gpu", "QueryDeviceObjectFromANGLE. eglGetProcAddress"); |
| 43 |
| 44 QueryDeviceAttribEXT = reinterpret_cast<PFNEGLQUERYDEVICEATTRIBEXTPROC>( |
| 45 eglGetProcAddress("eglQueryDeviceAttribEXT")); |
| 46 if (!QueryDeviceAttribEXT) |
| 47 return nullptr; |
| 48 } |
| 49 |
| 50 { |
| 51 TRACE_EVENT0("gpu", "QueryDeviceObjectFromANGLE. QueryDisplayAttribEXT"); |
| 52 |
| 53 if (!QueryDisplayAttribEXT(egl_display, EGL_DEVICE_EXT, &egl_device)) |
| 54 return nullptr; |
| 55 } |
| 56 if (!egl_device) |
| 57 return nullptr; |
| 58 |
| 59 { |
| 60 TRACE_EVENT0("gpu", "QueryDeviceObjectFromANGLE. QueryDisplayAttribEXT"); |
| 61 |
| 62 if (!QueryDeviceAttribEXT(reinterpret_cast<EGLDeviceEXT>(egl_device), |
| 63 object_type, &device)) { |
| 64 return nullptr; |
| 65 } |
| 66 } |
| 67 |
| 68 return reinterpret_cast<void*>(device); |
| 69 } |
| 70 |
| 71 base::win::ScopedComPtr<ID3D11Device> QueryD3D11DeviceObjectFromANGLE() { |
| 72 base::win::ScopedComPtr<ID3D11Device> d3d11_device; |
| 73 d3d11_device = reinterpret_cast<ID3D11Device*>( |
| 74 QueryDeviceObjectFromANGLE(EGL_D3D11_DEVICE_ANGLE)); |
| 75 return d3d11_device; |
| 76 } |
| 77 |
| 78 base::win::ScopedComPtr<IDirect3DDevice9> QueryD3D9DeviceObjectFromANGLE() { |
| 79 base::win::ScopedComPtr<IDirect3DDevice9> d3d9_device; |
| 80 d3d9_device = reinterpret_cast<IDirect3DDevice9*>( |
| 81 QueryDeviceObjectFromANGLE(EGL_D3D9_DEVICE_ANGLE)); |
| 82 return d3d9_device; |
| 83 } |
| 84 |
| 85 } // namespace gl |
| OLD | NEW |