blob: 5ccecf36bdb09fe00a9b70107429397bd9e763fb [file] [log] [blame]
Nicolas Capens17b29fd2016-09-15 09:32:16 -04001// 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
23namespace 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
Nicolas Capens3b9e1ea2017-06-12 12:43:48 -040034 ~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;
Nicolas Capens17b29fd2016-09-15 09:32:16 -040039
40 // IUnknown methods
Nicolas Capens3b9e1ea2017-06-12 12:43:48 -040041 long __stdcall QueryInterface(const IID &iid, void **object) override;
42 unsigned long __stdcall AddRef() override;
43 unsigned long __stdcall Release() override;
Nicolas Capens17b29fd2016-09-15 09:32:16 -040044
45 // IDirect3DSurface8 methods
Nicolas Capens3b9e1ea2017-06-12 12:43:48 -040046 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;
Nicolas Capens17b29fd2016-09-15 09:32:16 -040054
55 // Internal methods
56 static sw::Format translateFormat(D3DFORMAT format);
57 static int bytes(D3DFORMAT format);
58
59 private:
Nicolas Capens4e2f4e22017-12-14 12:32:51 -050060 static unsigned int memoryUsage(int width, int height, D3DMULTISAMPLE_TYPE multiSample, D3DFORMAT format); // FIXME: Surface::size
Nicolas Capens17b29fd2016-09-15 09:32:16 -040061
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