Direct3DSurface9.hpp revision 894018228b0e0bdbd7aa7e8f47d4a9458789ca82
1// SwiftShader Software Renderer
2//
3// Copyright(c) 2005-2011 TransGaming Inc.
4//
5// All rights reserved. No part of this software may be copied, distributed, transmitted,
6// transcribed, stored in a retrieval system, translated into any human or computer
7// language by any means, or disclosed to third parties without the explicit written
8// agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express
9// or implied, including but not limited to any patent rights, are granted to you.
10//
11
12#ifndef D3D9_Direct3DSurface9_hpp
13#define D3D9_Direct3DSurface9_hpp
14
15#include "Direct3DResource9.hpp"
16
17#include "Surface.hpp"
18
19#include <d3d9.h>
20
21namespace D3D9
22{
23	class Direct3DBaseTexture9;
24
25	class Direct3DSurface9 : public IDirect3DSurface9, public Direct3DResource9, public sw::Surface
26	{
27	public:
28		Direct3DSurface9(Direct3DDevice9 *device, Unknown *container, int width, int height, D3DFORMAT format, D3DPOOL pool, D3DMULTISAMPLE_TYPE multiSample, unsigned int quality, bool lockableOverride, unsigned long usage);
29
30		virtual ~Direct3DSurface9();
31
32		// IUnknown methods
33		long __stdcall QueryInterface(const IID &iid, void **object);
34		unsigned long __stdcall AddRef();
35		unsigned long __stdcall Release();
36
37		// IDirect3DResource9 methods
38		long __stdcall FreePrivateData(const GUID &guid);
39		long __stdcall GetPrivateData(const GUID &guid, void *data, unsigned long *size);
40		void __stdcall PreLoad();
41		long __stdcall SetPrivateData(const GUID &guid, const void *data, unsigned long size, unsigned long flags);
42		long __stdcall GetDevice(IDirect3DDevice9 **device);
43		unsigned long __stdcall SetPriority(unsigned long newPriority);
44		unsigned long __stdcall GetPriority();
45		D3DRESOURCETYPE __stdcall GetType();
46
47		// IDirect3DSurface9 methods
48		long __stdcall GetDC(HDC *deviceContext);
49		long __stdcall ReleaseDC(HDC deviceContext);
50		long __stdcall LockRect(D3DLOCKED_RECT *lockedRect, const RECT *rect, unsigned long Flags);
51		long __stdcall UnlockRect();
52		long __stdcall GetContainer(const IID &iid, void **container);
53		long __stdcall GetDesc(D3DSURFACE_DESC *desc);
54
55		// Internal methods
56		static sw::Format translateFormat(D3DFORMAT format);
57		static int bytes(D3DFORMAT format);
58
59	private:
60		static unsigned int memoryUsage(int width, int height, D3DFORMAT format);
61
62		// Creation parameters
63		Unknown *const container;
64		const int width;
65		const int height;
66		const D3DFORMAT format;
67		const D3DMULTISAMPLE_TYPE multiSample;
68		const unsigned int quality;
69		const D3DPOOL pool;
70		const bool lockable;
71		const unsigned long usage;
72
73		Direct3DBaseTexture9 *parentTexture;
74	};
75}
76
77#endif // D3D9_Direct3DSurface9_hpp
78