This repository has been archived by the owner on Sep 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 75
/
RenderManager.h
197 lines (152 loc) · 5.4 KB
/
RenderManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#pragma once
/*
* Copyright (C) 2005-2008 Team XBMC
* http://www.xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#include <list>
#include "cores/VideoRenderers/BaseRenderer.h"
#include "guilib/Geometry.h"
#include "guilib/Resolution.h"
#include "threads/SharedSection.h"
#include "threads/Thread.h"
#include "settings/VideoSettings.h"
#include "OverlayRenderer.h"
class CRenderCapture;
namespace DXVA { class CProcessor; }
namespace VAAPI { class CSurfaceHolder; }
class CVDPAU;
struct DVDVideoPicture;
#define ERRORBUFFSIZE 30
class CWinRenderer;
class CLinuxRenderer;
class CLinuxRendererGL;
class CLinuxRendererGLES;
class CXBMCRenderManager
{
public:
CXBMCRenderManager();
~CXBMCRenderManager();
// Functions called from the GUI
void GetVideoRect(CRect &source, CRect &dest);
float GetAspectRatio();
void Update(bool bPauseDrawing);
void RenderUpdate(bool clear, DWORD flags = 0, DWORD alpha = 255);
void SetupScreenshot();
CRenderCapture* AllocRenderCapture();
void ReleaseRenderCapture(CRenderCapture* capture);
void Capture(CRenderCapture *capture, unsigned int width, unsigned int height, int flags);
void ManageCaptures();
void SetViewMode(int iViewMode);
// Functions called from mplayer
bool Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags, ERenderFormat format, unsigned extended_format, unsigned int orientation);
bool IsConfigured();
int AddVideoPicture(DVDVideoPicture& picture);
void FlipPage(volatile bool& bStop, double timestamp = 0.0, int source = -1, EFIELDSYNC sync = FS_NONE);
unsigned int PreInit();
void UnInit();
bool Flush();
void AddOverlay(CDVDOverlay* o, double pts)
{
CSharedLock lock(m_sharedSection);
m_overlays.AddOverlay(o, pts);
}
void AddCleanup(OVERLAY::COverlay* o)
{
CSharedLock lock(m_sharedSection);
m_overlays.AddCleanup(o);
}
void Reset();
RESOLUTION GetResolution();
float GetMaximumFPS();
inline bool Paused() { return m_bPauseDrawing; };
inline bool IsStarted() { return m_bIsStarted;}
double GetDisplayLatency() { return m_displayLatency; }
bool Supports(ERENDERFEATURE feature);
bool Supports(EDEINTERLACEMODE method);
bool Supports(EINTERLACEMETHOD method);
bool Supports(ESCALINGMETHOD method);
EINTERLACEMETHOD AutoInterlaceMethod(EINTERLACEMETHOD mInt);
double GetPresentTime();
void WaitPresentTime(double presenttime);
CStdString GetVSyncState();
void UpdateResolution();
#ifdef HAS_GL
CLinuxRendererGL *m_pRenderer;
#elif HAS_GLES == 2
CLinuxRendererGLES *m_pRenderer;
#elif defined(HAS_DX)
CWinRenderer *m_pRenderer;
#elif defined(HAS_SDL)
CLinuxRenderer *m_pRenderer;
#endif
unsigned int GetProcessorSize();
// Supported pixel formats, can be called before configure
std::vector<ERenderFormat> SupportedFormats();
void Present();
void Recover(); // called after resolution switch if something special is needed
CSharedSection& GetSection() { return m_sharedSection; };
void RegisterRenderUpdateCallBack(const void *ctx, RenderUpdateCallBackFn fn);
protected:
void Render(bool clear, DWORD flags, DWORD alpha);
void PresentSingle(bool clear, DWORD flags, DWORD alpha);
void PresentFields(bool clear, DWORD flags, DWORD alpha);
void PresentBlend(bool clear, DWORD flags, DWORD alpha);
EINTERLACEMETHOD AutoInterlaceMethodInternal(EINTERLACEMETHOD mInt);
bool m_bPauseDrawing; // true if we should pause rendering
bool m_bIsStarted;
CSharedSection m_sharedSection;
bool m_bReconfigured;
int m_rendermethod;
enum EPRESENTSTEP
{
PRESENT_IDLE = 0
, PRESENT_FLIP
, PRESENT_FRAME
, PRESENT_FRAME2
};
enum EPRESENTMETHOD
{
PRESENT_METHOD_SINGLE = 0,
PRESENT_METHOD_BLEND,
PRESENT_METHOD_WEAVE,
PRESENT_METHOD_BOB,
};
double m_displayLatency;
void UpdateDisplayLatency();
double m_presenttime;
double m_presentcorr;
double m_presenterr;
double m_errorbuff[ERRORBUFFSIZE];
int m_errorindex;
EFIELDSYNC m_presentfield;
EPRESENTMETHOD m_presentmethod;
EPRESENTSTEP m_presentstep;
int m_presentsource;
CEvent m_presentevent;
CEvent m_flushEvent;
OVERLAY::CRenderer m_overlays;
void RenderCapture(CRenderCapture* capture);
void RemoveCapture(CRenderCapture* capture);
CCriticalSection m_captCritSect;
std::list<CRenderCapture*> m_captures;
//set to true when adding something to m_captures, set to false when m_captures is made empty
//std::list::empty() isn't thread safe, using an extra bool will save a lock per render when no captures are requested
bool m_hasCaptures;
};
extern CXBMCRenderManager g_renderManager;