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 // SwapChain9.h: Defines a back-end specific class for the D3D9 swap chain.
8 
9 #ifndef LIBANGLE_RENDERER_D3D_D3D9_SWAPCHAIN9_H_
10 #define LIBANGLE_RENDERER_D3D_D3D9_SWAPCHAIN9_H_
11 
12 #include "common/angleutils.h"
13 #include "libANGLE/renderer/d3d/SwapChainD3D.h"
14 #include "libANGLE/renderer/d3d/d3d9/RenderTarget9.h"
15 
16 namespace rx
17 {
18 class NativeWindow9;
19 class Renderer9;
20 
21 class SwapChain9 : public SwapChainD3D
22 {
23   public:
24     SwapChain9(Renderer9 *renderer,
25                NativeWindow9 *nativeWindow,
26                HANDLE shareHandle,
27                IUnknown *d3dTexture,
28                GLenum backBufferFormat,
29                GLenum depthBufferFormat,
30                EGLint orientation);
31     ~SwapChain9() override;
32 
33     EGLint resize(DisplayD3D *displayD3D, EGLint backbufferWidth, EGLint backbufferHeight) override;
34     EGLint reset(DisplayD3D *displayD3D,
35                  EGLint backbufferWidth,
36                  EGLint backbufferHeight,
37                  EGLint swapInterval) override;
38     EGLint swapRect(DisplayD3D *displayD3D,
39                     EGLint x,
40                     EGLint y,
41                     EGLint width,
42                     EGLint height) override;
43     void recreate() override;
44 
45     RenderTargetD3D *getColorRenderTarget() override;
46     RenderTargetD3D *getDepthStencilRenderTarget() override;
47 
48     virtual IDirect3DSurface9 *getRenderTarget();
49     virtual IDirect3DSurface9 *getDepthStencil();
50     virtual IDirect3DTexture9 *getOffscreenTexture();
51 
getWidth()52     EGLint getWidth() const { return mWidth; }
getHeight()53     EGLint getHeight() const { return mHeight; }
54 
55     void *getKeyedMutex() override;
56 
57     egl::Error getSyncValues(EGLuint64KHR *ust, EGLuint64KHR *msc, EGLuint64KHR *sbc) override;
58 
59   private:
60     void release();
61 
62     Renderer9 *mRenderer;
63     EGLint mWidth;
64     EGLint mHeight;
65     EGLint mSwapInterval;
66 
67     NativeWindow9 *mNativeWindow;
68 
69     IDirect3DSwapChain9 *mSwapChain;
70     IDirect3DSurface9 *mBackBuffer;
71     IDirect3DSurface9 *mRenderTarget;
72     IDirect3DSurface9 *mDepthStencil;
73     IDirect3DTexture9 *mOffscreenTexture;
74 
75     SurfaceRenderTarget9 mColorRenderTarget;
76     SurfaceRenderTarget9 mDepthStencilRenderTarget;
77 };
78 
79 }  // namespace rx
80 #endif  // LIBANGLE_RENDERER_D3D_D3D9_SWAPCHAIN9_H_
81