40 m_currentContext( aMainContext ),
41 m_mainContext( *aMainContext ),
42 m_currentAntialiasingMode( CAIRO_ANTIALIAS_DEFAULT )
45 cairo_matrix_init_identity( &
m_matrix );
83 m_stride = cairo_format_stride_for_width( CAIRO_FORMAT_ARGB32,
m_width );
94 cairo_surface_t* surface = cairo_image_surface_create_for_data(
96 cairo_t* context = cairo_create( surface );
99 cairo_status_t status = cairo_status( context );
100 wxASSERT_MSG( status == CAIRO_STATUS_SUCCESS, wxT(
"Cairo context creation error" ) );
108 cairo_set_matrix( context, &
m_matrix );
120 wxASSERT_MSG( aBufferHandle <=
usedBuffers(), wxT(
"Tried to use a not existing buffer" ) );
146 cairo_operator_t op )
149 wxT(
"Tried to use a not existing buffer" ) );
157 cairo_t* ct = cairo_create(
m_buffers[aDestHandle - 1].surface );
158 cairo_set_operator( ct, op );
159 cairo_set_source_surface( ct,
m_buffers[aSourceHandle - 1].surface, 0.0, 0.0 );
170 wxASSERT_MSG( aBufferHandle <=
usedBuffers(), wxT(
"Tried to use a not existing buffer" ) );
193 CAIRO_BUFFERS::const_iterator it;
197 cairo_destroy( it->context );
198 cairo_surface_destroy( it->surface );
Class that handles multitarget rendering (ie.
unsigned int m_bufferSize
Amount of memory needed to store a buffer.
virtual ~CAIRO_COMPOSITOR()
virtual void Present() override
Call this to present the output buffer to the screen.
unsigned int m_stride
Stride to use given the desired format and width.
CAIRO_COMPOSITOR(cairo_t **aMainContext)
cairo_antialias_t m_currentAntialiasingMode
virtual unsigned int CreateBuffer() override
Prepare a new buffer that may be used as a rendering target.
cairo_t * m_mainContext
Rendering target used for compositing (the main display)
virtual void ClearBuffer(const COLOR4D &aColor) override
Clear the selected buffer (set by the SetBuffer() function).
virtual void Begin() override
Call this at the beginning of each frame.
void clean()
Perform freeing of resources.
void DrawBuffer(unsigned int aSourceHandle, unsigned int aDestHandle, cairo_operator_t op)
Paints source to destination using the cairo operator.
unsigned int usedBuffers()
Return number of currently used buffers.
cairo_matrix_t m_matrix
Transformation matrix.
cairo_t ** m_currentContext
Pointer to the current context, so it can be changed.
void SetAntialiasingMode(CAIRO_ANTIALIASING_MODE aMode)
unsigned int m_current
Currently used buffer handle.
CAIRO_BUFFERS m_buffers
Stores information about initialized buffers.
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 void SetBuffer(unsigned int aBufferHandle) override
Set the selected buffer as the rendering target.
virtual void Initialize() override
Perform primary initialization, necessary to use the object.
A color representation with 4 components: red, green, blue, alpha.
unsigned int m_height
Height of the buffer (in pixels)
unsigned int m_width
Width of the buffer (in pixels)
The Cairo implementation of the graphics abstraction layer.