1 /* 2 * Copyright (C) 2017-2018 Team Kodi 3 * This file is part of Kodi - https://kodi.tv 4 * 5 * SPDX-License-Identifier: GPL-2.0-or-later 6 * See LICENSES/README.md for more information. 7 */ 8 9 #pragma once 10 11 extern "C" 12 { 13 #include <libavutil/pixfmt.h> 14 } 15 16 #include <memory> 17 #include <stdint.h> 18 19 namespace KODI 20 { 21 namespace RETRO 22 { 23 class IRenderBufferPool; 24 25 class IRenderBuffer 26 { 27 public: 28 virtual ~IRenderBuffer() = default; 29 30 // Pool functions 31 virtual void Acquire() = 0; 32 virtual void Acquire(std::shared_ptr<IRenderBufferPool> pool) = 0; 33 virtual void Release() = 0; 34 virtual IRenderBufferPool* GetPool() = 0; 35 36 // Buffer functions 37 virtual bool Allocate(AVPixelFormat format, unsigned int width, unsigned int height) = 0; Update()38 virtual void Update() {} //! @todo Remove me 39 virtual size_t GetFrameSize() const = 0; 40 virtual uint8_t* GetMemory() = 0; ReleaseMemory()41 virtual void ReleaseMemory() {} 42 virtual bool UploadTexture() = 0; BindToUnit(unsigned int unit)43 virtual void BindToUnit(unsigned int unit) {} SetHeader(void * header)44 virtual void SetHeader(void* header) {} 45 46 // Buffer properties GetFormat()47 AVPixelFormat GetFormat() const { return m_format; } GetWidth()48 unsigned int GetWidth() const { return m_width; } GetHeight()49 unsigned int GetHeight() const { return m_height; } IsLoaded()50 bool IsLoaded() const { return m_bLoaded; } SetLoaded(bool bLoaded)51 void SetLoaded(bool bLoaded) { m_bLoaded = bLoaded; } IsRendered()52 bool IsRendered() const { return m_bRendered; } SetRendered(bool bRendered)53 void SetRendered(bool bRendered) { m_bRendered = bRendered; } GetRotation()54 unsigned int GetRotation() const { return m_rotationDegCCW; } SetRotation(unsigned int rotationDegCCW)55 void SetRotation(unsigned int rotationDegCCW) { m_rotationDegCCW = rotationDegCCW; } 56 57 protected: 58 AVPixelFormat m_format = AV_PIX_FMT_NONE; 59 unsigned int m_width = 0; 60 unsigned int m_height = 0; 61 bool m_bLoaded = false; 62 bool m_bRendered = false; 63 unsigned int m_rotationDegCCW = 0; 64 }; 65 } // namespace RETRO 66 } // namespace KODI 67