[cosmetics] update date in GPL header
[vuplus_xbmc] / xbmc / cores / VideoRenderers / VideoShaders / VideoFilterShader.h
1 #ifndef __VIDEOFILTER_SHADER_H__
2 #define __VIDEOFILTER_SHADER_H__
3
4 /*
5  *      Copyright (C) 2007-2013 Team XBMC
6  *      http://www.xbmc.org
7  *
8  *  This Program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2, or (at your option)
11  *  any later version.
12  *
13  *  This Program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with XBMC; see the file COPYING.  If not, see
20  *  <http://www.gnu.org/licenses/>.
21  *
22  */
23
24 #include "system.h"
25
26 #if defined(HAS_GL) || HAS_GLES == 2
27 #include "system_gl.h"
28
29
30 #include "guilib/Shader.h"
31 #include "settings/VideoSettings.h"
32
33 namespace Shaders {
34
35   class BaseVideoFilterShader : public CGLSLShaderProgram
36   {
37   public:
38     BaseVideoFilterShader();
39     void Free() { CGLSLShaderProgram::Free(); }
40     virtual void  SetSourceTexture(GLint ytex) { m_sourceTexUnit = ytex; }
41     virtual void  SetWidth(int w)     { m_width  = w; m_stepX = w>0?1.0f/w:0; }
42     virtual void  SetHeight(int h)    { m_height = h; m_stepY = h>0?1.0f/h:0; }
43     virtual void  SetNonLinStretch(float stretch) { m_stretch = stretch; }
44     virtual bool  GetTextureFilter(GLint& filter) { return false; }
45
46   protected:
47     int   m_width;
48     int   m_height;
49     float m_stepX;
50     float m_stepY;
51     float m_stretch;
52     GLint m_sourceTexUnit;
53
54     // shader attribute handles
55     GLint m_hSourceTex;
56     GLint m_hStepXY;
57     GLint m_hStretch;
58   };
59
60   class ConvolutionFilterShader : public BaseVideoFilterShader
61   {
62   public:
63     ConvolutionFilterShader(ESCALINGMETHOD method, bool stretch);
64     void OnCompiledAndLinked();
65     bool OnEnabled();
66     void Free();
67
68     virtual bool GetTextureFilter(GLint& filter) { filter = GL_NEAREST; return true; }
69
70   protected:
71     // kernel textures
72     GLuint m_kernelTex1;
73
74     // shader handles to kernel textures
75     GLint m_hKernTex;
76
77     ESCALINGMETHOD m_method;
78     bool           m_floattex; //if float textures are supported
79     GLint          m_internalformat;
80   };
81
82   class StretchFilterShader : public BaseVideoFilterShader
83   {
84     public:
85       StretchFilterShader();
86       void  OnCompiledAndLinked();
87       bool  OnEnabled();
88   };
89
90 } // end namespace
91
92 #endif
93
94 #endif //__VIDEOFILTER_SHADER_H__