2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
11 #include "threads/Event.h"
16 CAPTURESTATE_NEEDSRENDER
,
17 CAPTURESTATE_NEEDSREADOUT
,
20 CAPTURESTATE_NEEDSDELETE
26 CRenderCapture() = default;
27 virtual ~CRenderCapture() = default;
29 virtual void BeginRender() = 0;
30 virtual void EndRender() = 0;
32 virtual void ReadOut() {}
33 virtual void* GetRenderBuffer() { return m_pixels
; }
35 /* \brief Called by the rendermanager to set the state, should not be called by anything else */
36 void SetState(ECAPTURESTATE state
) { m_state
= state
; }
38 /* \brief Called by the rendermanager to get the state, should not be called by anything else */
39 ECAPTURESTATE
GetState() { return m_state
;}
41 /* \brief Called by the rendermanager to set the userstate, should not be called by anything else */
42 void SetUserState(ECAPTURESTATE state
) { m_userState
= state
; }
44 /* \brief Called by the code requesting the capture
45 \return CAPTURESTATE_WORKING when the capture is in progress,
46 CAPTURESTATE_DONE when the capture has succeeded,
47 CAPTURESTATE_FAILED when the capture has failed
49 ECAPTURESTATE
GetUserState() { return m_userState
; }
51 /* \brief The internal event will be set when the rendermanager has captured and read a videoframe, or when it has failed
52 \return A reference to m_event
54 CEvent
& GetEvent() { return m_event
; }
56 /* \brief Called by the rendermanager to set the flags, should not be called by anything else */
57 void SetFlags(int flags
) { m_flags
= flags
; }
59 /* \brief Called by the rendermanager to get the flags, should not be called by anything else */
60 int GetFlags() { return m_flags
; }
62 /* \brief Called by the rendermanager to set the width, should not be called by anything else */
63 void SetWidth(unsigned int width
) { m_width
= width
; }
65 /* \brief Called by the rendermanager to set the height, should not be called by anything else */
66 void SetHeight(unsigned int height
) { m_height
= height
; }
68 /* \brief Called by the code requesting the capture to get the width */
69 unsigned int GetWidth() { return m_width
; }
71 /* \brief Called by the code requesting the capture to get the height */
72 unsigned int GetHeight() { return m_height
; }
74 /* \brief Called by the code requesting the capture to get the buffer where the videoframe is stored,
75 the format is BGRA, this buffer is only valid when GetUserState returns CAPTURESTATE_DONE.
76 The size of the buffer is GetWidth() * GetHeight() * 4.
78 uint8_t* GetPixels() const { return m_pixels
; }
80 /* \brief Called by the rendermanager to know if the capture is readout async (using dma for example),
81 should not be called by anything else.
83 bool IsAsync() { return m_asyncSupported
; }
86 bool UseOcclusionQuery();
88 ECAPTURESTATE m_state
{CAPTURESTATE_FAILED
}; //state for the rendermanager
89 ECAPTURESTATE m_userState
{CAPTURESTATE_FAILED
}; //state for the thread that wants the capture
93 uint8_t* m_pixels
{nullptr};
94 unsigned int m_width
{0};
95 unsigned int m_height
{0};
96 unsigned int m_bufferSize
{0};
98 // this is set after the first render
99 bool m_asyncSupported
{false};
100 bool m_asyncChecked
{false};