[videodb] remove unused seasons table from episode_view
[xbmc.git] / xbmc / rendering / gles / RenderSystemGLES.h
blob9c19bf6c28be96b8502d7111170757c856ce4136
1 /*
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.
7 */
9 #pragma once
11 #include "GLESShader.h"
12 #include "rendering/RenderSystem.h"
13 #include "utils/ColorUtils.h"
14 #include "utils/Map.h"
16 #include <map>
18 #include <fmt/format.h>
20 #include "system_gl.h"
22 enum class ShaderMethodGLES
24 SM_DEFAULT,
25 SM_TEXTURE,
26 SM_MULTI,
27 SM_FONTS,
28 SM_FONTS_SHADER_CLIP,
29 SM_TEXTURE_NOBLEND,
30 SM_MULTI_BLENDCOLOR,
31 SM_TEXTURE_RGBA,
32 SM_TEXTURE_RGBA_OES,
33 SM_TEXTURE_RGBA_BLENDCOLOR,
34 SM_TEXTURE_RGBA_BOB,
35 SM_TEXTURE_RGBA_BOB_OES,
36 SM_TEXTURE_NOALPHA,
37 SM_MAX
40 template<>
41 struct fmt::formatter<ShaderMethodGLES> : fmt::formatter<std::string_view>
43 template<typename FormatContext>
44 constexpr auto format(const ShaderMethodGLES& shaderMethod, FormatContext& ctx)
46 const auto it = ShaderMethodGLESMap.find(shaderMethod);
47 if (it == ShaderMethodGLESMap.cend())
48 throw std::range_error("no string mapping found for shader method");
50 return fmt::formatter<string_view>::format(it->second, ctx);
53 private:
54 static constexpr auto ShaderMethodGLESMap = make_map<ShaderMethodGLES, std::string_view>({
55 {ShaderMethodGLES::SM_DEFAULT, "default"},
56 {ShaderMethodGLES::SM_TEXTURE, "texture"},
57 {ShaderMethodGLES::SM_MULTI, "multi"},
58 {ShaderMethodGLES::SM_FONTS, "fonts"},
59 {ShaderMethodGLES::SM_FONTS_SHADER_CLIP, "fonts with vertex shader based clipping"},
60 {ShaderMethodGLES::SM_TEXTURE_NOBLEND, "texture no blending"},
61 {ShaderMethodGLES::SM_MULTI_BLENDCOLOR, "multi blend colour"},
62 {ShaderMethodGLES::SM_TEXTURE_RGBA, "texure rgba"},
63 {ShaderMethodGLES::SM_TEXTURE_RGBA_OES, "texture rgba OES"},
64 {ShaderMethodGLES::SM_TEXTURE_RGBA_BLENDCOLOR, "texture rgba blend colour"},
65 {ShaderMethodGLES::SM_TEXTURE_RGBA_BOB, "texture rgba bob"},
66 {ShaderMethodGLES::SM_TEXTURE_RGBA_BOB_OES, "texture rgba bob OES"},
67 {ShaderMethodGLES::SM_TEXTURE_NOALPHA, "texture no alpha"},
68 });
70 static_assert(static_cast<size_t>(ShaderMethodGLES::SM_MAX) == ShaderMethodGLESMap.size(),
71 "ShaderMethodGLESMap doesn't match the size of ShaderMethodGLES, did you forget to "
72 "add/remove a mapping?");
75 class CRenderSystemGLES : public CRenderSystemBase
77 public:
78 CRenderSystemGLES();
79 ~CRenderSystemGLES() override = default;
81 bool InitRenderSystem() override;
82 bool DestroyRenderSystem() override;
83 bool ResetRenderSystem(int width, int height) override;
85 bool BeginRender() override;
86 bool EndRender() override;
87 void PresentRender(bool rendered, bool videoLayer) override;
88 void InvalidateColorBuffer() override;
89 bool ClearBuffers(KODI::UTILS::COLOR::Color color) override;
90 bool IsExtSupported(const char* extension) const override;
92 void SetVSync(bool vsync);
93 void ResetVSync() { m_bVsyncInit = false; }
95 void SetViewPort(const CRect& viewPort) override;
96 void GetViewPort(CRect& viewPort) override;
98 bool ScissorsCanEffectClipping() override;
99 CRect ClipRectToScissorRect(const CRect &rect) override;
100 void SetScissors(const CRect& rect) override;
101 void ResetScissors() override;
103 void SetDepthCulling(DEPTH_CULLING culling) override;
105 void CaptureStateBlock() override;
106 void ApplyStateBlock() override;
108 void SetCameraPosition(const CPoint &camera, int screenWidth, int screenHeight, float stereoFactor = 0.0f) override;
110 bool SupportsStereo(RENDER_STEREO_MODE mode) const override;
112 void Project(float &x, float &y, float &z) override;
114 std::string GetShaderPath(const std::string &filename) override { return "GLES/2.0/"; }
116 void InitialiseShaders();
117 void ReleaseShaders();
118 void EnableGUIShader(ShaderMethodGLES method);
119 void DisableGUIShader();
121 GLint GUIShaderGetPos();
122 GLint GUIShaderGetCol();
123 GLint GUIShaderGetCoord0();
124 GLint GUIShaderGetCoord1();
125 GLint GUIShaderGetUniCol();
126 GLint GUIShaderGetCoord0Matrix();
127 GLint GUIShaderGetField();
128 GLint GUIShaderGetStep();
129 GLint GUIShaderGetContrast();
130 GLint GUIShaderGetBrightness();
131 GLint GUIShaderGetModel();
132 GLint GUIShaderGetMatrix();
133 GLint GUIShaderGetClip();
134 GLint GUIShaderGetCoordStep();
135 GLint GUIShaderGetDepth();
137 protected:
138 virtual void SetVSyncImpl(bool enable) = 0;
139 virtual void PresentRenderImpl(bool rendered) = 0;
140 void CalculateMaxTexturesize();
142 bool m_bVsyncInit{false};
143 int m_width;
144 int m_height;
146 std::string m_RenderExtensions;
148 std::map<ShaderMethodGLES, std::unique_ptr<CGLESShader>> m_pShader;
149 ShaderMethodGLES m_method = ShaderMethodGLES::SM_DEFAULT;
151 GLint m_viewPort[4];