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(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 61 FramebufferImpl *createDefaultFramebuffer(const gl::Context *context, 62 const gl::FramebufferState &data) override; 63 64 HDC getDC() const override; 65 66 private: 67 egl::Error setObjectsLocked(bool locked); 68 egl::Error checkForResize(); 69 70 egl::Error createSwapChain(); 71 72 EGLNativeWindowType mWindow; 73 74 StateManagerGL *mStateManager; 75 const FunctionsGL *mFunctionsGL; 76 const FunctionsWGL *mFunctionsWGL; 77 78 ID3D11Device *mDevice; 79 HANDLE mDeviceHandle; 80 81 HDC mWGLDevice; 82 83 DXGI_FORMAT mSwapChainFormat; 84 UINT mSwapChainFlags; 85 GLenum mDepthBufferFormat; 86 87 bool mFirstSwap; 88 IDXGISwapChain *mSwapChain; 89 IDXGISwapChain1 *mSwapChain1; 90 91 GLuint mColorRenderbufferID; 92 HANDLE mRenderbufferBufferHandle; 93 94 GLuint mDepthRenderbufferID; 95 96 GLuint mTextureID; 97 HANDLE mTextureHandle; 98 99 size_t mWidth; 100 size_t mHeight; 101 102 EGLint mSwapInterval; 103 104 EGLint mOrientation; 105 }; 106 } // namespace rx 107 108 #endif // LIBANGLE_RENDERER_GL_WGL_DXGISWAPCHAINSURFACEWGL_H_ 109