libgpac
Documentation of the core library of GPAC
Vector Graphics Rendering

Vector Graphics rendering of GPAC. More...

Data Structures

struct  GF_EVGFragmentParam
 
struct  GF_EVGVertexParam
 

Typedefs

typedef struct _gf_evg_base_stencil GF_EVGStencil
 
typedef struct _gf_evg_surface GF_EVGSurface
 
typedef void(* gf_evg_texture_callback) (void *cbk, u32 x, u32 y, Float *r, Float *g, Float *b, Float *a)
 
typedef u8(* gf_evg_get_alpha) (void *udta, u8 src_alpha, s32 x, s32 y)
 
typedef Bool(* gf_evg_fragment_shader) (void *udta, GF_EVGFragmentParam *fragp)
 
typedef Bool(* gf_evg_fragment_shader_init) (void *udta, GF_EVGFragmentParam *fragp, u32 th_id, Bool is_cleanup)
 
typedef Bool(* gf_evg_vertex_shader) (void *udta, GF_EVGVertexParam *vertp)
 

Enumerations

enum  GF_StencilType {
  GF_STENCIL_SOLID = 0 , GF_STENCIL_LINEAR_GRADIENT , GF_STENCIL_RADIAL_GRADIENT , GF_STENCIL_VERTEX_GRADIENT ,
  GF_STENCIL_TEXTURE
}
 
enum  GF_GradientMode { GF_GRADIENT_MODE_PAD , GF_GRADIENT_MODE_SPREAD , GF_GRADIENT_MODE_REPEAT }
 
enum  GF_TextureMapFlags { GF_TEXTURE_REPEAT_S = (1<<1) , GF_TEXTURE_REPEAT_T = (1<<2) , GF_TEXTURE_FLIP_X = (1<<3) , GF_TEXTURE_FLIP_Y = (1<<4) }
 
enum  GF_TextureFilter { GF_TEXTURE_FILTER_HIGH_SPEED , GF_TEXTURE_FILTER_MID , GF_TEXTURE_FILTER_HIGH_QUALITY }
 
enum  GF_RasterQuality { GF_RASTER_HIGH_SPEED , GF_RASTER_MID , GF_RASTER_HIGH_QUALITY }
 
enum  GF_EVGMultiTextureMode {
  GF_EVG_OPERAND_NONE = 0 , GF_EVG_OPERAND_MIX , GF_EVG_OPERAND_MIX_ALPHA , GF_EVG_OPERAND_REPLACE_ALPHA ,
  GF_EVG_OPERAND_REPLACE_ONE_MINUS_ALPHA , GF_EVG_OPERAND_MIX_DYN , GF_EVG_OPERAND_MIX_DYN_ALPHA , GF_EVG_OPERAND_ODD_FILL
}
 
enum  GF_EVGCompositeMode {
  GF_EVG_SRC_OVER = 0 , GF_EVG_SRC_ATOP , GF_EVG_SRC_IN , GF_EVG_SRC_OUT ,
  GF_EVG_DST_ATOP , GF_EVG_DST_IN , GF_EVG_DST_OUT , GF_EVG_DST_OVER ,
  GF_EVG_LIGHTER , GF_EVG_COPY , GF_EVG_XOR
}
 
enum  GF_EVGPrimitiveType {
  GF_EVG_POINTS =1 , GF_EVG_POLYGON , GF_EVG_LINES , GF_EVG_TRIANGLES ,
  GF_EVG_QUADS , GF_EVG_LINE_STRIP , GF_EVG_TRIANGLE_STRIP , GF_EVG_TRIANGLE_FAN ,
  GF_EVG_QUAD_STRIP
}
 
enum  GF_EVGDepthTest {
  GF_EVGDEPTH_DISABLE , GF_EVGDEPTH_NEVER , GF_EVGDEPTH_ALWAYS , GF_EVGDEPTH_EQUAL ,
  GF_EVGDEPTH_NEQUAL , GF_EVGDEPTH_LESS , GF_EVGDEPTH_LESS_EQUAL , GF_EVGDEPTH_GREATER ,
  GF_EVGDEPTH_GREATER_EQUAL
}
 
enum  GF_EVGFragmentType {
  GF_EVG_FRAG_INVALID = 0 , GF_EVG_FRAG_RGB , GF_EVG_FRAG_RGB_PACK , GF_EVG_FRAG_YUV ,
  GF_EVG_FRAG_YUV_PACK
}
 
enum  GF_EVGMaskMode {
  GF_EVGMASK_NONE = 0 , GF_EVGMASK_DRAW , GF_EVGMASK_DRAW_NO_CLEAR , GF_EVGMASK_USE ,
  GF_EVGMASK_USE_INV , GF_EVGMASK_RECORD
}
 

Functions

GF_EVGStencilgf_evg_stencil_new (GF_StencilType type)
 
void gf_evg_stencil_delete (GF_EVGStencil *stencil)
 
GF_Err gf_evg_stencil_set_matrix (GF_EVGStencil *stencil, GF_Matrix2D *mat)
 
Bool gf_evg_stencil_get_matrix (GF_EVGStencil *stencil, GF_Matrix2D *mat)
 
GF_Err gf_evg_stencil_set_auto_matrix (GF_EVGStencil *stencil, Bool auto_on)
 
Bool gf_evg_stencil_get_auto_matrix (GF_EVGStencil *stencil)
 
GF_StencilType gf_evg_stencil_type (GF_EVGStencil *stencil)
 
GF_Err gf_evg_stencil_set_brush_color (GF_EVGStencil *stencil, GF_Color color)
 
GF_Color gf_evg_stencil_get_brush_color (GF_EVGStencil *stencil)
 
GF_Err gf_evg_stencil_set_gradient_mode (GF_EVGStencil *stencil, GF_GradientMode mode)
 
GF_Err gf_evg_stencil_set_linear_gradient (GF_EVGStencil *stencil, Fixed start_x, Fixed start_y, Fixed end_x, Fixed end_y)
 
GF_Err gf_evg_stencil_set_radial_gradient (GF_EVGStencil *stencil, Fixed cx, Fixed cy, Fixed fx, Fixed fy, Fixed x_radius, Fixed y_radius)
 
GF_Err gf_evg_stencil_set_gradient_interpolation (GF_EVGStencil *stencil, Fixed *pos, GF_Color *col, u32 count)
 
GF_Err gf_evg_stencil_push_gradient_interpolation (GF_EVGStencil *stencil, Fixed pos, GF_Color col)
 
GF_Err gf_evg_stencil_set_alpha (GF_EVGStencil *stencil, u8 alpha)
 
u8 gf_evg_stencil_get_alpha (GF_EVGStencil *stencil)
 
Bool gf_evg_texture_format_ok (GF_PixelFormat pixelFormat)
 
GF_Err gf_evg_stencil_set_texture (GF_EVGStencil *stencil, u8 *pixels, u32 width, u32 height, u32 stride, GF_PixelFormat pixelFormat)
 
GF_Err gf_evg_stencil_set_texture_planes (GF_EVGStencil *stencil, u32 width, u32 height, GF_PixelFormat pixelFormat, const u8 *y_or_rgb, u32 stride, const u8 *u_plane, const u8 *v_plane, u32 uv_stride, const u8 *alpha_plane, u32 alpha_stride)
 
GF_Err gf_evg_stencil_set_palette (GF_EVGStencil *stencil, const u8 *palette, u32 pix_fmt, u32 nb_cols)
 
GF_Err gf_evg_stencil_set_texture_parametric (GF_EVGStencil *stencil, u32 width, u32 height, GF_PixelFormat pixelFormat, gf_evg_texture_callback callback, void *cbk_udta, Bool use_screen_coords)
 
GF_Err gf_evg_stencil_set_mapping (GF_EVGStencil *stencil, GF_TextureMapFlags map_mode)
 
GF_Err gf_evg_stencil_set_pad_color (GF_EVGStencil *stencil, GF_Color pad_color)
 
u32 gf_evg_stencil_get_pad_color (GF_EVGStencil *stencil)
 
GF_Err gf_evg_stencil_set_filter (GF_EVGStencil *stencil, GF_TextureFilter filter_mode)
 
GF_Err gf_evg_stencil_set_color_matrix (GF_EVGStencil *stencil, GF_ColorMatrix *cmat)
 
GF_Err gf_evg_stencil_get_color_matrix (GF_EVGStencil *stencil, GF_ColorMatrix *cmat)
 
u32 gf_evg_stencil_get_pixel (GF_EVGStencil *stencil, s32 x, s32 y)
 
u32 gf_evg_stencil_get_pixel_yuv (GF_EVGStencil *stencil, s32 x, s32 y)
 
u64 gf_evg_stencil_get_pixel_wide (GF_EVGStencil *stencil, s32 x, s32 y)
 
u64 gf_evg_stencil_get_pixel_yuv_wide (GF_EVGStencil *stencil, s32 x, s32 y)
 
GF_Vec4 gf_evg_stencil_get_pixel_f (GF_EVGStencil *stencil, Float x, Float y)
 
GF_Vec4 gf_evg_stencil_get_pixel_yuv_f (GF_EVGStencil *stencil, Float x, Float y)
 
GF_EVGSurfacegf_evg_surface_new (Bool center_coords)
 
void gf_evg_surface_delete (GF_EVGSurface *surf)
 
GF_Err gf_evg_enable_threading (GF_EVGSurface *surf, s32 nb_threads)
 
GF_Err gf_evg_surface_attach_to_texture (GF_EVGSurface *surf, GF_EVGStencil *sten)
 
Bool gf_evg_surface_format_ok (GF_PixelFormat pixelFormat)
 
GF_Err gf_evg_surface_attach_to_buffer (GF_EVGSurface *surf, u8 *pixels, u32 width, u32 height, s32 pitch_x, s32 pitch_y, GF_PixelFormat pixelFormat)
 
GF_Err gf_evg_surface_set_raster_level (GF_EVGSurface *surf, GF_RasterQuality level)
 
GF_RasterQuality gf_evg_surface_get_raster_level (GF_EVGSurface *surf)
 
GF_Err gf_evg_surface_force_aa (GF_EVGSurface *surf)
 
GF_Err gf_evg_surface_set_matrix (GF_EVGSurface *surf, GF_Matrix2D *mat)
 
GF_Err gf_evg_surface_set_matrix_3d (GF_EVGSurface *surf, GF_Matrix *mat)
 
GF_Err gf_evg_surface_set_clipper (GF_EVGSurface *surf, GF_IRect *rc)
 
Bool gf_evg_surface_use_clipper (GF_EVGSurface *surf)
 
GF_Err gf_evg_surface_set_path (GF_EVGSurface *surf, GF_Path *path)
 
GF_Err gf_evg_surface_fill (GF_EVGSurface *surf, GF_EVGStencil *stencil)
 
GF_Err gf_evg_surface_multi_fill (GF_EVGSurface *surf, GF_EVGMultiTextureMode operand, GF_EVGStencil *sten1, GF_EVGStencil *sten2, GF_EVGStencil *sten3, Float params[4])
 
GF_Err gf_evg_surface_clear (GF_EVGSurface *surf, GF_IRect *rc, GF_Color col)
 
void gf_evg_surface_set_center_coords (GF_EVGSurface *surf, Bool center_coords)
 
void gf_evg_surface_set_composite_mode (GF_EVGSurface *surf, GF_EVGCompositeMode comp_mode)
 
void gf_evg_surface_set_alpha_callback (GF_EVGSurface *surf, gf_evg_get_alpha get_alpha, void *cbk)
 
GF_Err gf_evg_surface_enable_3d (GF_EVGSurface *surf)
 
GF_Err gf_evg_surface_set_projection (GF_EVGSurface *surf, GF_Matrix *mx)
 
GF_Err gf_evg_surface_set_modelview (GF_EVGSurface *surf, GF_Matrix *mx)
 
GF_Err gf_evg_surface_draw_array (GF_EVGSurface *surf, u32 *indices, u32 nb_indices, Float *vertices, u32 nb_vertices, u32 nb_comp, GF_EVGPrimitiveType prim_type)
 
GF_Err gf_evg_surface_clear_depth (GF_EVGSurface *surf, Float depth)
 
GF_Err gf_evg_surface_viewport (GF_EVGSurface *surf, u32 x, u32 y, u32 w, u32 h)
 
GF_Err gf_evg_surface_draw_path (GF_EVGSurface *surf, GF_Path *path, Float z)
 
GF_Err gf_evg_set_depth_test (GF_EVGSurface *surf, GF_EVGDepthTest mode)
 
GF_Err gf_evg_surface_set_fragment_shader (GF_EVGSurface *surf, gf_evg_fragment_shader shader, gf_evg_fragment_shader_init shader_init, void *shader_udta)
 
GF_Err gf_evg_surface_set_vertex_shader (GF_EVGSurface *surf, gf_evg_vertex_shader shader, void *shader_udta)
 
GF_Err gf_evg_surface_set_ccw (GF_EVGSurface *surf, Bool is_ccw)
 
GF_Err gf_evg_surface_set_backcull (GF_EVGSurface *surf, Bool backcull)
 
GF_Err gf_evg_surface_set_antialias (GF_EVGSurface *surf, Bool antialias)
 
GF_Err gf_evg_surface_set_min_depth (GF_EVGSurface *surf, Float min_depth)
 
GF_Err gf_evg_surface_set_max_depth (GF_EVGSurface *surf, Float max_depth)
 
GF_Err gf_evg_surface_set_clip_zero (GF_EVGSurface *surf, Bool clip_zero)
 
GF_Err gf_evg_surface_set_point_size (GF_EVGSurface *surf, Float size)
 
GF_Err gf_evg_surface_set_line_size (GF_EVGSurface *surf, Float size)
 
GF_Err gf_evg_surface_set_point_smooth (GF_EVGSurface *surf, Bool smooth)
 
GF_Err gf_evg_surface_disable_early_depth (GF_EVGSurface *surf, Bool disable)
 
GF_Err gf_evg_surface_write_depth (GF_EVGSurface *surf, Bool do_write)
 
GF_Err gf_evg_surface_set_depth_buffer (GF_EVGSurface *surf, Float *depth)
 
GF_Err gf_gf_evg_rgb_to_yuv_f (GF_EVGSurface *surf, Float r, Float g, Float b, Float *y, Float *cb, Float *cr)
 
GF_Err gf_evg_yuv_to_rgb_f (GF_EVGSurface *surf, Float y, Float cb, Float cr, Float *r, Float *g, Float *b)
 
void gf_evg_rgb_to_yuv (GF_EVGSurface *surf, GF_Color col, u8 *y, u8 *cb, u8 *cr)
 
GF_Color gf_evg_argb_to_ayuv (GF_EVGSurface *surf, GF_Color col)
 
GF_Color gf_evg_ayuv_to_argb (GF_EVGSurface *surf, GF_Color col)
 
u64 gf_evg_argb_to_ayuv_wide (GF_EVGSurface *surf, u64 col)
 
u64 gf_evg_ayuv_to_argb_wide (GF_EVGSurface *surf, u64 col)
 
GF_Err gf_evg_surface_set_mask_mode (GF_EVGSurface *surf, GF_EVGMaskMode mask_mode)
 
GF_EVGMaskMode gf_evg_surface_get_mask_mode (GF_EVGSurface *surf)
 

Detailed Description

GPAC uses a software rasterizer for vector graphics based on FreeType's "ftgray" anti-aliased renderer.

The rasterizer supports

The rasterizer is only capable of filling a given GF_Path object

The rasterizer also supports experimental drawing of 3D primitives (point, lines, triangles). This is obviously not intended to replace GPU rendering, but can be useful to draw simple primitives over an existing video source. The following constraints apply in 3D mode:


Data Structure Documentation

◆ GF_EVGFragmentParam

struct GF_EVGFragmentParam

Parameters for the fragment callback

+ Collaboration diagram for GF_EVGFragmentParam:
Data Fields
Float screen_x

screen x in pixels - input param

Float screen_y

screen y in pixels - input param

Float screen_z

screen z in NDC - input param

Float depth

depth - input and output param - 3D shaders only

u32 prim_index

primitive index in the current gf_evg_surface_draw_array call, 0 being the first primitive - input param - 3D shaders only

u32 idx1

index of first vertex in the current primitive - input param - 3D shaders only

u32 idx2

index of second vertex in the current primitive (for lines or triangles/quads) - input param - 3D shaders only

u32 idx3

index of third vertex in the current primitive (for triangles/quads) - input param - 3D shaders only

GF_EVGPrimitiveType ptype

primitive type - input param - 3D shaders only

GF_Vec4 color

fragment color, must be written if fragment is not discarded - output value

u32 color_pack

fragment color in pack 32 bit ARGB/AYUV

u64 color_pack_wide

fragment color in pack 64 bit ARGB/AYUV

GF_EVGFragmentType frag_valid

fragment valid state - output value

Float pbc1

perspective corrected barycentric, eg bc1/q1, bc2/q2, bc3/q3 - 3D shaders only

Float pbc2
Float pbc3
Float persp_denum

perspective divider - 3D shaders only

Note
this is also 1/W of the fragment, eg opengl gl_fragCoord.w
void * shader_udta
u32 tx_x

horizontal texture coordinate, 0 is left of image - 2D shaders only

u32 tx_y

vertical texture coordinate, 0 is top of image - 2D shaders only

u32 tx_width

texture width - 2D shaders only

u32 tx_height

texture height - 2D shaders only

u8 coverage

coverage value between 0 and 0xFF - 2D shaders only

u8 odd_flag

odd / even flag for path drawn with zero/non-zero fill rule - 2D shaders only

◆ GF_EVGVertexParam

struct GF_EVGVertexParam

Parameters for the vertex callback

+ Collaboration diagram for GF_EVGVertexParam:
Data Fields
GF_Vec4 in_vertex

input vertex - input param

u32 prim_index

primitive index in the current gf_evg_surface_draw_array call, 0 being the first primitive - input param

u32 vertex_idx

index of the vertex - input param

u32 vertex_idx_in_prim

index of the vertex in the current primitive - input param

u32 ptype

primitive type - input param

GF_Vec4 out_vertex

transformed vertex to use, must be written - output values

Typedef Documentation

◆ GF_EVGStencil

typedef struct _gf_evg_base_stencil GF_EVGStencil

stencil type used for all stencils

◆ GF_EVGSurface

typedef struct _gf_evg_surface GF_EVGSurface

surface type

◆ gf_evg_texture_callback

typedef void(* gf_evg_texture_callback) (void *cbk, u32 x, u32 y, Float *r, Float *g, Float *b, Float *a)

callback function prototype for parametric textures

Parameters
cbkuser data callback
xhorizontal coordinate in texture, ranging between 0 and width-1, (0,0) being top-left pixel, or horizontal coordinate of destination pixel on surface
yvertical coordinate in texture, ranging between 0 and height-1, (0,0) being top-left pixel, or vertical coordinate of destination pixel on surface
rset to the red value (not initialized before call)
gset to the green value (not initialized before call)
bset to the blue value (not initialized before call)
aset to the alpha value (not initialized before call)

◆ gf_evg_get_alpha

typedef u8(* gf_evg_get_alpha) (void *udta, u8 src_alpha, s32 x, s32 y)

callback type for alpha override

Parameters
udtaopaque data passed back to caller
src_alphaalpha value about to be blended
xhorizontal coordinate of pixel to be drawn, {0,0} being top-left, positive Y go down
yvertical coordinate of pixel to be drawn, {0,0} being top-left, positive Y go down
Returns
final alpha value to use

◆ gf_evg_fragment_shader

typedef Bool(* gf_evg_fragment_shader) (void *udta, GF_EVGFragmentParam *fragp)

callback type for fragment shader

Parameters
udtaopaque data passed back to caller
fragpfragment paramters
Returns
GF_TRUE if success; GF_FALSE if error

◆ gf_evg_fragment_shader_init

typedef Bool(* gf_evg_fragment_shader_init) (void *udta, GF_EVGFragmentParam *fragp, u32 th_id, Bool is_cleanup)

callback type for fragment shader init, called once before each primitive - may be NULL

Parameters
udtaopaque data passed back to caller
fragpfragment paramters
th_idindex of thread context
is_cleanupif TRUE indicates and of primitive rendering, otherwise begin
Returns
GF_TRUE if success; GF_FALSE if error

◆ gf_evg_vertex_shader

typedef Bool(* gf_evg_vertex_shader) (void *udta, GF_EVGVertexParam *vertp)

callback type for vertex shader

Parameters
udtaopaque data passed back to caller
vertpvertex paramters
Returns
GF_TRUE if success; GF_FALSE if error

Enumeration Type Documentation

◆ GF_StencilType

stencil types

Enumerator
GF_STENCIL_SOLID 

solid color stencil

GF_STENCIL_LINEAR_GRADIENT 

linear color gradient stencil

GF_STENCIL_RADIAL_GRADIENT 

radial color gradient stencil

GF_STENCIL_VERTEX_GRADIENT 

texture stencil

GF_STENCIL_TEXTURE 

texture stencil

◆ GF_GradientMode

gradient filling modes

Enumerator
GF_GRADIENT_MODE_PAD 

edge colors are repeated until path is filled

GF_GRADIENT_MODE_SPREAD 

pattern is inversed each time it's repeated

GF_GRADIENT_MODE_REPEAT 

pattern is repeated to fill path

◆ GF_TextureMapFlags

texture map flags

Enumerator
GF_TEXTURE_REPEAT_S 

texture is repeated in its horizontal direction

GF_TEXTURE_REPEAT_T 

texture is repeated in its horizontal direction

GF_TEXTURE_FLIP_X 

texture is fliped horizontally

GF_TEXTURE_FLIP_Y 

texture is fliped vertically

◆ GF_TextureFilter

filter levels for texturing - up to the graphics engine but the following levels are used by the client

Enumerator
GF_TEXTURE_FILTER_HIGH_SPEED 

high speed mapping (ex, no filtering applied)

GF_TEXTURE_FILTER_MID 

compromise between speed and quality (ex, filter to nearest pixel)

GF_TEXTURE_FILTER_HIGH_QUALITY 

high quality mapping (ex, bi-linear/bi-cubic interpolation)

◆ GF_RasterQuality

rasterizer antialiasing depending on the graphics engine

Enumerator
GF_RASTER_HIGH_SPEED 

raster shall use no antialiasing

GF_RASTER_MID 

raster should use fast mode and good quality if possible

GF_RASTER_HIGH_QUALITY 

raster should use full antialiasing - this is the default for all new surfaces

◆ GF_EVGMultiTextureMode

Operands for multitexture operations

Enumerator
GF_EVG_OPERAND_NONE 

no multitexture

GF_EVG_OPERAND_MIX 

mix texture 1 and texure 2 using coefficient in first param, returning tx1*coef + tx2*(1-coef) but forcing alpha to full opacity

GF_EVG_OPERAND_MIX_ALPHA 

mix texture 1 and texure 2 using coefficient in first param, returning tx1*coef + tx2*(1-coef), including alpha channel

GF_EVG_OPERAND_REPLACE_ALPHA 

replace alpha of texture 1 with alpha of texture 2 if first param is 0 or not set, use alpha channel from texture 2 if first param is 1, use red channel from texture 2 if first param is 2, use green/Cb/U channel from texture 2 if first param is 3, use blue/Cr/V channel from texture 2

GF_EVG_OPERAND_REPLACE_ONE_MINUS_ALPHA 

replace alpha of texture 1 with (1-alpha) of texture 2 if first param is 0 or not set, use alpha channel from texture 2 if first param is 1, use red/Y channel from texture 2 if first param is 2, use green/Cb/U channel from texture 2 if first param is 3, use blue/Cr/V channel from texture 2

GF_EVG_OPERAND_MIX_DYN 

mix texture 1 and texure 2 using alpha coef of texture 3 but forcing alpha to full opacity if first param is 0 or not set, use alpha channel from texture 3 if first param is 1, use red channel from texture 3 if first param is 2, use green/Cb/U channel from texture 3 if first param is 3, use blue/Cr/V channel from texture 3

GF_EVG_OPERAND_MIX_DYN_ALPHA 

mix texture 1 and texure 2 using alpha coef of texture 3, including alpha channel. if first param is 0 or not set, use alpha channel from texture 3 if first param is 1, use red channel from texture 3 if first param is 2, use green/Cb/U channel from texture 3 if first param is 3, use blue/Cr/V channel from texture 3

GF_EVG_OPERAND_ODD_FILL 

use texture 1 for odd fill and texture 2 for even fill

◆ GF_EVGCompositeMode

Composition mode used for ARGB surfaces - cf Canvas2D modes

Enumerator
GF_EVG_SRC_OVER 

source over

GF_EVG_SRC_ATOP 

source atop

GF_EVG_SRC_IN 

source in

GF_EVG_SRC_OUT 

source out

GF_EVG_DST_ATOP 

destination atop

GF_EVG_DST_IN 

destination in

GF_EVG_DST_OUT 

destination out

GF_EVG_DST_OVER 

destination over

GF_EVG_LIGHTER 

destination * source

GF_EVG_COPY 

source copy

GF_EVG_XOR 

source XOR destination

◆ GF_EVGPrimitiveType

Primitive types for 3D software rasterize - see OpenGL terminology

Enumerator
GF_EVG_POINTS 

points, 1 vertex index per primitive

GF_EVG_POLYGON 

polygon, all vertex indices in array are used for a single face

GF_EVG_LINES 

lines, 2 vertex indices per primitive

GF_EVG_TRIANGLES 

triangles, 3 vertex indices per primitive

GF_EVG_QUADS 

quads, 4 vertex indices per primitive

GF_EVG_LINE_STRIP 

line strip, 2 vertex indices for first primitive, then one for subsequent ones

GF_EVG_TRIANGLE_STRIP 

triangle strip, 3 vertex indices for first primitive, then one for subsequent ones

GF_EVG_TRIANGLE_FAN 

triangle fan, 3 vertex indices for first primitive, then one for subsequent ones

GF_EVG_QUAD_STRIP 

quad strip, 4 vertex indices for first primitive, then one for subsequent ones

◆ GF_EVGDepthTest

Depth test modes

Enumerator
GF_EVGDEPTH_DISABLE 

depth test is disabled

GF_EVGDEPTH_NEVER 

depth test always fails

GF_EVGDEPTH_ALWAYS 

depth test always succeeds

GF_EVGDEPTH_EQUAL 

depth test succeeds if fragment depth is == than depth buffer value

GF_EVGDEPTH_NEQUAL 

depth test succeeds if fragment depth is != than depth buffer value

GF_EVGDEPTH_LESS 

depth test succeeds if fragment depth is < than depth buffer value

GF_EVGDEPTH_LESS_EQUAL 

depth test succeeds if fragment depth is <= than depth buffer value

GF_EVGDEPTH_GREATER 

depth test succeeds if fragment depth is > than depth buffer value

GF_EVGDEPTH_GREATER_EQUAL 

depth test succeeds if fragment depth is >= than depth buffer value

◆ GF_EVGFragmentType

fragment color type

Enumerator
GF_EVG_FRAG_INVALID 

fragment is invalid (discarded or error)

GF_EVG_FRAG_RGB 

fragment is RGB float

GF_EVG_FRAG_YUV 

fragment is YUV

◆ GF_EVGMaskMode

global alpha mask values

Enumerator
GF_EVGMASK_NONE 

global alpha mask not used

GF_EVGMASK_DRAW 

subsequent draw operations will target the global alpha mask

GF_EVGMASK_DRAW_NO_CLEAR 

subsequent draw operations will target the global alpha mask, but alpha mask is not cleared

GF_EVGMASK_USE 

subsequent draw operations will be filtered with the global alpha mask

GF_EVGMASK_USE_INV 

subsequent draw operations will be filtered with 1 minus the global alpha mask

GF_EVGMASK_RECORD 

combine draw and use: the mask is set to 0xFF, each pixel drawn turns the mask value to 0

Function Documentation

◆ gf_evg_stencil_new()

GF_EVGStencil* gf_evg_stencil_new ( GF_StencilType  type)

common constructor for all stencil types

Parameters
typethe stencil type
Returns
a new stencil object

◆ gf_evg_stencil_delete()

void gf_evg_stencil_delete ( GF_EVGStencil stencil)

common destructor for all stencils

Parameters
stencilthe target stencil

◆ gf_evg_stencil_set_matrix()

GF_Err gf_evg_stencil_set_matrix ( GF_EVGStencil stencil,
GF_Matrix2D mat 
)

sets stencil transformation matrix

Parameters
stencilthe target stencil
matthe 2D matrix to set
Returns
error if any

◆ gf_evg_stencil_get_matrix()

Bool gf_evg_stencil_get_matrix ( GF_EVGStencil stencil,
GF_Matrix2D mat 
)

gets stencil transformation matrix

Parameters
stencilthe target stencil
matthe 2D matrix to fetch
Returns
TRUE if resulting matrix is fetched, false otherwise (matrix is identity or does not apply to this stencil class)

◆ gf_evg_stencil_set_auto_matrix()

GF_Err gf_evg_stencil_set_auto_matrix ( GF_EVGStencil stencil,
Bool  auto_on 
)

sets stencil transformation matrix auto mode.

When auto matrix mode is activated, the stencil matrix only describes texture mapping transform in uv space (normalized UV coordinates, OpenGL like), and final transformation to raster coordinates is done internally. When auto matrix mode is not activated,, the stencil matrix must describe the complete transformation from uv space to raster coordinates (consequently, the matrix usually includes the final path transformation).

Stencils are by default created in auto matrix mode.

Parameters
stencilthe target stencil
auto_onIf true, the surface current matrix will be added to the stencil matrix when drawing, otherwise the stencil matrix is in final surface coordinates
Returns
error if any

◆ gf_evg_stencil_get_auto_matrix()

Bool gf_evg_stencil_get_auto_matrix ( GF_EVGStencil stencil)

sets stencil transformation matrix auto mode.

Parameters
stencilthe target stencil
Returns
true if auto mode is enabled, false otherwise

◆ gf_evg_stencil_type()

GF_StencilType gf_evg_stencil_type ( GF_EVGStencil stencil)

gets stencil type

Parameters
stencilthe target stencil
Returns
stencil type

◆ gf_evg_stencil_set_brush_color()

GF_Err gf_evg_stencil_set_brush_color ( GF_EVGStencil stencil,
GF_Color  color 
)

sets color for solid brush stencil

Parameters
stencilthe target stencil
colorthe color to set
Returns
error if any

◆ gf_evg_stencil_get_brush_color()

GF_Color gf_evg_stencil_get_brush_color ( GF_EVGStencil stencil)

gets color for solid brush stencil

Parameters
stencilthe target stencil
Returns
the stencil color

◆ gf_evg_stencil_set_gradient_mode()

GF_Err gf_evg_stencil_set_gradient_mode ( GF_EVGStencil stencil,
GF_GradientMode  mode 
)

sets gradient repeat mode for a gradient stencil

Note
this may be called before the gradient is setup
Parameters
stencilthe target stencil
modethe gradient mode
Returns
error if any

◆ gf_evg_stencil_set_linear_gradient()

GF_Err gf_evg_stencil_set_linear_gradient ( GF_EVGStencil stencil,
Fixed  start_x,
Fixed  start_y,
Fixed  end_x,
Fixed  end_y 
)

sets linear gradient direction for a gradient stencil Gradient line is defined by start and end. For example, {0,0}, {1,0} defines an horizontal gradient

Parameters
stencilthe target stencil
start_xhorizontal coordinate of starting point
start_yvertical coordinate of starting point
end_xhorizontal coordinate of ending point
end_yvertical coordinate of ending point
Returns
error if any

◆ gf_evg_stencil_set_radial_gradient()

GF_Err gf_evg_stencil_set_radial_gradient ( GF_EVGStencil stencil,
Fixed  cx,
Fixed  cy,
Fixed  fx,
Fixed  fy,
Fixed  x_radius,
Fixed  y_radius 
)

sets radial gradient center point, focal point and radius for a gradient stencil

Parameters
stencilthe target stencil
cxhorizontal coordinate of center
cyvertical coordinate of center
fxhorizontal coordinate of focal point
fyvertical coordinate of focal point
x_radiushorizontal radius
y_radiusvertical radius
Returns
error if any

◆ gf_evg_stencil_set_gradient_interpolation()

GF_Err gf_evg_stencil_set_gradient_interpolation ( GF_EVGStencil stencil,
Fixed pos,
GF_Color col,
u32  count 
)

sets color interpolation for a gradient stencil

Note
the colors at 0 and 1.0 MUST be provided
colors shall be fed in order from 0 to 1
Parameters
stencilthe target stencil
posinterpolation positions. Each position gives the distance from (center for radial, start for linear) expressed between 0 and 1 (1 being the gradient bounds) - may be NULL when count is 0
colcolors at the given position - may be NULL when count is 0
countnumber of colors and position. A value of 0 resets the gradient colors
Returns
error if any

◆ gf_evg_stencil_push_gradient_interpolation()

GF_Err gf_evg_stencil_push_gradient_interpolation ( GF_EVGStencil stencil,
Fixed  pos,
GF_Color  col 
)

pushes a single color interpolation for a gradient stencil

Note
the colors at 0 and 1.0 MUST be provided
colors shall be fed in order from 0 to 1
Parameters
stencilthe target stencil
posinterpolation position. A position gives the distance from (center for radial, start for linear) expressed between 0 and 1 (1 being the gradient bounds)
colcolor at the given position
Returns
error if any

◆ gf_evg_stencil_set_alpha()

GF_Err gf_evg_stencil_set_alpha ( GF_EVGStencil stencil,
u8  alpha 
)

sets global alpha blending level for a stencil The alpha channel will be combined with the color matrix if any

Warning
do not use with solid brush stencil
Parameters
stencilthe target stencil
alphathe alpha value between 0 (full transparency) and 255 (full opacityy)
Returns
error if any

◆ gf_evg_stencil_get_alpha()

u8 gf_evg_stencil_get_alpha ( GF_EVGStencil stencil)

gets global alpha blending level of a stencil

Parameters
stencilthe target stencil
Returns
the alpha value between 0 (full transparency) and 255 (full opacityy)

◆ gf_evg_texture_format_ok()

Bool gf_evg_texture_format_ok ( GF_PixelFormat  pixelFormat)

checks if pixel format is supported for a texture stencil

Parameters
pixelFormatthe target pixel format
Returns
GF_TRUE if supported, GF_FALSE otherwise

◆ gf_evg_stencil_set_texture()

GF_Err gf_evg_stencil_set_texture ( GF_EVGStencil stencil,
u8 pixels,
u32  width,
u32  height,
u32  stride,
GF_PixelFormat  pixelFormat 
)

sets pixel data for a texture stencil

Parameters
stencilthe target stencil
pixelstexture data starting from top row
widthtexture width in pixels
heighttexture height in pixels
stridetexture horizontal pitch (bytes to skip to get to next row)
pixelFormattexture pixel format
Note
this stencil acts as a data wrapper, the pixel data is not locally copied
Returns
error if any

◆ gf_evg_stencil_set_texture_planes()

GF_Err gf_evg_stencil_set_texture_planes ( GF_EVGStencil stencil,
u32  width,
u32  height,
GF_PixelFormat  pixelFormat,
const u8 y_or_rgb,
u32  stride,
const u8 u_plane,
const u8 v_plane,
u32  uv_stride,
const u8 alpha_plane,
u32  alpha_stride 
)

sets pixel planes data for a texture stencil

Parameters
stencilthe target stencil
widthtexture width in pixels
heighttexture height in pixels
pixelFormattexture pixel format
y_or_rgbY plane or RGB plane
stridestride of the Y or RGB plane
u_planeU plane or UV plane for semi-planar YUV formats
v_planeV plane for planar YUV format, NULL for semi-planar YUV formats
uv_stridestride of the U and V or UV plane
alpha_planealpha plane
alpha_stridestride of the alpha plane; if 0 and alpha plane is not NULL, the stride is assumed to be the same as the Y plane stride
Note
this stencil acts as a data wrapper, the pixel data is not locally copied
Returns
error if any

◆ gf_evg_stencil_set_palette()

GF_Err gf_evg_stencil_set_palette ( GF_EVGStencil stencil,
const u8 palette,
u32  pix_fmt,
u32  nb_cols 
)

sets texture palette, only for greyscale textures.

Parameters
stencilthe target stencil
palettepalette data
pix_fmtpalette pixel format, must be RGB/BGR or any RGBA format
nb_colsnumber of colors in palette
Returns
error if any

◆ gf_evg_stencil_set_texture_parametric()

GF_Err gf_evg_stencil_set_texture_parametric ( GF_EVGStencil stencil,
u32  width,
u32  height,
GF_PixelFormat  pixelFormat,
gf_evg_texture_callback  callback,
void *  cbk_udta,
Bool  use_screen_coords 
)

sets parametric callback on a texture stencil. A parametric texture gets its pixel values from a callback function, the resulting value being blended according to the antialiasing level of the pixel. This allows creating rather complex custom textures, in a fashion similar to fragment shaders.

Parameters
stencilthe target stencil
widthtexture width in pixels
heighttexture height in pixels
pixelFormattexture pixel format, indicates if the returned values are in RGB or YUV
callbackthe callback function to use
cbk_udtauser data to pass to the callback function
use_screen_coordsif set, the coordinates passed to the callback function are screen coordinates rather than texture coordinates
Returns
error if any

◆ gf_evg_stencil_set_mapping()

GF_Err gf_evg_stencil_set_mapping ( GF_EVGStencil stencil,
GF_TextureMapFlags  map_mode 
)

sets texture mapping options for a texture stencil

Parameters
stencilthe target stencil
map_modetexture mapping flags to set
Returns
error if any

◆ gf_evg_stencil_set_pad_color()

GF_Err gf_evg_stencil_set_pad_color ( GF_EVGStencil stencil,
GF_Color  pad_color 
)

sets padding color in RGBA If texture repeat is disabled and pad color is set, this color is used when outside of image, otherwise pixel is fetch from image border

Parameters
stencilthe target stencil
pad_colorcolor to use , 0 disables color padding
Returns
error if any

◆ gf_evg_stencil_get_pad_color()

u32 gf_evg_stencil_get_pad_color ( GF_EVGStencil stencil)

gets padding color in RGBA

Parameters
stencilthe target stencil
Returns
color used , 0 if error

◆ gf_evg_stencil_set_filter()

GF_Err gf_evg_stencil_set_filter ( GF_EVGStencil stencil,
GF_TextureFilter  filter_mode 
)

sets filtering mode for a texture stencil

Parameters
stencilthe target stencil
filter_modetexture filtering mode to set
Returns
error if any

◆ gf_evg_stencil_set_color_matrix()

GF_Err gf_evg_stencil_set_color_matrix ( GF_EVGStencil stencil,
GF_ColorMatrix cmat 
)

sets color matrix of a stencil

Parameters
stencilthe target stencil
cmatthe color matrix to use. If NULL, resets current color matrix
Returns
error if any

◆ gf_evg_stencil_get_color_matrix()

GF_Err gf_evg_stencil_get_color_matrix ( GF_EVGStencil stencil,
GF_ColorMatrix cmat 
)

gets color matrix of a stencil

Parameters
stencilthe target stencil
cmatfilled with current color matrix of stencil
Returns
error if any

◆ gf_evg_stencil_get_pixel()

u32 gf_evg_stencil_get_pixel ( GF_EVGStencil stencil,
s32  x,
s32  y 
)

gets pixel at given position in ARGB format

Parameters
stencilthe target stencil
xhorizontal coord
yvertical coord
Returns
pixel value

◆ gf_evg_stencil_get_pixel_yuv()

u32 gf_evg_stencil_get_pixel_yuv ( GF_EVGStencil stencil,
s32  x,
s32  y 
)

gets pixel at given position in AYUV format

Parameters
stencilthe target stencil
xhorizontal coord
yvertical coord
Returns
pixel value

◆ gf_evg_stencil_get_pixel_wide()

u64 gf_evg_stencil_get_pixel_wide ( GF_EVGStencil stencil,
s32  x,
s32  y 
)

gets pixel at given position in ARGB format for more than 8 bits textures

Parameters
stencilthe target stencil
xhorizontal coord
yvertical coord
Returns
pixel value

◆ gf_evg_stencil_get_pixel_yuv_wide()

u64 gf_evg_stencil_get_pixel_yuv_wide ( GF_EVGStencil stencil,
s32  x,
s32  y 
)

gets pixel at given position in AYUV format for more than 8 bits textures

Parameters
stencilthe target stencil
xhorizontal coord
yvertical coord
Returns
pixel value

◆ gf_evg_stencil_get_pixel_f()

GF_Vec4 gf_evg_stencil_get_pixel_f ( GF_EVGStencil stencil,
Float  x,
Float  y 
)

gets ARGB pixel at a given position The position is given as normalize coordinates (between 0.0 and 1.0), {0.0,0.0} is top-left, {1.0,1.0} is bottom-right

Parameters
stencilthe target stencil
xhorizontal coord
yvertical coord
Returns
output r, r, g, a components

◆ gf_evg_stencil_get_pixel_yuv_f()

GF_Vec4 gf_evg_stencil_get_pixel_yuv_f ( GF_EVGStencil stencil,
Float  x,
Float  y 
)

gets AYUV pixel at a given position The position is given as normalize coordinates (between 0.0 and 1.0), {0.0,0.0} is top-left, {1.0,1.0} is bottom-right

Parameters
stencilthe target stencil
xhorizontal coord
yvertical coord
Returns
output y, u, v, a components

◆ gf_evg_surface_new()

GF_EVGSurface* gf_evg_surface_new ( Bool  center_coords)

creates a canvas surface object

Parameters
center_coordsif GF_TRUE, indicates mathematical-like coord system (0,0) at the center of the canvas, otherwise indicates computer-like coord system (0,0) top-left corner
Returns
a new surface

◆ gf_evg_surface_delete()

void gf_evg_surface_delete ( GF_EVGSurface surf)

deletes a surface object

Parameters
surfthe surface object

◆ gf_evg_enable_threading()

GF_Err gf_evg_enable_threading ( GF_EVGSurface surf,
s32  nb_threads 
)

enables threading on a canvas surface object (can only be called once per surface)

Parameters
surfthe target surface
nb_threadsnumber of additional threads to use for rendering. -1 use all availables core
Returns
error if any, GF_BAD_PARAM if threading was already allocated, GF_IO_ERR if only one core available and nb_threads not assigned to a positive value

◆ gf_evg_surface_attach_to_texture()

GF_Err gf_evg_surface_attach_to_texture ( GF_EVGSurface surf,
GF_EVGStencil sten 
)

attaches a surface object to a texture stencil object

Parameters
surfthe surface object
stenthe stencil object (shll be a texture stencil)
Returns
error if any

◆ gf_evg_surface_format_ok()

Bool gf_evg_surface_format_ok ( GF_PixelFormat  pixelFormat)

checks if pixel format is supported for a surface

Parameters
pixelFormatthe target pixel format
Returns
GF_TRUE if supported, GF_FALSE otherwise

◆ gf_evg_surface_attach_to_buffer()

GF_Err gf_evg_surface_attach_to_buffer ( GF_EVGSurface surf,
u8 pixels,
u32  width,
u32  height,
s32  pitch_x,
s32  pitch_y,
GF_PixelFormat  pixelFormat 
)

attaches a surface object to a memory buffer

Parameters
surfthe surface object
pixelstexture data
widthtexture width in pixels
heighttexture height in pixels
pitch_xtexture horizontal pitch (bytes to skip to get to next pixel). O means linear frame buffer (eg pitch_x==bytes per pixel)
pitch_ytexture vertical pitch (bytes to skip to get to next line)
pixelFormattexture pixel format
Returns
error if any

◆ gf_evg_surface_set_raster_level()

GF_Err gf_evg_surface_set_raster_level ( GF_EVGSurface surf,
GF_RasterQuality  level 
)

sets rasterizer precision

Parameters
surfthe surface object
levelthe raster quality level
Returns
error if any

◆ gf_evg_surface_get_raster_level()

GF_RasterQuality gf_evg_surface_get_raster_level ( GF_EVGSurface surf)

gets rasterizer precision

Parameters
surfthe surface object
Returns
the raster quality level

◆ gf_evg_surface_force_aa()

GF_Err gf_evg_surface_force_aa ( GF_EVGSurface surf)

Force next path fill to use antialias, reset at each gf_evg_surface_set_path

Parameters
surfthe surface object
Returns
error if any

◆ gf_evg_surface_set_matrix()

GF_Err gf_evg_surface_set_matrix ( GF_EVGSurface surf,
GF_Matrix2D mat 
)

sets the given matrix as the current transformations for all drawn paths

Note
this is only used for 2D rasterizer, and ignored in 3D mode
Parameters
surfthe surface object
matthe matrix to set; if NULL, resets the current transformation
Returns
error if any

◆ gf_evg_surface_set_matrix_3d()

GF_Err gf_evg_surface_set_matrix_3d ( GF_EVGSurface surf,
GF_Matrix mat 
)

sets the given matrix as the current transformations for all drawn paths. The matrix shall be a projection matrix (ortho or perspective) with normalized coordinates in [-1,1]. It may also contain a modelview part.

Perspective correct mapping is supported for textures and gradients:

  • the bottom-left corner of the path bounds is texture coordinate 0,0
  • the top-right corner of the path bounds is texture coordinate 1,1
Warning
When 3D matrices are used, filling a path shall be done with a stencil in auto matrix mode.
Note
this is only used for 2D rasterizer, and ignored in 3D mode
Parameters
surfthe surface object
matthe matrix to set; if NULL, resets the current transformation
Returns
error if any

◆ gf_evg_surface_set_clipper()

GF_Err gf_evg_surface_set_clipper ( GF_EVGSurface surf,
GF_IRect rc 
)

sets the given rectangle as a clipper When a clipper is enabled, nothing is drawn outside of the clipper. The clipper is not affected by the surface matrix

Parameters
surfthe surface object
rcthe clipper to set, in pixel coordinates of the surface; if NULL, disables clipper
Returns
error if any

◆ gf_evg_surface_use_clipper()

Bool gf_evg_surface_use_clipper ( GF_EVGSurface surf)

checks if clipper is active

Parameters
surfthe surface object
Returns
GF_TRUE if clipper is active, GF_FALSE otherwise

◆ gf_evg_surface_set_path()

GF_Err gf_evg_surface_set_path ( GF_EVGSurface surf,
GF_Path path 
)

sets the given path as the current one for drawing

Warning
This will internally copy the path after transformation with the current transfom. Changing the surface transform will have no effect unless calling this function again. The clipper and stencil mode may be changed at will
Note
this is only used for 2D rasterizer, and ignored in 3D mode
Parameters
surfthe surface object
paththe target path to rasterize
Returns
error if any

◆ gf_evg_surface_fill()

GF_Err gf_evg_surface_fill ( GF_EVGSurface surf,
GF_EVGStencil stencil 
)

draw (filling) the current path on a surface using the given stencil and current clipper if any. If the stencil is a solid brush and its alpha value is 0, the surface is cleared if it has an alpha component, otherwise the call is ignored.

Note
this can be called several times with the same current path
this is only used for 2D rasterizer, and ignored in 3D mode
Parameters
surfthe surface object
stencilthe stencil to use to fill a path, if NULL uses 2D shader if setup
Returns
error if any

◆ gf_evg_surface_multi_fill()

GF_Err gf_evg_surface_multi_fill ( GF_EVGSurface surf,
GF_EVGMultiTextureMode  operand,
GF_EVGStencil sten1,
GF_EVGStencil sten2,
GF_EVGStencil sten3,
Float  params[4] 
)

draw (filling) the current path on a surface using a compinaison of stencils and current clipper if any.

Parameters
surfthe surface object
operandstencil combine effect
sten1the first stencil to use, if NULL assumes shader and ignores operand
sten2the second stencil to use, may be NULL depending on operand
sten3the third stencil to use, may be NULL depending on operand
paramsthe parameters to control the operand
Returns
error if any

◆ gf_evg_surface_clear()

GF_Err gf_evg_surface_clear ( GF_EVGSurface surf,
GF_IRect rc,
GF_Color  col 
)

clears given pixel rectangle on a surface with the given color

Warning
this ignores any clipper set on the surface
Parameters
surfthe surface object
rcthe rectangle in pixel coordinates to clear. This may lay outside the surface, and shall not be NULL
colthe color used to clear the canvas. The alpha component is discarded if the surface does not have alpha, otherwise it is used
Returns
error if any

◆ gf_evg_surface_set_center_coords()

void gf_evg_surface_set_center_coords ( GF_EVGSurface surf,
Bool  center_coords 
)

sets center coord mode of a surface

Note
this is only used for 2D rasterizer, and ignored in 3D mode
Parameters
surfthe surface object
center_coordsif GF_TRUE, indicates mathematical-like coord system (0,0) at the center of the canvas, otherwise indicates computer-like coord system (0,0) top-left corner

◆ gf_evg_surface_set_composite_mode()

void gf_evg_surface_set_composite_mode ( GF_EVGSurface surf,
GF_EVGCompositeMode  comp_mode 
)

sets surface composite mode, as defined in Canvas2D - only used for ARGB surfaces

Warning
this is still experimental
Parameters
surfthe surface object
comp_modethe composition mode to use

◆ gf_evg_surface_set_alpha_callback()

void gf_evg_surface_set_alpha_callback ( GF_EVGSurface surf,
gf_evg_get_alpha  get_alpha,
void *  cbk 
)

sets alpha callback function. This allows finer control over the blending, but does not allow for pixel color modification

Parameters
surfthe surface object
get_alphathe callback function to alter the alpha value
cbkopaque data for the callback function

◆ gf_evg_surface_enable_3d()

GF_Err gf_evg_surface_enable_3d ( GF_EVGSurface surf)

enables 3D software rasterizer for surface

Parameters
surfthe target 3D surface
Returns
error if any

◆ gf_evg_surface_set_projection()

GF_Err gf_evg_surface_set_projection ( GF_EVGSurface surf,
GF_Matrix mx 
)

sets projection matrix

Note
this is only used for 3D rasterizer, and fails 2D mode
Parameters
surfthe target 3D surface
mxthe target projection matrix
Returns
error if any

◆ gf_evg_surface_set_modelview()

GF_Err gf_evg_surface_set_modelview ( GF_EVGSurface surf,
GF_Matrix mx 
)

sets modelview matrix

Note
this is only used for 3D rasterizer, and fails 2D mode
Parameters
surfthe target 3D surface
mxthe target modelview matrix
Returns
error if any

◆ gf_evg_surface_draw_array()

GF_Err gf_evg_surface_draw_array ( GF_EVGSurface surf,
u32 indices,
u32  nb_indices,
Float vertices,
u32  nb_vertices,
u32  nb_comp,
GF_EVGPrimitiveType  prim_type 
)

draws a set of primitive using vertices and an index buffer modelview matrix

Note
this is only used for 3D rasterizer, and fails 2D mode
Parameters
surfthe target 3D surface
indicesthe array of indices to use in the vertex buffer
nb_indicesthe number of indices
verticesthe array of vertices to use
nb_verticesthe number of vertices
nb_compthe number of component per vertices (eg, 2, 3)
prim_typethe primitive type to use
Returns
error if any

◆ gf_evg_surface_clear_depth()

GF_Err gf_evg_surface_clear_depth ( GF_EVGSurface surf,
Float  depth 
)

clears the depth buffer

Note
the depth buffer is set by the caller. If no depth buffer is assigned, this function returns GF_OK
the color buffer is cleared using gf_evg_surface_clear
this is only used for 3D rasterizer, and fails 2D mode
Parameters
surfthe target 3D surface
depththe depth value to use
Returns
error if any

◆ gf_evg_surface_viewport()

GF_Err gf_evg_surface_viewport ( GF_EVGSurface surf,
u32  x,
u32  y,
u32  w,
u32  h 
)

sets the surface viewport to convert from projected coordiantes to screen coordinates

Note
this is only used for 3D rasterizer, and fails 2D mode
Parameters
surfthe target 3D surface
xthe top-left coordinate of the viewport in pixels
ythe top-left coordinate of the viewport in pixels
wthe width of the viewport in pixels
hthe height of the viewport in pixels
Returns
error if any

◆ gf_evg_surface_draw_path()

GF_Err gf_evg_surface_draw_path ( GF_EVGSurface surf,
GF_Path path,
Float  z 
)

draws path on a 3D surface with the given z.

The vertex shader is ignored (surface matrix must be set), and the fragment shader is called using perspective interpolation weights derived from the path bounds, using path bounds (top-left, top-right, bottom-right) vertices.

Note
this is only used for 3D rasterizer, and fails 2D mode
Parameters
surfthe target 3D surface
paththe path to draw
zthe z value to assign to the path in local coordinate system
Returns
error if any

◆ gf_evg_set_depth_test()

GF_Err gf_evg_set_depth_test ( GF_EVGSurface surf,
GF_EVGDepthTest  mode 
)

sets depth buffer test

Note
this is only used for 3D rasterizer, and fails 2D mode
Parameters
surfthe target 3D surface
modethe desired depth test mode
Returns
error if any

◆ gf_evg_surface_set_fragment_shader()

GF_Err gf_evg_surface_set_fragment_shader ( GF_EVGSurface surf,
gf_evg_fragment_shader  shader,
gf_evg_fragment_shader_init  shader_init,
void *  shader_udta 
)

assigns fragment shader to the rasterizer.

Warning
If multithread is enabled, the shader must be thread-safe This can be used for 3D and 2D modes. In 2D mode, texture coordinates are derived from path bounds
Parameters
surfthe target 3D surface
shaderthe fragment shader callback to use
shader_initthe fragment shader init callback to use
shader_udtaopaque data to pass to the callback function
Returns
error if any

◆ gf_evg_surface_set_vertex_shader()

GF_Err gf_evg_surface_set_vertex_shader ( GF_EVGSurface surf,
gf_evg_vertex_shader  shader,
void *  shader_udta 
)

assigns vertex shader to the rasterizer

Note
this is only used for 3D rasterizer, and fails 2D mode
Parameters
surfthe target 3D surface
shaderthe vertex shader callback to use
shader_udtaopaque data to pass to the callback function
Returns
error if any

◆ gf_evg_surface_set_ccw()

GF_Err gf_evg_surface_set_ccw ( GF_EVGSurface surf,
Bool  is_ccw 
)

sets face orientation for the primitives

Note
this is only used for 3D rasterizer, and fails 2D mode
Parameters
surfthe target 3D surface
is_ccwif GF_TRUE, face are given in counter-clockwise order, otherwise in clockwise order
Returns
error if any

◆ gf_evg_surface_set_backcull()

GF_Err gf_evg_surface_set_backcull ( GF_EVGSurface surf,
Bool  backcull 
)

enables/disables backface culling

Warning
not enabling backface culling when anti-aliasing is on may result in visual artefacts
Note
this is only used for 3D rasterizer, and fails 2D mode
Parameters
surfthe target 3D surface
backcullif GF_TRUE, faces with normals poiting away from camera will not be drawn
Returns
error if any

◆ gf_evg_surface_set_antialias()

GF_Err gf_evg_surface_set_antialias ( GF_EVGSurface surf,
Bool  antialias 
)

enables/disables anti-aliased rendering

Warning
not enabling backface culling when anti-aliasing is on may result in visual artefacts
Note
this is only used for 3D rasterizer, and fails 2D mode
Parameters
surfthe target 3D surface
antialiasif GF_TRUE, edges will be anti-aliased
Returns
error if any

◆ gf_evg_surface_set_min_depth()

GF_Err gf_evg_surface_set_min_depth ( GF_EVGSurface surf,
Float  min_depth 
)

sets minimum depth value for coordinates normalization - see OpenGL glDepthRange

Note
this is only used for 3D rasterizer, and fails 2D mode
Parameters
surfthe target 3D surface
min_depththe minimum depth value
Returns
error if any

◆ gf_evg_surface_set_max_depth()

GF_Err gf_evg_surface_set_max_depth ( GF_EVGSurface surf,
Float  max_depth 
)

sets maximum depth value for coordinates normalization - see OpenGL glDepthRange

Note
this is only used for 3D rasterizer, and fails 2D mode
Parameters
surfthe target 3D surface
max_depththe maximum depth value
Returns
error if any

◆ gf_evg_surface_set_clip_zero()

GF_Err gf_evg_surface_set_clip_zero ( GF_EVGSurface surf,
Bool  clip_zero 
)

indicates that the clip space after projection is [0,1] and not [-1, 1]

Note
this is only used for 3D rasterizer, and fails 2D mode
Parameters
surfthe target 3D surface
clip_zeroif GF_TRUE, the projected vertices depth are in [0, 1], otherwise in [-1, 1]
Returns
error if any

◆ gf_evg_surface_set_point_size()

GF_Err gf_evg_surface_set_point_size ( GF_EVGSurface surf,
Float  size 
)

sets point size value for points primitives

Note
this is only used for 3D rasterizer, and fails 2D mode
Parameters
surfthe target 3D surface
sizethe desired point size in pixels
Returns
error if any

◆ gf_evg_surface_set_line_size()

GF_Err gf_evg_surface_set_line_size ( GF_EVGSurface surf,
Float  size 
)

sets line size (width) value for points primitives

Note
this is only used for 3D rasterizer, and fails 2D mode
Parameters
surfthe target 3D surface
sizethe desired line size in pixels
Returns
error if any

◆ gf_evg_surface_set_point_smooth()

GF_Err gf_evg_surface_set_point_smooth ( GF_EVGSurface surf,
Bool  smooth 
)

enables point smoothing. When point smoothing is enabled, the geometry drawn is a circle, otherwise a square

Note
this is only used for 3D rasterizer, and fails 2D mode
Parameters
surfthe target 3D surface
smoothif GF_TRUE, point smoothing is enabled
Returns
error if any

◆ gf_evg_surface_disable_early_depth()

GF_Err gf_evg_surface_disable_early_depth ( GF_EVGSurface surf,
Bool  disable 
)

disables early depth test If your fragment shader modifies the depth of the fragment, you must call this function to avoid early depth test (fragment discarded before calling the shader)

Note
this is only used for 3D rasterizer, and fails 2D mode
Parameters
surfthe target 3D surface
disableif GF_TRUE, early depth test is disabled
Returns
error if any

◆ gf_evg_surface_write_depth()

GF_Err gf_evg_surface_write_depth ( GF_EVGSurface surf,
Bool  do_write 
)

disables depth buffer write

Note
this is only used for 3D rasterizer, and fails 2D mode
Parameters
surfthe target 3D surface
do_writeif GF_TRUE, depth values are written to the depth buffer (default when creating the rasterizer)
Returns
error if any

◆ gf_evg_surface_set_depth_buffer()

GF_Err gf_evg_surface_set_depth_buffer ( GF_EVGSurface surf,
Float depth 
)

sets depth buffer The 3D rasterizer does not allocate any surface (depth or color buffers), it is the user responsibility to set these buffers

Warning
do NOT forget to resize your depth buffer when resizing the canvas !
Note
this is only used for 3D rasterizer, and fails 2D mode
Parameters
surfthe target 3D surface
depththe depth buffer to use. Its size shall be Float*width*height
Returns
error if any

◆ gf_gf_evg_rgb_to_yuv_f()

GF_Err gf_gf_evg_rgb_to_yuv_f ( GF_EVGSurface surf,
Float  r,
Float  g,
Float  b,
Float y,
Float cb,
Float cr 
)

performs RGB to YUV conversion

Parameters
surfthe target surface
rthe source red component
gthe source green component
bthe source blue component
ythe output Y component
cbthe output U/Cb component
crthe output V/Cr component
Returns
error if any

◆ gf_evg_yuv_to_rgb_f()

GF_Err gf_evg_yuv_to_rgb_f ( GF_EVGSurface surf,
Float  y,
Float  cb,
Float  cr,
Float r,
Float g,
Float b 
)

performs YUV to RGB conversion

Parameters
surfthe target surface
ythe source Y component
cbthe source U/Cb component
crthe source V/Cr component
rthe output red component
gthe output green component
bthe output blue component
Returns
error if any

◆ gf_evg_rgb_to_yuv()

void gf_evg_rgb_to_yuv ( GF_EVGSurface surf,
GF_Color  col,
u8 y,
u8 cb,
u8 cr 
)

converts RGB to YUV

Parameters
surfthe target surface
colthe source RGBA color
ythe output Y value
cbthe output Cb/U value
crthe output Cr/V value

◆ gf_evg_argb_to_ayuv()

GF_Color gf_evg_argb_to_ayuv ( GF_EVGSurface surf,
GF_Color  col 
)

converts ARGB to AYUV

Parameters
surfthe target surface
colthe source ARGB color
Returns
the result AYUV color

◆ gf_evg_ayuv_to_argb()

GF_Color gf_evg_ayuv_to_argb ( GF_EVGSurface surf,
GF_Color  col 
)

converts AYUV to ARGB

Parameters
surfthe target surface
colthe source AYUV color
Returns
the result ARGB color

◆ gf_evg_argb_to_ayuv_wide()

u64 gf_evg_argb_to_ayuv_wide ( GF_EVGSurface surf,
u64  col 
)

converts ARGB to AYUV for wide colors

Parameters
surfthe target surface
colthe source ARGB color
Returns
the result AYUV color

◆ gf_evg_ayuv_to_argb_wide()

u64 gf_evg_ayuv_to_argb_wide ( GF_EVGSurface surf,
u64  col 
)

converts AYUV to ARGB for wide color

Parameters
surfthe target surface
colthe source AYUV color
Returns
the result ARGB color

◆ gf_evg_surface_set_mask_mode()

GF_Err gf_evg_surface_set_mask_mode ( GF_EVGSurface surf,
GF_EVGMaskMode  mask_mode 
)

sets global alpha mask mode

The global alpha mask is an 8-bit alpha channel the size of the surface. Any resize operation on the surface will reset the alpha mask Typcial usage for the alpha mask is to setup the surface, use GF_EVGMASK_DRAW to draw your mask then GF_EVGMASK_USE to apply the mask on your draw calls

Whenever the mask mode is changed to GF_EVGMASK_DRAW, the alpha masked is cleared

Parameters
surfthe target surface
mask_modethe current mask mode
Returns
error if any

◆ gf_evg_surface_get_mask_mode()

GF_EVGMaskMode gf_evg_surface_get_mask_mode ( GF_EVGSurface surf)

gets global alpha mask mode

Parameters
surfthe target surface
Returns
the current mask mode