tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

SwapChain11.h (4740B)


      1 //
      2 // Copyright 2012 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 // SwapChain11.h: Defines a back-end specific class for the D3D11 swap chain.
      8 
      9 #ifndef LIBANGLE_RENDERER_D3D_D3D11_SWAPCHAIN11_H_
     10 #define LIBANGLE_RENDERER_D3D_D3D11_SWAPCHAIN11_H_
     11 
     12 #include "common/angleutils.h"
     13 #include "libANGLE/renderer/d3d/SwapChainD3D.h"
     14 #include "libANGLE/renderer/d3d/d3d11/RenderTarget11.h"
     15 
     16 namespace rx
     17 {
     18 class Renderer11;
     19 class NativeWindow11;
     20 
     21 class SwapChain11 final : public SwapChainD3D
     22 {
     23  public:
     24    SwapChain11(Renderer11 *renderer,
     25                NativeWindow11 *nativeWindow,
     26                HANDLE shareHandle,
     27                IUnknown *d3dTexture,
     28                GLenum backBufferFormat,
     29                GLenum depthBufferFormat,
     30                EGLint orientation,
     31                EGLint samples);
     32    ~SwapChain11() override;
     33 
     34    EGLint resize(DisplayD3D *displayD3D, EGLint backbufferWidth, EGLint backbufferHeight) override;
     35    EGLint reset(DisplayD3D *displayD3D,
     36                 EGLint backbufferWidth,
     37                 EGLint backbufferHeight,
     38                 EGLint swapInterval) override;
     39    EGLint swapRect(DisplayD3D *displayD3D,
     40                    EGLint x,
     41                    EGLint y,
     42                    EGLint width,
     43                    EGLint height) override;
     44    void recreate() override;
     45 
     46    RenderTargetD3D *getColorRenderTarget() override;
     47    RenderTargetD3D *getDepthStencilRenderTarget() override;
     48 
     49    const TextureHelper11 &getOffscreenTexture();
     50    const d3d11::RenderTargetView &getRenderTarget();
     51    angle::Result getRenderTargetShaderResource(d3d::Context *context,
     52                                                const d3d11::SharedSRV **outSRV);
     53 
     54    const TextureHelper11 &getDepthStencilTexture();
     55    const d3d11::DepthStencilView &getDepthStencil();
     56    const d3d11::SharedSRV &getDepthStencilShaderResource();
     57 
     58    EGLint getWidth() const { return mWidth; }
     59    EGLint getHeight() const { return mHeight; }
     60    void *getKeyedMutex() override;
     61    EGLint getSamples() const { return mEGLSamples; }
     62 
     63    egl::Error getSyncValues(EGLuint64KHR *ust, EGLuint64KHR *msc, EGLuint64KHR *sbc) override;
     64 
     65  private:
     66    void release();
     67    angle::Result initPassThroughResources(DisplayD3D *displayD3D);
     68 
     69    void releaseOffscreenColorBuffer();
     70    void releaseOffscreenDepthBuffer();
     71    EGLint resetOffscreenBuffers(DisplayD3D *displayD3D, int backbufferWidth, int backbufferHeight);
     72    EGLint resetOffscreenColorBuffer(DisplayD3D *displayD3D,
     73                                     int backbufferWidth,
     74                                     int backbufferHeight);
     75    EGLint resetOffscreenDepthBuffer(DisplayD3D *displayD3D,
     76                                     int backbufferWidth,
     77                                     int backbufferHeight);
     78 
     79    DXGI_FORMAT getSwapChainNativeFormat() const;
     80 
     81    EGLint copyOffscreenToBackbuffer(DisplayD3D *displayD3D,
     82                                     EGLint x,
     83                                     EGLint y,
     84                                     EGLint width,
     85                                     EGLint height);
     86    EGLint present(DisplayD3D *displayD3D, EGLint x, EGLint y, EGLint width, EGLint height);
     87    UINT getD3DSamples() const;
     88 
     89    Renderer11 *mRenderer;
     90    EGLint mWidth;
     91    EGLint mHeight;
     92    const EGLint mOrientation;
     93    bool mAppCreatedShareHandle;
     94    unsigned int mSwapInterval;
     95    bool mPassThroughResourcesInit;
     96 
     97    NativeWindow11 *mNativeWindow;  // Handler for the Window that the surface is created for.
     98 
     99    bool mFirstSwap;
    100    IDXGISwapChain *mSwapChain;
    101    IDXGISwapChain1 *mSwapChain1;
    102    IDXGIKeyedMutex *mKeyedMutex;
    103 
    104    TextureHelper11 mBackBufferTexture;
    105    d3d11::RenderTargetView mBackBufferRTView;
    106    d3d11::SharedSRV mBackBufferSRView;
    107 
    108    const bool mNeedsOffscreenTexture;
    109    TextureHelper11 mOffscreenTexture;
    110    d3d11::RenderTargetView mOffscreenRTView;
    111    d3d11::SharedSRV mOffscreenSRView;
    112    bool mNeedsOffscreenTextureCopy;
    113    TextureHelper11 mOffscreenTextureCopyForSRV;
    114 
    115    TextureHelper11 mDepthStencilTexture;
    116    d3d11::DepthStencilView mDepthStencilDSView;
    117    d3d11::SharedSRV mDepthStencilSRView;
    118 
    119    d3d11::Buffer mQuadVB;
    120    d3d11::SamplerState mPassThroughSampler;
    121    d3d11::InputLayout mPassThroughIL;
    122    d3d11::VertexShader mPassThroughVS;
    123    d3d11::PixelShader mPassThroughOrResolvePS;
    124    d3d11::RasterizerState mPassThroughRS;
    125 
    126    SurfaceRenderTarget11 mColorRenderTarget;
    127    SurfaceRenderTarget11 mDepthStencilRenderTarget;
    128 
    129    EGLint mEGLSamples;
    130    LONGLONG mQPCFrequency;
    131 };
    132 
    133 }  // namespace rx
    134 #endif  // LIBANGLE_RENDERER_D3D_D3D11_SWAPCHAIN11_H_