[3d] fix stretched gui in sbs/ou mode when using hq scalers
[vuplus_xbmc] / xbmc / rendering / RenderSystem.h
1 /*
2  *      Copyright (C) 2005-2013 Team XBMC
3  *      http://xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 #ifndef RENDER_SYSTEM_H
22 #define RENDER_SYSTEM_H
23
24 #pragma once
25
26 #include "guilib/Geometry.h"
27 #include "guilib/TransformMatrix.h"
28 #include "guilib/DirtyRegion.h"
29 #include "utils/StdString.h"
30 #include <stdint.h>
31
32 typedef enum _RenderingSystemType
33 {
34   RENDERING_SYSTEM_OPENGL,
35   RENDERING_SYSTEM_DIRECTX,
36   RENDERING_SYSTEM_OPENGLES
37 } RenderingSystemType;
38
39 /*
40 *   CRenderSystemBase interface allows us to create the rendering engine we use.
41 *   We currently have two engines: OpenGL and DirectX
42 *   This interface is very basic since a lot of the actual details will go in to the derived classes
43 */
44
45 typedef uint32_t color_t;
46
47 enum
48 {
49   RENDER_CAPS_DXT      = (1 << 0),
50   RENDER_CAPS_NPOT     = (1 << 1),
51   RENDER_CAPS_DXT_NPOT = (1 << 2),
52   RENDER_CAPS_BGRA     = (1 << 3),
53   RENDER_CAPS_BGRA_APPLE = (1 << 4)
54 };
55
56 enum
57 {
58   RENDER_QUIRKS_MAJORMEMLEAK_OVERLAYRENDERER = 1 << 0,
59   RENDER_QUIRKS_YV12_PREFERED                = 1 << 1,
60   RENDER_QUIRKS_BROKEN_OCCLUSION_QUERY       = 1 << 2,
61 };
62
63 enum RENDER_STEREO_VIEW
64 {
65   RENDER_STEREO_VIEW_OFF,
66   RENDER_STEREO_VIEW_LEFT,
67   RENDER_STEREO_VIEW_RIGHT,
68 };
69
70 enum RENDER_STEREO_MODE
71 {
72   RENDER_STEREO_MODE_OFF,
73   RENDER_STEREO_MODE_SPLIT_HORIZONTAL,
74   RENDER_STEREO_MODE_SPLIT_VERTICAL,
75   RENDER_STEREO_MODE_ANAGLYPH_RED_CYAN,
76   RENDER_STEREO_MODE_ANAGLYPH_GREEN_MAGENTA,
77   RENDER_STEREO_MODE_INTERLACED,
78   RENDER_STEREO_MODE_HARDWAREBASED,
79   RENDER_STEREO_MODE_MONO,
80   RENDER_STEREO_MODE_COUNT,
81
82   // psuevdo modes
83   RENDER_STEREO_MODE_AUTO = 100,
84 };
85
86
87 class CRenderSystemBase
88 {
89 public:
90   CRenderSystemBase();
91   virtual ~CRenderSystemBase();
92
93   // Retrieve
94   RenderingSystemType GetRenderingSystemType() { return m_enumRenderingSystem; }
95
96   virtual bool InitRenderSystem() = 0;
97   virtual bool DestroyRenderSystem() = 0;
98   virtual bool ResetRenderSystem(int width, int height, bool fullScreen, float refreshRate) = 0;
99
100   virtual bool BeginRender() = 0;
101   virtual bool EndRender() = 0;
102   virtual bool PresentRender(const CDirtyRegionList& dirty) = 0;
103   virtual bool ClearBuffers(color_t color) = 0;
104   virtual bool IsExtSupported(const char* extension) = 0;
105
106   virtual void SetVSync(bool vsync) = 0;
107   bool GetVSync() { return m_bVSync; }
108
109   virtual void SetViewPort(CRect& viewPort) = 0;
110   virtual void GetViewPort(CRect& viewPort) = 0;
111   virtual void RestoreViewPort() {};
112
113   virtual void SetScissors(const CRect &rect) = 0;
114   virtual void ResetScissors() = 0;
115
116   virtual void CaptureStateBlock() = 0;
117   virtual void ApplyStateBlock() = 0;
118
119   virtual void SetCameraPosition(const CPoint &camera, int screenWidth, int screenHeight) = 0;
120   virtual void ApplyHardwareTransform(const TransformMatrix &matrix) = 0;
121   virtual void RestoreHardwareTransform() = 0;
122   virtual void SetStereoMode(RENDER_STEREO_MODE mode, RENDER_STEREO_VIEW view)
123   {
124     m_stereoMode = mode;
125     m_stereoView = view;
126   }
127
128   virtual bool TestRender() = 0;
129
130   /**
131    * Project (x,y,z) 3d scene coordinates to (x,y) 2d screen coordinates
132    */
133   virtual void Project(float &x, float &y, float &z) { }
134
135   void GetRenderVersion(unsigned int& major, unsigned int& minor) const;
136   const CStdString& GetRenderVendor() const { return m_RenderVendor; }
137   const CStdString& GetRenderRenderer() const { return m_RenderRenderer; }
138   const CStdString& GetRenderVersionString() const { return m_RenderVersion; }
139   bool SupportsDXT() const;
140   bool SupportsBGRA() const;
141   bool SupportsBGRAApple() const;
142   bool SupportsNPOT(bool dxt) const;
143   bool SupportsStereo(RENDER_STEREO_MODE mode) const;
144   unsigned int GetMaxTextureSize() const { return m_maxTextureSize; }
145   unsigned int GetMinDXTPitch() const { return m_minDXTPitch; }
146   unsigned int GetRenderQuirks() const { return m_renderQuirks; }
147
148 protected:
149   bool                m_bRenderCreated;
150   RenderingSystemType m_enumRenderingSystem;
151   bool                m_bVSync;
152   unsigned int        m_maxTextureSize;
153   unsigned int        m_minDXTPitch;
154
155   CStdString   m_RenderRenderer;
156   CStdString   m_RenderVendor;
157   CStdString   m_RenderVersion;
158   int          m_RenderVersionMinor;
159   int          m_RenderVersionMajor;
160   unsigned int m_renderCaps;
161   unsigned int m_renderQuirks;
162   RENDER_STEREO_VIEW m_stereoView;
163   RENDER_STEREO_MODE m_stereoMode;
164 };
165
166 #endif // RENDER_SYSTEM_H