kodi
VideoFilterShaderGL.h
1 /*
2  * Copyright (C) 2007-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 "GLSLOutput.h"
12 #include "cores/VideoSettings.h"
13 #include "guilib/Shader.h"
14 
15 #include "system_gl.h"
16 
17 namespace Shaders {
18 
19 namespace GL
20 {
21 
23 {
24 public:
26  ~BaseVideoFilterShader() override;
27  virtual bool GetTextureFilter(GLint& filter) { return false; }
28 
29  void SetSourceTexture(GLint ytex) { m_sourceTexUnit = ytex; }
30  void SetWidth(int w)
31  {
32  m_width = w;
33  m_stepX = w > 0 ? 1.0f / w : 0;
34  }
35  void SetHeight(int h)
36  {
37  m_height = h;
38  m_stepY = h > 0 ? 1.0f / h : 0;
39  }
40  void SetNonLinStretch(float stretch) { m_stretch = stretch; }
41  void SetAlpha(GLfloat alpha) { m_alpha = alpha; }
42 
43  GLint GetVertexLoc() { return m_hVertex; }
44  GLint GetCoordLoc() { return m_hCoord; }
45 
46  void SetMatrices(const GLfloat* p, const GLfloat* m)
47  {
48  m_proj = p;
49  m_model = m;
50  }
51 
52 protected:
53  int m_width;
54  int m_height;
55  float m_stepX;
56  float m_stepY;
57  float m_stretch;
58  GLfloat m_alpha;
59  GLint m_sourceTexUnit = 0;
60  const GLfloat* m_proj = nullptr;
61  const GLfloat* m_model = nullptr;
62 
63  // shader attribute handles
64  GLint m_hSourceTex = 0;
65  GLint m_hStepXY = 0;
66  GLint m_hStretch = -1;
67  GLint m_hAlpha = -1;
68  GLint m_hVertex = -1;
69  GLint m_hCoord = -1;
70  GLint m_hProj = -1;
71  GLint m_hModel = -1;
72  };
73 
75  {
76  public:
77  ConvolutionFilterShader(ESCALINGMETHOD method, bool stretch, GLSLOutput *output=NULL);
78  ~ConvolutionFilterShader() override;
79  void OnCompiledAndLinked() override;
80  bool OnEnabled() override;
81  void OnDisabled() override;
82  void Free();
83 
84  bool GetTextureFilter(GLint& filter) override { filter = GL_NEAREST; return true; }
85 
86  protected:
87  // kernel textures
88  GLuint m_kernelTex1 = 0;
89 
90  // shader handles to kernel textures
91  GLint m_hKernTex;
92 
93  ESCALINGMETHOD m_method;
94  bool m_floattex; //if float textures are supported
95  GLint m_internalformat;
96 
97  GLSLOutput* m_glslOutput;
98  };
99 
101  {
102  public:
104  void OnCompiledAndLinked() override;
105  bool OnEnabled() override;
106  };
107 
109  {
110  public:
111  void OnCompiledAndLinked() override;
112  bool OnEnabled() override;
113  };
114 
115  } // namespace GL
116 } // end namespace
117 
118 
Definition: VideoFilterShaderGL.h:100
Definition: LinuxRendererGL.h:30
Definition: VideoFilterShaderGL.h:74
Definition: VideoFilterShaderGL.h:22
Definition: Shader.h:148
Definition: GLSLOutput.h:18
Definition: VideoFilterShaderGL.h:108