1 /*
2  *  Copyright (C) 2005-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 "RenderSystemTypes.h"
12 #include "utils/Color.h"
13 #include "utils/Geometry.h"
14 
15 #include <memory>
16 #include <string>
17 
18 /*
19  *   CRenderSystemBase interface allows us to create the rendering engine we use.
20  *   We currently have two engines: OpenGL and DirectX
21  *   This interface is very basic since a lot of the actual details will go in to the derived classes
22  */
23 
24 class CGUIImage;
25 class CGUITextLayout;
26 
27 class CRenderSystemBase
28 {
29 public:
30   CRenderSystemBase();
31   virtual ~CRenderSystemBase();
32 
33   virtual bool InitRenderSystem() = 0;
34   virtual bool DestroyRenderSystem() = 0;
35   virtual bool ResetRenderSystem(int width, int height) = 0;
36 
37   virtual bool BeginRender() = 0;
38   virtual bool EndRender() = 0;
39   virtual void PresentRender(bool rendered, bool videoLayer) = 0;
40   virtual bool ClearBuffers(UTILS::Color color) = 0;
41   virtual bool IsExtSupported(const char* extension) const = 0;
42 
43   virtual void SetViewPort(const CRect& viewPort) = 0;
44   virtual void GetViewPort(CRect& viewPort) = 0;
RestoreViewPort()45   virtual void RestoreViewPort() {};
46 
ScissorsCanEffectClipping()47   virtual bool ScissorsCanEffectClipping() { return false; }
ClipRectToScissorRect(const CRect & rect)48   virtual CRect ClipRectToScissorRect(const CRect &rect) { return CRect(); }
49   virtual void SetScissors(const CRect &rect) = 0;
50   virtual void ResetScissors() = 0;
51 
52   virtual void CaptureStateBlock() = 0;
53   virtual void ApplyStateBlock() = 0;
54 
55   virtual void SetCameraPosition(const CPoint &camera, int screenWidth, int screenHeight, float stereoFactor = 0.f) = 0;
SetStereoMode(RENDER_STEREO_MODE mode,RENDER_STEREO_VIEW view)56   virtual void SetStereoMode(RENDER_STEREO_MODE mode, RENDER_STEREO_VIEW view)
57   {
58     m_stereoMode = mode;
59     m_stereoView = view;
60   }
61 
62   /**
63    * Project (x,y,z) 3d scene coordinates to (x,y) 2d screen coordinates
64    */
Project(float & x,float & y,float & z)65   virtual void Project(float &x, float &y, float &z) { }
66 
GetShaderPath(const std::string & filename)67   virtual std::string GetShaderPath(const std::string &filename) { return ""; }
68 
69   void GetRenderVersion(unsigned int& major, unsigned int& minor) const;
GetRenderVendor()70   const std::string& GetRenderVendor() const { return m_RenderVendor; }
GetRenderRenderer()71   const std::string& GetRenderRenderer() const { return m_RenderRenderer; }
GetRenderVersionString()72   const std::string& GetRenderVersionString() const { return m_RenderVersion; }
73   virtual bool SupportsNPOT(bool dxt) const;
74   virtual bool SupportsStereo(RENDER_STEREO_MODE mode) const;
GetMaxTextureSize()75   unsigned int GetMaxTextureSize() const { return m_maxTextureSize; }
GetMinDXTPitch()76   unsigned int GetMinDXTPitch() const { return m_minDXTPitch; }
77 
78   virtual void ShowSplash(const std::string& message);
79 
80 protected:
81   bool                m_bRenderCreated;
82   bool                m_bVSync;
83   unsigned int        m_maxTextureSize;
84   unsigned int        m_minDXTPitch;
85 
86   std::string   m_RenderRenderer;
87   std::string   m_RenderVendor;
88   std::string   m_RenderVersion;
89   int          m_RenderVersionMinor;
90   int          m_RenderVersionMajor;
91   RENDER_STEREO_VIEW m_stereoView = RENDER_STEREO_VIEW_OFF;
92   RENDER_STEREO_MODE m_stereoMode = RENDER_STEREO_MODE_OFF;
93   bool m_limitedColorRange = false;
94 
95   std::unique_ptr<CGUIImage> m_splashImage;
96   std::unique_ptr<CGUITextLayout> m_splashMessageLayout;
97 };
98 
99