| 1 | /** |
| 2 | * Copyright (c) 2006-2023 LOVE Development Team |
| 3 | * |
| 4 | * This software is provided 'as-is', without any express or implied |
| 5 | * warranty. In no event will the authors be held liable for any damages |
| 6 | * arising from the use of this software. |
| 7 | * |
| 8 | * Permission is granted to anyone to use this software for any purpose, |
| 9 | * including commercial applications, and to alter it and redistribute it |
| 10 | * freely, subject to the following restrictions: |
| 11 | * |
| 12 | * 1. The origin of this software must not be misrepresented; you must not |
| 13 | * claim that you wrote the original software. If you use this software |
| 14 | * in a product, an acknowledgment in the product documentation would be |
| 15 | * appreciated but is not required. |
| 16 | * 2. Altered source versions must be plainly marked as such, and must not be |
| 17 | * misrepresented as being the original software. |
| 18 | * 3. This notice may not be removed or altered from any source distribution. |
| 19 | **/ |
| 20 | |
| 21 | #pragma once |
| 22 | |
| 23 | // LOVE |
| 24 | #include "common/int.h" |
| 25 | #include "vertex.h" |
| 26 | #include "Resource.h" |
| 27 | |
| 28 | // C |
| 29 | #include <cstddef> |
| 30 | |
| 31 | namespace love |
| 32 | { |
| 33 | namespace graphics |
| 34 | { |
| 35 | |
| 36 | class StreamBuffer : public Resource |
| 37 | { |
| 38 | public: |
| 39 | |
| 40 | struct MapInfo |
| 41 | { |
| 42 | uint8 *data = nullptr; |
| 43 | size_t size = 0; |
| 44 | |
| 45 | MapInfo() {} |
| 46 | |
| 47 | MapInfo(uint8 *data, size_t size) |
| 48 | : data(data) |
| 49 | , size(size) |
| 50 | {} |
| 51 | }; |
| 52 | |
| 53 | virtual ~StreamBuffer() {} |
| 54 | |
| 55 | size_t getSize() const { return bufferSize; } |
| 56 | BufferType getMode() const { return mode; } |
| 57 | size_t getUsableSize() const { return bufferSize - frameGPUReadOffset; } |
| 58 | |
| 59 | virtual MapInfo map(size_t minsize) = 0; |
| 60 | virtual size_t unmap(size_t usedsize) = 0; |
| 61 | virtual void markUsed(size_t usedsize) = 0; |
| 62 | |
| 63 | virtual void nextFrame() {} |
| 64 | |
| 65 | protected: |
| 66 | |
| 67 | StreamBuffer(BufferType mode, size_t size); |
| 68 | |
| 69 | size_t bufferSize; |
| 70 | size_t frameGPUReadOffset; |
| 71 | BufferType mode; |
| 72 | |
| 73 | }; // StreamBuffer |
| 74 | |
| 75 | } // graphics |
| 76 | } // love |
| 77 | |