[videodb] remove unused seasons table from episode_view
[xbmc.git] / xbmc / cores / VideoPlayer / VideoRenderers / LinuxRendererGLES.h
blob5fb5118fbd4ba99511ab14d52b686816e49bcd36
1 /*
2 * Copyright (C) 2010-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 <vector>
13 #include "system_gl.h"
15 #include "BaseRenderer.h"
16 #include "cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.h"
17 #include "cores/VideoSettings.h"
18 #include "FrameBufferObject.h"
19 #include "guilib/Shader.h"
20 #include "RenderFlags.h"
21 #include "RenderInfo.h"
22 #include "windowing/GraphicContext.h"
24 extern "C" {
25 #include <libavutil/mastering_display_metadata.h>
28 class CRenderCapture;
29 class CRenderSystemGLES;
31 class CTexture;
32 namespace Shaders
34 namespace GLES
36 class BaseYUV2RGBGLSLShader;
37 class BaseVideoFilterShader;
39 } // namespace Shaders
41 enum RenderMethod
43 RENDER_GLSL = 0x01,
44 RENDER_CUSTOM = 0x02,
47 enum RenderQuality
49 RQ_LOW = 1,
50 RQ_SINGLEPASS,
51 RQ_MULTIPASS,
52 RQ_SOFTWARE
55 class CEvent;
57 class CLinuxRendererGLES : public CBaseRenderer
59 public:
60 CLinuxRendererGLES();
61 ~CLinuxRendererGLES() override;
63 // Registration
64 static CBaseRenderer* Create(CVideoBuffer *buffer);
65 static bool Register();
67 // Player functions
68 bool Configure(const VideoPicture& picture, float fps, unsigned int orientation) override;
69 bool IsConfigured() override { return m_bConfigured; }
70 void AddVideoPicture(const VideoPicture& picture, int index) override;
71 void UnInit() override;
72 bool Flush(bool saveBuffers) override;
73 void SetBufferSize(int numBuffers) override { m_NumYV12Buffers = numBuffers; }
74 bool IsGuiLayer() override;
75 void ReleaseBuffer(int idx) override;
76 void RenderUpdate(int index, int index2, bool clear, unsigned int flags, unsigned int alpha) override;
77 void Update() override;
78 bool RenderCapture(int index, CRenderCapture* capture) override;
79 CRenderInfo GetRenderInfo() override;
80 bool ConfigChanged(const VideoPicture& picture) override;
82 // Feature support
83 bool SupportsMultiPassRendering() override;
84 bool Supports(ERENDERFEATURE feature) const override;
85 bool Supports(ESCALINGMETHOD method) const override;
87 CRenderCapture* GetRenderCapture() override;
89 protected:
90 static const int FIELD_FULL{0};
91 static const int FIELD_TOP{1};
92 static const int FIELD_BOT{2};
94 virtual bool Render(unsigned int flags, int index);
95 virtual void RenderUpdateVideo(bool clear, unsigned int flags = 0, unsigned int alpha = 255);
97 int NextYV12Texture();
98 virtual bool ValidateRenderTarget();
99 virtual void LoadShaders(int field=FIELD_FULL);
100 virtual void ReleaseShaders();
101 void SetTextureFilter(GLenum method);
102 void UpdateVideoFilter();
103 AVColorPrimaries GetSrcPrimaries(AVColorPrimaries srcPrimaries, unsigned int width, unsigned int height);
105 // textures
106 virtual bool UploadTexture(int index);
107 virtual void DeleteTexture(int index);
108 virtual bool CreateTexture(int index);
110 bool UploadYV12Texture(int index);
111 void DeleteYV12Texture(int index);
112 bool CreateYV12Texture(int index);
113 virtual bool SkipUploadYV12(int index) { return false; }
115 bool UploadNV12Texture(int index);
116 void DeleteNV12Texture(int index);
117 bool CreateNV12Texture(int index);
119 void CalculateTextureSourceRects(int source, int num_planes);
121 // renderers
122 void RenderToFBO(int index, int field);
123 void RenderFromFBO();
124 void RenderSinglePass(int index, int field); // single pass glsl renderer
126 // hooks for HwDec Renderered
127 virtual bool LoadShadersHook() { return false; }
128 virtual bool RenderHook(int idx) { return false; }
129 virtual void AfterRenderHook(int idx) {}
131 struct
133 CFrameBufferObject fbo;
134 float width{0.0};
135 float height{0.0};
136 } m_fbo;
138 int m_iYV12RenderBuffer{0};
139 int m_NumYV12Buffers{0};
141 bool m_bConfigured{false};
142 bool m_bValidated{false};
143 GLenum m_textureTarget = GL_TEXTURE_2D;
144 int m_renderMethod{RENDER_GLSL};
145 RenderQuality m_renderQuality{RQ_SINGLEPASS};
147 // Raw data used by renderer
148 int m_currentField{FIELD_FULL};
149 int m_reloadShaders{0};
150 CRenderSystemGLES *m_renderSystem{nullptr};
151 GLenum m_pixelStoreKey{0};
153 struct CYuvPlane
155 GLuint id{0};
156 CRect rect{0, 0, 0, 0};
158 float width{0.0};
159 float height{0.0};
161 unsigned texwidth{0};
162 unsigned texheight{0};
164 //pixels per texel
165 unsigned pixpertex_x{0};
166 unsigned pixpertex_y{0};
169 struct CPictureBuffer
171 CYuvPlane fields[MAX_FIELDS][YuvImage::MAX_PLANES];
172 YuvImage image;
174 CVideoBuffer *videoBuffer{nullptr};
175 bool loaded{false};
177 AVColorPrimaries m_srcPrimaries;
178 AVColorSpace m_srcColSpace;
179 int m_srcBits{8};
180 int m_srcTextureBits{8};
181 bool m_srcFullRange;
183 bool hasDisplayMetadata{false};
184 AVMasteringDisplayMetadata displayMetadata;
185 bool hasLightMetadata{false};
186 AVContentLightMetadata lightMetadata;
189 // YV12 decoder textures
190 // field index 0 is full image, 1 is odd scanlines, 2 is even scanlines
191 CPictureBuffer m_buffers[NUM_BUFFERS];
193 void LoadPlane(CYuvPlane& plane, int type,
194 unsigned width, unsigned height,
195 int stride, int bpp, void* data);
197 Shaders::GLES::BaseYUV2RGBGLSLShader* m_pYUVProgShader{nullptr};
198 Shaders::GLES::BaseYUV2RGBGLSLShader* m_pYUVBobShader{nullptr};
199 Shaders::GLES::BaseVideoFilterShader* m_pVideoFilterShader{nullptr};
200 ESCALINGMETHOD m_scalingMethod{VS_SCALINGMETHOD_LINEAR};
201 ESCALINGMETHOD m_scalingMethodGui{VS_SCALINGMETHOD_MAX};
202 bool m_fullRange;
203 AVColorPrimaries m_srcPrimaries;
204 bool m_toneMap = false;
205 ETONEMAPMETHOD m_toneMapMethod = VS_TONEMAPMETHOD_OFF;
206 bool m_passthroughHDR = false;
207 unsigned char* m_planeBuffer = nullptr;
208 size_t m_planeBufferSize = 0;
210 // clear colour for "black" bars
211 float m_clearColour{0.0f};
212 CRect m_viewRect;
214 private:
215 void ClearBackBuffer();
216 void ClearBackBufferQuad();
217 void DrawBlackBars();