4 * Copyright (C) 2005-2013 Team XBMC
7 * This Program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This Program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with XBMC; see the file COPYING. If not, see
19 * <http://www.gnu.org/licenses/>.
25 #include "cores/VideoRenderers/BaseRenderer.h"
26 #include "guilib/Geometry.h"
27 #include "guilib/Resolution.h"
28 #include "threads/SharedSection.h"
29 #include "threads/Thread.h"
30 #include "settings/VideoSettings.h"
31 #include "OverlayRenderer.h"
35 namespace DXVA { class CProcessor; }
36 namespace VAAPI { class CSurfaceHolder; }
38 struct DVDVideoPicture;
40 #define ERRORBUFFSIZE 30
44 class CLinuxRendererGL;
45 class CLinuxRendererGLES;
47 class CXBMCRenderManager
51 ~CXBMCRenderManager();
53 // Functions called from the GUI
54 void GetVideoRect(CRect &source, CRect &dest);
55 float GetAspectRatio();
56 void Update(bool bPauseDrawing);
57 void RenderUpdate(bool clear, DWORD flags = 0, DWORD alpha = 255);
58 void SetupScreenshot();
60 CRenderCapture* AllocRenderCapture();
61 void ReleaseRenderCapture(CRenderCapture* capture);
62 void Capture(CRenderCapture *capture, unsigned int width, unsigned int height, int flags);
63 void ManageCaptures();
65 void SetViewMode(int iViewMode);
67 // Functions called from mplayer
68 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);
71 int AddVideoPicture(DVDVideoPicture& picture);
73 void FlipPage(volatile bool& bStop, double timestamp = 0.0, int source = -1, EFIELDSYNC sync = FS_NONE);
74 unsigned int PreInit();
78 void AddOverlay(CDVDOverlay* o, double pts)
80 CSharedLock lock(m_sharedSection);
81 m_overlays.AddOverlay(o, pts);
84 void AddCleanup(OVERLAY::COverlay* o)
86 CSharedLock lock(m_sharedSection);
87 m_overlays.AddCleanup(o);
92 RESOLUTION GetResolution();
94 float GetMaximumFPS();
95 inline bool Paused() { return m_bPauseDrawing; };
96 inline bool IsStarted() { return m_bIsStarted;}
97 double GetDisplayLatency() { return m_displayLatency; }
99 bool Supports(ERENDERFEATURE feature);
100 bool Supports(EDEINTERLACEMODE method);
101 bool Supports(EINTERLACEMETHOD method);
102 bool Supports(ESCALINGMETHOD method);
104 EINTERLACEMETHOD AutoInterlaceMethod(EINTERLACEMETHOD mInt);
106 double GetPresentTime();
107 void WaitPresentTime(double presenttime);
109 CStdString GetVSyncState();
111 void UpdateResolution();
114 CLinuxRendererGL *m_pRenderer;
116 CLinuxRendererGLES *m_pRenderer;
117 #elif defined(HAS_DX)
118 CWinRenderer *m_pRenderer;
119 #elif defined(HAS_SDL)
120 CLinuxRenderer *m_pRenderer;
123 unsigned int GetProcessorSize();
125 // Supported pixel formats, can be called before configure
126 std::vector<ERenderFormat> SupportedFormats();
129 void Recover(); // called after resolution switch if something special is needed
131 CSharedSection& GetSection() { return m_sharedSection; };
133 void RegisterRenderUpdateCallBack(const void *ctx, RenderUpdateCallBackFn fn);
136 void Render(bool clear, DWORD flags, DWORD alpha);
138 void PresentSingle(bool clear, DWORD flags, DWORD alpha);
139 void PresentFields(bool clear, DWORD flags, DWORD alpha);
140 void PresentBlend(bool clear, DWORD flags, DWORD alpha);
142 EINTERLACEMETHOD AutoInterlaceMethodInternal(EINTERLACEMETHOD mInt);
144 bool m_bPauseDrawing; // true if we should pause rendering
147 CSharedSection m_sharedSection;
149 bool m_bReconfigured;
163 PRESENT_METHOD_SINGLE = 0,
164 PRESENT_METHOD_BLEND,
165 PRESENT_METHOD_WEAVE,
169 double m_displayLatency;
170 void UpdateDisplayLatency();
172 double m_presenttime;
173 double m_presentcorr;
175 double m_errorbuff[ERRORBUFFSIZE];
177 EFIELDSYNC m_presentfield;
178 EPRESENTMETHOD m_presentmethod;
179 EPRESENTSTEP m_presentstep;
181 CEvent m_presentevent;
185 OVERLAY::CRenderer m_overlays;
187 void RenderCapture(CRenderCapture* capture);
188 void RemoveCapture(CRenderCapture* capture);
189 CCriticalSection m_captCritSect;
190 std::list<CRenderCapture*> m_captures;
191 //set to true when adding something to m_captures, set to false when m_captures is made empty
192 //std::list::empty() isn't thread safe, using an extra bool will save a lock per render when no captures are requested
196 extern CXBMCRenderManager g_renderManager;