Debian Codegraph @

xbmc/cores/RetroPlayer/buffers/IRenderBufferPool.h

raw
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 CRenderBufferManager;
26 class CRenderVideoSettings;
27 class CRPBaseRenderer;
28 class IRenderBuffer;
29
30 class IRenderBufferPool : public std::enable_shared_from_this<IRenderBufferPool>
31 {
32 public:
33 virtual ~IRenderBufferPool() = default;
34
35 virtual void RegisterRenderer(CRPBaseRenderer* renderer) = 0;
36 virtual void UnregisterRenderer(CRPBaseRenderer* renderer) = 0;
37 virtual bool HasVisibleRenderer() const = 0;
38
39 virtual bool Configure(AVPixelFormat format) = 0;
40
41 virtual bool IsConfigured() const = 0;
42
43 virtual bool IsCompatible(const CRenderVideoSettings& renderSettings) const = 0;
44
45 /*!
46 * \brief Get a free buffer from the pool, sets ref count to 1
47 *
48 * \param width The horizontal pixel count of the buffer
49 * \param height The vertical pixel could of the buffer
50 *
51 * \return The allocated buffer, or nullptr on failure
52 */
53 virtual IRenderBuffer* GetBuffer(unsigned int width, unsigned int height) = 0;
54
55 /*!
56 * \brief Called by buffer when ref count goes to zero
57 *
58 * \param buffer A fully dereferenced buffer
59 */
60 virtual void Return(IRenderBuffer* buffer) = 0;
61
62 virtual void Prime(unsigned int width, unsigned int height) = 0;
63
64 virtual void Flush() = 0;
65
66 virtual DataAccess GetMemoryAccess() const { return DataAccess::READ_WRITE; }
67 virtual DataAlignment GetMemoryAlignment() const { return DataAlignment::DATA_UNALIGNED; }
68
69 /*!
70 * \brief Call in GetBuffer() before returning buffer to caller
71 */
72 virtual std::shared_ptr<IRenderBufferPool> GetPtr() { return shared_from_this(); }
73 };
74 } // namespace RETRO
75 } // namespace KODI