Commit 190ed585 authored by Maciej Suminski's avatar Maciej Suminski

Code refactoring.

parent 790a1f85
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
using namespace KiGfx; using namespace KiGfx;
CAIRO_COMPOSITOR::CAIRO_COMPOSITOR( cairo_t** aMainContext ) : CAIRO_COMPOSITOR::CAIRO_COMPOSITOR( cairo_t** aMainContext ) :
m_current( 0 ), m_currentContext( aMainContext ), m_mainContext( *aMainContext ) m_current( 0 ), m_currentContext( aMainContext ), m_mainContext( *aMainContext )
{ {
// Obtain the transformation matrix used in the main context // Obtain the transformation matrix used in the main context
cairo_get_matrix( m_mainContext, &m_matrix ); cairo_get_matrix( m_mainContext, &m_matrix );
...@@ -69,6 +69,7 @@ unsigned int CAIRO_COMPOSITOR::GetBuffer() ...@@ -69,6 +69,7 @@ unsigned int CAIRO_COMPOSITOR::GetBuffer()
{ {
// Pixel storage // Pixel storage
BitmapPtr bitmap( new unsigned int[m_bufferSize] ); BitmapPtr bitmap( new unsigned int[m_bufferSize] );
memset( bitmap.get(), 0x00, m_bufferSize * sizeof(int) ); memset( bitmap.get(), 0x00, m_bufferSize * sizeof(int) );
// Create the Cairo surface // Create the Cairo surface
...@@ -105,6 +106,7 @@ void CAIRO_COMPOSITOR::SetBuffer( unsigned int aBufferHandle ) ...@@ -105,6 +106,7 @@ void CAIRO_COMPOSITOR::SetBuffer( unsigned int aBufferHandle )
m_current = aBufferHandle - 1; m_current = aBufferHandle - 1;
*m_currentContext = m_buffers[m_current].context; *m_currentContext = m_buffers[m_current].context;
} }
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
else else
wxLogDebug( wxT( "Tried to use a not existing buffer" ) ); wxLogDebug( wxT( "Tried to use a not existing buffer" ) );
...@@ -141,6 +143,7 @@ void CAIRO_COMPOSITOR::DrawBuffer( unsigned int aBufferHandle ) ...@@ -141,6 +143,7 @@ void CAIRO_COMPOSITOR::DrawBuffer( unsigned int aBufferHandle )
// Restore the transformation matrix // Restore the transformation matrix
cairo_set_matrix( m_mainContext, &m_matrix ); cairo_set_matrix( m_mainContext, &m_matrix );
} }
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
else else
wxLogDebug( wxT( "Tried to use a not existing buffer" ) ); wxLogDebug( wxT( "Tried to use a not existing buffer" ) );
......
This diff is collapsed.
...@@ -63,6 +63,33 @@ GAL::~GAL() ...@@ -63,6 +63,33 @@ GAL::~GAL()
} }
void GAL::ComputeWorldScreenMatrix()
{
ComputeWorldScale();
worldScreenMatrix.SetIdentity();
MATRIX3x3D translation;
translation.SetIdentity();
translation.SetTranslation( 0.5 * screenSize );
MATRIX3x3D scale;
scale.SetIdentity();
scale.SetScale( VECTOR2D( worldScale, worldScale ) );
MATRIX3x3D flip;
flip.SetIdentity();
flip.SetScale( VECTOR2D( 1.0, 1.0 ) );
MATRIX3x3D lookat;
lookat.SetIdentity();
lookat.SetTranslation( -lookAtPoint );
worldScreenMatrix = translation * flip * scale * lookat * worldScreenMatrix;
}
void GAL::DrawGrid() void GAL::DrawGrid()
{ {
if( !gridVisibility ) if( !gridVisibility )
...@@ -136,7 +163,7 @@ void GAL::DrawGrid() ...@@ -136,7 +163,7 @@ void GAL::DrawGrid()
if( ( j % gridTick == 0 && gridScreenSizeCoarse > gridDrawThreshold ) if( ( j % gridTick == 0 && gridScreenSizeCoarse > gridDrawThreshold )
|| gridScreenSizeDense > gridDrawThreshold ) || gridScreenSizeDense > gridDrawThreshold )
{ {
DrawGridLine( VECTOR2D( gridStartX * gridSize.x, j * gridSize.y ), drawGridLine( VECTOR2D( gridStartX * gridSize.x, j * gridSize.y ),
VECTOR2D( gridEndX * gridSize.x, j * gridSize.y ) ); VECTOR2D( gridEndX * gridSize.x, j * gridSize.y ) );
} }
} }
...@@ -155,7 +182,7 @@ void GAL::DrawGrid() ...@@ -155,7 +182,7 @@ void GAL::DrawGrid()
if( ( i % gridTick == 0 && gridScreenSizeCoarse > gridDrawThreshold ) if( ( i % gridTick == 0 && gridScreenSizeCoarse > gridDrawThreshold )
|| gridScreenSizeDense > gridDrawThreshold ) || gridScreenSizeDense > gridDrawThreshold )
{ {
DrawGridLine( VECTOR2D( i * gridSize.x, gridStartY * gridSize.y ), drawGridLine( VECTOR2D( i * gridSize.x, gridStartY * gridSize.y ),
VECTOR2D( i * gridSize.x, gridEndY * gridSize.y ) ); VECTOR2D( i * gridSize.x, gridEndY * gridSize.y ) );
} }
} }
......
...@@ -52,7 +52,7 @@ GPU_MANAGER* GPU_MANAGER::MakeManager( VERTEX_CONTAINER* aContainer ) ...@@ -52,7 +52,7 @@ GPU_MANAGER* GPU_MANAGER::MakeManager( VERTEX_CONTAINER* aContainer )
GPU_MANAGER::GPU_MANAGER( VERTEX_CONTAINER* aContainer ) : GPU_MANAGER::GPU_MANAGER( VERTEX_CONTAINER* aContainer ) :
m_isDrawing( false ), m_container( aContainer ), m_shader( NULL ) m_isDrawing( false ), m_container( aContainer ), m_shader( NULL )
{ {
} }
......
...@@ -104,7 +104,7 @@ unsigned int OPENGL_COMPOSITOR::GetBuffer() ...@@ -104,7 +104,7 @@ unsigned int OPENGL_COMPOSITOR::GetBuffer()
wxASSERT( m_initialized ); wxASSERT( m_initialized );
if( m_buffers.size() >= m_maxBuffers ) if( m_buffers.size() >= m_maxBuffers )
return 0; // Unfortunately we have no more free buffers left return 0; // Unfortunately we have no more free buffers left
// GL_COLOR_ATTACHMENTn are consecutive integers // GL_COLOR_ATTACHMENTn are consecutive integers
GLuint attachmentPoint = GL_COLOR_ATTACHMENT0 + usedBuffers(); GLuint attachmentPoint = GL_COLOR_ATTACHMENT0 + usedBuffers();
...@@ -229,9 +229,11 @@ void OPENGL_COMPOSITOR::clean() ...@@ -229,9 +229,11 @@ void OPENGL_COMPOSITOR::clean()
{ {
glDeleteTextures( 1, &it->textureTarget ); glDeleteTextures( 1, &it->textureTarget );
} }
m_buffers.clear(); m_buffers.clear();
m_initialized = false; m_initialized = false;
} }
GLuint OPENGL_COMPOSITOR::m_currentFbo = 0; GLuint OPENGL_COMPOSITOR::m_currentFbo = 0;
This diff is collapsed.
...@@ -37,12 +37,12 @@ ...@@ -37,12 +37,12 @@
using namespace KiGfx; using namespace KiGfx;
SHADER::SHADER() : SHADER::SHADER() :
isProgramCreated( false ), isProgramCreated( false ),
isShaderLinked( false ), isShaderLinked( false ),
active( false ), active( false ),
maximumVertices( 4 ), maximumVertices( 4 ),
geomInputType( GL_LINES ), geomInputType( GL_LINES ),
geomOutputType( GL_LINES ) geomOutputType( GL_LINES )
{ {
} }
...@@ -97,7 +97,8 @@ bool SHADER::Link() ...@@ -97,7 +97,8 @@ bool SHADER::Link()
programInfo( programNumber ); programInfo( programNumber );
// Check the Link state // Check the Link state
glGetObjectParameterivARB( programNumber, GL_OBJECT_LINK_STATUS_ARB, (GLint*) &isShaderLinked ); glGetObjectParameterivARB( programNumber, GL_OBJECT_LINK_STATUS_ARB,
(GLint*) &isShaderLinked );
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
if( !isShaderLinked ) if( !isShaderLinked )
...@@ -253,6 +254,7 @@ bool SHADER::addSource( const std::string& aShaderSource, ShaderType aShaderType ...@@ -253,6 +254,7 @@ bool SHADER::addSource( const std::string& aShaderSource, ShaderType aShaderType
glCompileShader( shaderNumber ); glCompileShader( shaderNumber );
GLint status; GLint status;
glGetShaderiv( shaderNumber, GL_COMPILE_STATUS, &status ); glGetShaderiv( shaderNumber, GL_COMPILE_STATUS, &status );
if( status != GL_TRUE ) if( status != GL_TRUE )
{ {
wxLogError( wxT( "Shader compilation error" ) ); wxLogError( wxT( "Shader compilation error" ) );
...@@ -275,4 +277,3 @@ bool SHADER::addSource( const std::string& aShaderSource, ShaderType aShaderType ...@@ -275,4 +277,3 @@ bool SHADER::addSource( const std::string& aShaderSource, ShaderType aShaderType
return true; return true;
} }
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
using namespace KiGfx; using namespace KiGfx;
VERTEX_MANAGER::VERTEX_MANAGER( bool aCached ) : VERTEX_MANAGER::VERTEX_MANAGER( bool aCached ) :
m_noTransform( true ), m_transform( 1.0f ) m_noTransform( true ), m_transform( 1.0f )
{ {
m_container.reset( VERTEX_CONTAINER::MakeContainer( aCached ) ); m_container.reset( VERTEX_CONTAINER::MakeContainer( aCached ) );
m_gpu.reset( GPU_MANAGER::MakeManager( m_container.get() ) ); m_gpu.reset( GPU_MANAGER::MakeManager( m_container.get() ) );
...@@ -52,6 +52,7 @@ void VERTEX_MANAGER::Vertex( GLfloat aX, GLfloat aY, GLfloat aZ ) const ...@@ -52,6 +52,7 @@ void VERTEX_MANAGER::Vertex( GLfloat aX, GLfloat aY, GLfloat aZ ) const
{ {
// Obtain the pointer to the vertex in the currently used container // Obtain the pointer to the vertex in the currently used container
VERTEX* newVertex = m_container->Allocate( 1 ); VERTEX* newVertex = m_container->Allocate( 1 );
if( newVertex == NULL ) if( newVertex == NULL )
{ {
wxLogError( wxT( "Vertex allocation error" ) ); wxLogError( wxT( "Vertex allocation error" ) );
...@@ -66,6 +67,7 @@ void VERTEX_MANAGER::Vertices( const VERTEX aVertices[], unsigned int aSize ) co ...@@ -66,6 +67,7 @@ void VERTEX_MANAGER::Vertices( const VERTEX aVertices[], unsigned int aSize ) co
{ {
// Obtain pointer to the vertex in currently used container // Obtain pointer to the vertex in currently used container
VERTEX* newVertex = m_container->Allocate( aSize ); VERTEX* newVertex = m_container->Allocate( aSize );
if( newVertex == NULL ) if( newVertex == NULL )
{ {
wxLogError( wxT( "Vertex allocation error" ) ); wxLogError( wxT( "Vertex allocation error" ) );
...@@ -95,7 +97,7 @@ void VERTEX_MANAGER::FreeItem( VERTEX_ITEM& aItem ) const ...@@ -95,7 +97,7 @@ void VERTEX_MANAGER::FreeItem( VERTEX_ITEM& aItem ) const
void VERTEX_MANAGER::ChangeItemColor( const VERTEX_ITEM& aItem, const COLOR4D& aColor ) const void VERTEX_MANAGER::ChangeItemColor( const VERTEX_ITEM& aItem, const COLOR4D& aColor ) const
{ {
unsigned int size = aItem.GetSize(); unsigned int size = aItem.GetSize();
unsigned int offset = aItem.GetOffset(); unsigned int offset = aItem.GetOffset();
VERTEX* vertex = m_container->GetVertices( offset ); VERTEX* vertex = m_container->GetVertices( offset );
...@@ -114,7 +116,7 @@ void VERTEX_MANAGER::ChangeItemColor( const VERTEX_ITEM& aItem, const COLOR4D& a ...@@ -114,7 +116,7 @@ void VERTEX_MANAGER::ChangeItemColor( const VERTEX_ITEM& aItem, const COLOR4D& a
void VERTEX_MANAGER::ChangeItemDepth( const VERTEX_ITEM& aItem, GLfloat aDepth ) const void VERTEX_MANAGER::ChangeItemDepth( const VERTEX_ITEM& aItem, GLfloat aDepth ) const
{ {
unsigned int size = aItem.GetSize(); unsigned int size = aItem.GetSize();
unsigned int offset = aItem.GetOffset(); unsigned int offset = aItem.GetOffset();
VERTEX* vertex = m_container->GetVertices( offset ); VERTEX* vertex = m_container->GetVertices( offset );
...@@ -131,7 +133,7 @@ void VERTEX_MANAGER::ChangeItemDepth( const VERTEX_ITEM& aItem, GLfloat aDepth ) ...@@ -131,7 +133,7 @@ void VERTEX_MANAGER::ChangeItemDepth( const VERTEX_ITEM& aItem, GLfloat aDepth )
VERTEX* VERTEX_MANAGER::GetVertices( const VERTEX_ITEM& aItem ) const VERTEX* VERTEX_MANAGER::GetVertices( const VERTEX_ITEM& aItem ) const
{ {
if( aItem.GetSize() == 0 ) if( aItem.GetSize() == 0 )
return NULL; // The item is not stored in the container return NULL; // The item is not stored in the container
return m_container->GetVertices( aItem.GetOffset() ); return m_container->GetVertices( aItem.GetOffset() );
} }
...@@ -158,6 +160,7 @@ void VERTEX_MANAGER::BeginDrawing() const ...@@ -158,6 +160,7 @@ void VERTEX_MANAGER::BeginDrawing() const
void VERTEX_MANAGER::DrawItem( const VERTEX_ITEM& aItem ) const void VERTEX_MANAGER::DrawItem( const VERTEX_ITEM& aItem ) const
{ {
int size = aItem.GetSize(); int size = aItem.GetSize();
if( size > 0 ) if( size > 0 )
{ {
int offset = aItem.GetOffset(); int offset = aItem.GetOffset();
......
...@@ -85,7 +85,6 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& event ) ...@@ -85,7 +85,6 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& event )
else else
scrollSpeed = scrollVec.y; scrollSpeed = scrollVec.y;
VECTOR2D t = m_view->GetScreenPixelSize();
VECTOR2D delta( event.ControlDown() ? -scrollSpeed : 0.0, VECTOR2D delta( event.ControlDown() ? -scrollSpeed : 0.0,
event.ShiftDown() ? -scrollSpeed : 0.0 ); event.ShiftDown() ? -scrollSpeed : 0.0 );
......
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
namespace KiGfx namespace KiGfx
{ {
class CAIRO_COMPOSITOR : public COMPOSITOR class CAIRO_COMPOSITOR : public COMPOSITOR
{ {
public: public:
...@@ -67,25 +66,25 @@ protected: ...@@ -67,25 +66,25 @@ protected:
typedef boost::shared_array<unsigned int> BitmapPtr; typedef boost::shared_array<unsigned int> BitmapPtr;
typedef struct typedef struct
{ {
cairo_t* context; ///< Main texture handle cairo_t* context; ///< Main texture handle
cairo_surface_t* surface; ///< Point to which an image from texture is attached cairo_surface_t* surface; ///< Point to which an image from texture is attached
BitmapPtr bitmap; ///< Pixel storage BitmapPtr bitmap; ///< Pixel storage
} CAIRO_BUFFER; } CAIRO_BUFFER;
unsigned int m_current; ///< Currently used buffer handle unsigned int m_current; ///< Currently used buffer handle
typedef std::deque<CAIRO_BUFFER> CAIRO_BUFFERS; typedef std::deque<CAIRO_BUFFER> CAIRO_BUFFERS;
/// Pointer to the current context, so it can be changed /// Pointer to the current context, so it can be changed
cairo_t** m_currentContext; cairo_t** m_currentContext;
/// Rendering target used for compositing (the main display) /// Rendering target used for compositing (the main display)
cairo_t* m_mainContext; cairo_t* m_mainContext;
/// Transformation matrix /// Transformation matrix
cairo_matrix_t m_matrix; cairo_matrix_t m_matrix;
/// Stores information about initialized buffers /// Stores information about initialized buffers
CAIRO_BUFFERS m_buffers; CAIRO_BUFFERS m_buffers;
unsigned int m_stride; ///< Stride to use given the desired format and width 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 unsigned int m_bufferSize; ///< Amount of memory needed to store a buffer
...@@ -102,7 +101,6 @@ protected: ...@@ -102,7 +101,6 @@ protected:
return m_buffers.size(); return m_buffers.size();
} }
}; };
} // namespace KiGfx } // namespace KiGfx
#endif /* COMPOSITOR_H_ */ #endif /* COMPOSITOR_H_ */
...@@ -45,9 +45,6 @@ ...@@ -45,9 +45,6 @@
#endif #endif
#endif #endif
#define EXCEPTION_ZERO_CLIENT_RECTANGLE 0
#define EXCEPTION_ZERO_CONTEXT 1
/** /**
* @brief Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer. * @brief Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
* *
...@@ -92,7 +89,7 @@ public: ...@@ -92,7 +89,7 @@ public:
// --------------- // ---------------
/// @copydoc GAL::BeginDrawing() /// @copydoc GAL::BeginDrawing()
virtual void BeginDrawing() throw (int); virtual void BeginDrawing();
/// @copydoc GAL::EndDrawing() /// @copydoc GAL::EndDrawing()
virtual void EndDrawing(); virtual void EndDrawing();
...@@ -103,19 +100,19 @@ public: ...@@ -103,19 +100,19 @@ public:
/// @copydoc GAL::DrawSegment() /// @copydoc GAL::DrawSegment()
virtual void DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint, double aWidth ); virtual void DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint, double aWidth );
/// @copydoc GAL::DrawPolyline()
virtual void DrawPolyline( std::deque<VECTOR2D>& aPointList );
/// @copydoc GAL::DrawCircle() /// @copydoc GAL::DrawCircle()
virtual void DrawCircle( const VECTOR2D& aCenterPoint, double aRadius ); virtual void DrawCircle( const VECTOR2D& aCenterPoint, double aRadius );
/// @copydoc GAL::DrawArc() /// @copydoc GAL::DrawArc()
virtual void virtual void DrawArc( const VECTOR2D& aCenterPoint, double aRadius,
DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle, double aEndAngle ); double aStartAngle, double aEndAngle );
/// @copydoc GAL::DrawRectangle() /// @copydoc GAL::DrawRectangle()
virtual void DrawRectangle( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ); virtual void DrawRectangle( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint );
/// @copydoc GAL::DrawPolyline()
virtual void DrawPolyline( std::deque<VECTOR2D>& aPointList );
/// @copydoc GAL::DrawPolygon() /// @copydoc GAL::DrawPolygon()
virtual void DrawPolygon( const std::deque<VECTOR2D>& aPointList ); virtual void DrawPolygon( const std::deque<VECTOR2D>& aPointList );
...@@ -149,24 +146,15 @@ public: ...@@ -149,24 +146,15 @@ public:
/// @copydoc GAL::SetIsStroke() /// @copydoc GAL::SetIsStroke()
virtual void SetIsStroke( bool aIsStrokeEnabled ); virtual void SetIsStroke( bool aIsStrokeEnabled );
/// @copydoc GAL::SetFillColor()
virtual void SetFillColor( const COLOR4D& aColor );
/// @copydoc GAL::SetStrokeColor() /// @copydoc GAL::SetStrokeColor()
virtual void SetStrokeColor( const COLOR4D& aColor ); virtual void SetStrokeColor( const COLOR4D& aColor );
/// @copydoc GAL::GetStrokeColor() /// @copydoc GAL::SetFillColor()
COLOR4D GetStrokeColor(); virtual void SetFillColor( const COLOR4D& aColor );
/// @copydoc GAL::SetBackgroundColor()
virtual void SetBackgroundColor( const COLOR4D& aColor );
/// @copydoc GAL::SetLineWidth() /// @copydoc GAL::SetLineWidth()
virtual void SetLineWidth( double aLineWidth ); virtual void SetLineWidth( double aLineWidth );
/// @copydoc GAL::GetLineWidth()
double GetLineWidth();
/// @copydoc GAL::SetLayerDepth() /// @copydoc GAL::SetLayerDepth()
virtual void SetLayerDepth( double aLayerDepth ); virtual void SetLayerDepth( double aLayerDepth );
...@@ -221,33 +209,6 @@ public: ...@@ -221,33 +209,6 @@ public:
// Handling the world <-> screen transformation // Handling the world <-> screen transformation
// -------------------------------------------------------- // --------------------------------------------------------
/// @copydoc GAL::ComputeWorldScreenMatrix()
virtual void ComputeWorldScreenMatrix();
/// @copydoc GAL::GetWorldScreenMatrix()
MATRIX3x3D GetWorldScreenMatrix();
/// @copydoc GAL::SetWorldScreenMatrix()
void SetWorldScreenMatrix( MATRIX3x3D aMatrix );
/// @copydoc GAL::SetWorldUnitLength()
void SetWorldUnitLength( double aWorldUnitLength );
/// @copydoc GAL::SetScreenDPI()
void SetScreenDPI( double aScreenDPI );
/// @copydoc GAL::SetLookAtPoint()
void SetLookAtPoint( const VECTOR2D& aPoint );
/// @copydoc GAL::GetLookAtPoint()
VECTOR2D GetLookAtPoint();
/// @copydoc GAL::SetZoomFactor()
void SetZoomFactor( double aZoomFactor );
/// @copydoc GAL::GetZoomFactor()
double GetZoomFactor();
/// @copydoc GAL::SaveScreen() /// @copydoc GAL::SaveScreen()
virtual void SaveScreen(); virtual void SaveScreen();
...@@ -264,9 +225,6 @@ public: ...@@ -264,9 +225,6 @@ public:
/// @copydoc GAL::ComputeCursorToWorld() /// @copydoc GAL::ComputeCursorToWorld()
virtual VECTOR2D ComputeCursorToWorld( const VECTOR2D& aCursorPosition ); virtual VECTOR2D ComputeCursorToWorld( const VECTOR2D& aCursorPosition );
/// @copydoc GAL::SetIsCursorEnabled()
void SetIsCursorEnabled( bool aIsCursorEnabled );
/// @copydoc GAL::DrawCursor() /// @copydoc GAL::DrawCursor()
virtual void DrawCursor( VECTOR2D aCursorPosition ); virtual void DrawCursor( VECTOR2D aCursorPosition );
...@@ -295,7 +253,7 @@ public: ...@@ -295,7 +253,7 @@ public:
} }
protected: protected:
virtual void DrawGridLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ); virtual void drawGridLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint );
private: private:
/// Super class definition /// Super class definition
...@@ -303,30 +261,29 @@ private: ...@@ -303,30 +261,29 @@ private:
// Compositing variables // Compositing variables
boost::shared_ptr<CAIRO_COMPOSITOR> compositor; ///< Object for layers compositing boost::shared_ptr<CAIRO_COMPOSITOR> compositor; ///< Object for layers compositing
unsigned int mainBuffer; ///< Handle to the main buffer unsigned int mainBuffer; ///< Handle to the main buffer
unsigned int overlayBuffer; ///< Handle to the overlay buffer unsigned int overlayBuffer; ///< Handle to the overlay buffer
// Variables related to wxWidgets // Variables related to wxWidgets
wxWindow* parentWindow; ///< Parent window wxWindow* parentWindow; ///< Parent window
wxEvtHandler* mouseListener; ///< Mouse listener wxEvtHandler* mouseListener; ///< Mouse listener
wxEvtHandler* paintListener; ///< Paint listener wxEvtHandler* paintListener; ///< Paint listener
unsigned int bufferSize; ///< Size of buffers cairoOutput, bitmapBuffers unsigned int bufferSize; ///< Size of buffers cairoOutput, bitmapBuffers
unsigned char* wxOutput; ///< wxImage comaptible buffer unsigned char* wxOutput; ///< wxImage comaptible buffer
// Cursor variables // Cursor variables
std::deque<wxColour> savedCursorPixels; ///< Saved pixels of the cursor std::deque<wxColour> savedCursorPixels; ///< Saved pixels of the cursor
bool isDeleteSavedPixels; ///< True, if the saved pixels can be discarded bool isDeleteSavedPixels; ///< True, if the saved pixels can be discarded
wxPoint savedCursorPosition; ///< The last cursor position wxPoint savedCursorPosition; ///< The last cursor position
wxBitmap* cursorPixels; ///< Cursor pixels wxBitmap* cursorPixels; ///< Cursor pixels
wxBitmap* cursorPixelsSaved; ///< Saved cursor pixels wxBitmap* cursorPixelsSaved; ///< Saved cursor pixels
int cursorSize; ///< Cursor size int cursorSize; ///< Cursor size
/// Maximum number of arguments for one command /// Maximum number of arguments for one command
static const int MAX_CAIRO_ARGUMENTS = 6; static const int MAX_CAIRO_ARGUMENTS = 6;
/// Definitions for the command recorder /// Definitions for the command recorder
enum GraphicsCommand enum GraphicsCommand {
{
CMD_SET_FILL, ///< Enable/disable filling CMD_SET_FILL, ///< Enable/disable filling
CMD_SET_STROKE, ///< Enable/disable stroking CMD_SET_STROKE, ///< Enable/disable stroking
CMD_SET_FILLCOLOR, ///< Set the fill color CMD_SET_FILLCOLOR, ///< Set the fill color
...@@ -392,18 +349,18 @@ private: ...@@ -392,18 +349,18 @@ private:
/// @copydoc GAL::initCursor() /// @copydoc GAL::initCursor()
virtual void initCursor( int aCursorSize ); virtual void initCursor( int aCursorSize );
/// Allocate the bitmaps for drawing
void allocateBitmaps();
/// Allocate the bitmaps for drawing
void deleteBitmaps();
/// Prepare Cairo surfaces for drawing /// Prepare Cairo surfaces for drawing
void initSurface(); void initSurface();
/// Destroy Cairo surfaces when are not needed anymore /// Destroy Cairo surfaces when are not needed anymore
void deinitSurface(); void deinitSurface();
/// Allocate the bitmaps for drawing
void allocateBitmaps();
/// Allocate the bitmaps for drawing
void deleteBitmaps();
/// Prepare the compositor /// Prepare the compositor
void setCompositor(); void setCompositor();
......
...@@ -231,7 +231,10 @@ public: ...@@ -231,7 +231,10 @@ public:
* *
* @param aColor is the color for background filling. * @param aColor is the color for background filling.
*/ */
virtual void SetBackgroundColor( const COLOR4D& aColor ) = 0; inline virtual void SetBackgroundColor( const COLOR4D& aColor )
{
backgroundColor = aColor;
}
/** /**
* @brief Set the line width. * @brief Set the line width.
...@@ -417,7 +420,7 @@ public: ...@@ -417,7 +420,7 @@ public:
// -------------------------------------------------------- // --------------------------------------------------------
/// @brief Compute the world <-> screen transformation matrix /// @brief Compute the world <-> screen transformation matrix
virtual void ComputeWorldScreenMatrix() = 0; virtual void ComputeWorldScreenMatrix();
/** /**
* @brief Get the world <-> screen transformation matrix. * @brief Get the world <-> screen transformation matrix.
...@@ -745,7 +748,6 @@ protected: ...@@ -745,7 +748,6 @@ protected:
bool isFillEnabled; ///< Is filling of graphic objects enabled ? bool isFillEnabled; ///< Is filling of graphic objects enabled ?
bool isStrokeEnabled; ///< Are the outlines stroked ? bool isStrokeEnabled; ///< Are the outlines stroked ?
bool isSetAttributes; ///< True, if the attributes have been set
COLOR4D backgroundColor; ///< The background color COLOR4D backgroundColor; ///< The background color
COLOR4D fillColor; ///< The fill color COLOR4D fillColor; ///< The fill color
...@@ -784,7 +786,7 @@ protected: ...@@ -784,7 +786,7 @@ protected:
* @param aStartPoint is the start point of the line. * @param aStartPoint is the start point of the line.
* @param aEndPoint is the end point of the line. * @param aEndPoint is the end point of the line.
*/ */
virtual void DrawGridLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ) = 0; virtual void drawGridLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ) = 0;
/** /**
* @brief Initialize the cursor. * @brief Initialize the cursor.
......
...@@ -94,12 +94,12 @@ protected: ...@@ -94,12 +94,12 @@ protected:
unsigned int m_itemSize; unsigned int m_itemSize;
/** /**
* Function reallocate() * Function reallocate()
* resizes the chunk that stores the current item to the given size. * resizes the chunk that stores the current item to the given size.
* *
* @param aSize is the number of vertices to be stored. * @param aSize is the number of vertices to be stored.
* @return offset of the new chunk. * @return offset of the new chunk.
*/ */
virtual unsigned int reallocate( unsigned int aSize ); virtual unsigned int reallocate( unsigned int aSize );
/** /**
......
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
namespace KiGfx namespace KiGfx
{ {
class OPENGL_COMPOSITOR : public COMPOSITOR class OPENGL_COMPOSITOR : public COMPOSITOR
{ {
public: public:
...@@ -94,7 +93,6 @@ protected: ...@@ -94,7 +93,6 @@ protected:
return m_buffers.size(); return m_buffers.size();
} }
}; };
} // namespace KiGfx } // namespace KiGfx
#endif /* COMPOSITOR_H_ */ #endif /* COMPOSITOR_H_ */
This diff is collapsed.
...@@ -35,9 +35,8 @@ ...@@ -35,9 +35,8 @@
namespace KiGfx namespace KiGfx
{ {
// Possible types of shaders // Possible types of shaders
enum SHADER_TYPE enum SHADER_TYPE {
{ SHADER_NONE = 0,
SHADER_NONE = 0,
SHADER_LINE, SHADER_LINE,
SHADER_FILLED_CIRCLE, SHADER_FILLED_CIRCLE,
SHADER_STROKED_CIRCLE, SHADER_STROKED_CIRCLE,
...@@ -60,7 +59,7 @@ const unsigned int CoordStride = CoordSize / sizeof(GLfloat); ...@@ -60,7 +59,7 @@ const unsigned int CoordStride = CoordSize / sizeof(GLfloat);
// Offset of color data from the beginning of each vertex data // Offset of color data from the beginning of each vertex data
const unsigned int ColorOffset = offsetof(VERTEX, r); const unsigned int ColorOffset = offsetof(VERTEX, r);
const unsigned int ColorSize = sizeof(VERTEX().r) + sizeof(VERTEX().g) + const unsigned int ColorSize = sizeof(VERTEX().r) + sizeof(VERTEX().g) +
sizeof(VERTEX().b) + sizeof(VERTEX().a); sizeof(VERTEX().b) + sizeof(VERTEX().a);
const unsigned int ColorStride = ColorSize / sizeof(GLubyte); const unsigned int ColorStride = ColorSize / sizeof(GLubyte);
// Shader attributes // Shader attributes
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment