• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The SwiftShader Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //    http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef D3D9_Direct3DSwapChain9_hpp
16 #define D3D9_Direct3DSwapChain9_hpp
17 
18 #include "Unknown.hpp"
19 
20 #include "Direct3DSurface9.hpp"
21 
22 #include "FrameBufferWin.hpp"
23 
24 #include <d3d9.h>
25 
26 namespace D3D9
27 {
28 	class Direct3DDevice9;
29 
30 	class Direct3DSwapChain9 : public IDirect3DSwapChain9, public Unknown
31 	{
32 	public:
33 		Direct3DSwapChain9(Direct3DDevice9 *device, D3DPRESENT_PARAMETERS *presentParameters);
34 
35 		~Direct3DSwapChain9() override;
36 
37 		// IUnknown methods
38 		long __stdcall QueryInterface(const IID &iid, void **object) override;
39 		unsigned long __stdcall AddRef() override;
40 		unsigned long __stdcall Release() override;
41 
42 		// IDirect3DSwapChain9 methods
43 		long __stdcall Present(const RECT *sourceRect, const RECT *destRect, HWND destWindowOverride, const RGNDATA *dirtyRegion, unsigned long flags) override;
44 		long __stdcall GetFrontBufferData(IDirect3DSurface9 *destSurface) override;
45 		long __stdcall GetBackBuffer(unsigned int index, D3DBACKBUFFER_TYPE type, IDirect3DSurface9 **backBuffer) override;
46 		long __stdcall GetRasterStatus(D3DRASTER_STATUS *rasterStatus) override;
47 		long __stdcall GetDisplayMode(D3DDISPLAYMODE *displayMode) override;
48 		long __stdcall GetDevice(IDirect3DDevice9 **device) override;
49 		long __stdcall GetPresentParameters(D3DPRESENT_PARAMETERS *presentParameters) override;
50 
51 		// Internal methods
52 		void reset(D3DPRESENT_PARAMETERS *presentParameters);
53 
54 		void setGammaRamp(sw::GammaRamp *gammaRamp, bool calibrate);
55 		void getGammaRamp(sw::GammaRamp *gammaRamp);
56 
57 		void *lockBackBuffer(int index);
58 		void unlockBackBuffer(int index);
59 
60 	private:
61 		void release();
62 
63 		// Creation parameters
64 		Direct3DDevice9 *const device;
65 		D3DPRESENT_PARAMETERS presentParameters;
66 
67 		bool lockable;
68 
69 		sw::FrameBufferWin *frameBuffer;
70 
71 	public:   // FIXME
72 		Direct3DSurface9 *backBuffer[3];
73 	};
74 }
75 
76 #endif // D3D9_Direct3DSwapChain9_hpp
77