1 // 2 // Copyright 2014 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 // SurfaceD3D.h: D3D implementation of an EGL surface 8 9 #ifndef LIBANGLE_RENDERER_D3D_SURFACED3D_H_ 10 #define LIBANGLE_RENDERER_D3D_SURFACED3D_H_ 11 12 #include "libANGLE/renderer/SurfaceImpl.h" 13 #include "libANGLE/renderer/d3d/NativeWindowD3D.h" 14 15 namespace egl 16 { 17 class Surface; 18 } 19 20 namespace rx 21 { 22 class DisplayD3D; 23 class SwapChainD3D; 24 class RendererD3D; 25 26 class SurfaceD3D : public SurfaceImpl 27 { 28 public: 29 ~SurfaceD3D() override; 30 void releaseSwapChain(); 31 32 egl::Error initialize(const egl::Display *display) override; 33 FramebufferImpl *createDefaultFramebuffer(const gl::Context *context, 34 const gl::FramebufferState &state) override; 35 36 egl::Error swap(const gl::Context *context) override; 37 egl::Error postSubBuffer(const gl::Context *context, 38 EGLint x, 39 EGLint y, 40 EGLint width, 41 EGLint height) override; 42 egl::Error querySurfacePointerANGLE(EGLint attribute, void **value) override; 43 egl::Error bindTexImage(const gl::Context *context, 44 gl::Texture *texture, 45 EGLint buffer) override; 46 egl::Error releaseTexImage(const gl::Context *context, EGLint buffer) override; 47 egl::Error getSyncValues(EGLuint64KHR *ust, EGLuint64KHR *msc, EGLuint64KHR *sbc) override; 48 egl::Error getMscRate(EGLint *numerator, EGLint *denominator) override; 49 void setSwapInterval(EGLint interval) override; 50 void setFixedWidth(EGLint width) override; 51 void setFixedHeight(EGLint height) override; 52 53 EGLint getWidth() const override; 54 EGLint getHeight() const override; 55 56 EGLint isPostSubBufferSupported() const override; 57 EGLint getSwapBehavior() const override; 58 59 // D3D implementations 60 SwapChainD3D *getSwapChain() const; 61 62 egl::Error resetSwapChain(const egl::Display *display); 63 64 egl::Error checkForOutOfDateSwapChain(DisplayD3D *displayD3D); 65 66 angle::Result getAttachmentRenderTarget(const gl::Context *context, 67 GLenum binding, 68 const gl::ImageIndex &imageIndex, 69 GLsizei samples, 70 FramebufferAttachmentRenderTarget **rtOut) override; 71 angle::Result initializeContents(const gl::Context *context, 72 const gl::ImageIndex &imageIndex) override; 73 74 const angle::Format *getD3DTextureColorFormat() const override; 75 76 protected: 77 SurfaceD3D(const egl::SurfaceState &state, 78 RendererD3D *renderer, 79 egl::Display *display, 80 EGLNativeWindowType window, 81 EGLenum buftype, 82 EGLClientBuffer clientBuffer, 83 const egl::AttributeMap &attribs); 84 85 egl::Error swapRect(DisplayD3D *displayD3D, EGLint x, EGLint y, EGLint width, EGLint height); 86 egl::Error resetSwapChain(DisplayD3D *displayD3D, int backbufferWidth, int backbufferHeight); 87 egl::Error resizeSwapChain(DisplayD3D *displayD3D, int backbufferWidth, int backbufferHeight); 88 89 RendererD3D *mRenderer; 90 egl::Display *mDisplay; 91 92 bool mFixedSize; 93 GLint mFixedWidth; 94 GLint mFixedHeight; 95 GLint mOrientation; 96 97 GLenum mRenderTargetFormat; 98 GLenum mDepthStencilFormat; 99 const angle::Format *mColorFormat; 100 101 SwapChainD3D *mSwapChain; 102 bool mSwapIntervalDirty; 103 104 NativeWindowD3D *mNativeWindow; // Handler for the Window that the surface is created for. 105 EGLint mWidth; 106 EGLint mHeight; 107 108 EGLint mSwapInterval; 109 110 HANDLE mShareHandle; 111 IUnknown *mD3DTexture; 112 113 EGLenum mBuftype; 114 }; 115 116 class WindowSurfaceD3D : public SurfaceD3D 117 { 118 public: 119 WindowSurfaceD3D(const egl::SurfaceState &state, 120 RendererD3D *renderer, 121 egl::Display *display, 122 EGLNativeWindowType window, 123 const egl::AttributeMap &attribs); 124 ~WindowSurfaceD3D() override; 125 }; 126 127 class PbufferSurfaceD3D : public SurfaceD3D 128 { 129 public: 130 PbufferSurfaceD3D(const egl::SurfaceState &state, 131 RendererD3D *renderer, 132 egl::Display *display, 133 EGLenum buftype, 134 EGLClientBuffer clientBuffer, 135 const egl::AttributeMap &attribs); 136 ~PbufferSurfaceD3D() override; 137 }; 138 139 } // namespace rx 140 141 #endif // LIBANGLE_RENDERER_D3D_SURFACED3D_H_ 142