|
KiCad PCB EDA Suite
|
#include <opengl_compositor.h>
Classes | |
| struct | OPENGL_BUFFER |
Public Member Functions | |
| OPENGL_COMPOSITOR () | |
| virtual | ~OPENGL_COMPOSITOR () |
| virtual void | Initialize () override |
| Perform primary initialization, necessary to use the object. | |
| virtual void | Resize (unsigned int aWidth, unsigned int aHeight) override |
| Clear the state of COMPOSITOR, so it has to be reinitialized again with the new dimensions. | |
| virtual unsigned int | CreateBuffer () override |
| Prepare a new buffer that may be used as a rendering target. | |
| virtual void | SetBuffer (unsigned int aBufferHandle) override |
| Set the selected buffer as the rendering target. | |
| virtual unsigned int | GetBuffer () const override |
| Return currently used buffer handle. | |
| virtual void | ClearBuffer (const COLOR4D &aColor) override |
| Clear the selected buffer (set by the SetBuffer() function). | |
| virtual void | DrawBuffer (unsigned int aBufferHandle) override |
| Draw the selected buffer to the output buffer. | |
| virtual void | Begin () override |
| Call this at the beginning of each frame. | |
| virtual void | Present () override |
| Call this to present the output buffer to the screen. | |
| VECTOR2I | GetScreenSize () const |
| GLenum | GetBufferTexture (unsigned int aBufferHandle) |
| void | DrawBuffer (unsigned int aSourceHandle, unsigned int aDestHandle) |
| void | DrawBufferDifference (unsigned int aSourceHandle, unsigned int aDestHandle) |
| Draw buffer with difference blending (XOR-style for gerbview). | |
| unsigned int | CreateBuffer (VECTOR2I aDimensions) |
| void | SetAntialiasingMode (GAL_ANTIALIASING_MODE aMode) |
| GAL_ANTIALIASING_MODE | GetAntialiasingMode () const |
| int | GetAntialiasSupersamplingFactor () const |
| VECTOR2D | GetAntialiasRenderingOffset () const |
Static Public Attributes | |
| static const unsigned int | DIRECT_RENDERING = 0 |
Protected Types | |
| typedef std::deque< OPENGL_BUFFER > | OPENGL_BUFFERS |
Protected Member Functions | |
| void | bindFb (unsigned int aFb) |
| Binds a specific Framebuffer Object. | |
| void | clean () |
| Perform freeing of resources. | |
| unsigned int | usedBuffers () |
| Returns number of used buffers. | |
| bool | initDifferenceShader () |
| Initialize the difference shader program. | |
| void | drawFullScreenQuad () |
| Draw a fullscreen quad for compositing. | |
Protected Attributes | |
| bool | m_initialized |
| Initialization status flag. | |
| unsigned int | m_curBuffer |
| Currently used buffer handle. | |
| GLuint | m_mainFbo |
| Main FBO handle (storing all target textures) | |
| GLuint | m_depthBuffer |
| Depth buffer handle. | |
| OPENGL_BUFFERS | m_buffers |
| Stores information about initialized buffers. | |
| GLuint | m_curFbo |
| Store the used FBO name in case there was more than one compositor used. | |
| GAL_ANTIALIASING_MODE | m_currentAntialiasingMode |
| std::unique_ptr< OPENGL_PRESENTOR > | m_antialiasing |
| GLuint | m_differenceShader |
| Difference shader program. | |
| GLint | m_diffSrcTexUniform |
| Source texture uniform location. | |
| GLint | m_diffDstTexUniform |
| Destination texture uniform location. | |
| bool | m_differenceShaderInitialized |
| unsigned int | m_width |
| Width of the buffer (in pixels) | |
| unsigned int | m_height |
| Height of the buffer (in pixels) | |
Definition at line 46 of file opengl_compositor.h.
|
protected |
Definition at line 137 of file opengl_compositor.h.
| OPENGL_COMPOSITOR::OPENGL_COMPOSITOR | ( | ) |
Definition at line 52 of file opengl_compositor.cpp.
References KIGFX::AA_NONE, DIRECT_RENDERING, m_antialiasing, m_curBuffer, m_curFbo, m_currentAntialiasingMode, m_depthBuffer, m_diffDstTexUniform, m_differenceShader, m_differenceShaderInitialized, m_diffSrcTexUniform, m_initialized, and m_mainFbo.
|
virtual |
Definition at line 68 of file opengl_compositor.cpp.
References clean(), and m_initialized.
|
overridevirtual |
Call this at the beginning of each frame.
Implements KIGFX::COMPOSITOR.
Definition at line 316 of file opengl_compositor.cpp.
References m_antialiasing.
|
protected |
Binds a specific Framebuffer Object.
Definition at line 380 of file opengl_compositor.cpp.
References checkGlError(), DIRECT_RENDERING, m_curFbo, and m_mainFbo.
Referenced by clean(), CreateBuffer(), DrawBufferDifference(), Initialize(), and SetBuffer().
|
protected |
Perform freeing of resources.
Definition at line 394 of file opengl_compositor.cpp.
References bindFb(), DIRECT_RENDERING, m_buffers, m_depthBuffer, m_differenceShader, m_differenceShaderInitialized, m_initialized, and m_mainFbo.
Referenced by Resize(), SetAntialiasingMode(), and ~OPENGL_COMPOSITOR().
|
overridevirtual |
Clear the selected buffer (set by the SetBuffer() function).
Implements KIGFX::COMPOSITOR.
Definition at line 297 of file opengl_compositor.cpp.
References KIGFX::COLOR4D::b, DIRECT_RENDERING, KIGFX::COLOR4D::g, m_curFbo, m_initialized, and KIGFX::COLOR4D::r.
Referenced by CreateBuffer().
|
overridevirtual |
Prepare a new buffer that may be used as a rendering target.
Implements KIGFX::COMPOSITOR.
Definition at line 167 of file opengl_compositor.cpp.
References m_antialiasing.
| unsigned int OPENGL_COMPOSITOR::CreateBuffer | ( | VECTOR2I | aDimensions | ) |
Definition at line 173 of file opengl_compositor.cpp.
References bindFb(), KIGFX::COLOR4D::BLACK, checkGlError(), ClearBuffer(), DIRECT_RENDERING, m_buffers, m_initialized, m_mainFbo, usedBuffers(), VECTOR2< T >::x, and VECTOR2< T >::y.
|
overridevirtual |
Draw the selected buffer to the output buffer.
| aBufferHandle | is the handle of the buffer to be drawn. |
Implements KIGFX::COMPOSITOR.
Definition at line 322 of file opengl_compositor.cpp.
References m_antialiasing.
Referenced by DrawBufferDifference().
| void OPENGL_COMPOSITOR::DrawBuffer | ( | unsigned int | aSourceHandle, |
| unsigned int | aDestHandle ) |
Definition at line 328 of file opengl_compositor.cpp.
References m_buffers, m_initialized, SetBuffer(), and usedBuffers().
| void OPENGL_COMPOSITOR::DrawBufferDifference | ( | unsigned int | aSourceHandle, |
| unsigned int | aDestHandle ) |
Draw buffer with difference blending (XOR-style for gerbview).
Computes |src - dst| for each color channel, showing differences and canceling out identical overlapping content.
| aSourceHandle | Source buffer (new layer) |
| aDestHandle | Destination buffer (existing content) |
Definition at line 599 of file opengl_compositor.cpp.
References bindFb(), checkGlError(), DrawBuffer(), drawFullScreenQuad(), initDifferenceShader(), m_buffers, m_diffDstTexUniform, m_differenceShader, m_diffSrcTexUniform, m_initialized, m_mainFbo, SetBuffer(), traceGalXorMode, usedBuffers(), VECTOR2< T >::x, and VECTOR2< T >::y.
|
protected |
Draw a fullscreen quad for compositing.
Definition at line 568 of file opengl_compositor.cpp.
Referenced by DrawBufferDifference().
| GAL_ANTIALIASING_MODE OPENGL_COMPOSITOR::GetAntialiasingMode | ( | ) | const |
Definition at line 94 of file opengl_compositor.cpp.
References m_currentAntialiasingMode.
| VECTOR2D OPENGL_COMPOSITOR::GetAntialiasRenderingOffset | ( | ) | const |
Definition at line 433 of file opengl_compositor.cpp.
References KIGFX::AA_HIGHQUALITY, and m_currentAntialiasingMode.
| int OPENGL_COMPOSITOR::GetAntialiasSupersamplingFactor | ( | ) | const |
Definition at line 423 of file opengl_compositor.cpp.
References KIGFX::AA_HIGHQUALITY, and m_currentAntialiasingMode.
|
inlineoverridevirtual |
Return currently used buffer handle.
Implements KIGFX::COMPOSITOR.
Definition at line 65 of file opengl_compositor.h.
References DIRECT_RENDERING, m_curBuffer, and m_curFbo.
| GLenum OPENGL_COMPOSITOR::GetBufferTexture | ( | unsigned int | aBufferHandle | ) |
Definition at line 267 of file opengl_compositor.cpp.
References m_buffers, and usedBuffers().
| VECTOR2I OPENGL_COMPOSITOR::GetScreenSize | ( | ) | const |
Definition at line 306 of file opengl_compositor.cpp.
References KIGFX::COMPOSITOR::m_height, and KIGFX::COMPOSITOR::m_width.
Referenced by SetBuffer().
|
protected |
Initialize the difference shader program.
Definition at line 443 of file opengl_compositor.cpp.
References m_diffDstTexUniform, m_differenceShader, m_differenceShaderInitialized, m_diffSrcTexUniform, and traceGalXorMode.
Referenced by DrawBufferDifference().
|
overridevirtual |
Perform primary initialization, necessary to use the object.
Implements KIGFX::COMPOSITOR.
Definition at line 100 of file opengl_compositor.cpp.
References KIGFX::AA_FAST, KIGFX::AA_HIGHQUALITY, bindFb(), checkGlError(), DIRECT_RENDERING, m_antialiasing, m_currentAntialiasingMode, m_depthBuffer, m_initialized, m_mainFbo, VECTOR2< T >::x, and VECTOR2< T >::y.
|
overridevirtual |
Call this to present the output buffer to the screen.
Implements KIGFX::COMPOSITOR.
Definition at line 374 of file opengl_compositor.cpp.
References m_antialiasing.
|
overridevirtual |
Clear the state of COMPOSITOR, so it has to be reinitialized again with the new dimensions.
| aWidth | is the framebuffer width (in pixels). |
| aHeight | is the framebuffer height (in pixels). |
Implements KIGFX::COMPOSITOR.
Definition at line 155 of file opengl_compositor.cpp.
References clean(), m_antialiasing, KIGFX::COMPOSITOR::m_height, m_initialized, and KIGFX::COMPOSITOR::m_width.
| void OPENGL_COMPOSITOR::SetAntialiasingMode | ( | GAL_ANTIALIASING_MODE | aMode | ) |
Definition at line 85 of file opengl_compositor.cpp.
References clean(), m_currentAntialiasingMode, and m_initialized.
|
overridevirtual |
Set the selected buffer as the rendering target.
All the following drawing functions are going to be rendered in the selected buffer.
| aBufferHandle | is the handle of the buffer or 0 in case of rendering directly to the display. |
Implements KIGFX::COMPOSITOR.
Definition at line 274 of file opengl_compositor.cpp.
References bindFb(), checkGlError(), DIRECT_RENDERING, GetScreenSize(), m_buffers, m_curBuffer, m_curFbo, m_initialized, m_mainFbo, and usedBuffers().
Referenced by DrawBuffer(), and DrawBufferDifference().
|
inlineprotected |
Returns number of used buffers.
Definition at line 120 of file opengl_compositor.h.
References m_buffers.
Referenced by CreateBuffer(), DrawBuffer(), DrawBufferDifference(), GetBufferTexture(), and SetBuffer().
|
static |
Definition at line 86 of file opengl_compositor.h.
Referenced by KIGFX::OPENGL_GAL::BeginDrawing(), bindFb(), KIGFX::OPENGL_GAL::blitCursor(), clean(), ClearBuffer(), KIGFX::OPENGL_GAL::ClearScreen(), CreateBuffer(), KIGFX::ANTIALIASING_NONE::DrawBuffer(), GetBuffer(), Initialize(), OPENGL_COMPOSITOR(), KIGFX::ANTIALIASING_SMAA::Present(), KIGFX::ANTIALIASING_SUPERSAMPLING::Present(), and SetBuffer().
|
protected |
Definition at line 146 of file opengl_compositor.h.
Referenced by Begin(), CreateBuffer(), DrawBuffer(), Initialize(), OPENGL_COMPOSITOR(), Present(), and Resize().
|
protected |
Stores information about initialized buffers.
Definition at line 140 of file opengl_compositor.h.
Referenced by clean(), CreateBuffer(), DrawBuffer(), DrawBufferDifference(), GetBufferTexture(), SetBuffer(), and usedBuffers().
|
protected |
Currently used buffer handle.
Definition at line 134 of file opengl_compositor.h.
Referenced by GetBuffer(), OPENGL_COMPOSITOR(), and SetBuffer().
|
protected |
Store the used FBO name in case there was more than one compositor used.
Definition at line 143 of file opengl_compositor.h.
Referenced by bindFb(), ClearBuffer(), GetBuffer(), OPENGL_COMPOSITOR(), and SetBuffer().
|
protected |
Definition at line 145 of file opengl_compositor.h.
Referenced by GetAntialiasingMode(), GetAntialiasRenderingOffset(), GetAntialiasSupersamplingFactor(), Initialize(), OPENGL_COMPOSITOR(), and SetAntialiasingMode().
|
protected |
Depth buffer handle.
Definition at line 136 of file opengl_compositor.h.
Referenced by clean(), Initialize(), and OPENGL_COMPOSITOR().
|
protected |
Destination texture uniform location.
Definition at line 151 of file opengl_compositor.h.
Referenced by DrawBufferDifference(), initDifferenceShader(), and OPENGL_COMPOSITOR().
|
protected |
Difference shader program.
Definition at line 149 of file opengl_compositor.h.
Referenced by clean(), DrawBufferDifference(), initDifferenceShader(), and OPENGL_COMPOSITOR().
|
protected |
Definition at line 152 of file opengl_compositor.h.
Referenced by clean(), initDifferenceShader(), and OPENGL_COMPOSITOR().
|
protected |
Source texture uniform location.
Definition at line 150 of file opengl_compositor.h.
Referenced by DrawBufferDifference(), initDifferenceShader(), and OPENGL_COMPOSITOR().
|
protectedinherited |
Height of the buffer (in pixels)
Definition at line 113 of file compositor.h.
Referenced by COMPOSITOR(), KIGFX::CAIRO_COMPOSITOR::CreateBuffer(), KIGFX::OPENGL_COMPOSITOR::GetScreenSize(), KIGFX::CAIRO_COMPOSITOR::Resize(), and KIGFX::OPENGL_COMPOSITOR::Resize().
|
protected |
Initialization status flag.
Definition at line 133 of file opengl_compositor.h.
Referenced by clean(), ClearBuffer(), CreateBuffer(), DrawBuffer(), DrawBufferDifference(), Initialize(), OPENGL_COMPOSITOR(), Resize(), SetAntialiasingMode(), SetBuffer(), and ~OPENGL_COMPOSITOR().
|
protected |
Main FBO handle (storing all target textures)
Definition at line 135 of file opengl_compositor.h.
Referenced by bindFb(), clean(), CreateBuffer(), DrawBufferDifference(), Initialize(), OPENGL_COMPOSITOR(), and SetBuffer().
|
protectedinherited |
Width of the buffer (in pixels)
Definition at line 112 of file compositor.h.
Referenced by COMPOSITOR(), KIGFX::CAIRO_COMPOSITOR::CreateBuffer(), KIGFX::OPENGL_COMPOSITOR::GetScreenSize(), KIGFX::CAIRO_COMPOSITOR::Resize(), and KIGFX::OPENGL_COMPOSITOR::Resize().