KiCad PCB EDA Suite
Loading...
Searching...
No Matches
KIGFX::CAIRO_COMPOSITOR Class Reference

#include <cairo_compositor.h>

Inheritance diagram for KIGFX::CAIRO_COMPOSITOR:
KIGFX::COMPOSITOR

Classes

struct  CAIRO_BUFFER
 

Public Member Functions

 CAIRO_COMPOSITOR (cairo_t **aMainContext)
 
virtual ~CAIRO_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 unsigned int GetBuffer () const override
 Return currently used buffer handle.
 
virtual void SetBuffer (unsigned int aBufferHandle) override
 Set the selected buffer as the rendering target.
 
virtual void Begin () override
 Call this at the beginning of each frame.
 
virtual void ClearBuffer (const COLOR4D &aColor) override
 Clear the selected buffer (set by the SetBuffer() function).
 
void DrawBuffer (unsigned int aSourceHandle, unsigned int aDestHandle, cairo_operator_t op)
 Paints source to destination using the cairo operator.
 
virtual void DrawBuffer (unsigned int aBufferHandle) override
 Draw the selected buffer to the output buffer.
 
virtual void Present () override
 Call this to present the output buffer to the screen.
 
void SetAntialiasingMode (CAIRO_ANTIALIASING_MODE aMode)
 
CAIRO_ANTIALIASING_MODE GetAntialiasingMode () const
 
virtual void SetMainContext (cairo_t *aMainContext)
 Set a context to be treated as the main context (ie.
 

Protected Types

typedef uint8_t * BitmapPtr
 
typedef std::deque< CAIRO_BUFFERCAIRO_BUFFERS
 

Protected Member Functions

void clean ()
 Perform freeing of resources.
 
unsigned int usedBuffers ()
 Return number of currently used buffers.
 

Protected Attributes

unsigned int m_current
 Currently used buffer handle.
 
cairo_t ** m_currentContext
 Pointer to the current context, so it can be changed.
 
cairo_t * m_mainContext
 Rendering target used for compositing (the main display)
 
cairo_matrix_t m_matrix
 Transformation matrix.
 
CAIRO_BUFFERS m_buffers
 Stores information about initialized buffers.
 
unsigned int m_stride
 Stride to use given the desired format and width.
 
unsigned int m_bufferSize
 Amount of memory needed to store a buffer.
 
cairo_antialias_t m_currentAntialiasingMode
 
unsigned int m_width
 Width of the buffer (in pixels)
 
unsigned int m_height
 Height of the buffer (in pixels)
 

Detailed Description

Definition at line 44 of file cairo_compositor.h.

Member Typedef Documentation

◆ BitmapPtr

typedef uint8_t* KIGFX::CAIRO_COMPOSITOR::BitmapPtr
protected

Definition at line 129 of file cairo_compositor.h.

◆ CAIRO_BUFFERS

Definition at line 138 of file cairo_compositor.h.

Constructor & Destructor Documentation

◆ CAIRO_COMPOSITOR()

CAIRO_COMPOSITOR::CAIRO_COMPOSITOR ( cairo_t **  aMainContext)

Definition at line 38 of file cairo_compositor.cpp.

References m_bufferSize, m_matrix, and m_stride.

◆ ~CAIRO_COMPOSITOR()

CAIRO_COMPOSITOR::~CAIRO_COMPOSITOR ( )
virtual

Definition at line 51 of file cairo_compositor.cpp.

References clean().

Member Function Documentation

◆ Begin()

void CAIRO_COMPOSITOR::Begin ( )
overridevirtual

Call this at the beginning of each frame.

Implements KIGFX::COMPOSITOR.

Definition at line 133 of file cairo_compositor.cpp.

◆ clean()

void CAIRO_COMPOSITOR::clean ( )
protected

Perform freeing of resources.

Definition at line 191 of file cairo_compositor.cpp.

References m_buffers.

Referenced by Resize(), SetAntialiasingMode(), and ~CAIRO_COMPOSITOR().

◆ ClearBuffer()

void CAIRO_COMPOSITOR::ClearBuffer ( const COLOR4D aColor)
overridevirtual

Clear the selected buffer (set by the SetBuffer() function).

Implements KIGFX::COMPOSITOR.

Definition at line 138 of file cairo_compositor.cpp.

References m_buffers, m_bufferSize, and m_current.

◆ CreateBuffer()

unsigned int CAIRO_COMPOSITOR::CreateBuffer ( )
overridevirtual

Prepare a new buffer that may be used as a rendering target.

Returns
is the handle of the buffer. In case of failure 0 (zero) is returned as the handle.

Implements KIGFX::COMPOSITOR.

Definition at line 88 of file cairo_compositor.cpp.

References m_buffers, m_bufferSize, m_currentAntialiasingMode, KIGFX::COMPOSITOR::m_height, m_mainContext, m_matrix, m_stride, KIGFX::COMPOSITOR::m_width, and usedBuffers().

◆ DrawBuffer() [1/2]

void CAIRO_COMPOSITOR::DrawBuffer ( unsigned int  aBufferHandle)
overridevirtual

Draw the selected buffer to the output buffer.

Parameters
aBufferHandleis the handle of the buffer to be drawn.

Implements KIGFX::COMPOSITOR.

Definition at line 168 of file cairo_compositor.cpp.

References m_buffers, m_mainContext, m_matrix, and usedBuffers().

◆ DrawBuffer() [2/2]

void CAIRO_COMPOSITOR::DrawBuffer ( unsigned int  aSourceHandle,
unsigned int  aDestHandle,
cairo_operator_t  op 
)

Paints source to destination using the cairo operator.

Useful for differential mode.

Parameters
aSourceHandleSource buffer to paint
aDestHandleDestination buffer to paint on to
opPainting operation

Definition at line 145 of file cairo_compositor.cpp.

References m_buffers, m_mainContext, m_matrix, and usedBuffers().

◆ GetAntialiasingMode()

CAIRO_ANTIALIASING_MODE KIGFX::CAIRO_COMPOSITOR::GetAntialiasingMode ( ) const
inline

Definition at line 90 of file cairo_compositor.h.

References KIGFX::FAST, KIGFX::GOOD, m_currentAntialiasingMode, and KIGFX::NONE.

◆ GetBuffer()

virtual unsigned int KIGFX::CAIRO_COMPOSITOR::GetBuffer ( ) const
inlineoverridevirtual

Return currently used buffer handle.

Returns
Currently used buffer handle.

Implements KIGFX::COMPOSITOR.

Definition at line 60 of file cairo_compositor.h.

References m_current.

◆ Initialize()

void CAIRO_COMPOSITOR::Initialize ( )
overridevirtual

Perform primary initialization, necessary to use the object.

Implements KIGFX::COMPOSITOR.

Definition at line 57 of file cairo_compositor.cpp.

◆ Present()

void CAIRO_COMPOSITOR::Present ( )
overridevirtual

Call this to present the output buffer to the screen.

Implements KIGFX::COMPOSITOR.

Definition at line 186 of file cairo_compositor.cpp.

◆ Resize()

void CAIRO_COMPOSITOR::Resize ( unsigned int  aWidth,
unsigned int  aHeight 
)
overridevirtual

Clear the state of COMPOSITOR, so it has to be reinitialized again with the new dimensions.

Parameters
aWidthis the framebuffer width (in pixels).
aHeightis the framebuffer height (in pixels).

Implements KIGFX::COMPOSITOR.

Definition at line 76 of file cairo_compositor.cpp.

References clean(), m_bufferSize, KIGFX::COMPOSITOR::m_height, m_stride, and KIGFX::COMPOSITOR::m_width.

◆ SetAntialiasingMode()

void CAIRO_COMPOSITOR::SetAntialiasingMode ( CAIRO_ANTIALIASING_MODE  aMode)

Definition at line 63 of file cairo_compositor.cpp.

References clean(), KIGFX::FAST, KIGFX::GOOD, and m_currentAntialiasingMode.

◆ SetBuffer()

void CAIRO_COMPOSITOR::SetBuffer ( unsigned int  aBufferHandle)
overridevirtual

Set the selected buffer as the rendering target.

All the following drawing functions are going to be rendered in the selected buffer.

Parameters
aBufferHandleis the handle of the buffer or 0 in case of rendering directly to the display.

Implements KIGFX::COMPOSITOR.

Definition at line 118 of file cairo_compositor.cpp.

References m_buffers, m_current, m_currentContext, m_matrix, and usedBuffers().

◆ SetMainContext()

virtual void KIGFX::CAIRO_COMPOSITOR::SetMainContext ( cairo_t *  aMainContext)
inlinevirtual

Set a context to be treated as the main context (ie.

as a target of buffers rendering and as a source of settings for newly created buffers).

Parameters
aMainContextis the context that should be treated as the main one.

Definition at line 109 of file cairo_compositor.h.

References m_mainContext, and m_matrix.

◆ usedBuffers()

unsigned int KIGFX::CAIRO_COMPOSITOR::usedBuffers ( )
inlineprotected

Return number of currently used buffers.

Definition at line 124 of file cairo_compositor.h.

References m_buffers.

Referenced by CreateBuffer(), DrawBuffer(), and SetBuffer().

Member Data Documentation

◆ m_buffers

CAIRO_BUFFERS KIGFX::CAIRO_COMPOSITOR::m_buffers
protected

Stores information about initialized buffers.

Definition at line 150 of file cairo_compositor.h.

Referenced by clean(), ClearBuffer(), CreateBuffer(), DrawBuffer(), SetBuffer(), and usedBuffers().

◆ m_bufferSize

unsigned int KIGFX::CAIRO_COMPOSITOR::m_bufferSize
protected

Amount of memory needed to store a buffer.

Definition at line 153 of file cairo_compositor.h.

Referenced by CAIRO_COMPOSITOR(), ClearBuffer(), CreateBuffer(), and Resize().

◆ m_current

unsigned int KIGFX::CAIRO_COMPOSITOR::m_current
protected

Currently used buffer handle.

Definition at line 137 of file cairo_compositor.h.

Referenced by ClearBuffer(), GetBuffer(), and SetBuffer().

◆ m_currentAntialiasingMode

cairo_antialias_t KIGFX::CAIRO_COMPOSITOR::m_currentAntialiasingMode
protected

Definition at line 155 of file cairo_compositor.h.

Referenced by CreateBuffer(), GetAntialiasingMode(), and SetAntialiasingMode().

◆ m_currentContext

cairo_t** KIGFX::CAIRO_COMPOSITOR::m_currentContext
protected

Pointer to the current context, so it can be changed.

Definition at line 141 of file cairo_compositor.h.

Referenced by SetBuffer().

◆ m_height

unsigned int KIGFX::COMPOSITOR::m_height
protectedinherited

Height of the buffer (in pixels)

Definition at line 113 of file compositor.h.

Referenced by CreateBuffer(), KIGFX::OPENGL_COMPOSITOR::GetScreenSize(), Resize(), and KIGFX::OPENGL_COMPOSITOR::Resize().

◆ m_mainContext

cairo_t* KIGFX::CAIRO_COMPOSITOR::m_mainContext
protected

Rendering target used for compositing (the main display)

Definition at line 144 of file cairo_compositor.h.

Referenced by CreateBuffer(), DrawBuffer(), and SetMainContext().

◆ m_matrix

cairo_matrix_t KIGFX::CAIRO_COMPOSITOR::m_matrix
protected

Transformation matrix.

Definition at line 147 of file cairo_compositor.h.

Referenced by CAIRO_COMPOSITOR(), CreateBuffer(), DrawBuffer(), SetBuffer(), and SetMainContext().

◆ m_stride

unsigned int KIGFX::CAIRO_COMPOSITOR::m_stride
protected

Stride to use given the desired format and width.

Definition at line 152 of file cairo_compositor.h.

Referenced by CAIRO_COMPOSITOR(), CreateBuffer(), and Resize().

◆ m_width

unsigned int KIGFX::COMPOSITOR::m_width
protectedinherited

Width of the buffer (in pixels)

Definition at line 112 of file compositor.h.

Referenced by CreateBuffer(), KIGFX::OPENGL_COMPOSITOR::GetScreenSize(), Resize(), and KIGFX::OPENGL_COMPOSITOR::Resize().


The documentation for this class was generated from the following files: