• 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_Direct3DSurface9_hpp
16 #define D3D9_Direct3DSurface9_hpp
17 
18 #include "Direct3DResource9.hpp"
19 
20 #include "Surface.hpp"
21 
22 #include <d3d9.h>
23 
24 namespace D3D9
25 {
26 	class Direct3DBaseTexture9;
27 
28 	class Direct3DSurface9 : public IDirect3DSurface9, public Direct3DResource9, public sw::Surface
29 	{
30 	public:
31 		Direct3DSurface9(Direct3DDevice9 *device, Unknown *container, int width, int height, D3DFORMAT format, D3DPOOL pool, D3DMULTISAMPLE_TYPE multiSample, unsigned int quality, bool lockableOverride, unsigned long usage);
32 
33 		virtual ~Direct3DSurface9();
34 
35 		// IUnknown methods
36 		long __stdcall QueryInterface(const IID &iid, void **object);
37 		unsigned long __stdcall AddRef();
38 		unsigned long __stdcall Release();
39 
40 		// IDirect3DResource9 methods
41 		long __stdcall FreePrivateData(const GUID &guid);
42 		long __stdcall GetPrivateData(const GUID &guid, void *data, unsigned long *size);
43 		void __stdcall PreLoad();
44 		long __stdcall SetPrivateData(const GUID &guid, const void *data, unsigned long size, unsigned long flags);
45 		long __stdcall GetDevice(IDirect3DDevice9 **device);
46 		unsigned long __stdcall SetPriority(unsigned long newPriority);
47 		unsigned long __stdcall GetPriority();
48 		D3DRESOURCETYPE __stdcall GetType();
49 
50 		// IDirect3DSurface9 methods
51 		long __stdcall GetDC(HDC *deviceContext);
52 		long __stdcall ReleaseDC(HDC deviceContext);
53 		long __stdcall LockRect(D3DLOCKED_RECT *lockedRect, const RECT *rect, unsigned long Flags);
54 		long __stdcall UnlockRect();
55 		long __stdcall GetContainer(const IID &iid, void **container);
56 		long __stdcall GetDesc(D3DSURFACE_DESC *desc);
57 
58 		// Internal methods
59 		static sw::Format translateFormat(D3DFORMAT format);
60 		static int bytes(D3DFORMAT format);
61 
62 	private:
63 		static unsigned int memoryUsage(int width, int height, D3DFORMAT format);
64 
65 		// Creation parameters
66 		Unknown *const container;
67 		const int width;
68 		const int height;
69 		const D3DFORMAT format;
70 		const D3DMULTISAMPLE_TYPE multiSample;
71 		const unsigned int quality;
72 		const D3DPOOL pool;
73 		const bool lockable;
74 		const unsigned long usage;
75 
76 		Direct3DBaseTexture9 *parentTexture;
77 	};
78 }
79 
80 #endif // D3D9_Direct3DSurface9_hpp
81