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