blob: bdf64075ec0dc864730031508d30ae0e7ed6bea5 [file] [log] [blame]
Nicolas Capens0bac2852016-05-07 06:09:58 -04001// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
Nicolas Capensee16f0d2015-07-16 17:40:10 -04002//
Nicolas Capens0bac2852016-05-07 06:09:58 -04003// 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 Capensee16f0d2015-07-16 17:40:10 -04006//
Nicolas Capens0bac2852016-05-07 06:09:58 -04007// http://www.apache.org/licenses/LICENSE-2.0
Nicolas Capensee16f0d2015-07-16 17:40:10 -04008//
Nicolas Capens0bac2852016-05-07 06:09:58 -04009// 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 Capensee16f0d2015-07-16 17:40:10 -040014
15#ifndef D3D9_Direct3DSwapChain9_hpp
16#define D3D9_Direct3DSwapChain9_hpp
17
18#include "Unknown.hpp"
19
20#include "Direct3DSurface9.hpp"
21
Nicolas Capens66839432015-07-17 11:45:49 -040022#include "FrameBufferWin.hpp"
Nicolas Capensee16f0d2015-07-16 17:40:10 -040023
24#include <d3d9.h>
25
26namespace 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 Capens66839432015-07-17 11:45:49 -040069 sw::FrameBufferWin *frameBuffer;
Nicolas Capensee16f0d2015-07-16 17:40:10 -040070
71 public: // FIXME
72 Direct3DSurface9 *backBuffer[3];
73 };
74}
75
76#endif // D3D9_Direct3DSwapChain9_hpp