1 // 2 // Copyright 2015 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 7 // DXGISwapChainWindowSurfaceWGL.h: WGL implementation of egl::Surface for windows using a DXGI 8 // swapchain. 9 10 #ifndef LIBANGLE_RENDERER_GL_WGL_DXGISWAPCHAINSURFACEWGL_H_ 11 #define LIBANGLE_RENDERER_GL_WGL_DXGISWAPCHAINSURFACEWGL_H_ 12 13 #include "libANGLE/renderer/gl/wgl/SurfaceWGL.h" 14 15 #include <GL/wglext.h> 16 17 namespace rx 18 { 19 20 class FunctionsGL; 21 class FunctionsWGL; 22 class DisplayWGL; 23 class StateManagerGL; 24 25 class DXGISwapChainWindowSurfaceWGL : public SurfaceWGL 26 { 27 public: 28 DXGISwapChainWindowSurfaceWGL(const egl::SurfaceState &state, 29 StateManagerGL *stateManager, 30 EGLNativeWindowType window, 31 ID3D11Device *device, 32 HANDLE deviceHandle, 33 HDC deviceContext, 34 const FunctionsGL *functionsGL, 35 const FunctionsWGL *functionsWGL, 36 EGLint orientation); 37 ~DXGISwapChainWindowSurfaceWGL() override; 38 39 egl::Error initialize(const egl::Display *display) override; 40 egl::Error makeCurrent(const gl::Context *context) override; 41 42 egl::Error swap(const gl::Context *context) override; 43 egl::Error postSubBuffer(const gl::Context *context, 44 EGLint x, 45 EGLint y, 46 EGLint width, 47 EGLint height) override; 48 egl::Error querySurfacePointerANGLE(EGLint attribute, void **value) override; 49 egl::Error bindTexImage(const gl::Context *context, 50 gl::Texture *texture, 51 EGLint buffer) override; 52 egl::Error releaseTexImage(const gl::Context *context, EGLint buffer) override; 53 void setSwapInterval(const egl::Display *display, EGLint interval) override; 54 55 EGLint getWidth() const override; 56 EGLint getHeight() const override; 57 58 EGLint isPostSubBufferSupported() const override; 59 EGLint getSwapBehavior() const override; 60 HDC getDC() const override; 61 62 egl::Error attachToFramebuffer(const gl::Context *context, 63 gl::Framebuffer *framebuffer) override; 64 egl::Error detachFromFramebuffer(const gl::Context *context, 65 gl::Framebuffer *framebuffer) override; 66 67 private: 68 egl::Error setObjectsLocked(bool locked); 69 egl::Error checkForResize(); 70 71 egl::Error createSwapChain(); 72 73 EGLNativeWindowType mWindow; 74 75 StateManagerGL *mStateManager; 76 const FunctionsGL *mFunctionsGL; 77 const FunctionsWGL *mFunctionsWGL; 78 79 ID3D11Device *mDevice; 80 HANDLE mDeviceHandle; 81 82 HDC mWGLDevice; 83 84 DXGI_FORMAT mSwapChainFormat; 85 UINT mSwapChainFlags; 86 GLenum mDepthBufferFormat; 87 88 bool mFirstSwap; 89 IDXGISwapChain *mSwapChain; 90 IDXGISwapChain1 *mSwapChain1; 91 92 GLuint mFramebufferID; 93 GLuint mColorRenderbufferID; 94 HANDLE mRenderbufferBufferHandle; 95 96 GLuint mDepthRenderbufferID; 97 98 GLuint mTextureID; 99 HANDLE mTextureHandle; 100 101 size_t mWidth; 102 size_t mHeight; 103 104 EGLint mSwapInterval; 105 106 EGLint mOrientation; 107 }; 108 } // namespace rx 109 110 #endif // LIBANGLE_RENDERER_GL_WGL_DXGISWAPCHAINSURFACEWGL_H_ 111