• 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_Direct3DSurface8_hpp
16 #define D3D8_Direct3DSurface8_hpp
17 
18 #include "Unknown.hpp"
19 #include "Surface.hpp"
20 
21 #include <d3d8.h>
22 
23 namespace D3D8
24 {
25 	class Direct3DDevice8;
26 	class Direct3DResource8;
27 	class Direct3DBaseTexture8;
28 
29 	class Direct3DSurface8 : public IDirect3DSurface8, public Unknown, public sw::Surface
30 	{
31 	public:
32 		Direct3DSurface8(Direct3DDevice8 *device, Unknown *container, int width, int height, D3DFORMAT format, D3DPOOL pool, D3DMULTISAMPLE_TYPE multiSample, bool lockable, unsigned long usage);
33 
34 		~Direct3DSurface8() override;
35 
36 		// Surface methods
37 		void *lockInternal(int x, int y, int z, sw::Lock lock, sw::Accessor client) override;
38 		void unlockInternal() override;
39 
40 		// IUnknown methods
41 		long __stdcall QueryInterface(const IID &iid, void **object) override;
42 		unsigned long __stdcall AddRef() override;
43 		unsigned long __stdcall Release() override;
44 
45 		// IDirect3DSurface8 methods
46 		long __stdcall GetDevice(IDirect3DDevice8 **device) override;
47 		long __stdcall SetPrivateData(const GUID &guid, const void *data, unsigned long size, unsigned long flags) override;
48 		long __stdcall GetPrivateData(const GUID &guid, void *data, unsigned long *size) override;
49 		long __stdcall FreePrivateData(const GUID &guid) override;
50 		long __stdcall GetContainer(const IID &iid, void **container) override;
51 		long __stdcall GetDesc(D3DSURFACE_DESC *desc) override;
52 		long __stdcall LockRect(D3DLOCKED_RECT *lockedRect, const RECT *rect, unsigned long Flags) override;
53 		long __stdcall UnlockRect() override;
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);   // FIXME: Surface::size
61 
62 		// Creation parameters
63 		Direct3DDevice8 *const device;
64 		Unknown *const container;
65 		const int width;
66 		const int height;
67 		const D3DFORMAT format;
68 		const D3DMULTISAMPLE_TYPE multiSample;
69 		const D3DPOOL pool;
70 		const bool lockable;
71 		const unsigned long usage;
72 
73 		Direct3DBaseTexture8 *parentTexture;
74 		Direct3DResource8 *resource;
75 	};
76 }
77 
78 #endif // D3D8_Direct3DSurface8_hpp
79