• 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 D3D8_Direct3DSwapChain8_hpp
16 #define D3D8_Direct3DSwapChain8_hpp
17 
18 #include "Unknown.hpp"
19 
20 #include "Direct3DSurface8.hpp"
21 
22 #include "FrameBufferWin.hpp"
23 
24 #include <d3d8.h>
25 
26 namespace D3D8
27 {
28 	class Direct3DSwapChain8 : public IDirect3DSwapChain8, public Unknown
29 	{
30 	public:
31 		Direct3DSwapChain8(Direct3DDevice8 *device, D3DPRESENT_PARAMETERS *presentParameters);
32 
33 		~Direct3DSwapChain8() override;
34 
35 		// IUnknown methods
36 		long __stdcall QueryInterface(const IID &iid, void **object) override;
37 		unsigned long __stdcall AddRef() override;
38 		unsigned long __stdcall Release() override;
39 
40 		// IDirect3DSwapChain8 methods
41 	    long __stdcall Present(const RECT *sourceRect, const RECT *destRect, HWND destWindowOverride, const RGNDATA *dirtyRegion) override;
42 	    long __stdcall GetBackBuffer(unsigned int index, D3DBACKBUFFER_TYPE type, IDirect3DSurface8 **backBuffer) override;
43 
44 		// Internal methods
45 		void reset(D3DPRESENT_PARAMETERS *presentParameters);
46 
47 		void screenshot(void *destBuffer);
48 		void setGammaRamp(sw::GammaRamp *gammaRamp, bool calibrate);
49 		void getGammaRamp(sw::GammaRamp *gammaRamp);
50 
51 		void *lockBackBuffer(int index);
52 		void unlockBackBuffer(int index);
53 
54 	private:
55 		void release();
56 
57 		// Creation parameters
58 		Direct3DDevice8 *const device;
59 		D3DPRESENT_PARAMETERS presentParameters;
60 
61 		bool lockable;
62 
63 		sw::FrameBufferWin *frameBuffer;
64 
65 	public:   // FIXME
66 		Direct3DSurface8 *backBuffer[3];   // NOTE: Up to three
67 	};
68 }
69 
70 #endif // D3D8_Direct3DSwapChain8_hpp
71