| 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 |
#include "cores/RetroPlayer/RetroPlayerTypes.h" |
| 12 |
|
| 13 |
extern "C" |
| 14 |
{ |
| 15 |
#include <libavutil/pixfmt.h> |
| 16 |
} |
| 17 |
|
| 18 |
#include <memory> |
| 19 |
#include <stdint.h> |
| 20 |
|
| 21 |
namespace KODI |
| 22 |
{ |
| 23 |
namespace RETRO |
| 24 |
{ |
| 25 |
class IRenderBufferPool; |
| 26 |
|
| 27 |
class IRenderBuffer |
| 28 |
{ |
| 29 |
public: |
| 30 |
virtual ~IRenderBuffer() = default; |
| 31 |
|
| 32 |
// Pool functions |
| 33 |
virtual void Acquire() = 0; |
| 34 |
virtual void Acquire(std::shared_ptr<IRenderBufferPool> pool) = 0; |
| 35 |
virtual void Release() = 0; |
| 36 |
virtual IRenderBufferPool* GetPool() = 0; |
| 37 |
virtual DataAccess GetMemoryAccess() const = 0; |
| 38 |
virtual DataAlignment GetMemoryAlignment() const = 0; |
| 39 |
|
| 40 |
// Buffer functions |
| 41 |
virtual bool Allocate(AVPixelFormat format, unsigned int width, unsigned int height) = 0; |
| 42 |
virtual void Update() {} //! @todo Remove me |
| 43 |
virtual size_t GetFrameSize() const = 0; |
| 44 |
virtual uint8_t* GetMemory() = 0; |
| 45 |
virtual void ReleaseMemory() {} |
| 46 |
virtual bool UploadTexture() = 0; |
| 47 |
virtual void BindToUnit(unsigned int unit) {} |
| 48 |
virtual void SetHeader(void* header) {} |
| 49 |
|
| 50 |
// Buffer properties |
| 51 |
AVPixelFormat GetFormat() const { return m_format; } |
| 52 |
unsigned int GetWidth() const { return m_width; } |
| 53 |
unsigned int GetHeight() const { return m_height; } |
| 54 |
bool IsLoaded() const { return m_bLoaded; } |
| 55 |
void SetLoaded(bool bLoaded) { m_bLoaded = bLoaded; } |
| 56 |
bool IsRendered() const { return m_bRendered; } |
| 57 |
void SetRendered(bool bRendered) { m_bRendered = bRendered; } |
| 58 |
unsigned int GetRotation() const { return m_rotationDegCCW; } |
| 59 |
void SetRotation(unsigned int rotationDegCCW) { m_rotationDegCCW = rotationDegCCW; } |
| 60 |
|
| 61 |
protected: |
| 62 |
AVPixelFormat m_format = AV_PIX_FMT_NONE; |
| 63 |
unsigned int m_width = 0; |
| 64 |
unsigned int m_height = 0; |
| 65 |
bool m_bLoaded = false; |
| 66 |
bool m_bRendered = false; |
| 67 |
unsigned int m_rotationDegCCW = 0; |
| 68 |
}; |
| 69 |
} // namespace RETRO |
| 70 |
} // namespace KODI |