diff --git a/3rdparty/plutovg/plutovg-blend.c b/3rdparty/plutovg/plutovg-blend.c index a8a0c2a..e1344b2 100644 --- a/3rdparty/plutovg/plutovg-blend.c +++ b/3rdparty/plutovg/plutovg-blend.c @@ -48,7 +48,7 @@ typedef struct { int extended; } radial_gradient_values_t; -static inline uint32_t premultiply_color(const plutovg_color_t* color, double opacity) +static inline uint32_t premultiply_color(const plutovg_color_t* color, const double opacity) { uint32_t alpha = (uint8_t)(color->a * opacity * 255); uint32_t pr = (uint8_t)(color->r * alpha); @@ -58,7 +58,7 @@ static inline uint32_t premultiply_color(const plutovg_color_t* color, double op return (alpha << 24) | (pr << 16) | (pg << 8) | (pb); } -static inline uint32_t combine_opacity(const plutovg_color_t* color, double opacity) +static inline uint32_t combine_opacity(const plutovg_color_t* color, const double opacity) { uint32_t a = (uint8_t)(color->a * opacity * 255); uint32_t r = (uint8_t)(color->r * 255); @@ -68,7 +68,7 @@ static inline uint32_t combine_opacity(const plutovg_color_t* color, double opac return (a << 24) | (r << 16) | (g << 8) | (b); } -static inline uint32_t premultiply_pixel(uint32_t color) +static inline uint32_t premultiply_pixel(const uint32_t color) { uint32_t a = plutovg_alpha(color); uint32_t r = plutovg_red(color); @@ -81,7 +81,7 @@ static inline uint32_t premultiply_pixel(uint32_t color) return (a << 24) | (pr << 16) | (pg << 8) | (pb); } -static inline uint32_t interpolate_pixel(uint32_t x, uint32_t a, uint32_t y, uint32_t b) +static inline uint32_t interpolate_pixel(uint32_t x, const uint32_t a, const uint32_t y, const uint32_t b) { uint32_t t = (x & 0xff00ff) * a + (y & 0xff00ff) * b; t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8; @@ -93,7 +93,7 @@ static inline uint32_t interpolate_pixel(uint32_t x, uint32_t a, uint32_t y, uin return x; } -static inline uint32_t BYTE_MUL(uint32_t x, uint32_t a) +static inline uint32_t BYTE_MUL(uint32_t x, const uint32_t a) { uint32_t t = (x & 0xff00ff) * a; t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8; @@ -105,7 +105,7 @@ static inline uint32_t BYTE_MUL(uint32_t x, uint32_t a) return x; } -static inline void memfill32(uint32_t* dest, uint32_t value, int length) +static inline void memfill32(uint32_t* dest, const uint32_t value, const int length) { for(int i = 0;i < length;i++) dest[i] = value; @@ -138,19 +138,19 @@ static inline int gradient_clamp(const gradient_data_t* gradient, int ipos) #define FIXPT_BITS 8 #define FIXPT_SIZE (1 << FIXPT_BITS) -static inline uint32_t gradient_pixel_fixed(const gradient_data_t* gradient, int fixed_pos) +static inline uint32_t gradient_pixel_fixed(const gradient_data_t* gradient, const int fixed_pos) { int ipos = (fixed_pos + (FIXPT_SIZE / 2)) >> FIXPT_BITS; return gradient->colortable[gradient_clamp(gradient, ipos)]; } -static inline uint32_t gradient_pixel(const gradient_data_t* gradient, double pos) +static inline uint32_t gradient_pixel(const gradient_data_t* gradient, const double pos) { int ipos = (int)(pos * (COLOR_TABLE_SIZE - 1) + 0.5); return gradient->colortable[gradient_clamp(gradient, ipos)]; } -static void fetch_linear_gradient(uint32_t* buffer, const linear_gradient_values_t* v, const gradient_data_t* gradient, int y, int x, int length) +static void fetch_linear_gradient(uint32_t* buffer, const linear_gradient_values_t* v, const gradient_data_t* gradient, const int y, const int x, const int length) { double t, inc; double rx = 0, ry = 0; @@ -199,7 +199,7 @@ static void fetch_linear_gradient(uint32_t* buffer, const linear_gradient_values } } -static void fetch_radial_gradient(uint32_t* buffer, const radial_gradient_values_t* v, const gradient_data_t* gradient, int y, int x, int length) +static void fetch_radial_gradient(uint32_t* buffer, const radial_gradient_values_t* v, const gradient_data_t* gradient, const int y, const int x, const int length) { if(v->a == 0.0) { @@ -276,7 +276,7 @@ static void fetch_radial_gradient(uint32_t* buffer, const radial_gradient_values } } -static void composition_solid_source(uint32_t* dest, int length, uint32_t color, uint32_t alpha) +static void composition_solid_source(uint32_t* dest, const int length, uint32_t color, const uint32_t alpha) { if(alpha == 255) { @@ -291,7 +291,7 @@ static void composition_solid_source(uint32_t* dest, int length, uint32_t color, } } -static void composition_solid_source_over(uint32_t* dest, int length, uint32_t color, uint32_t const_alpha) +static void composition_solid_source_over(uint32_t* dest, const int length, uint32_t color, const uint32_t const_alpha) { if(const_alpha != 255) color = BYTE_MUL(color, const_alpha); uint32_t ialpha = 255 - plutovg_alpha(color); @@ -299,7 +299,7 @@ static void composition_solid_source_over(uint32_t* dest, int length, uint32_t c dest[i] = color + BYTE_MUL(dest[i], ialpha); } -static void composition_solid_destination_in(uint32_t* dest, int length, uint32_t color, uint32_t const_alpha) +static void composition_solid_destination_in(uint32_t* dest, const int length, const uint32_t color, const uint32_t const_alpha) { uint32_t a = plutovg_alpha(color); if(const_alpha != 255) a = BYTE_MUL(a, const_alpha) + 255 - const_alpha; @@ -307,7 +307,7 @@ static void composition_solid_destination_in(uint32_t* dest, int length, uint32_ dest[i] = BYTE_MUL(dest[i], a); } -static void composition_solid_destination_out(uint32_t* dest, int length, uint32_t color, uint32_t const_alpha) +static void composition_solid_destination_out(uint32_t* dest, const int length, const uint32_t color, const uint32_t const_alpha) { uint32_t a = plutovg_alpha(~color); if(const_alpha != 255) a = BYTE_MUL(a, const_alpha) + 255 - const_alpha; @@ -315,7 +315,7 @@ static void composition_solid_destination_out(uint32_t* dest, int length, uint32 dest[i] = BYTE_MUL(dest[i], a); } -static void composition_source(uint32_t* dest, int length, const uint32_t* src, uint32_t const_alpha) +static void composition_source(uint32_t* dest, const int length, const uint32_t* src, const uint32_t const_alpha) { if(const_alpha == 255) { @@ -329,7 +329,7 @@ static void composition_source(uint32_t* dest, int length, const uint32_t* src, } } -static void composition_source_over(uint32_t* dest, int length, const uint32_t* src, uint32_t const_alpha) +static void composition_source_over(uint32_t* dest, const int length, const uint32_t* src, const uint32_t const_alpha) { uint32_t s, sia; if(const_alpha == 255) @@ -357,7 +357,7 @@ static void composition_source_over(uint32_t* dest, int length, const uint32_t* } } -static void composition_destination_in(uint32_t* dest, int length, const uint32_t* src, uint32_t const_alpha) +static void composition_destination_in(uint32_t* dest, const int length, const uint32_t* src, const uint32_t const_alpha) { if(const_alpha == 255) { @@ -376,7 +376,7 @@ static void composition_destination_in(uint32_t* dest, int length, const uint32_ } } -static void composition_destination_out(uint32_t* dest, int length, const uint32_t* src, uint32_t const_alpha) +static void composition_destination_out(uint32_t* dest, const int length, const uint32_t* src, const uint32_t const_alpha) { if(const_alpha == 255) { @@ -412,7 +412,7 @@ static const composition_function_t composition_map[] = { composition_destination_out }; -static void blend_solid(plutovg_surface_t* surface, plutovg_operator_t op, const plutovg_rle_t* rle, uint32_t solid) +static void blend_solid(plutovg_surface_t* surface, const plutovg_operator_t op, const plutovg_rle_t* rle, const uint32_t solid) { composition_solid_function_t func = composition_solid_map[op]; int count = rle->spans.size; @@ -426,7 +426,7 @@ static void blend_solid(plutovg_surface_t* surface, plutovg_operator_t op, const } #define BUFFER_SIZE 1024 -static void blend_linear_gradient(plutovg_surface_t* surface, plutovg_operator_t op, const plutovg_rle_t* rle, const gradient_data_t* gradient) +static void blend_linear_gradient(plutovg_surface_t* surface, const plutovg_operator_t op, const plutovg_rle_t* rle, const gradient_data_t* gradient) { composition_function_t func = composition_map[op]; unsigned int buffer[BUFFER_SIZE]; @@ -463,7 +463,7 @@ static void blend_linear_gradient(plutovg_surface_t* surface, plutovg_operator_t } } -static void blend_radial_gradient(plutovg_surface_t* surface, plutovg_operator_t op, const plutovg_rle_t* rle, const gradient_data_t* gradient) +static void blend_radial_gradient(plutovg_surface_t* surface, const plutovg_operator_t op, const plutovg_rle_t* rle, const gradient_data_t* gradient) { composition_function_t func = composition_map[op]; unsigned int buffer[BUFFER_SIZE]; @@ -498,7 +498,7 @@ static void blend_radial_gradient(plutovg_surface_t* surface, plutovg_operator_t } #define FIXED_SCALE (1 << 16) -static void blend_transformed_argb(plutovg_surface_t* surface, plutovg_operator_t op, const plutovg_rle_t* rle, const texture_data_t* texture) +static void blend_transformed_argb(plutovg_surface_t* surface, const plutovg_operator_t op, const plutovg_rle_t* rle, const texture_data_t* texture) { composition_function_t func = composition_map[op]; uint32_t buffer[BUFFER_SIZE]; @@ -548,7 +548,7 @@ static void blend_transformed_argb(plutovg_surface_t* surface, plutovg_operator_ } } -static void blend_untransformed_argb(plutovg_surface_t* surface, plutovg_operator_t op, const plutovg_rle_t* rle, const texture_data_t* texture) +static void blend_untransformed_argb(plutovg_surface_t* surface, const plutovg_operator_t op, const plutovg_rle_t* rle, const texture_data_t* texture) { composition_function_t func = composition_map[op]; @@ -588,7 +588,7 @@ static void blend_untransformed_argb(plutovg_surface_t* surface, plutovg_operato } } -static void blend_untransformed_tiled_argb(plutovg_surface_t* surface, plutovg_operator_t op, const plutovg_rle_t* rle, const texture_data_t* texture) +static void blend_untransformed_tiled_argb(plutovg_surface_t* surface, const plutovg_operator_t op, const plutovg_rle_t* rle, const texture_data_t* texture) { composition_function_t func = composition_map[op]; @@ -634,7 +634,7 @@ static void blend_untransformed_tiled_argb(plutovg_surface_t* surface, plutovg_o } } -static void blend_transformed_tiled_argb(plutovg_surface_t* surface, plutovg_operator_t op, const plutovg_rle_t* rle, const texture_data_t* texture) +static void blend_transformed_tiled_argb(plutovg_surface_t* surface, const plutovg_operator_t op, const plutovg_rle_t* rle, const texture_data_t* texture) { composition_function_t func = composition_map[op]; uint32_t buffer[BUFFER_SIZE]; diff --git a/3rdparty/plutovg/plutovg-dash.c b/3rdparty/plutovg/plutovg-dash.c index 40a8027..8e05516 100644 --- a/3rdparty/plutovg/plutovg-dash.c +++ b/3rdparty/plutovg/plutovg-dash.c @@ -2,7 +2,7 @@ #include -plutovg_dash_t* plutovg_dash_create(double offset, const double* data, int size) +plutovg_dash_t* plutovg_dash_create(const double offset, const double* data, const int size) { if(data==NULL || size==0) return NULL; diff --git a/3rdparty/plutovg/plutovg-ft-math.c b/3rdparty/plutovg/plutovg-ft-math.c index 417242b..98c01ac 100644 --- a/3rdparty/plutovg/plutovg-ft-math.c +++ b/3rdparty/plutovg/plutovg-ft-math.c @@ -19,7 +19,7 @@ #if defined(_MSC_VER) #include -static unsigned int __inline clz(unsigned int x) { +static unsigned int __inline clz(const unsigned int x) { unsigned long r = 0; if (x != 0) { @@ -281,7 +281,7 @@ static void ft_trig_pseudo_polarize(PVG_FT_Vector* vec) /* documentation is in fttrigon.h */ -PVG_FT_Fixed PVG_FT_Cos(PVG_FT_Angle angle) +PVG_FT_Fixed PVG_FT_Cos(const PVG_FT_Angle angle) { PVG_FT_Vector v; @@ -294,14 +294,14 @@ PVG_FT_Fixed PVG_FT_Cos(PVG_FT_Angle angle) /* documentation is in fttrigon.h */ -PVG_FT_Fixed PVG_FT_Sin(PVG_FT_Angle angle) +PVG_FT_Fixed PVG_FT_Sin(const PVG_FT_Angle angle) { return PVG_FT_Cos(PVG_FT_ANGLE_PI2 - angle); } /* documentation is in fttrigon.h */ -PVG_FT_Fixed PVG_FT_Tan(PVG_FT_Angle angle) +PVG_FT_Fixed PVG_FT_Tan(const PVG_FT_Angle angle) { PVG_FT_Vector v; @@ -314,7 +314,7 @@ PVG_FT_Fixed PVG_FT_Tan(PVG_FT_Angle angle) /* documentation is in fttrigon.h */ -PVG_FT_Angle PVG_FT_Atan2(PVG_FT_Fixed dx, PVG_FT_Fixed dy) +PVG_FT_Angle PVG_FT_Atan2(const PVG_FT_Fixed dx, const PVG_FT_Fixed dy) { PVG_FT_Vector v; @@ -330,7 +330,7 @@ PVG_FT_Angle PVG_FT_Atan2(PVG_FT_Fixed dx, PVG_FT_Fixed dy) /* documentation is in fttrigon.h */ -void PVG_FT_Vector_Unit(PVG_FT_Vector* vec, PVG_FT_Angle angle) +void PVG_FT_Vector_Unit(PVG_FT_Vector* vec, const PVG_FT_Angle angle) { vec->x = PVG_FT_TRIG_SCALE >> 8; vec->y = 0; @@ -339,7 +339,7 @@ void PVG_FT_Vector_Unit(PVG_FT_Vector* vec, PVG_FT_Angle angle) vec->y = (vec->y + 0x80L) >> 8; } -void PVG_FT_Vector_Rotate(PVG_FT_Vector* vec, PVG_FT_Angle angle) +void PVG_FT_Vector_Rotate(PVG_FT_Vector* vec, const PVG_FT_Angle angle) { PVG_FT_Int shift; PVG_FT_Vector v = *vec; @@ -419,8 +419,8 @@ void PVG_FT_Vector_Polarize(PVG_FT_Vector* vec, PVG_FT_Fixed* length, /* documentation is in fttrigon.h */ -void PVG_FT_Vector_From_Polar(PVG_FT_Vector* vec, PVG_FT_Fixed length, - PVG_FT_Angle angle) +void PVG_FT_Vector_From_Polar(PVG_FT_Vector* vec, const PVG_FT_Fixed length, + const PVG_FT_Angle angle) { vec->x = length; vec->y = 0; @@ -430,7 +430,7 @@ void PVG_FT_Vector_From_Polar(PVG_FT_Vector* vec, PVG_FT_Fixed length, /* documentation is in fttrigon.h */ -PVG_FT_Angle PVG_FT_Angle_Diff( PVG_FT_Angle angle1, PVG_FT_Angle angle2 ) +PVG_FT_Angle PVG_FT_Angle_Diff(const PVG_FT_Angle angle1, const PVG_FT_Angle angle2 ) { PVG_FT_Angle delta = angle2 - angle1; diff --git a/3rdparty/plutovg/plutovg-ft-raster.c b/3rdparty/plutovg/plutovg-ft-raster.c index dd99c86..304c9d7 100644 --- a/3rdparty/plutovg/plutovg-ft-raster.c +++ b/3rdparty/plutovg/plutovg-ft-raster.c @@ -203,7 +203,7 @@ PVG_FT_END_STMNT /* */ static void gray_init_cells( RAS_ARG_ void* buffer, - long byte_size ) + const long byte_size ) { ras.buffer = buffer; ras.buffer_size = byte_size; @@ -372,7 +372,7 @@ PVG_FT_END_STMNT /* */ static void gray_start_cell( RAS_ARG_ TCoord ex, - TCoord ey ) + const TCoord ey ) { if ( ex > ras.max_ex ) ex = (TCoord)( ras.max_ex ); @@ -397,11 +397,11 @@ PVG_FT_END_STMNT /* Render a scanline as one or more cells. */ /* */ static void - gray_render_scanline( RAS_ARG_ TCoord ey, - TPos x1, - TCoord y1, - TPos x2, - TCoord y2 ) + gray_render_scanline( RAS_ARG_ const TCoord ey, + const TPos x1, + TCoord y1, + const TPos x2, + const TCoord y2 ) { TCoord ex1, ex2, fx1, fx2, first, dy, delta, mod; TPos p, dx; @@ -492,8 +492,8 @@ PVG_FT_END_STMNT /* Render a given line as a series of scanlines. */ /* */ static void - gray_render_line( RAS_ARG_ TPos to_x, - TPos to_y ) + gray_render_line( RAS_ARG_ const TPos to_x, + const TPos to_y ) { TCoord ey1, ey2, fy1, fy2, first, delta, mod; TPos p, dx, dy, x, x2; @@ -1006,7 +1006,7 @@ PVG_FT_END_STMNT static int gray_move_to( const PVG_FT_Vector* to, - PWorker worker ) + const PWorker worker ) { TPos x, y; @@ -1030,8 +1030,8 @@ PVG_FT_END_STMNT static void gray_hline( RAS_ARG_ TCoord x, TCoord y, - TPos area, - int acount ) + const TPos area, + const int acount ) { int coverage; @@ -1557,7 +1557,7 @@ PVG_FT_END_STMNT static int - gray_raster_render( RAS_ARG_ void* buffer, long buffer_size, + gray_raster_render( RAS_ARG_ void* buffer, const long buffer_size, const PVG_FT_Raster_Params* params ) { const PVG_FT_Outline* outline = (const PVG_FT_Outline*)params->source; diff --git a/3rdparty/plutovg/plutovg-ft-stroker.c b/3rdparty/plutovg/plutovg-ft-stroker.c index 2d2f446..8dd63fa 100644 --- a/3rdparty/plutovg/plutovg-ft-stroker.c +++ b/3rdparty/plutovg/plutovg-ft-stroker.c @@ -38,7 +38,7 @@ #define PVG_FT_IS_SMALL(x) ((x) > -PVG_FT_EPSILON && (x) < PVG_FT_EPSILON) -static PVG_FT_Pos ft_pos_abs(PVG_FT_Pos x) +static PVG_FT_Pos ft_pos_abs(const PVG_FT_Pos x) { return x >= 0 ? x : -x; } @@ -132,7 +132,7 @@ static void ft_cubic_split(PVG_FT_Vector* base) /* Return the average of `angle1' and `angle2'. */ /* This gives correct result even if `angle1' and `angle2' */ /* have opposite signs. */ -static PVG_FT_Angle ft_angle_mean(PVG_FT_Angle angle1, PVG_FT_Angle angle2) +static PVG_FT_Angle ft_angle_mean(const PVG_FT_Angle angle1, const PVG_FT_Angle angle2) { return angle1 + PVG_FT_Angle_Diff(angle1, angle2) / 2; } @@ -309,8 +309,8 @@ void PVG_FT_Outline_Get_CBox(const PVG_FT_Outline* outline, PVG_FT_BBox* acbox) } } -static PVG_FT_Error ft_stroke_border_grow(PVG_FT_StrokeBorder border, - PVG_FT_UInt new_points) +static PVG_FT_Error ft_stroke_border_grow(const PVG_FT_StrokeBorder border, + const PVG_FT_UInt new_points) { PVG_FT_UInt old_max = border->max_points; PVG_FT_UInt new_max = border->num_points + new_points; @@ -335,8 +335,8 @@ static PVG_FT_Error ft_stroke_border_grow(PVG_FT_StrokeBorder border, return error; } -static void ft_stroke_border_close(PVG_FT_StrokeBorder border, - PVG_FT_Bool reverse) +static void ft_stroke_border_close(const PVG_FT_StrokeBorder border, + const PVG_FT_Bool reverse) { PVG_FT_UInt start = border->start; PVG_FT_UInt count = border->num_points; @@ -391,8 +391,8 @@ static void ft_stroke_border_close(PVG_FT_StrokeBorder border, border->movable = FALSE; } -static PVG_FT_Error ft_stroke_border_lineto(PVG_FT_StrokeBorder border, - PVG_FT_Vector* to, PVG_FT_Bool movable) +static PVG_FT_Error ft_stroke_border_lineto(const PVG_FT_StrokeBorder border, + PVG_FT_Vector* to, const PVG_FT_Bool movable) { PVG_FT_Error error = 0; @@ -424,9 +424,9 @@ static PVG_FT_Error ft_stroke_border_lineto(PVG_FT_StrokeBorder border, return error; } -static PVG_FT_Error ft_stroke_border_conicto(PVG_FT_StrokeBorder border, - PVG_FT_Vector* control, - PVG_FT_Vector* to) +static PVG_FT_Error ft_stroke_border_conicto(const PVG_FT_StrokeBorder border, + PVG_FT_Vector* control, + PVG_FT_Vector* to) { PVG_FT_Error error; @@ -451,10 +451,10 @@ static PVG_FT_Error ft_stroke_border_conicto(PVG_FT_StrokeBorder border, return error; } -static PVG_FT_Error ft_stroke_border_cubicto(PVG_FT_StrokeBorder border, - PVG_FT_Vector* control1, - PVG_FT_Vector* control2, - PVG_FT_Vector* to) +static PVG_FT_Error ft_stroke_border_cubicto(const PVG_FT_StrokeBorder border, + PVG_FT_Vector* control1, + PVG_FT_Vector* control2, + PVG_FT_Vector* to) { PVG_FT_Error error; @@ -485,11 +485,11 @@ static PVG_FT_Error ft_stroke_border_cubicto(PVG_FT_StrokeBorder border, static PVG_FT_Error -ft_stroke_border_arcto( PVG_FT_StrokeBorder border, - PVG_FT_Vector* center, - PVG_FT_Fixed radius, - PVG_FT_Angle angle_start, - PVG_FT_Angle angle_diff ) +ft_stroke_border_arcto(const PVG_FT_StrokeBorder border, + PVG_FT_Vector* center, + const PVG_FT_Fixed radius, + const PVG_FT_Angle angle_start, + const PVG_FT_Angle angle_diff ) { PVG_FT_Fixed coef; PVG_FT_Vector a0, a1, a2, a3; @@ -542,8 +542,8 @@ ft_stroke_border_arcto( PVG_FT_StrokeBorder border, return error; } -static PVG_FT_Error ft_stroke_border_moveto(PVG_FT_StrokeBorder border, - PVG_FT_Vector* to) +static PVG_FT_Error ft_stroke_border_moveto(const PVG_FT_StrokeBorder border, + PVG_FT_Vector* to) { /* close current open path if any ? */ if (border->start >= 0) ft_stroke_border_close(border, FALSE); @@ -554,7 +554,7 @@ static PVG_FT_Error ft_stroke_border_moveto(PVG_FT_StrokeBorder border, return ft_stroke_border_lineto(border, to, FALSE); } -static void ft_stroke_border_init(PVG_FT_StrokeBorder border) +static void ft_stroke_border_init(const PVG_FT_StrokeBorder border) { border->points = NULL; border->tags = NULL; @@ -565,14 +565,14 @@ static void ft_stroke_border_init(PVG_FT_StrokeBorder border) border->valid = FALSE; } -static void ft_stroke_border_reset(PVG_FT_StrokeBorder border) +static void ft_stroke_border_reset(const PVG_FT_StrokeBorder border) { border->num_points = 0; border->start = -1; border->valid = FALSE; } -static void ft_stroke_border_done(PVG_FT_StrokeBorder border) +static void ft_stroke_border_done(const PVG_FT_StrokeBorder border) { free(border->points); free(border->tags); @@ -583,9 +583,9 @@ static void ft_stroke_border_done(PVG_FT_StrokeBorder border) border->valid = FALSE; } -static PVG_FT_Error ft_stroke_border_get_counts(PVG_FT_StrokeBorder border, - PVG_FT_UInt* anum_points, - PVG_FT_UInt* anum_contours) +static PVG_FT_Error ft_stroke_border_get_counts(const PVG_FT_StrokeBorder border, + PVG_FT_UInt* anum_points, + PVG_FT_UInt* anum_contours) { PVG_FT_Error error = 0; PVG_FT_UInt num_points = 0; @@ -625,7 +625,7 @@ static PVG_FT_Error ft_stroke_border_get_counts(PVG_FT_StrokeBorder border, goto Exit; } -static void ft_stroke_border_export(PVG_FT_StrokeBorder border, +static void ft_stroke_border_export(const PVG_FT_StrokeBorder border, PVG_FT_Outline* outline) { /* copy point locations */ @@ -720,7 +720,7 @@ PVG_FT_Error PVG_FT_Stroker_New(PVG_FT_Stroker* astroker) return error; } -void PVG_FT_Stroker_Rewind(PVG_FT_Stroker stroker) +void PVG_FT_Stroker_Rewind(const PVG_FT_Stroker stroker) { if (stroker) { ft_stroke_border_reset(&stroker->borders[0]); @@ -730,10 +730,10 @@ void PVG_FT_Stroker_Rewind(PVG_FT_Stroker stroker) /* documentation is in ftstroke.h */ -void PVG_FT_Stroker_Set(PVG_FT_Stroker stroker, PVG_FT_Fixed radius, - PVG_FT_Stroker_LineCap line_cap, - PVG_FT_Stroker_LineJoin line_join, - PVG_FT_Fixed miter_limit) +void PVG_FT_Stroker_Set(const PVG_FT_Stroker stroker, const PVG_FT_Fixed radius, + const PVG_FT_Stroker_LineCap line_cap, + const PVG_FT_Stroker_LineJoin line_join, + const PVG_FT_Fixed miter_limit) { stroker->radius = radius; stroker->line_cap = line_cap; @@ -752,7 +752,7 @@ void PVG_FT_Stroker_Set(PVG_FT_Stroker stroker, PVG_FT_Fixed radius, /* documentation is in ftstroke.h */ -void PVG_FT_Stroker_Done(PVG_FT_Stroker stroker) +void PVG_FT_Stroker_Done(const PVG_FT_Stroker stroker) { if (stroker) { ft_stroke_border_done(&stroker->borders[0]); @@ -763,7 +763,7 @@ void PVG_FT_Stroker_Done(PVG_FT_Stroker stroker) } /* create a circular arc at a corner or cap */ -static PVG_FT_Error ft_stroker_arcto(PVG_FT_Stroker stroker, PVG_FT_Int side) +static PVG_FT_Error ft_stroker_arcto(const PVG_FT_Stroker stroker, const PVG_FT_Int side) { PVG_FT_Angle total, rotate; PVG_FT_Fixed radius = stroker->radius; @@ -783,9 +783,9 @@ static PVG_FT_Error ft_stroker_arcto(PVG_FT_Stroker stroker, PVG_FT_Int side) /* add a cap at the end of an opened path */ static PVG_FT_Error -ft_stroker_cap(PVG_FT_Stroker stroker, - PVG_FT_Angle angle, - PVG_FT_Int side) +ft_stroker_cap(const PVG_FT_Stroker stroker, + const PVG_FT_Angle angle, + const PVG_FT_Int side) { PVG_FT_Error error = 0; @@ -839,8 +839,8 @@ ft_stroker_cap(PVG_FT_Stroker stroker, } /* process an inside corner, i.e. compute intersection */ -static PVG_FT_Error ft_stroker_inside(PVG_FT_Stroker stroker, PVG_FT_Int side, - PVG_FT_Fixed line_length) +static PVG_FT_Error ft_stroker_inside(const PVG_FT_Stroker stroker, const PVG_FT_Int side, + const PVG_FT_Fixed line_length) { PVG_FT_StrokeBorder border = stroker->borders + side; PVG_FT_Angle phi, theta, rotate; @@ -898,9 +898,9 @@ static PVG_FT_Error ft_stroker_inside(PVG_FT_Stroker stroker, PVG_FT_Int side, /* process an outside corner, i.e. compute bevel/miter/round */ static PVG_FT_Error -ft_stroker_outside( PVG_FT_Stroker stroker, - PVG_FT_Int side, - PVG_FT_Fixed line_length ) +ft_stroker_outside(const PVG_FT_Stroker stroker, + const PVG_FT_Int side, + const PVG_FT_Fixed line_length ) { PVG_FT_StrokeBorder border = stroker->borders + side; PVG_FT_Error error; @@ -1049,8 +1049,8 @@ ft_stroker_outside( PVG_FT_Stroker stroker, return error; } -static PVG_FT_Error ft_stroker_process_corner(PVG_FT_Stroker stroker, - PVG_FT_Fixed line_length) +static PVG_FT_Error ft_stroker_process_corner(const PVG_FT_Stroker stroker, + const PVG_FT_Fixed line_length) { PVG_FT_Error error = 0; PVG_FT_Angle turn; @@ -1080,9 +1080,9 @@ static PVG_FT_Error ft_stroker_process_corner(PVG_FT_Stroker stroker, /* add two points to the left and right borders corresponding to the */ /* start of the subpath */ -static PVG_FT_Error ft_stroker_subpath_start(PVG_FT_Stroker stroker, - PVG_FT_Angle start_angle, - PVG_FT_Fixed line_length) +static PVG_FT_Error ft_stroker_subpath_start(const PVG_FT_Stroker stroker, + const PVG_FT_Angle start_angle, + const PVG_FT_Fixed line_length) { PVG_FT_Vector delta; PVG_FT_Vector point; @@ -1117,7 +1117,7 @@ static PVG_FT_Error ft_stroker_subpath_start(PVG_FT_Stroker stroker, /* documentation is in ftstroke.h */ -PVG_FT_Error PVG_FT_Stroker_LineTo(PVG_FT_Stroker stroker, PVG_FT_Vector* to) +PVG_FT_Error PVG_FT_Stroker_LineTo(const PVG_FT_Stroker stroker, PVG_FT_Vector* to) { PVG_FT_Error error = 0; PVG_FT_StrokeBorder border; @@ -1177,8 +1177,8 @@ PVG_FT_Error PVG_FT_Stroker_LineTo(PVG_FT_Stroker stroker, PVG_FT_Vector* to) /* documentation is in ftstroke.h */ -PVG_FT_Error PVG_FT_Stroker_ConicTo(PVG_FT_Stroker stroker, PVG_FT_Vector* control, - PVG_FT_Vector* to) +PVG_FT_Error PVG_FT_Stroker_ConicTo(const PVG_FT_Stroker stroker, PVG_FT_Vector* control, + PVG_FT_Vector* to) { PVG_FT_Error error = 0; PVG_FT_Vector bez_stack[34]; @@ -1350,8 +1350,8 @@ PVG_FT_Error PVG_FT_Stroker_ConicTo(PVG_FT_Stroker stroker, PVG_FT_Vector* contr /* documentation is in ftstroke.h */ -PVG_FT_Error PVG_FT_Stroker_CubicTo(PVG_FT_Stroker stroker, PVG_FT_Vector* control1, - PVG_FT_Vector* control2, PVG_FT_Vector* to) +PVG_FT_Error PVG_FT_Stroker_CubicTo(const PVG_FT_Stroker stroker, PVG_FT_Vector* control1, + PVG_FT_Vector* control2, PVG_FT_Vector* to) { PVG_FT_Error error = 0; PVG_FT_Vector bez_stack[37]; @@ -1534,8 +1534,8 @@ PVG_FT_Error PVG_FT_Stroker_CubicTo(PVG_FT_Stroker stroker, PVG_FT_Vector* contr /* documentation is in ftstroke.h */ -PVG_FT_Error PVG_FT_Stroker_BeginSubPath(PVG_FT_Stroker stroker, PVG_FT_Vector* to, - PVG_FT_Bool open) +PVG_FT_Error PVG_FT_Stroker_BeginSubPath(const PVG_FT_Stroker stroker, PVG_FT_Vector* to, + const PVG_FT_Bool open) { /* We cannot process the first point, because there is not enough */ /* information regarding its corner/cap. The latter will be processed */ @@ -1563,8 +1563,8 @@ PVG_FT_Error PVG_FT_Stroker_BeginSubPath(PVG_FT_Stroker stroker, PVG_FT_Vector* return 0; } -static PVG_FT_Error ft_stroker_add_reverse_left(PVG_FT_Stroker stroker, - PVG_FT_Bool open) +static PVG_FT_Error ft_stroker_add_reverse_left(const PVG_FT_Stroker stroker, + const PVG_FT_Bool open) { PVG_FT_StrokeBorder right = stroker->borders + 0; PVG_FT_StrokeBorder left = stroker->borders + 1; @@ -1621,7 +1621,7 @@ static PVG_FT_Error ft_stroker_add_reverse_left(PVG_FT_Stroker stroker, /* documentation is in ftstroke.h */ /* there's a lot of magic in this function! */ -PVG_FT_Error PVG_FT_Stroker_EndSubPath(PVG_FT_Stroker stroker) +PVG_FT_Error PVG_FT_Stroker_EndSubPath(const PVG_FT_Stroker stroker) { PVG_FT_Error error = 0; @@ -1691,10 +1691,10 @@ PVG_FT_Error PVG_FT_Stroker_EndSubPath(PVG_FT_Stroker stroker) /* documentation is in ftstroke.h */ -PVG_FT_Error PVG_FT_Stroker_GetBorderCounts(PVG_FT_Stroker stroker, - PVG_FT_StrokerBorder border, - PVG_FT_UInt* anum_points, - PVG_FT_UInt* anum_contours) +PVG_FT_Error PVG_FT_Stroker_GetBorderCounts(const PVG_FT_Stroker stroker, + const PVG_FT_StrokerBorder border, + PVG_FT_UInt* anum_points, + PVG_FT_UInt* anum_contours) { PVG_FT_UInt num_points = 0, num_contours = 0; PVG_FT_Error error; @@ -1716,9 +1716,9 @@ PVG_FT_Error PVG_FT_Stroker_GetBorderCounts(PVG_FT_Stroker stroker, /* documentation is in ftstroke.h */ -PVG_FT_Error PVG_FT_Stroker_GetCounts(PVG_FT_Stroker stroker, - PVG_FT_UInt* anum_points, - PVG_FT_UInt* anum_contours) +PVG_FT_Error PVG_FT_Stroker_GetCounts(const PVG_FT_Stroker stroker, + PVG_FT_UInt* anum_points, + PVG_FT_UInt* anum_contours) { PVG_FT_UInt count1, count2, num_points = 0; PVG_FT_UInt count3, count4, num_contours = 0; @@ -1741,9 +1741,9 @@ PVG_FT_Error PVG_FT_Stroker_GetCounts(PVG_FT_Stroker stroker, /* documentation is in ftstroke.h */ -void PVG_FT_Stroker_ExportBorder(PVG_FT_Stroker stroker, - PVG_FT_StrokerBorder border, - PVG_FT_Outline* outline) +void PVG_FT_Stroker_ExportBorder(const PVG_FT_Stroker stroker, + const PVG_FT_StrokerBorder border, + PVG_FT_Outline* outline) { if (border == PVG_FT_STROKER_BORDER_LEFT || border == PVG_FT_STROKER_BORDER_RIGHT) { @@ -1755,7 +1755,7 @@ void PVG_FT_Stroker_ExportBorder(PVG_FT_Stroker stroker, /* documentation is in ftstroke.h */ -void PVG_FT_Stroker_Export(PVG_FT_Stroker stroker, PVG_FT_Outline* outline) +void PVG_FT_Stroker_Export(const PVG_FT_Stroker stroker, PVG_FT_Outline* outline) { PVG_FT_Stroker_ExportBorder(stroker, PVG_FT_STROKER_BORDER_LEFT, outline); PVG_FT_Stroker_ExportBorder(stroker, PVG_FT_STROKER_BORDER_RIGHT, outline); @@ -1767,8 +1767,8 @@ void PVG_FT_Stroker_Export(PVG_FT_Stroker stroker, PVG_FT_Outline* outline) * The following is very similar to PVG_FT_Outline_Decompose, except * that we do support opened paths, and do not scale the outline. */ -PVG_FT_Error PVG_FT_Stroker_ParseOutline(PVG_FT_Stroker stroker, - const PVG_FT_Outline* outline) +PVG_FT_Error PVG_FT_Stroker_ParseOutline(const PVG_FT_Stroker stroker, + const PVG_FT_Outline* outline) { PVG_FT_Vector v_last; PVG_FT_Vector v_control; diff --git a/3rdparty/plutovg/plutovg-geometry.c b/3rdparty/plutovg/plutovg-geometry.c index 6bc7489..54ec309 100644 --- a/3rdparty/plutovg/plutovg-geometry.c +++ b/3rdparty/plutovg/plutovg-geometry.c @@ -2,7 +2,7 @@ #include -void plutovg_rect_init(plutovg_rect_t* rect, double x, double y, double w, double h) +void plutovg_rect_init(plutovg_rect_t* rect, const double x, const double y, const double w, const double h) { rect->x = x; rect->y = y; @@ -18,7 +18,7 @@ void plutovg_rect_init_zero(plutovg_rect_t* rect) rect->h = 0.0; } -void plutovg_matrix_init(plutovg_matrix_t* matrix, double m00, double m10, double m01, double m11, double m02, double m12) +void plutovg_matrix_init(plutovg_matrix_t* matrix, const double m00, const double m10, const double m01, const double m11, const double m02, const double m12) { matrix->m00 = m00; matrix->m10 = m10; matrix->m01 = m01; matrix->m11 = m11; @@ -32,22 +32,22 @@ void plutovg_matrix_init_identity(plutovg_matrix_t* matrix) matrix->m02 = 0.0; matrix->m12 = 0.0; } -void plutovg_matrix_init_translate(plutovg_matrix_t* matrix, double x, double y) +void plutovg_matrix_init_translate(plutovg_matrix_t* matrix, const double x, const double y) { plutovg_matrix_init(matrix, 1.0, 0.0, 0.0, 1.0, x, y); } -void plutovg_matrix_init_scale(plutovg_matrix_t* matrix, double x, double y) +void plutovg_matrix_init_scale(plutovg_matrix_t* matrix, const double x, const double y) { plutovg_matrix_init(matrix, x, 0.0, 0.0, y, 0.0, 0.0); } -void plutovg_matrix_init_shear(plutovg_matrix_t* matrix, double x, double y) +void plutovg_matrix_init_shear(plutovg_matrix_t* matrix, const double x, const double y) { plutovg_matrix_init(matrix, 1.0, tan(y), tan(x), 1.0, 0.0, 0.0); } -void plutovg_matrix_init_rotate(plutovg_matrix_t* matrix, double radians, double x, double y) +void plutovg_matrix_init_rotate(plutovg_matrix_t* matrix, const double radians, const double x, const double y) { double c = cos(radians); double s = sin(radians); @@ -58,28 +58,28 @@ void plutovg_matrix_init_rotate(plutovg_matrix_t* matrix, double radians, double plutovg_matrix_init(matrix, c, s, -s, c, cx, cy); } -void plutovg_matrix_translate(plutovg_matrix_t* matrix, double x, double y) +void plutovg_matrix_translate(plutovg_matrix_t* matrix, const double x, const double y) { plutovg_matrix_t m; plutovg_matrix_init_translate(&m, x, y); plutovg_matrix_multiply(matrix, &m, matrix); } -void plutovg_matrix_scale(plutovg_matrix_t* matrix, double x, double y) +void plutovg_matrix_scale(plutovg_matrix_t* matrix, const double x, const double y) { plutovg_matrix_t m; plutovg_matrix_init_scale(&m, x, y); plutovg_matrix_multiply(matrix, &m, matrix); } -void plutovg_matrix_shear(plutovg_matrix_t* matrix, double x, double y) +void plutovg_matrix_shear(plutovg_matrix_t* matrix, const double x, const double y) { plutovg_matrix_t m; plutovg_matrix_init_shear(&m, x, y); plutovg_matrix_multiply(matrix, &m, matrix); } -void plutovg_matrix_rotate(plutovg_matrix_t* matrix, double radians, double x, double y) +void plutovg_matrix_rotate(plutovg_matrix_t* matrix, const double radians, const double x, const double y) { plutovg_matrix_t m; plutovg_matrix_init_rotate(&m, radians, x, y); @@ -116,7 +116,7 @@ int plutovg_matrix_invert(plutovg_matrix_t* matrix) return 1; } -void plutovg_matrix_map(const plutovg_matrix_t* matrix, double x, double y, double* _x, double* _y) +void plutovg_matrix_map(const plutovg_matrix_t* matrix, const double x, const double y, double* _x, double* _y) { *_x = x * matrix->m00 + y * matrix->m01 + matrix->m02; *_y = x * matrix->m10 + y * matrix->m11 + matrix->m12; @@ -199,7 +199,7 @@ int plutovg_path_get_reference_count(const plutovg_path_t* path) return path->ref; } -void plutovg_path_move_to(plutovg_path_t* path, double x, double y) +void plutovg_path_move_to(plutovg_path_t* path, const double x, const double y) { plutovg_array_ensure(path->elements, 1); plutovg_array_ensure(path->points, 1); @@ -217,7 +217,7 @@ void plutovg_path_move_to(plutovg_path_t* path, double x, double y) path->start.y = y; } -void plutovg_path_line_to(plutovg_path_t* path, double x, double y) +void plutovg_path_line_to(plutovg_path_t* path, const double x, const double y) { plutovg_array_ensure(path->elements, 1); plutovg_array_ensure(path->points, 1); @@ -231,7 +231,7 @@ void plutovg_path_line_to(plutovg_path_t* path, double x, double y) path->points.size += 1; } -void plutovg_path_quad_to(plutovg_path_t* path, double x1, double y1, double x2, double y2) +void plutovg_path_quad_to(plutovg_path_t* path, const double x1, const double y1, const double x2, const double y2) { double x, y; plutovg_path_get_current_point(path, &x, &y); @@ -243,7 +243,7 @@ void plutovg_path_quad_to(plutovg_path_t* path, double x1, double y1, double x2, plutovg_path_cubic_to(path, cx, cy, cx1, cy1, x2, y2); } -void plutovg_path_cubic_to(plutovg_path_t* path, double x1, double y1, double x2, double y2, double x3, double y3) +void plutovg_path_cubic_to(plutovg_path_t* path, const double x1, const double y1, const double x2, const double y2, const double x3, const double y3) { plutovg_array_ensure(path->elements, 1); plutovg_array_ensure(path->points, 3); @@ -317,7 +317,7 @@ void plutovg_path_rel_cubic_to(plutovg_path_t* path, double x1, double y1, doubl plutovg_path_cubic_to(path, x1, y1, x2, y2, x3, y3); } -void plutovg_path_add_rect(plutovg_path_t* path, double x, double y, double w, double h) +void plutovg_path_add_rect(plutovg_path_t* path, const double x, const double y, const double w, const double h) { plutovg_path_move_to(path, x, y); plutovg_path_line_to(path, x + w, y); @@ -327,7 +327,7 @@ void plutovg_path_add_rect(plutovg_path_t* path, double x, double y, double w, d plutovg_path_close(path); } -void plutovg_path_add_round_rect(plutovg_path_t* path, double x, double y, double w, double h, double rx, double ry) +void plutovg_path_add_round_rect(plutovg_path_t* path, const double x, const double y, const double w, const double h, const double rx, const double ry) { double right = x + w; double bottom = y + h; @@ -347,7 +347,7 @@ void plutovg_path_add_round_rect(plutovg_path_t* path, double x, double y, doubl plutovg_path_close(path); } -void plutovg_path_add_ellipse(plutovg_path_t* path, double cx, double cy, double rx, double ry) +void plutovg_path_add_ellipse(plutovg_path_t* path, const double cx, const double cy, const double rx, const double ry) { double left = cx - rx; double top = cy - ry; @@ -365,7 +365,7 @@ void plutovg_path_add_ellipse(plutovg_path_t* path, double cx, double cy, double plutovg_path_close(path); } -void plutovg_path_add_circle(plutovg_path_t* path, double cx, double cy, double r) +void plutovg_path_add_circle(plutovg_path_t* path, const double cx, const double cy, const double r) { plutovg_path_add_ellipse(path, cx, cy, r, r); } diff --git a/3rdparty/plutovg/plutovg-paint.c b/3rdparty/plutovg/plutovg-paint.c index 2472313..1b5bb36 100644 --- a/3rdparty/plutovg/plutovg-paint.c +++ b/3rdparty/plutovg/plutovg-paint.c @@ -1,11 +1,11 @@ #include "plutovg-private.h" -void plutovg_color_init_rgb(plutovg_color_t* color, double r, double g, double b) +void plutovg_color_init_rgb(plutovg_color_t* color, const double r, const double g, const double b) { plutovg_color_init_rgba(color, r, g, b, 1.0); } -void plutovg_color_init_rgba(plutovg_color_t* color, double r, double g, double b, double a) +void plutovg_color_init_rgba(plutovg_color_t* color, const double r, const double g, const double b, const double a) { color->r = plutovg_clamp(r, 0.0, 1.0); color->g = plutovg_clamp(g, 0.0, 1.0); @@ -13,7 +13,7 @@ void plutovg_color_init_rgba(plutovg_color_t* color, double r, double g, double color->a = plutovg_clamp(a, 0.0, 1.0); } -void plutovg_gradient_init_linear(plutovg_gradient_t* gradient, double x1, double y1, double x2, double y2) +void plutovg_gradient_init_linear(plutovg_gradient_t* gradient, const double x1, const double y1, const double x2, const double y2) { gradient->type = plutovg_gradient_type_linear; gradient->spread = plutovg_spread_method_pad; @@ -23,7 +23,7 @@ void plutovg_gradient_init_linear(plutovg_gradient_t* gradient, double x1, doubl plutovg_gradient_set_values_linear(gradient, x1, y1, x2, y2); } -void plutovg_gradient_init_radial(plutovg_gradient_t* gradient, double cx, double cy, double cr, double fx, double fy, double fr) +void plutovg_gradient_init_radial(plutovg_gradient_t* gradient, const double cx, const double cy, const double cr, const double fx, const double fy, const double fr) { gradient->type = plutovg_gradient_type_radial; gradient->spread = plutovg_spread_method_pad; @@ -33,7 +33,7 @@ void plutovg_gradient_init_radial(plutovg_gradient_t* gradient, double cx, doubl plutovg_gradient_set_values_radial(gradient, cx, cy, cr, fx, fy, fr); } -void plutovg_gradient_set_spread(plutovg_gradient_t* gradient, plutovg_spread_method_t spread) +void plutovg_gradient_set_spread(plutovg_gradient_t* gradient, const plutovg_spread_method_t spread) { gradient->spread = spread; } @@ -53,12 +53,12 @@ void plutovg_gradient_get_matrix(const plutovg_gradient_t* gradient, plutovg_mat *matrix = gradient->matrix; } -void plutovg_gradient_add_stop_rgb(plutovg_gradient_t* gradient, double offset, double r, double g, double b) +void plutovg_gradient_add_stop_rgb(plutovg_gradient_t* gradient, const double offset, const double r, const double g, const double b) { plutovg_gradient_add_stop_rgba(gradient, offset, r, g, b, 1.0); } -void plutovg_gradient_add_stop_rgba(plutovg_gradient_t* gradient, double offset, double r, double g, double b, double a) +void plutovg_gradient_add_stop_rgba(plutovg_gradient_t* gradient, double offset, const double r, const double g, const double b, const double a) { if(offset < 0.0) offset = 0.0; if(offset > 1.0) offset = 1.0; @@ -80,7 +80,7 @@ void plutovg_gradient_add_stop_rgba(plutovg_gradient_t* gradient, double offset, gradient->stops.size += 1; } -void plutovg_gradient_add_stop_color(plutovg_gradient_t* gradient, double offset, const plutovg_color_t* color) +void plutovg_gradient_add_stop_color(plutovg_gradient_t* gradient, const double offset, const plutovg_color_t* color) { plutovg_gradient_add_stop_rgba(gradient, offset, color->r, color->g, color->b, color->a); } @@ -128,7 +128,7 @@ void plutovg_gradient_get_values_radial(const plutovg_gradient_t* gradient, doub if(fr) *fr = gradient->values[5]; } -void plutovg_gradient_set_values_linear(plutovg_gradient_t* gradient, double x1, double y1, double x2, double y2) +void plutovg_gradient_set_values_linear(plutovg_gradient_t* gradient, const double x1, const double y1, const double x2, const double y2) { gradient->values[0] = x1; gradient->values[1] = y1; @@ -136,7 +136,7 @@ void plutovg_gradient_set_values_linear(plutovg_gradient_t* gradient, double x1, gradient->values[3] = y2; } -void plutovg_gradient_set_values_radial(plutovg_gradient_t* gradient, double cx, double cy, double cr, double fx, double fy, double fr) +void plutovg_gradient_set_values_radial(plutovg_gradient_t* gradient, const double cx, const double cy, const double cr, const double fx, const double fy, const double fr) { gradient->values[0] = cx; gradient->values[1] = cy; @@ -146,7 +146,7 @@ void plutovg_gradient_set_values_radial(plutovg_gradient_t* gradient, double cx, gradient->values[5] = fr; } -void plutovg_gradient_set_opacity(plutovg_gradient_t* gradient, double opacity) +void plutovg_gradient_set_opacity(plutovg_gradient_t* gradient, const double opacity) { gradient->opacity = plutovg_clamp(opacity, 0.0, 1.0); } @@ -172,7 +172,7 @@ void plutovg_gradient_destroy(plutovg_gradient_t* gradient) plutovg_array_destroy(gradient->stops); } -void plutovg_texture_init(plutovg_texture_t* texture, plutovg_surface_t* surface, plutovg_texture_type_t type) +void plutovg_texture_init(plutovg_texture_t* texture, plutovg_surface_t* surface, const plutovg_texture_type_t type) { surface = plutovg_surface_reference(surface); plutovg_surface_destroy(texture->surface); @@ -182,7 +182,7 @@ void plutovg_texture_init(plutovg_texture_t* texture, plutovg_surface_t* surface plutovg_matrix_init_identity(&texture->matrix); } -void plutovg_texture_set_type(plutovg_texture_t* texture, plutovg_texture_type_t type) +void plutovg_texture_set_type(plutovg_texture_t* texture, const plutovg_texture_type_t type) { texture->type = type; } @@ -214,7 +214,7 @@ plutovg_surface_t* plutovg_texture_get_surface(const plutovg_texture_t* texture) return texture->surface; } -void plutovg_texture_set_opacity(plutovg_texture_t* texture, double opacity) +void plutovg_texture_set_opacity(plutovg_texture_t* texture, const double opacity) { texture->opacity = plutovg_clamp(opacity, 0.0, 1.0); } diff --git a/3rdparty/plutovg/plutovg-rle.c b/3rdparty/plutovg/plutovg-rle.c index 31eb865..80f8251 100644 --- a/3rdparty/plutovg/plutovg-rle.c +++ b/3rdparty/plutovg/plutovg-rle.c @@ -7,7 +7,7 @@ #include #define ALIGN_SIZE(size) (((size) + 7ul) & ~7ul) -static void ft_outline_init(PVG_FT_Outline* outline, plutovg_t* pluto, int points, int contours) +static void ft_outline_init(PVG_FT_Outline* outline, plutovg_t* pluto, const int points, const int contours) { size_t size_a = ALIGN_SIZE((points + contours) * sizeof(PVG_FT_Vector)); size_t size_b = ALIGN_SIZE((points + contours) * sizeof(char)); @@ -34,7 +34,7 @@ static void ft_outline_init(PVG_FT_Outline* outline, plutovg_t* pluto, int point } #define FT_COORD(x) (PVG_FT_Pos)((x) * 64) -static void ft_outline_move_to(PVG_FT_Outline* ft, double x, double y) +static void ft_outline_move_to(PVG_FT_Outline* ft, const double x, const double y) { ft->points[ft->n_points].x = FT_COORD(x); ft->points[ft->n_points].y = FT_COORD(y); @@ -48,7 +48,7 @@ static void ft_outline_move_to(PVG_FT_Outline* ft, double x, double y) ft->n_points++; } -static void ft_outline_line_to(PVG_FT_Outline* ft, double x, double y) +static void ft_outline_line_to(PVG_FT_Outline* ft, const double x, const double y) { ft->points[ft->n_points].x = FT_COORD(x); ft->points[ft->n_points].y = FT_COORD(y); @@ -56,7 +56,7 @@ static void ft_outline_line_to(PVG_FT_Outline* ft, double x, double y) ft->n_points++; } -static void ft_outline_cubic_to(PVG_FT_Outline* ft, double x1, double y1, double x2, double y2, double x3, double y3) +static void ft_outline_cubic_to(PVG_FT_Outline* ft, const double x1, const double y1, const double x2, const double y2, const double x3, const double y3) { ft->points[ft->n_points].x = FT_COORD(x1); ft->points[ft->n_points].y = FT_COORD(y1); @@ -137,7 +137,7 @@ static void ft_outline_convert_dash(PVG_FT_Outline* outline, plutovg_t* pluto, c plutovg_path_destroy(dashed); } -static void generation_callback(int count, const PVG_FT_Span* spans, void* user) +static void generation_callback(const int count, const PVG_FT_Span* spans, void* user) { plutovg_rle_t* rle = user; plutovg_array_ensure(rle->spans, count); @@ -166,7 +166,7 @@ void plutovg_rle_destroy(plutovg_rle_t* rle) free(rle); } -void plutovg_rle_rasterize(plutovg_t* pluto, plutovg_rle_t* rle, const plutovg_path_t* path, const plutovg_matrix_t* matrix, const plutovg_rect_t* clip, const plutovg_stroke_data_t* stroke, plutovg_fill_rule_t winding) +void plutovg_rle_rasterize(plutovg_t* pluto, plutovg_rle_t* rle, const plutovg_path_t* path, const plutovg_matrix_t* matrix, const plutovg_rect_t* clip, const plutovg_stroke_data_t* stroke, const plutovg_fill_rule_t winding) { PVG_FT_Raster_Params params; params.flags = PVG_FT_RASTER_FLAG_DIRECT | PVG_FT_RASTER_FLAG_AA; diff --git a/3rdparty/plutovg/plutovg.c b/3rdparty/plutovg/plutovg.c index 3b357bc..58a55d4 100644 --- a/3rdparty/plutovg/plutovg.c +++ b/3rdparty/plutovg/plutovg.c @@ -1,6 +1,6 @@ #include "plutovg-private.h" -plutovg_surface_t* plutovg_surface_create(int width, int height) +plutovg_surface_t* plutovg_surface_create(const int width, const int height) { plutovg_surface_t* surface = malloc(sizeof(plutovg_surface_t)); surface->ref = 1; @@ -12,7 +12,7 @@ plutovg_surface_t* plutovg_surface_create(int width, int height) return surface; } -plutovg_surface_t* plutovg_surface_create_for_data(unsigned char* data, int width, int height, int stride) +plutovg_surface_t* plutovg_surface_create_for_data(unsigned char* data, const int width, const int height, const int stride) { plutovg_surface_t* surface = malloc(sizeof(plutovg_surface_t)); surface->ref = 1; @@ -178,12 +178,12 @@ void plutovg_restore(plutovg_t* pluto) plutovg_state_destroy(oldstate); } -plutovg_color_t* plutovg_set_rgb(plutovg_t* pluto, double r, double g, double b) +plutovg_color_t* plutovg_set_rgb(plutovg_t* pluto, const double r, const double g, const double b) { return plutovg_set_rgba(pluto, r, g, b, 1.0); } -plutovg_color_t* plutovg_set_rgba(plutovg_t* pluto, double r, double g, double b, double a) +plutovg_color_t* plutovg_set_rgba(plutovg_t* pluto, const double r, const double g, const double b, const double a) { plutovg_paint_t* paint = &pluto->state->paint; paint->type = plutovg_paint_type_color; @@ -196,7 +196,7 @@ plutovg_color_t* plutovg_set_color(plutovg_t* pluto, const plutovg_color_t* colo return plutovg_set_rgba(pluto, color->r, color->g, color->b, color->a); } -plutovg_gradient_t* plutovg_set_linear_gradient(plutovg_t* pluto, double x1, double y1, double x2, double y2) +plutovg_gradient_t* plutovg_set_linear_gradient(plutovg_t* pluto, const double x1, const double y1, const double x2, const double y2) { plutovg_paint_t* paint = &pluto->state->paint; paint->type = plutovg_paint_type_gradient; @@ -204,7 +204,7 @@ plutovg_gradient_t* plutovg_set_linear_gradient(plutovg_t* pluto, double x1, dou return &paint->gradient; } -plutovg_gradient_t* plutovg_set_radial_gradient(plutovg_t* pluto, double cx, double cy, double cr, double fx, double fy, double fr) +plutovg_gradient_t* plutovg_set_radial_gradient(plutovg_t* pluto, const double cx, const double cy, const double cr, const double fx, const double fy, const double fr) { plutovg_paint_t* paint = &pluto->state->paint; paint->type = plutovg_paint_type_gradient; @@ -212,14 +212,14 @@ plutovg_gradient_t* plutovg_set_radial_gradient(plutovg_t* pluto, double cx, dou return &paint->gradient; } -plutovg_texture_t* plutovg_set_texture_surface(plutovg_t* pluto, plutovg_surface_t* surface, double x, double y) +plutovg_texture_t* plutovg_set_texture_surface(plutovg_t* pluto, plutovg_surface_t* surface, const double x, const double y) { plutovg_texture_t* texture = plutovg_set_texture(pluto, surface, plutovg_texture_type_plain); plutovg_matrix_init_translate(&texture->matrix, x, y); return texture; } -plutovg_texture_t* plutovg_set_texture(plutovg_t* pluto, plutovg_surface_t* surface, plutovg_texture_type_t type) +plutovg_texture_t* plutovg_set_texture(plutovg_t* pluto, plutovg_surface_t* surface, const plutovg_texture_type_t type) { plutovg_paint_t* paint = &pluto->state->paint; paint->type = plutovg_paint_type_texture; @@ -227,17 +227,17 @@ plutovg_texture_t* plutovg_set_texture(plutovg_t* pluto, plutovg_surface_t* surf return &paint->texture; } -void plutovg_set_operator(plutovg_t* pluto, plutovg_operator_t op) +void plutovg_set_operator(plutovg_t* pluto, const plutovg_operator_t op) { pluto->state->op = op; } -void plutovg_set_opacity(plutovg_t* pluto, double opacity) +void plutovg_set_opacity(plutovg_t* pluto, const double opacity) { pluto->state->opacity = opacity; } -void plutovg_set_fill_rule(plutovg_t* pluto, plutovg_fill_rule_t fill_rule) +void plutovg_set_fill_rule(plutovg_t* pluto, const plutovg_fill_rule_t fill_rule) { pluto->state->winding = fill_rule; } @@ -257,27 +257,27 @@ plutovg_fill_rule_t plutovg_get_fill_rule(const plutovg_t* pluto) return pluto->state->winding; } -void plutovg_set_line_width(plutovg_t* pluto, double width) +void plutovg_set_line_width(plutovg_t* pluto, const double width) { pluto->state->stroke.width = width; } -void plutovg_set_line_cap(plutovg_t* pluto, plutovg_line_cap_t cap) +void plutovg_set_line_cap(plutovg_t* pluto, const plutovg_line_cap_t cap) { pluto->state->stroke.cap = cap; } -void plutovg_set_line_join(plutovg_t* pluto, plutovg_line_join_t join) +void plutovg_set_line_join(plutovg_t* pluto, const plutovg_line_join_t join) { pluto->state->stroke.join = join; } -void plutovg_set_miter_limit(plutovg_t* pluto, double limit) +void plutovg_set_miter_limit(plutovg_t* pluto, const double limit) { pluto->state->stroke.miterlimit = limit; } -void plutovg_set_dash(plutovg_t* pluto, double offset, const double* data, int size) +void plutovg_set_dash(plutovg_t* pluto, const double offset, const double* data, const int size) { plutovg_dash_destroy(pluto->state->stroke.dash); pluto->state->stroke.dash = plutovg_dash_create(offset, data, size); @@ -303,17 +303,17 @@ double plutovg_get_miter_limit(const plutovg_t* pluto) return pluto->state->stroke.miterlimit; } -void plutovg_translate(plutovg_t* pluto, double x, double y) +void plutovg_translate(plutovg_t* pluto, const double x, const double y) { plutovg_matrix_translate(&pluto->state->matrix, x, y); } -void plutovg_scale(plutovg_t* pluto, double x, double y) +void plutovg_scale(plutovg_t* pluto, const double x, const double y) { plutovg_matrix_scale(&pluto->state->matrix, x, y); } -void plutovg_rotate(plutovg_t* pluto, double radians, double x, double y) +void plutovg_rotate(plutovg_t* pluto, const double radians, const double x, const double y) { plutovg_matrix_rotate(&pluto->state->matrix, radians, x, y); } @@ -338,62 +338,62 @@ void plutovg_get_matrix(const plutovg_t* pluto, plutovg_matrix_t* matrix) *matrix = pluto->state->matrix; } -void plutovg_move_to(plutovg_t* pluto, double x, double y) +void plutovg_move_to(plutovg_t* pluto, const double x, const double y) { plutovg_path_move_to(pluto->path, x, y); } -void plutovg_line_to(plutovg_t* pluto, double x, double y) +void plutovg_line_to(plutovg_t* pluto, const double x, const double y) { plutovg_path_line_to(pluto->path, x, y); } -void plutovg_quad_to(plutovg_t* pluto, double x1, double y1, double x2, double y2) +void plutovg_quad_to(plutovg_t* pluto, const double x1, const double y1, const double x2, const double y2) { plutovg_path_quad_to(pluto->path, x1, y1, x2, y2); } -void plutovg_cubic_to(plutovg_t* pluto, double x1, double y1, double x2, double y2, double x3, double y3) +void plutovg_cubic_to(plutovg_t* pluto, const double x1, const double y1, const double x2, const double y2, const double x3, const double y3) { plutovg_path_cubic_to(pluto->path, x1, y1, x2, y2, x3, y3); } -void plutovg_rel_move_to(plutovg_t* pluto, double x, double y) +void plutovg_rel_move_to(plutovg_t* pluto, const double x, const double y) { plutovg_path_rel_move_to(pluto->path, x, y); } -void plutovg_rel_line_to(plutovg_t* pluto, double x, double y) +void plutovg_rel_line_to(plutovg_t* pluto, const double x, const double y) { plutovg_path_rel_line_to(pluto->path, x, y); } -void plutovg_rel_quad_to(plutovg_t* pluto, double x1, double y1, double x2, double y2) +void plutovg_rel_quad_to(plutovg_t* pluto, const double x1, const double y1, const double x2, const double y2) { plutovg_path_rel_quad_to(pluto->path, x1, y1, x2, y2); } -void plutovg_rel_cubic_to(plutovg_t* pluto, double x1, double y1, double x2, double y2, double x3, double y3) +void plutovg_rel_cubic_to(plutovg_t* pluto, const double x1, const double y1, const double x2, const double y2, const double x3, const double y3) { plutovg_path_rel_cubic_to(pluto->path, x1, y1, x2, y2, x3, y3); } -void plutovg_rect(plutovg_t* pluto, double x, double y, double w, double h) +void plutovg_rect(plutovg_t* pluto, const double x, const double y, const double w, const double h) { plutovg_path_add_rect(pluto->path, x, y, w, h); } -void plutovg_round_rect(plutovg_t* pluto, double x, double y, double w, double h, double rx, double ry) +void plutovg_round_rect(plutovg_t* pluto, const double x, const double y, const double w, const double h, const double rx, const double ry) { plutovg_path_add_round_rect(pluto->path, x, y, w, h, rx, ry); } -void plutovg_ellipse(plutovg_t* pluto, double cx, double cy, double rx, double ry) +void plutovg_ellipse(plutovg_t* pluto, const double cx, const double cy, const double rx, const double ry) { plutovg_path_add_ellipse(pluto->path, cx, cy, rx, ry); } -void plutovg_circle(plutovg_t* pluto, double cx, double cy, double r) +void plutovg_circle(plutovg_t* pluto, const double cx, const double cy, const double r) { plutovg_ellipse(pluto, cx, cy, r, r); } diff --git a/source/canvas.cpp b/source/canvas.cpp index 8fb1cf7..5bfca07 100644 --- a/source/canvas.cpp +++ b/source/canvas.cpp @@ -14,12 +14,12 @@ static plutovg_texture_type_t to_plutovg_texture_type(TextureType type); static void to_plutovg_stops(plutovg_gradient_t* gradient, const GradientStops& stops); static void to_plutovg_path(plutovg_t* pluto, const Path& path); -std::shared_ptr Canvas::create(unsigned char* data, unsigned int width, unsigned int height, unsigned int stride) +std::shared_ptr Canvas::create(unsigned char* data, const unsigned int width, const unsigned int height, const unsigned int stride) { return std::shared_ptr(new Canvas(data, static_cast(width), static_cast(height), static_cast(stride))); } -std::shared_ptr Canvas::create(double x, double y, double width, double height) +std::shared_ptr Canvas::create(const double x, const double y, const double width, const double height) { if(width <= 0.0 || height <= 0.0) return std::shared_ptr(new Canvas(0, 0, 1, 1)); @@ -36,7 +36,7 @@ std::shared_ptr Canvas::create(const Rect& box) return create(box.x, box.y, box.w, box.h); } -Canvas::Canvas(unsigned char* data, int width, int height, int stride) +Canvas::Canvas(unsigned char* data, const int width, const int height, const int stride) { m_surface = plutovg_surface_create_for_data(data, width, height, stride); m_pluto = plutovg_create(m_surface); @@ -44,7 +44,7 @@ Canvas::Canvas(unsigned char* data, int width, int height, int stride) plutovg_rect_init(&m_rect, 0, 0, width, height); } -Canvas::Canvas(int x, int y, int width, int height) +Canvas::Canvas(const int x, const int y, const int width, const int height) { m_surface = plutovg_surface_create(width, height); m_pluto = plutovg_create(m_surface); @@ -63,7 +63,7 @@ void Canvas::setColor(const Color& color) plutovg_set_rgba(m_pluto, color.red() / 255.0, color.green() / 255.0, color.blue() / 255.0, color.alpha() / 255.0); } -void Canvas::setLinearGradient(double x1, double y1, double x2, double y2, const GradientStops& stops, SpreadMethod spread, const Transform& transform) +void Canvas::setLinearGradient(const double x1, const double y1, const double x2, const double y2, const GradientStops& stops, const SpreadMethod spread, const Transform& transform) { auto gradient = plutovg_set_linear_gradient(m_pluto, x1, y1, x2, y2); auto matrix = to_plutovg_matrix(transform); @@ -72,7 +72,7 @@ void Canvas::setLinearGradient(double x1, double y1, double x2, double y2, const plutovg_gradient_set_matrix(gradient, &matrix); } -void Canvas::setRadialGradient(double cx, double cy, double r, double fx, double fy, const GradientStops& stops, SpreadMethod spread, const Transform& transform) +void Canvas::setRadialGradient(const double cx, const double cy, const double r, const double fx, const double fy, const GradientStops& stops, const SpreadMethod spread, const Transform& transform) { auto gradient = plutovg_set_radial_gradient(m_pluto, cx, cy, r, fx, fy, 0); auto matrix = to_plutovg_matrix(transform); @@ -81,14 +81,14 @@ void Canvas::setRadialGradient(double cx, double cy, double r, double fx, double plutovg_gradient_set_matrix(gradient, &matrix); } -void Canvas::setTexture(const Canvas* source, TextureType type, const Transform& transform) +void Canvas::setTexture(const Canvas* source, const TextureType type, const Transform& transform) { auto texture = plutovg_set_texture(m_pluto, source->surface(), to_plutovg_texture_type(type)); auto matrix = to_plutovg_matrix(transform); plutovg_texture_set_matrix(texture, &matrix); } -void Canvas::fill(const Path& path, const Transform& transform, WindRule winding, BlendMode mode, double opacity) +void Canvas::fill(const Path& path, const Transform& transform, const WindRule winding, const BlendMode mode, const double opacity) { auto matrix = to_plutovg_matrix(transform); plutovg_matrix_multiply(&matrix, &matrix, &m_translation); @@ -100,7 +100,7 @@ void Canvas::fill(const Path& path, const Transform& transform, WindRule winding plutovg_fill(m_pluto); } -void Canvas::stroke(const Path& path, const Transform& transform, double width, LineCap cap, LineJoin join, double miterlimit, const DashData& dash, BlendMode mode, double opacity) +void Canvas::stroke(const Path& path, const Transform& transform, const double width, const LineCap cap, const LineJoin join, const double miterlimit, const DashData& dash, const BlendMode mode, const double opacity) { auto matrix = to_plutovg_matrix(transform); plutovg_matrix_multiply(&matrix, &matrix, &m_translation); @@ -116,7 +116,7 @@ void Canvas::stroke(const Path& path, const Transform& transform, double width, plutovg_stroke(m_pluto); } -void Canvas::blend(const Canvas* source, BlendMode mode, double opacity) +void Canvas::blend(const Canvas* source, const BlendMode mode, const double opacity) { plutovg_set_texture_surface(m_pluto, source->surface(), source->x(), source->y()); plutovg_set_operator(m_pluto, to_plutovg_operator(mode)); @@ -190,32 +190,32 @@ plutovg_matrix_t to_plutovg_matrix(const Transform& transform) return matrix; } -plutovg_fill_rule_t to_plutovg_fill_rule(WindRule winding) +plutovg_fill_rule_t to_plutovg_fill_rule(const WindRule winding) { return winding == WindRule::EvenOdd ? plutovg_fill_rule_even_odd : plutovg_fill_rule_non_zero; } -plutovg_operator_t to_plutovg_operator(BlendMode mode) +plutovg_operator_t to_plutovg_operator(const BlendMode mode) { return mode == BlendMode::Src ? plutovg_operator_src : mode == BlendMode::Src_Over ? plutovg_operator_src_over : mode == BlendMode::Dst_In ? plutovg_operator_dst_in : plutovg_operator_dst_out; } -plutovg_line_cap_t to_plutovg_line_cap(LineCap cap) +plutovg_line_cap_t to_plutovg_line_cap(const LineCap cap) { return cap == LineCap::Butt ? plutovg_line_cap_butt : cap == LineCap::Round ? plutovg_line_cap_round : plutovg_line_cap_square; } -plutovg_line_join_t to_plutovg_line_join(LineJoin join) +plutovg_line_join_t to_plutovg_line_join(const LineJoin join) { return join == LineJoin::Miter ? plutovg_line_join_miter : join == LineJoin::Round ? plutovg_line_join_round : plutovg_line_join_bevel; } -static plutovg_spread_method_t to_plutovg_spread_method(SpreadMethod spread) +static plutovg_spread_method_t to_plutovg_spread_method(const SpreadMethod spread) { return spread == SpreadMethod::Pad ? plutovg_spread_method_pad : spread == SpreadMethod::Reflect ? plutovg_spread_method_reflect : plutovg_spread_method_repeat; } -static plutovg_texture_type_t to_plutovg_texture_type(TextureType type) +static plutovg_texture_type_t to_plutovg_texture_type(const TextureType type) { return type == TextureType::Plain ? plutovg_texture_type_plain : plutovg_texture_type_tiled; } diff --git a/source/element.cpp b/source/element.cpp index ba905b5..01d84a7 100644 --- a/source/element.cpp +++ b/source/element.cpp @@ -22,12 +22,12 @@ std::unique_ptr TextNode::clone() const return std::move(node); } -Element::Element(ElementID id) +Element::Element(const ElementID id) : m_id(id) { } -std::unique_ptr Element::create(ElementID id) +std::unique_ptr Element::create(const ElementID id) { switch(id) { case ElementID::Svg: @@ -79,7 +79,7 @@ std::unique_ptr Element::create(ElementID id) return nullptr; } -void Element::set(PropertyID id, const std::string& value, int specificity) +void Element::set(const PropertyID id, const std::string& value, const int specificity) { for(auto& property : m_properties) { if(property.id == id) { @@ -97,7 +97,7 @@ void Element::set(PropertyID id, const std::string& value, int specificity) static const std::string EmptyString; -const std::string& Element::get(PropertyID id) const +const std::string& Element::get(const PropertyID id) const { for(auto& property : m_properties) { if(property.id == id) { @@ -110,7 +110,7 @@ const std::string& Element::get(PropertyID id) const static const std::string InheritString{"inherit"}; -const std::string& Element::find(PropertyID id) const +const std::string& Element::find(const PropertyID id) const { auto element = this; do { @@ -122,7 +122,7 @@ const std::string& Element::find(PropertyID id) const return EmptyString; } -bool Element::has(PropertyID id) const +bool Element::has(const PropertyID id) const { for(auto& property : m_properties) { if(property.id == id) { diff --git a/source/geometryelement.cpp b/source/geometryelement.cpp index be87424..dcd22fd 100644 --- a/source/geometryelement.cpp +++ b/source/geometryelement.cpp @@ -4,7 +4,7 @@ namespace lunasvg { -GeometryElement::GeometryElement(ElementID id) +GeometryElement::GeometryElement(const ElementID id) : GraphicsElement(id) { } @@ -47,7 +47,7 @@ Path PathElement::path() const return d(); } -PolyElement::PolyElement(ElementID id) +PolyElement::PolyElement(const ElementID id) : GeometryElement(id) { } diff --git a/source/graphicselement.cpp b/source/graphicselement.cpp index 9df1a00..bcd4f8a 100644 --- a/source/graphicselement.cpp +++ b/source/graphicselement.cpp @@ -3,7 +3,7 @@ namespace lunasvg { -GraphicsElement::GraphicsElement(ElementID id) +GraphicsElement::GraphicsElement(const ElementID id) : StyledElement(id) { } diff --git a/source/layoutcontext.cpp b/source/layoutcontext.cpp index 4bca5f3..3d8c3e2 100644 --- a/source/layoutcontext.cpp +++ b/source/layoutcontext.cpp @@ -11,13 +11,13 @@ namespace lunasvg { -LayoutObject::LayoutObject(Node* node, LayoutId id) +LayoutObject::LayoutObject(Node* node, const LayoutId id) : m_node(node), m_id(id) { node->setBox(this); } -LayoutContainer::LayoutContainer(Node* node, LayoutId id) +LayoutContainer::LayoutContainer(Node* node, const LayoutId id) : LayoutObject(node, id) { } @@ -157,7 +157,7 @@ LayoutMarker::LayoutMarker(Node* node) { } -Transform LayoutMarker::markerTransform(const Point& origin, double angle, double strokeWidth) const +Transform LayoutMarker::markerTransform(const Point& origin, const double angle, const double strokeWidth) const { auto markerTransformation = Transform::translated(origin.x, origin.y); if(orient.type() == MarkerOrient::Auto) @@ -172,12 +172,12 @@ Transform LayoutMarker::markerTransform(const Point& origin, double angle, doubl return markerTransformation; } -Rect LayoutMarker::markerBoundingBox(const Point& origin, double angle, double strokeWidth) const +Rect LayoutMarker::markerBoundingBox(const Point& origin, const double angle, const double strokeWidth) const { return markerTransform(origin, angle, strokeWidth).map(transform.map(strokeBoundingBox())); } -void LayoutMarker::renderMarker(RenderState& state, const Point& origin, double angle, double strokeWidth) const +void LayoutMarker::renderMarker(RenderState& state, const Point& origin, const double angle, const double strokeWidth) const { BlendInfo info{clipper, masker, opacity, clip}; RenderState newState(this, state.mode()); @@ -227,7 +227,7 @@ void LayoutPattern::apply(RenderState& state) const state.canvas->setTexture(newState.canvas.get(), TextureType::Tiled, patternTransform); } -LayoutGradient::LayoutGradient(Node* node, LayoutId id) +LayoutGradient::LayoutGradient(Node* node, const LayoutId id) : LayoutObject(node, id) { } @@ -322,7 +322,7 @@ void StrokeData::inflate(Rect& box) const box.h += delta * 2.0; } -MarkerPosition::MarkerPosition(const LayoutMarker* marker, const Point& origin, double angle) +MarkerPosition::MarkerPosition(const LayoutMarker* marker, const Point& origin, const double angle) : marker(marker), origin(origin), angle(angle) { } @@ -393,7 +393,7 @@ const Rect& LayoutShape::strokeBoundingBox() const return m_strokeBoundingBox; } -RenderState::RenderState(const LayoutObject* object, RenderMode mode) +RenderState::RenderState(const LayoutObject* object, const RenderMode mode) : m_object(object), m_mode(mode) { } diff --git a/source/lunasvg.cpp b/source/lunasvg.cpp index a340372..b0b15eb 100644 --- a/source/lunasvg.cpp +++ b/source/lunasvg.cpp @@ -9,7 +9,7 @@ namespace lunasvg { -Box::Box(double x, double y, double w, double h) +Box::Box(const double x, const double y, const double w, const double h) : x(x), y(y), w(w), h(h) { } @@ -30,7 +30,7 @@ Box Box::transformed(const Matrix& matrix) const return Transform(matrix).map(*this); } -Matrix::Matrix(double a, double b, double c, double d, double e, double f) +Matrix::Matrix(const double a, const double b, const double c, const double d, const double e, const double f) : a(a), b(b), c(c), d(d), e(e), f(f) { } @@ -40,37 +40,37 @@ Matrix::Matrix(const Transform& transform) { } -Matrix& Matrix::rotate(double angle) +Matrix& Matrix::rotate(const double angle) { *this = rotated(angle) * *this; return *this; } -Matrix& Matrix::rotate(double angle, double cx, double cy) +Matrix& Matrix::rotate(const double angle, const double cx, const double cy) { *this = rotated(angle, cx, cy) * *this; return *this; } -Matrix& Matrix::scale(double sx, double sy) +Matrix& Matrix::scale(const double sx, const double sy) { *this = scaled(sx, sy) * *this; return *this; } -Matrix& Matrix::shear(double shx, double shy) +Matrix& Matrix::shear(const double shx, const double shy) { *this = sheared(shx, shy) * *this; return *this; } -Matrix& Matrix::translate(double tx, double ty) +Matrix& Matrix::translate(const double tx, const double ty) { *this = translated(tx, ty) * *this; return *this; } -Matrix& Matrix::transform(double _a, double _b, double _c, double _d, double _e, double _f) +Matrix& Matrix::transform(const double _a, const double _b, const double _c, const double _d, const double _e, const double _f) { *this = Matrix{_a, _b, _c, _d, _e, _f} * *this; return *this; @@ -116,27 +116,27 @@ Matrix Matrix::operator*(const Matrix& matrix) const return Transform(*this) * Transform(matrix); } -Matrix Matrix::rotated(double angle) +Matrix Matrix::rotated(const double angle) { return Transform::rotated(angle); } -Matrix Matrix::rotated(double angle, double cx, double cy) +Matrix Matrix::rotated(const double angle, const double cx, const double cy) { return Transform::rotated(angle, cx, cy); } -Matrix Matrix::scaled(double sx, double sy) +Matrix Matrix::scaled(const double sx, const double sy) { return Transform::scaled(sx, sy); } -Matrix Matrix::sheared(double shx, double shy) +Matrix Matrix::sheared(const double shx, const double shy) { return Transform::sheared(shx, shy); } -Matrix Matrix::translated(double tx, double ty) +Matrix Matrix::translated(const double tx, const double ty) { return Transform::translated(tx, ty); } @@ -152,12 +152,12 @@ struct Bitmap::Impl { std::uint32_t stride; }; -Bitmap::Impl::Impl(std::uint8_t* data, std::uint32_t width, std::uint32_t height, std::uint32_t stride) +Bitmap::Impl::Impl(std::uint8_t* data, const std::uint32_t width, const std::uint32_t height, const std::uint32_t stride) : data(data), width(width), height(height), stride(stride) { } -Bitmap::Impl::Impl(std::uint32_t width, std::uint32_t height) +Bitmap::Impl::Impl(const std::uint32_t width, const std::uint32_t height) : ownData(new std::uint8_t[width*height*4]), data(nullptr), width(width), height(height), stride(width * 4) { } @@ -166,22 +166,22 @@ Bitmap::Bitmap() { } -Bitmap::Bitmap(std::uint8_t* data, std::uint32_t width, std::uint32_t height, std::uint32_t stride) +Bitmap::Bitmap(std::uint8_t* data, const std::uint32_t width, const std::uint32_t height, const std::uint32_t stride) : m_impl(new Impl(data, width, height, stride)) { } -Bitmap::Bitmap(std::uint32_t width, std::uint32_t height) +Bitmap::Bitmap(const std::uint32_t width, const std::uint32_t height) : m_impl(new Impl(width, height)) { } -void Bitmap::reset(std::uint8_t* data, std::uint32_t width, std::uint32_t height, std::uint32_t stride) +void Bitmap::reset(std::uint8_t* data, const std::uint32_t width, const std::uint32_t height, const std::uint32_t stride) { m_impl.reset(new Impl(data, width, height, stride)); } -void Bitmap::reset(std::uint32_t width, std::uint32_t height) +void Bitmap::reset(const std::uint32_t width, const std::uint32_t height) { m_impl.reset(new Impl(width, height)); } @@ -210,7 +210,7 @@ std::uint32_t Bitmap::stride() const return m_impl ? m_impl->stride : 0; } -void Bitmap::clear(std::uint32_t color) +void Bitmap::clear(const std::uint32_t color) { auto r = (color >> 24) & 0xFF; auto g = (color >> 16) & 0xFF; @@ -240,7 +240,7 @@ void Bitmap::clear(std::uint32_t color) } } -void Bitmap::convert(int ri, int gi, int bi, int ai, bool unpremultiply) +void Bitmap::convert(const int ri, const int gi, const int bi, const int ai, const bool unpremultiply) { auto width = this->width(); auto height = this->height(); @@ -344,7 +344,7 @@ Matrix DomElement::getAbsoluteTransform() const return transform; } -Bitmap DomElement::renderToBitmap(std::uint32_t width, std::uint32_t height, std::uint32_t backgroundColor) const +Bitmap DomElement::renderToBitmap(std::uint32_t width, std::uint32_t height, const std::uint32_t backgroundColor) const { if(m_element == nullptr || !m_element->box()) return Bitmap(); @@ -392,7 +392,7 @@ std::unique_ptr Document::loadFromData(const std::string& string) return loadFromData(string.data(), string.size()); } -std::unique_ptr Document::loadFromData(const char* data, std::size_t size) +std::unique_ptr Document::loadFromData(const char* data, const std::size_t size) { std::unique_ptr document(new Document); if(!document->parse(data, size)) @@ -451,7 +451,7 @@ void Document::render(Bitmap bitmap, const Matrix& matrix) const m_rootBox->render(state); } -Bitmap Document::renderToBitmap(std::uint32_t width, std::uint32_t height, std::uint32_t backgroundColor) const +Bitmap Document::renderToBitmap(std::uint32_t width, std::uint32_t height, const std::uint32_t backgroundColor) const { if(m_rootBox == nullptr || m_rootBox->width == 0.0 || m_rootBox->height == 0.0) return Bitmap(); diff --git a/source/paintelement.cpp b/source/paintelement.cpp index 5d76c45..fab2c0d 100644 --- a/source/paintelement.cpp +++ b/source/paintelement.cpp @@ -7,12 +7,12 @@ namespace lunasvg { -PaintElement::PaintElement(ElementID id) +PaintElement::PaintElement(const ElementID id) : StyledElement(id) { } -GradientElement::GradientElement(ElementID id) +GradientElement::GradientElement(const ElementID id) : PaintElement(id) { } diff --git a/source/paintelement.h b/source/paintelement.h index 98b1452..05d49d5 100644 --- a/source/paintelement.h +++ b/source/paintelement.h @@ -97,12 +97,12 @@ class GradientAttributes { m_hasGradientTransform = true; } - void setSpreadMethod(SpreadMethod spreadMethod) { + void setSpreadMethod(const SpreadMethod spreadMethod) { m_spreadMethod = spreadMethod; m_hasSpreadMethod = true; } - void setGradientUnits(Units gradientUnits) { + void setGradientUnits(const Units gradientUnits) { m_gradientUnits = gradientUnits; m_hasGradientUnits = true; } @@ -277,12 +277,12 @@ class PatternAttributes { m_hasPatternTransform = true; } - void setPatternUnits(Units patternUnits) { + void setPatternUnits(const Units patternUnits) { m_patternUnits = patternUnits; m_hasPatternUnits = true; } - void setPatternContentUnits(Units patternContentUnits) { + void setPatternContentUnits(const Units patternContentUnits) { m_patternContentUnits = patternContentUnits; m_hasPatternContentUnits = true; } diff --git a/source/parser.cpp b/source/parser.cpp index d5d1c2b..e5d387b 100644 --- a/source/parser.cpp +++ b/source/parser.cpp @@ -5,7 +5,7 @@ namespace lunasvg { -Length Parser::parseLength(const std::string& string, LengthNegativeValuesMode mode, const Length& defaultValue) +Length Parser::parseLength(const std::string& string, const LengthNegativeValuesMode mode, const Length& defaultValue) { if(string.empty()) return defaultValue; @@ -21,7 +21,7 @@ Length Parser::parseLength(const std::string& string, LengthNegativeValuesMode m return Length{value, units}; } -LengthList Parser::parseLengthList(const std::string& string, LengthNegativeValuesMode mode) +LengthList Parser::parseLengthList(const std::string& string, const LengthNegativeValuesMode mode) { if(string.empty()) return LengthList{}; @@ -43,7 +43,7 @@ LengthList Parser::parseLengthList(const std::string& string, LengthNegativeValu return values; } -double Parser::parseNumber(const std::string& string, double defaultValue) +double Parser::parseNumber(const std::string& string, const double defaultValue) { if(string.empty()) return defaultValue; @@ -58,7 +58,7 @@ double Parser::parseNumber(const std::string& string, double defaultValue) return value; } -double Parser::parseNumberPercentage(const std::string& string, double defaultValue) +double Parser::parseNumberPercentage(const std::string& string, const double defaultValue) { if(string.empty()) return defaultValue; @@ -469,7 +469,7 @@ SpreadMethod Parser::parseSpreadMethod(const std::string& string) return SpreadMethod::Pad; } -Units Parser::parseUnits(const std::string& string, Units defaultValue) +Units Parser::parseUnits(const std::string& string, const Units defaultValue) { if(string.empty()) return defaultValue; @@ -758,7 +758,7 @@ Visibility Parser::parseVisibility(const std::string& string) return Visibility::Hidden; } -Overflow Parser::parseOverflow(const std::string& string, Overflow defaultValue) +Overflow Parser::parseOverflow(const std::string& string, const Overflow defaultValue) { if(string.empty()) return defaultValue; @@ -770,7 +770,7 @@ Overflow Parser::parseOverflow(const std::string& string, Overflow defaultValue) return defaultValue; } -bool Parser::parseLength(const char*& ptr, const char* end, double& value, LengthUnits& units, LengthNegativeValuesMode mode) +bool Parser::parseLength(const char*& ptr, const char* end, double& value, LengthUnits& units, const LengthNegativeValuesMode mode) { if(!Utils::parseNumber(ptr, end, value)) return false; @@ -836,7 +836,7 @@ bool Parser::parseLength(const char*& ptr, const char* end, double& value, Lengt return true; } -bool Parser::parseNumberList(const char*& ptr, const char* end, double* values, int count) +bool Parser::parseNumberList(const char*& ptr, const char* end, double* values, const int count) { for(int i = 0; i < count; i++) { if(!Utils::parseNumber(ptr, end, values[i])) @@ -1666,7 +1666,7 @@ static inline void removeComments(std::string& value) } } -bool Document::parse(const char* data, std::size_t size) +bool Document::parse(const char* data, const std::size_t size) { auto ptr = data; auto end = ptr + size; @@ -1676,7 +1676,7 @@ bool Document::parse(const char* data, std::size_t size) std::string name; std::string value; int ignoring = 0; - auto handleText = [&](const char* start, const char* end, bool in_cdata) { + auto handleText = [&](const char* start, const char* end, const bool in_cdata) { if(ignoring > 0 || current == nullptr || current->id() != ElementID::Style) return; diff --git a/source/parser.h b/source/parser.h index e20daad..5d7101c 100644 --- a/source/parser.h +++ b/source/parser.h @@ -130,7 +130,7 @@ struct Rule { class RuleData { public: - RuleData(const Selector& selector, const DeclarationList& declarations, uint32_t specificity, uint32_t position) + RuleData(const Selector& selector, const DeclarationList& declarations, const uint32_t specificity, const uint32_t position) : m_selector(selector), m_declarations(declarations), m_specificity(specificity), m_position(position) {} diff --git a/source/parserutils.h b/source/parserutils.h index d7d00e5..1b93a9e 100644 --- a/source/parserutils.h +++ b/source/parserutils.h @@ -124,7 +124,7 @@ inline bool skipWsComma(const char*& ptr, const char* end) return skipWsDelimiter(ptr, end, ','); } -inline bool isIntegralDigit(char ch, int base) +inline bool isIntegralDigit(const char ch, const int base) { if(IS_NUM(ch)) return ch - '0' < base; diff --git a/source/property.cpp b/source/property.cpp index 2de3dee..b86be77 100644 --- a/source/property.cpp +++ b/source/property.cpp @@ -11,13 +11,13 @@ const Color Color::Black(0xFF000000); const Color Color::White(0xFFFFFFFF); const Color Color::Transparent(0x00000000); -Color& Color::combine(double opacity) +Color& Color::combine(const double opacity) { *this = combined(opacity); return *this; } -Color Color::combined(double opacity) const +Color Color::combined(const double opacity) const { auto rgb = m_value & 0x00FFFFFF; auto a = static_cast(clamp(opacity * alpha(), 0.0, 255.0)); @@ -34,7 +34,7 @@ Paint::Paint(const std::string& ref, const Color& color) { } -Point::Point(double x, double y) +Point::Point(const double x, const double y) : x(x), y(y) { } @@ -42,7 +42,7 @@ Point::Point(double x, double y) const Rect Rect::Empty{0, 0, 0, 0}; const Rect Rect::Invalid{0, 0, -1, -1}; -Rect::Rect(double x, double y, double w, double h) +Rect::Rect(const double x, const double y, const double w, const double h) : x(x), y(y), w(w), h(h) { } @@ -98,7 +98,7 @@ Rect& Rect::unite(const Rect& rect) const Transform Transform::Identity(1, 0, 0, 1, 0, 0); -Transform::Transform(double m00, double m10, double m01, double m11, double m02, double m12) +Transform::Transform(const double m00, const double m10, const double m01, const double m11, const double m02, const double m12) : m00(m00), m10(m10), m01(m01), m11(m11), m02(m02), m12(m12) { } @@ -155,37 +155,37 @@ Transform& Transform::postmultiply(const Transform& transform) return *this; } -Transform& Transform::rotate(double angle) +Transform& Transform::rotate(const double angle) { *this = rotated(angle) * *this; return *this; } -Transform& Transform::rotate(double angle, double cx, double cy) +Transform& Transform::rotate(const double angle, const double cx, const double cy) { *this = rotated(angle, cx, cy) * *this; return *this; } -Transform& Transform::scale(double sx, double sy) +Transform& Transform::scale(const double sx, const double sy) { *this = scaled(sx, sy) * *this; return *this; } -Transform& Transform::shear(double shx, double shy) +Transform& Transform::shear(const double shx, const double shy) { *this = sheared(shx, shy) * *this; return *this; } -Transform& Transform::translate(double tx, double ty) +Transform& Transform::translate(const double tx, const double ty) { *this = translated(tx, ty) * *this; return *this; } -Transform& Transform::transform(double _m00, double _m10, double _m01, double _m11, double _m02, double _m12) +Transform& Transform::transform(const double _m00, const double _m10, const double _m01, const double _m11, const double _m02, const double _m12) { *this = Transform{_m00, _m10, _m01, _m11, _m02, _m12} * *this; return *this; @@ -203,7 +203,7 @@ Transform& Transform::invert() return *this; } -void Transform::map(double x, double y, double* _x, double* _y) const +void Transform::map(const double x, const double y, double* _x, double* _y) const { *_x = x * m00 + y * m01 + m02; *_y = x * m10 + y * m11 + m12; @@ -252,7 +252,7 @@ Rect Transform::map(const Rect& rect) const static const double pi = 3.14159265358979323846; -Transform Transform::rotated(double angle) +Transform Transform::rotated(const double angle) { auto c = std::cos(angle * pi / 180.0); auto s = std::sin(angle * pi / 180.0); @@ -260,7 +260,7 @@ Transform Transform::rotated(double angle) return Transform{c, s, -s, c, 0, 0}; } -Transform Transform::rotated(double angle, double cx, double cy) +Transform Transform::rotated(const double angle, const double cx, const double cy) { auto c = std::cos(angle * pi / 180.0); auto s = std::sin(angle * pi / 180.0); @@ -271,12 +271,12 @@ Transform Transform::rotated(double angle, double cx, double cy) return Transform{c, s, -s, c, x, y}; } -Transform Transform::scaled(double sx, double sy) +Transform Transform::scaled(const double sx, const double sy) { return Transform{sx, 0, 0, sy, 0, 0}; } -Transform Transform::sheared(double shx, double shy) +Transform Transform::sheared(const double shx, const double shy) { auto x = std::tan(shx * pi / 180.0); auto y = std::tan(shy * pi / 180.0); @@ -284,7 +284,7 @@ Transform Transform::sheared(double shx, double shy) return Transform{1, y, x, 1, 0, 0}; } -Transform Transform::translated(double tx, double ty) +Transform Transform::translated(const double tx, const double ty) { return Transform{1, 0, 0, 1, tx, ty}; } @@ -331,7 +331,7 @@ bool Path::empty() const return m_commands.empty(); } -void Path::quadTo(double cx, double cy, double x1, double y1, double x2, double y2) +void Path::quadTo(const double cx, const double cy, const double x1, const double y1, const double x2, const double y2) { auto cx1 = 2.0 / 3.0 * x1 + 1.0 / 3.0 * cx; auto cy1 = 2.0 / 3.0 * y1 + 1.0 / 3.0 * cy; @@ -340,7 +340,7 @@ void Path::quadTo(double cx, double cy, double x1, double y1, double x2, double cubicTo(cx1, cy1, cx2, cy2, x2, y2); } -void Path::arcTo(double cx, double cy, double rx, double ry, double xAxisRotation, bool largeArcFlag, bool sweepFlag, double x, double y) +void Path::arcTo(const double cx, const double cy, double rx, double ry, const double xAxisRotation, const bool largeArcFlag, const bool sweepFlag, const double x, const double y) { rx = std::fabs(rx); ry = std::fabs(ry); @@ -418,7 +418,7 @@ void Path::arcTo(double cx, double cy, double rx, double ry, double xAxisRotatio static const double kappa = 0.55228474983079339840; -void Path::ellipse(double cx, double cy, double rx, double ry) +void Path::ellipse(const double cx, const double cy, const double rx, const double ry) { auto left = cx - rx; auto top = cy - ry; @@ -436,7 +436,7 @@ void Path::ellipse(double cx, double cy, double rx, double ry) close(); } -void Path::rect(double x, double y, double w, double h, double rx, double ry) +void Path::rect(const double x, const double y, const double w, const double h, double rx, double ry) { rx = std::min(rx, w * 0.5); ry = std::min(ry, h * 0.5); @@ -548,19 +548,19 @@ const Length Length::FiftyPercent{50, LengthUnits::Percent}; const Length Length::OneTwentyPercent{120, LengthUnits::Percent}; const Length Length::MinusTenPercent{-10, LengthUnits::Percent}; -Length::Length(double value) +Length::Length(const double value) : m_value(value) { } -Length::Length(double value, LengthUnits units) +Length::Length(const double value, const LengthUnits units) : m_value(value), m_units(units) { } static const double dpi = 96.0; -double Length::value(double max) const +double Length::value(const double max) const { switch(m_units) { case LengthUnits::Number: @@ -587,7 +587,7 @@ double Length::value(double max) const static const double sqrt2 = 1.41421356237309504880; -double Length::value(const Element* element, LengthMode mode) const +double Length::value(const Element* element, const LengthMode mode) const { if(m_units == LengthUnits::Percent) { auto viewport = element->currentViewport(); @@ -605,24 +605,24 @@ LengthContext::LengthContext(const Element* element) { } -LengthContext::LengthContext(const Element* element, Units units) +LengthContext::LengthContext(const Element* element, const Units units) : m_element(element), m_units(units) { } -double LengthContext::valueForLength(const Length& length, LengthMode mode) const +double LengthContext::valueForLength(const Length& length, const LengthMode mode) const { if(m_units == Units::ObjectBoundingBox) return length.value(1.0); return length.value(m_element, mode); } -PreserveAspectRatio::PreserveAspectRatio(Align align, MeetOrSlice scale) +PreserveAspectRatio::PreserveAspectRatio(const Align align, const MeetOrSlice scale) : m_align(align), m_scale(scale) { } -Transform PreserveAspectRatio::getMatrix(double width, double height, const Rect& viewBox) const +Transform PreserveAspectRatio::getMatrix(const double width, const double height, const Rect& viewBox) const { if(viewBox.empty()) return Transform{}; @@ -675,7 +675,7 @@ Transform PreserveAspectRatio::getMatrix(double width, double height, const Rect return Transform{scale, 0, 0, scale, xoffset, yoffset}; } -Rect PreserveAspectRatio::getClip(double width, double height, const Rect& viewBox) const +Rect PreserveAspectRatio::getClip(const double width, const double height, const Rect& viewBox) const { if(viewBox.empty()) return Rect{0, 0, width, height}; @@ -719,12 +719,12 @@ Rect PreserveAspectRatio::getClip(double width, double height, const Rect& viewB return Rect(-xOffset / scale, -yOffset / scale, width / scale, height / scale); } -Angle::Angle(MarkerOrient type) +Angle::Angle(const MarkerOrient type) : m_type(type) { } -Angle::Angle(double value, MarkerOrient type) +Angle::Angle(const double value, const MarkerOrient type) : m_value(value), m_type(type) { } diff --git a/source/property.h b/source/property.h index a6ffed9..2b59092 100644 --- a/source/property.h +++ b/source/property.h @@ -65,8 +65,8 @@ constexpr const T& clamp(const T& val, const T& lo, const T& hi) class Color { public: Color() = default; - explicit Color(uint32_t value) : m_value(value) {} - Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a) : m_value(a << 24 | r << 16 | g << 8 | b) {} + explicit Color(const uint32_t value) : m_value(value) {} + Color(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t a) : m_value(a << 24 | r << 16 | g << 8 | b) {} uint8_t alpha() const { return (m_value >> 24) & 0xff; } uint8_t red() const { return (m_value >> 16) & 0xff; } diff --git a/source/styledelement.cpp b/source/styledelement.cpp index ccd4868..0f01261 100644 --- a/source/styledelement.cpp +++ b/source/styledelement.cpp @@ -3,7 +3,7 @@ namespace lunasvg { -StyledElement::StyledElement(ElementID id) +StyledElement::StyledElement(const ElementID id) : Element(id) { }