Skip to content

Commit

Permalink
const qlfr
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuria-Shikibe committed May 30, 2024
1 parent ec60b71 commit 5719ad0
Show file tree
Hide file tree
Showing 23 changed files with 301 additions and 301 deletions.
50 changes: 25 additions & 25 deletions 3rdparty/plutovg/plutovg-blend.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand All @@ -291,31 +291,31 @@ 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);
for(int i = 0;i < length;i++)
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;
for(int i = 0;i < length;i++)
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;
for(int i = 0; i < length;i++)
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)
{
Expand All @@ -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)
Expand Down Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand Down Expand Up @@ -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;
Expand All @@ -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];
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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];

Expand Down Expand Up @@ -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];

Expand Down Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/plutovg/plutovg-dash.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <math.h>

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;
Expand Down
20 changes: 10 additions & 10 deletions 3rdparty/plutovg/plutovg-ft-math.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#if defined(_MSC_VER)
#include <intrin.h>
static unsigned int __inline clz(unsigned int x) {
static unsigned int __inline clz(const unsigned int x) {
unsigned long r = 0;
if (x != 0)
{
Expand Down Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;

Expand Down
26 changes: 13 additions & 13 deletions 3rdparty/plutovg/plutovg-ft-raster.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 );
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 5719ad0

Please sign in to comment.