void vkvg_device_set_dpy (VkvgDevice dev, int hdpy, int vdpy);
void vkvg_device_get_dpy (VkvgDevice dev, int* hdpy, int* vdpy);
-VkvgSurface vkvg_surface_create (VkvgDevice dev, uint32_t width, uint32_t height);
+VkvgSurface vkvg_surface_create (VkvgDevice dev, uint32_t width, uint32_t height);
VkvgSurface vkvg_surface_create_from_image (VkvgDevice dev, const char* filePath);
-VkvgSurface vkvg_surface_create_for_VkhImage (VkvgDevice dev, void* vkhImg);
+VkvgSurface vkvg_surface_create_from_svg (VkvgDevice dev, const char* filePath);
+VkvgSurface vkvg_surface_create_for_VkhImage(VkvgDevice dev, void* vkhImg);
// VkvgSurface vkvg_surface_create_from_bitmap (VkvgDevice dev, unsigned char* img, uint32_t width, uint32_t height);
VkvgSurface vkvg_surface_reference (VkvgSurface surf);
uint32_t vkvg_surface_get_reference_count(VkvgSurface surf);
ctx->lineWidth = 1;
ctx->pSurf = surf;
ctx->curOperator = VKVG_OPERATOR_OVER;
- ctx->curFillRule = VKVG_FILL_RULE_EVEN_ODD;
+ ctx->curFillRule = VKVG_FILL_RULE_NON_ZERO;
push_constants pc = {
{.height=1},
_init_cmd_buff (ctx);
_clear_path (ctx);
+ vkvg_reset_clip (ctx);
ctx->references = 1;
ctx->status = VKVG_STATUS_SUCCESS;
if (ctx->pointCount * 4 > ctx->sizeIndices - ctx->indCount)//flush if vk buff is full
vkvg_flush(ctx);
+ _check_cmd_buff_state(ctx);
if (ctx->curFillRule == VKVG_FILL_RULE_EVEN_ODD){
- _check_cmd_buff_state(ctx);
_poly_fill (ctx);
_bind_draw_pipeline (ctx);
CmdSetStencilCompareMask(ctx->cmd, VK_STENCIL_FRONT_AND_BACK, STENCIL_FILL_BIT);
CmdSetStencilCompareMask(ctx->cmd, VK_STENCIL_FRONT_AND_BACK, STENCIL_CLIP_BIT);
}else{
//CmdSetStencilCompareMask(ctx->cmd, VK_STENCIL_FRONT_AND_BACK, STENCIL_FILL_BIT);
+ CmdSetStencilCompareMask(ctx->cmd, VK_STENCIL_FRONT_AND_BACK, STENCIL_CLIP_BIT);
_fill_ec(ctx);
- //CmdSetStencilCompareMask(ctx->cmd, VK_STENCIL_FRONT_AND_BACK, STENCIL_CLIP_BIT);
}
}
void vkvg_stroke_preserve (VkvgContext ctx)
VK_CHECK_RESULT(vkEndCommandBuffer(ctx->cmd));
_submit_ctx_cmd(ctx);
- sav->sizePoints = ctx->sizePoints;
- sav->pointCount = ctx->pointCount;
-
- sav->points = (vec2*)malloc (sav->pointCount * sizeof(vec2));
- memcpy (sav->points, ctx->points, sav->pointCount * sizeof(vec2));
-
- sav->pathPtr = ctx->pathPtr;
- sav->sizePathes = ctx->sizePathes;
-
- sav->pathes = (uint32_t*)malloc (sav->pathPtr * sizeof(uint32_t));
- memcpy (sav->pathes, ctx->pathes, sav->pathPtr * sizeof(uint32_t));
-
sav->lineWidth = ctx->lineWidth;
sav->curOperator= ctx->curOperator;
sav->lineCap = ctx->lineCap;
VK_CHECK_RESULT(vkEndCommandBuffer(ctx->cmd));
_submit_ctx_cmd(ctx);
- ctx->sizePoints = sav->sizePoints;
- ctx->pointCount = sav->pointCount;
-
- ctx->points = (vec2*)realloc ( ctx->points, ctx->sizePoints * sizeof(vec2));
- memset (ctx->points, 0, ctx->sizePoints * sizeof(vec2));
- memcpy (ctx->points, sav->points, ctx->pointCount * sizeof(vec2));
-
- ctx->pathPtr = sav->pathPtr;
- ctx->sizePathes = sav->sizePathes;
-
- ctx->pathes = (uint32_t*)realloc (ctx->pathes, ctx->sizePathes * sizeof(uint32_t));
- memset (ctx->pathes, 0, ctx->sizePathes * sizeof(uint32_t));
- memcpy (ctx->pathes, sav->pathes, ctx->pathPtr * sizeof(uint32_t));
-
ctx->lineWidth = sav->lineWidth;
ctx->curOperator= sav->curOperator;
ctx->lineCap = sav->lineCap;
}
void _free_ctx_save (vkvg_context_save_t* sav){
- free(sav->pathes);
- free(sav->points);
free(sav->selectedFont.fontFile);
vkh_image_destroy (sav->stencilMS);
free (sav);
_add_vertex(ctx, v);
ear_clip_point* ecp_current = ecps;
+ uint32_t tries = 0;
while (ecps_count > 3) {
+ if (tries > ecps_count) {
+ break;
+ }
ear_clip_point* v0 = ecp_current->next,
*v1 = ecp_current, *v2 = ecp_current->next->next;
if (ecp_zcross (v0, v2, v1)<0){
ecp_current = ecp_current->next;
+ tries++;
continue;
}
ear_clip_point* vP = v2->next;
_add_triangle_indices (ctx, v0->idx, v1->idx, v2->idx);
v1->next = v2;
ecps_count --;
- }else
+ tries = 0;
+ }else{
ecp_current = ecp_current->next;
+ tries++;
+ }
}
if (ecps_count == 3)
_add_triangle_indices(ctx, ecp_current->next->idx, ecp_current->idx, ecp_current->next->next->idx);
VkhImage stencilMS;
uint32_t stencilRef;
- vec2* points; //points array
- size_t sizePoints; //reserved size
- uint32_t pointCount; //effective points count
-
- uint32_t pathPtr;
- uint32_t* pathes;
- size_t sizePathes;
float lineWidth;
vkvg_line_join_t lineJoint;
vkvg_fill_rule_t curFillRule;
- _vkvg_font_t selectedFont; //hold current face and size before cache addition
- _vkvg_font_t* currentFont; //font ready for lookup
- vkvg_direction_t textDirection;
- push_constants pushConsts;
- VkvgPattern pattern;
+ _vkvg_font_t selectedFont; //hold current face and size before cache addition
+ _vkvg_font_t* currentFont; //font ready for lookup
+ vkvg_direction_t textDirection;
+ push_constants pushConsts;
+ VkvgPattern pattern;
}vkvg_context_save_t;