Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 1 | // Copyright 2016 The SwiftShader Authors. All Rights Reserved. |
Nicolas Capens | ee16f0d | 2015-07-16 17:40:10 -0400 | [diff] [blame] | 2 | // |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 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 |
Nicolas Capens | ee16f0d | 2015-07-16 17:40:10 -0400 | [diff] [blame] | 6 | // |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
Nicolas Capens | ee16f0d | 2015-07-16 17:40:10 -0400 | [diff] [blame] | 8 | // |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 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. |
Nicolas Capens | ee16f0d | 2015-07-16 17:40:10 -0400 | [diff] [blame] | 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 | |
Nicolas Capens | 3b9e1ea | 2017-06-12 12:43:48 -0400 | [diff] [blame] | 33 | ~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 Capens | ee16f0d | 2015-07-16 17:40:10 -0400 | [diff] [blame] | 38 | |
| 39 | // IUnknown methods |
Nicolas Capens | 3b9e1ea | 2017-06-12 12:43:48 -0400 | [diff] [blame] | 40 | long __stdcall QueryInterface(const IID &iid, void **object) override; |
| 41 | unsigned long __stdcall AddRef() override; |
| 42 | unsigned long __stdcall Release() override; |
Nicolas Capens | ee16f0d | 2015-07-16 17:40:10 -0400 | [diff] [blame] | 43 | |
| 44 | // IDirect3DResource9 methods |
Nicolas Capens | 3b9e1ea | 2017-06-12 12:43:48 -0400 | [diff] [blame] | 45 | 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 Capens | ee16f0d | 2015-07-16 17:40:10 -0400 | [diff] [blame] | 53 | |
| 54 | // IDirect3DSurface9 methods |
Nicolas Capens | 3b9e1ea | 2017-06-12 12:43:48 -0400 | [diff] [blame] | 55 | 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 Capens | ee16f0d | 2015-07-16 17:40:10 -0400 | [diff] [blame] | 61 | |
| 62 | // Internal methods |
| 63 | static sw::Format translateFormat(D3DFORMAT format); |
| 64 | static int bytes(D3DFORMAT format); |
| 65 | |
| 66 | private: |
Nicolas Capens | bfa23b3 | 2017-12-11 10:06:37 -0500 | [diff] [blame] | 67 | static unsigned int memoryUsage(int width, int height, D3DMULTISAMPLE_TYPE multiSample, unsigned int quality, D3DFORMAT format); |
Nicolas Capens | ee16f0d | 2015-07-16 17:40:10 -0400 | [diff] [blame] | 68 | |
| 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 |