KiCad PCB EDA Suite
antialiasing.h
Go to the documentation of this file.
1 /*
2 * This program source code file is part of KICAD, a free EDA CAD application.
3 *
4 * Copyright (C) 2016 Kicad Developers, see change_log.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23 
24 #ifndef OPENGL_ANTIALIASING_H__
25 #define OPENGL_ANTIALIASING_H__
26 
27 #include <memory>
28 #include <gal/opengl/shader.h>
29 #include <math/vector2d.h>
30 
31 namespace KIGFX {
32 
33  class OPENGL_COMPOSITOR;
34 
36  {
37  public:
39  {
40  }
41 
42  virtual bool Init() = 0;
43  virtual unsigned int CreateBuffer() = 0;
44 
45  virtual VECTOR2U GetInternalBufferSize() = 0;
46  virtual void OnLostBuffers() = 0;
47 
48  virtual void Begin() = 0;
49  virtual void DrawBuffer( GLuint aBuffer ) = 0;
50  virtual void Present() = 0;
51  };
52 
53 
55  {
56  public:
57  ANTIALIASING_NONE( OPENGL_COMPOSITOR* aCompositor );
58 
59  bool Init() override;
60  unsigned int CreateBuffer() override;
61 
63  void OnLostBuffers() override;
64 
65  void Begin() override;
66  void DrawBuffer( GLuint aBuffer ) override;
67  void Present() override;
68 
69  private:
71  };
72 
73  enum class SUPERSAMPLING_MODE {
74  X2,
75  X4
76  };
77 
78 
80  {
81  public:
83 
84  bool Init() override;
85  unsigned int CreateBuffer() override;
86 
88  void OnLostBuffers() override;
89 
90  void Begin() override;
91  void DrawBuffer( GLuint ) override;
92  void Present() override;
93 
94  private:
97 
98  unsigned int ssaaMainBuffer;
100 
102  std::unique_ptr<SHADER> x4_shader;
103  };
104 
105  enum class SMAA_QUALITY {
106  HIGH,
107  ULTRA
108  };
109 
111  {
112  public:
113  ANTIALIASING_SMAA( OPENGL_COMPOSITOR* aCompositor, SMAA_QUALITY aQuality );
114 
115  bool Init() override;
116  unsigned int CreateBuffer () override;
117 
118  VECTOR2U GetInternalBufferSize() override;
119  void OnLostBuffers() override;
120 
121  void Begin() override;
122  void DrawBuffer( GLuint buffer ) override;
123  void Present() override;
124 
125  private:
126  void loadShaders();
127  void updateUniforms();
128 
130 
131  unsigned int smaaBaseBuffer; // base + overlay temporary
132  unsigned int smaaEdgesBuffer;
133  unsigned int smaaBlendBuffer;
134 
135  // smaa shader lookup textures
136  unsigned int smaaAreaTex;
137  unsigned int smaaSearchTex;
138 
140 
141  std::unique_ptr<SHADER> pass_1_shader;
143 
144  std::unique_ptr<SHADER> pass_2_shader;
146 
147  std::unique_ptr<SHADER> pass_3_shader;
149 
152  };
153 
154 }
155 
156 #endif
SUPERSAMPLING_MODE
Definition: antialiasing.h:73
VECTOR2U GetInternalBufferSize() override
virtual void Begin()=0
void Present() override
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:58
virtual void DrawBuffer(GLuint aBuffer)=0
ANTIALIASING_NONE(OPENGL_COMPOSITOR *aCompositor)
virtual bool Init()=0
unsigned int smaaEdgesBuffer
Definition: antialiasing.h:132
VECTOR2U GetInternalBufferSize() override
unsigned int smaaSearchTex
Definition: antialiasing.h:137
void DrawBuffer(GLuint aBuffer) override
std::unique_ptr< SHADER > x4_shader
Definition: antialiasing.h:102
OPENGL_COMPOSITOR * compositor
Definition: antialiasing.h:70
VECTOR2U GetInternalBufferSize() override
virtual unsigned int CreateBuffer()=0
void DrawBuffer(GLuint buffer) override
void DrawBuffer(GLuint) override
virtual void OnLostBuffers()=0
ANTIALIASING_SUPERSAMPLING(OPENGL_COMPOSITOR *aCompositor, SUPERSAMPLING_MODE aMode)
unsigned int smaaBlendBuffer
Definition: antialiasing.h:133
OPENGL_COMPOSITOR * compositor
Definition: antialiasing.h:95
std::unique_ptr< SHADER > pass_2_shader
Definition: antialiasing.h:144
std::unique_ptr< SHADER > pass_3_shader
Definition: antialiasing.h:147
unsigned int CreateBuffer() override
std::unique_ptr< SHADER > pass_1_shader
Definition: antialiasing.h:141
virtual VECTOR2U GetInternalBufferSize()=0
OPENGL_COMPOSITOR * compositor
Definition: antialiasing.h:151
unsigned int CreateBuffer() override
ANTIALIASING_SMAA(OPENGL_COMPOSITOR *aCompositor, SMAA_QUALITY aQuality)
unsigned int CreateBuffer() override
virtual void Present()=0
void OnLostBuffers() override
void OnLostBuffers() override
unsigned int smaaBaseBuffer
Definition: antialiasing.h:131