tor-browser

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

SurfaceD3D.h (4878B)


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