Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 1 | // Copyright 2016 The SwiftShader Authors. All Rights Reserved. |
Nicolas Capens | ee16f0d | 2015-07-16 17:40:10 -0400 | [diff] [blame] | 2 | // |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 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 |
Nicolas Capens | ee16f0d | 2015-07-16 17:40:10 -0400 | [diff] [blame] | 6 | // |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
Nicolas Capens | ee16f0d | 2015-07-16 17:40:10 -0400 | [diff] [blame] | 8 | // |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 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. |
Nicolas Capens | ee16f0d | 2015-07-16 17:40:10 -0400 | [diff] [blame] | 14 | |
| 15 | #ifndef D3D9_Direct3DSwapChain9_hpp |
| 16 | #define D3D9_Direct3DSwapChain9_hpp |
| 17 | |
| 18 | #include "Unknown.hpp" |
| 19 | |
| 20 | #include "Direct3DSurface9.hpp" |
| 21 | |
Nicolas Capens | 6683943 | 2015-07-17 11:45:49 -0400 | [diff] [blame] | 22 | #include "FrameBufferWin.hpp" |
Nicolas Capens | ee16f0d | 2015-07-16 17:40:10 -0400 | [diff] [blame] | 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 | virtual ~Direct3DSwapChain9(); |
| 36 | |
| 37 | // IUnknown methods |
| 38 | long __stdcall QueryInterface(const IID &iid, void **object); |
| 39 | unsigned long __stdcall AddRef(); |
| 40 | unsigned long __stdcall Release(); |
| 41 | |
| 42 | // IDirect3DSwapChain9 methods |
| 43 | long __stdcall Present(const RECT *sourceRect, const RECT *destRect, HWND destWindowOverride, const RGNDATA *dirtyRegion, unsigned long flags); |
| 44 | long __stdcall GetFrontBufferData(IDirect3DSurface9 *destSurface); |
| 45 | long __stdcall GetBackBuffer(unsigned int index, D3DBACKBUFFER_TYPE type, IDirect3DSurface9 **backBuffer); |
| 46 | long __stdcall GetRasterStatus(D3DRASTER_STATUS *rasterStatus); |
| 47 | long __stdcall GetDisplayMode(D3DDISPLAYMODE *displayMode); |
| 48 | long __stdcall GetDevice(IDirect3DDevice9 **device); |
| 49 | long __stdcall GetPresentParameters(D3DPRESENT_PARAMETERS *presentParameters); |
| 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 | |
Nicolas Capens | 6683943 | 2015-07-17 11:45:49 -0400 | [diff] [blame] | 69 | sw::FrameBufferWin *frameBuffer; |
Nicolas Capens | ee16f0d | 2015-07-16 17:40:10 -0400 | [diff] [blame] | 70 | |
| 71 | public: // FIXME |
| 72 | Direct3DSurface9 *backBuffer[3]; |
| 73 | }; |
| 74 | } |
| 75 | |
| 76 | #endif // D3D9_Direct3DSwapChain9_hpp |