StreamBuffer.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /**
  2. * Copyright (c) 2006-2018 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. #pragma once
  21. // LOVE
  22. #include "common/int.h"
  23. #include "vertex.h"
  24. #include "Resource.h"
  25. // C
  26. #include <cstddef>
  27. namespace love
  28. {
  29. namespace graphics
  30. {
  31. class StreamBuffer : public Resource
  32. {
  33. public:
  34. struct MapInfo
  35. {
  36. uint8 *data = nullptr;
  37. size_t size = 0;
  38. MapInfo() {}
  39. MapInfo(uint8 *data, size_t size)
  40. : data(data)
  41. , size(size)
  42. {}
  43. };
  44. virtual ~StreamBuffer() {}
  45. size_t getSize() const { return bufferSize; }
  46. BufferType getMode() const { return mode; }
  47. size_t getUsableSize() const { return bufferSize - frameGPUReadOffset; }
  48. virtual MapInfo map(size_t minsize) = 0;
  49. virtual size_t unmap(size_t usedsize) = 0;
  50. virtual void markUsed(size_t usedsize) = 0;
  51. virtual void nextFrame() {}
  52. protected:
  53. StreamBuffer(BufferType mode, size_t size);
  54. size_t bufferSize;
  55. size_t frameGPUReadOffset;
  56. BufferType mode;
  57. }; // StreamBuffer
  58. } // graphics
  59. } // love