Debian Codegraph @

xbmc/cores/RetroPlayer/buffers/RenderBufferDMA.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/buffers/BaseRenderBuffer.h"
12
13 #include <memory>
14
15 #include "system_gl.h"
16
17 class CEGLImage;
18 class IBufferObject;
19
20 namespace KODI
21 {
22 namespace RETRO
23 {
24 class CRenderContext;
25
26 /**
27 * @brief Special IRenderBuffer implementation for use with CBufferObject.
28 * This buffer type uses Direct Memory Access (DMA) sharing via file
29 * descriptors (fds). The file descriptor is then used to create an
30 * EGL image.
31 *
32 */
33 class CRenderBufferDMA : public CBaseRenderBuffer
34 {
35 public:
36 CRenderBufferDMA(CRenderContext& context, int fourcc);
37 ~CRenderBufferDMA() override;
38
39 // implementation of IRenderBuffer via CRenderBufferSysMem
40 bool Allocate(AVPixelFormat format, unsigned int width, unsigned int height) override;
41 size_t GetFrameSize() const override;
42 uint8_t* GetMemory() override;
43 void ReleaseMemory() override;
44
45 // implementation of IRenderBuffer
46 bool UploadTexture() override;
47
48 GLuint TextureID() const { return m_textureId; }
49
50 protected:
51 // Construction parameters
52 CRenderContext& m_context;
53 const int m_fourcc = 0;
54
55 const GLenum m_textureTarget = GL_TEXTURE_2D;
56 GLuint m_textureId = 0;
57
58 private:
59 void CreateTexture();
60 void DeleteTexture();
61
62 std::unique_ptr<CEGLImage> m_egl;
63 std::unique_ptr<IBufferObject> m_bo;
64 };
65 } // namespace RETRO
66 } // namespace KODI