gal: minor cleanup & formatting
This commit is contained in:
parent
bbee30671a
commit
85a7ab7795
|
@ -109,7 +109,7 @@ unsigned int CAIRO_COMPOSITOR::CreateBuffer()
|
|||
#endif /* __WXDEBUG__ */
|
||||
|
||||
// Set default settings for the buffer
|
||||
cairo_set_antialias( context, m_currentAntialiasingMode );
|
||||
cairo_set_antialias( context, m_currentAntialiasingMode );
|
||||
|
||||
// Use the same transformation matrix as the main context
|
||||
cairo_get_matrix( m_mainContext, &m_matrix );
|
||||
|
|
|
@ -93,6 +93,7 @@ void CAIRO_GAL_BASE::updateWorldScreenMatrix()
|
|||
cairo_matrix_multiply( ¤tWorld2Screen, ¤tXform, &cairoWorldScreenMatrix );
|
||||
}
|
||||
|
||||
|
||||
const VECTOR2D CAIRO_GAL_BASE::xform( double x, double y )
|
||||
{
|
||||
VECTOR2D rv;
|
||||
|
@ -102,11 +103,13 @@ const VECTOR2D CAIRO_GAL_BASE::xform( double x, double y )
|
|||
return rv;
|
||||
}
|
||||
|
||||
|
||||
const VECTOR2D CAIRO_GAL_BASE::xform( const VECTOR2D& aP )
|
||||
{
|
||||
return xform(aP.x, aP.y);
|
||||
return xform( aP.x, aP.y );
|
||||
}
|
||||
|
||||
|
||||
const double CAIRO_GAL_BASE::xform( double x )
|
||||
{
|
||||
double dx = currentWorld2Screen.xx * x;
|
||||
|
@ -114,14 +117,16 @@ const double CAIRO_GAL_BASE::xform( double x )
|
|||
return sqrt( dx * dx + dy * dy );
|
||||
}
|
||||
|
||||
|
||||
static double roundp( double x )
|
||||
{
|
||||
return floor( x + 0.5 ) + 0.5;
|
||||
}
|
||||
|
||||
|
||||
const VECTOR2D CAIRO_GAL_BASE::roundp( const VECTOR2D& v )
|
||||
{
|
||||
if ( lineWidthIsOdd )
|
||||
if( lineWidthIsOdd )
|
||||
return VECTOR2D( ::roundp( v.x ), ::roundp( v.y ) );
|
||||
else
|
||||
return VECTOR2D( floor( v.x + 0.5 ), floor( v.y + 0.5 ) );
|
||||
|
@ -165,6 +170,7 @@ void CAIRO_GAL_BASE::syncLineWidth( bool aForceWidth, double aWidth )
|
|||
lineWidthInPixels = w;
|
||||
}
|
||||
|
||||
|
||||
void CAIRO_GAL_BASE::DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint,
|
||||
double aWidth )
|
||||
{
|
||||
|
@ -223,7 +229,7 @@ void CAIRO_GAL_BASE::DrawCircle( const VECTOR2D& aCenterPoint, double aRadius )
|
|||
auto r = ::roundp( xform( aRadius ) );
|
||||
|
||||
cairo_new_sub_path( currentContext );
|
||||
cairo_arc( currentContext, c.x, c.y, r, 0.0, 2 * M_PI);
|
||||
cairo_arc( currentContext, c.x, c.y, r, 0.0, 2 * M_PI );
|
||||
cairo_close_path( currentContext );
|
||||
flushPath();
|
||||
isElementAdded = true;
|
||||
|
@ -265,7 +271,7 @@ void CAIRO_GAL_BASE::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, doub
|
|||
SetStrokeColor( fgcolor );
|
||||
}
|
||||
|
||||
cairo_set_line_width(currentContext, lineWidthInPixels );
|
||||
cairo_set_line_width( currentContext, lineWidthInPixels );
|
||||
cairo_new_sub_path( currentContext );
|
||||
cairo_arc( currentContext, c.x, c.y, r, aStartAngle, aEndAngle );
|
||||
flushPath();
|
||||
|
@ -849,6 +855,7 @@ void CAIRO_GAL_BASE::drawGridLine( const VECTOR2D& aStartPoint, const VECTOR2D&
|
|||
cairo_stroke( currentContext );
|
||||
}
|
||||
|
||||
|
||||
void CAIRO_GAL_BASE::drawGridPoint( const VECTOR2D& aPoint, double aSize )
|
||||
{
|
||||
auto p = roundp( xform( aPoint ) );
|
||||
|
@ -861,12 +868,12 @@ void CAIRO_GAL_BASE::drawGridPoint( const VECTOR2D& aPoint, double aSize )
|
|||
|
||||
cairo_set_line_join( currentContext, CAIRO_LINE_JOIN_MITER );
|
||||
cairo_set_line_cap( currentContext, CAIRO_LINE_CAP_BUTT );
|
||||
cairo_set_line_width( currentContext, 1.0 ); //floor( aSize + 0.5 ) - 0.5 );
|
||||
cairo_set_line_width( currentContext, 1.0 );
|
||||
|
||||
cairo_move_to( currentContext, p.x - s, p.y - s);
|
||||
cairo_line_to( currentContext, p.x + s, p.y - s);
|
||||
cairo_line_to( currentContext, p.x + s, p.y + s);
|
||||
cairo_line_to( currentContext, p.x - s, p.y + s);
|
||||
cairo_move_to( currentContext, p.x - s, p.y - s );
|
||||
cairo_line_to( currentContext, p.x + s, p.y - s );
|
||||
cairo_line_to( currentContext, p.x + s, p.y + s );
|
||||
cairo_line_to( currentContext, p.x - s, p.y + s );
|
||||
cairo_close_path( currentContext );
|
||||
|
||||
cairo_fill( currentContext );
|
||||
|
@ -1342,7 +1349,6 @@ void CAIRO_GAL::setCompositor()
|
|||
compositor->Resize( screenSize.x, screenSize.y );
|
||||
compositor->SetAntialiasingMode( options.cairo_antialiasing_mode );
|
||||
|
||||
|
||||
// Prepare buffers
|
||||
mainBuffer = compositor->CreateBuffer();
|
||||
overlayBuffer = compositor->CreateBuffer();
|
||||
|
@ -1388,6 +1394,7 @@ bool CAIRO_GAL::updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions )
|
|||
return refresh;
|
||||
}
|
||||
|
||||
|
||||
void CAIRO_GAL_BASE::DrawGrid()
|
||||
{
|
||||
SetTarget( TARGET_NONCACHED );
|
||||
|
|
|
@ -213,7 +213,6 @@ double GAL::computeMinGridSpacing() const
|
|||
}
|
||||
|
||||
|
||||
|
||||
VECTOR2D GAL::GetGridPoint( const VECTOR2D& aPoint ) const
|
||||
{
|
||||
#if 0
|
||||
|
|
|
@ -405,6 +405,7 @@ void OPENGL_COMPOSITOR::clean()
|
|||
m_initialized = false;
|
||||
}
|
||||
|
||||
|
||||
int OPENGL_COMPOSITOR::GetAntialiasSupersamplingFactor() const
|
||||
{
|
||||
switch( m_currentAntialiasingMode )
|
||||
|
|
|
@ -346,12 +346,14 @@ bool OPENGL_GAL::updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions )
|
|||
return refresh;
|
||||
}
|
||||
|
||||
|
||||
double OPENGL_GAL::getWorldPixelSize() const
|
||||
{
|
||||
auto matrix = GetScreenWorldMatrix();
|
||||
return std::min( std::abs( matrix.GetScale().x ), std::abs( matrix.GetScale().y ) );
|
||||
}
|
||||
|
||||
|
||||
VECTOR2D OPENGL_GAL::getScreenPixelSize() const
|
||||
{
|
||||
auto sf = GetBackingScaleFactor();
|
||||
|
|
|
@ -309,7 +309,7 @@ protected:
|
|||
*/
|
||||
unsigned int getNewGroupNumber();
|
||||
|
||||
void syncLineWidth( bool aForceWidth = false, double aWidth = 0.0);
|
||||
void syncLineWidth( bool aForceWidth = false, double aWidth = 0.0 );
|
||||
void updateWorldScreenMatrix();
|
||||
const VECTOR2D roundp( const VECTOR2D& v );
|
||||
|
||||
|
|
Loading…
Reference in New Issue