blob: fa5f48129b32a423df5feb918bebef6a2658b66c [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_Direct3DSurface9_hpp
16#define D3D9_Direct3DSurface9_hpp
17
18#include "Direct3DResource9.hpp"
19
20#include "Surface.hpp"
21
22#include <d3d9.h>
23
24namespace 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
Nicolas Capens3b9e1ea2017-06-12 12:43:48 -040033 ~Direct3DSurface9() override;
34
35 // Surface methods
36 void *lockInternal(int x, int y, int z, sw::Lock lock, sw::Accessor client) override;
37 void unlockInternal() override;
Nicolas Capensee16f0d2015-07-16 17:40:10 -040038
39 // IUnknown methods
Nicolas Capens3b9e1ea2017-06-12 12:43:48 -040040 long __stdcall QueryInterface(const IID &iid, void **object) override;
41 unsigned long __stdcall AddRef() override;
42 unsigned long __stdcall Release() override;
Nicolas Capensee16f0d2015-07-16 17:40:10 -040043
44 // IDirect3DResource9 methods
Nicolas Capens3b9e1ea2017-06-12 12:43:48 -040045 long __stdcall FreePrivateData(const GUID &guid) override;
46 long __stdcall GetPrivateData(const GUID &guid, void *data, unsigned long *size) override;
47 void __stdcall PreLoad() override;
48 long __stdcall SetPrivateData(const GUID &guid, const void *data, unsigned long size, unsigned long flags) override;
49 long __stdcall GetDevice(IDirect3DDevice9 **device) override;
50 unsigned long __stdcall SetPriority(unsigned long newPriority) override;
51 unsigned long __stdcall GetPriority() override;
52 D3DRESOURCETYPE __stdcall GetType() override;
Nicolas Capensee16f0d2015-07-16 17:40:10 -040053
54 // IDirect3DSurface9 methods
Nicolas Capens3b9e1ea2017-06-12 12:43:48 -040055 long __stdcall GetDC(HDC *deviceContext) override;
56 long __stdcall ReleaseDC(HDC deviceContext) override;
57 long __stdcall LockRect(D3DLOCKED_RECT *lockedRect, const RECT *rect, unsigned long Flags) override;
58 long __stdcall UnlockRect() override;
59 long __stdcall GetContainer(const IID &iid, void **container) override;
60 long __stdcall GetDesc(D3DSURFACE_DESC *desc) override;
Nicolas Capensee16f0d2015-07-16 17:40:10 -040061
62 // Internal methods
63 static sw::Format translateFormat(D3DFORMAT format);
64 static int bytes(D3DFORMAT format);
65
66 private:
Nicolas Capensbfa23b32017-12-11 10:06:37 -050067 static unsigned int memoryUsage(int width, int height, D3DMULTISAMPLE_TYPE multiSample, unsigned int quality, D3DFORMAT format);
Nicolas Capensee16f0d2015-07-16 17:40:10 -040068
69 // Creation parameters
70 Unknown *const container;
71 const int width;
72 const int height;
73 const D3DFORMAT format;
74 const D3DMULTISAMPLE_TYPE multiSample;
75 const unsigned int quality;
76 const D3DPOOL pool;
77 const bool lockable;
78 const unsigned long usage;
79
80 Direct3DBaseTexture9 *parentTexture;
81 };
82}
83
84#endif // D3D9_Direct3DSurface9_hpp