From 47d0eaa2c607debf5c81b134f4499c442646d5b6 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Fri, 28 Sep 2018 12:46:20 +0200 Subject: [PATCH] GAL: changed line width setting to float type --- common/gal/cairo/cairo_gal.cpp | 9 ++++----- common/gal/graphics_abstraction_layer.cpp | 8 ++++---- common/gal/opengl/opengl_gal.cpp | 4 ++-- include/gal/cairo/cairo_gal.h | 2 +- include/gal/graphics_abstraction_layer.h | 10 +++++----- 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/common/gal/cairo/cairo_gal.cpp b/common/gal/cairo/cairo_gal.cpp index e253db0adf..a7068a2469 100644 --- a/common/gal/cairo/cairo_gal.cpp +++ b/common/gal/cairo/cairo_gal.cpp @@ -417,11 +417,10 @@ void CAIRO_GAL_BASE::SetFillColor( const COLOR4D& aColor ) } -void CAIRO_GAL_BASE::SetLineWidth( double aLineWidth ) +void CAIRO_GAL_BASE::SetLineWidth( float aLineWidth ) { storePath(); - - lineWidth = aLineWidth; + GAL::SetLineWidth( aLineWidth ); if( isGrouping ) { @@ -435,8 +434,8 @@ void CAIRO_GAL_BASE::SetLineWidth( double aLineWidth ) // Make lines appear at least 1 pixel wide, no matter of zoom double x = 1.0, y = 1.0; cairo_device_to_user_distance( currentContext, &x, &y ); - double minWidth = std::min( fabs( x ), fabs( y ) ); - cairo_set_line_width( currentContext, std::max( aLineWidth, minWidth ) ); + float minWidth = std::min( fabs( x ), fabs( y ) ); + cairo_set_line_width( currentContext, std::fmax( aLineWidth, minWidth ) ); } } diff --git a/common/gal/graphics_abstraction_layer.cpp b/common/gal/graphics_abstraction_layer.cpp index 15c5e4c404..db4c1ad412 100644 --- a/common/gal/graphics_abstraction_layer.cpp +++ b/common/gal/graphics_abstraction_layer.cpp @@ -54,14 +54,14 @@ GAL::GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions ) : SetDepthRange( VECTOR2D( GAL::MIN_DEPTH, GAL::MAX_DEPTH ) ); SetLayerDepth( 0.0 ); SetFlip( false, false ); - SetLineWidth( 1.0 ); + SetLineWidth( 1.0f ); computeWorldScale(); SetAxesEnabled( false ); // Set grid defaults SetGridVisibility( true ); SetCoarseGrid( 10 ); - gridLineWidth = 0.5; + gridLineWidth = 0.5f; gridStyle = GRID_STYLE::LINES; gridMinSpacing = 10; @@ -231,8 +231,8 @@ void GAL::DrawGrid() // Note: generic grids can't handle sub-pixel lines without // either losing fine/course distinction or having some dots // fail to render - double marker = std::max( 1.0, gridLineWidth ) / worldScale; - double doubleMarker = 2.0 * marker; + float marker = std::fmax( 1.0f, gridLineWidth ) / worldScale; + float doubleMarker = 2.0f * marker; // Draw axes if desired if( axesEnabled ) diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp index d5059e7699..5123ce32be 100644 --- a/common/gal/opengl/opengl_gal.cpp +++ b/common/gal/opengl/opengl_gal.cpp @@ -1182,8 +1182,8 @@ void OPENGL_GAL::DrawGrid() nonCachedManager->EnableDepthTest( false ); // sub-pixel lines all render the same - double minorLineWidth = std::max( 1.0, gridLineWidth ) * getWorldPixelSize(); - double majorLineWidth = minorLineWidth * 2.0; + float minorLineWidth = std::fmax( 1.0f, gridLineWidth ) * getWorldPixelSize(); + float majorLineWidth = minorLineWidth * 2.0f; // Draw the axis and grid // For the drawing the start points, end points and increments have diff --git a/include/gal/cairo/cairo_gal.h b/include/gal/cairo/cairo_gal.h index 603dd6ad81..e51c351807 100644 --- a/include/gal/cairo/cairo_gal.h +++ b/include/gal/cairo/cairo_gal.h @@ -143,7 +143,7 @@ public: virtual void SetFillColor( const COLOR4D& aColor ) override; /// @copydoc GAL::SetLineWidth() - virtual void SetLineWidth( double aLineWidth ) override; + virtual void SetLineWidth( float aLineWidth ) override; /// @copydoc GAL::SetLayerDepth() virtual void SetLayerDepth( double aLayerDepth ) override; diff --git a/include/gal/graphics_abstraction_layer.h b/include/gal/graphics_abstraction_layer.h index 815e5fcb04..c7eb1affde 100644 --- a/include/gal/graphics_abstraction_layer.h +++ b/include/gal/graphics_abstraction_layer.h @@ -283,7 +283,7 @@ public: * * @param aLineWidth is the line width. */ - virtual void SetLineWidth( double aLineWidth ) + virtual void SetLineWidth( float aLineWidth ) { lineWidth = aLineWidth; } @@ -293,7 +293,7 @@ public: * * @return the actual line width. */ - inline double GetLineWidth() const + inline float GetLineWidth() const { return lineWidth; } @@ -916,7 +916,7 @@ public: * * @return the grid line width */ - inline double GetGridLineWidth() const + inline float GetGridLineWidth() const { return gridLineWidth; } @@ -1042,7 +1042,7 @@ protected: bool globalFlipX; ///< Flag for X axis flipping bool globalFlipY; ///< Flag for Y axis flipping - double lineWidth; ///< The line width + float lineWidth; ///< The line width bool isFillEnabled; ///< Is filling of graphic objects enabled ? bool isStrokeEnabled; ///< Are the outlines stroked ? @@ -1064,7 +1064,7 @@ protected: COLOR4D axesColor; ///< Color of the axes bool axesEnabled; ///< Should the axes be drawn int gridTick; ///< Every tick line gets the double width - double gridLineWidth; ///< Line width of the grid + float gridLineWidth; ///< Line width of the grid int gridMinSpacing; ///< Minimum screen size of the grid (pixels) ///< below which the grid is not drawn