static const VkClearAttachment clearColorAttach = {VK_IMAGE_ASPECT_COLOR_BIT, 0, {{{0}}}};
void vkvg_reset_clip (VkvgContext ctx){
- _flush_undrawn_vertices(ctx);
+ _emit_draw_cmd_undrawn_vertices(ctx);
if (!ctx->cmdStarted) {
//if command buffer is not already started and in a renderpass, we use the renderpass
//with the loadop clear for stencil
vkCmdClearAttachments(ctx->cmd, 1, &clearStencil, 1, &ctx->clearRect);
}
void vkvg_clear (VkvgContext ctx){
- _flush_undrawn_vertices(ctx);
+ _emit_draw_cmd_undrawn_vertices(ctx);
if (!ctx->cmdStarted) {
ctx->renderPassBeginInfo.renderPass = ctx->pSurf->dev->renderPass_ClearAll;
_start_cmd_for_render_pass(ctx);
if (ctx->pathPtr == 0 && _current_path_is_empty(ctx))//nothing to clip
return;
- _flush_undrawn_vertices(ctx);
+ _emit_draw_cmd_undrawn_vertices(ctx);
_finish_path(ctx);
CmdSetStencilCompareMask(ctx->cmd, VK_STENCIL_FRONT_AND_BACK, STENCIL_CLIP_BIT);
CmdSetStencilWriteMask (ctx->cmd, VK_STENCIL_FRONT_AND_BACK, STENCIL_FILL_BIT);
_fill_ec(ctx);
- _flush_undrawn_vertices(ctx);
+ _emit_draw_cmd_undrawn_vertices(ctx);
}
CmdSetStencilReference (ctx->cmd, VK_STENCIL_FRONT_AND_BACK, STENCIL_CLIP_BIT);
CmdSetStencilCompareMask(ctx->cmd, VK_STENCIL_FRONT_AND_BACK, STENCIL_FILL_BIT);
LOG(VKVG_LOG_INFO, "FILL: ctx = %p; path cpt = %d;\n", ctx, ctx->pathPtr / 2);
if (ctx->curFillRule == VKVG_FILL_RULE_EVEN_ODD){
- _flush_undrawn_vertices(ctx);
+ _emit_draw_cmd_undrawn_vertices(ctx);
_poly_fill (ctx);
_bind_draw_pipeline (ctx);
}
if (ctx->vertCount - ctx->curVertOffset + ctx->pointCount > VKVG_IBO_MAX)
- _flush_undrawn_vertices(ctx);//limit draw call to addressable vx with choosen index type
+ _emit_draw_cmd_undrawn_vertices(ctx);//limit draw call to addressable vx with choosen index type
if (ctx->pattern)//if not solid color, source img of gradient has to be bound
_ensure_renderpass_is_started(ctx);
void _draw_stoke_cap (VkvgContext ctx, float hw, vec2 p0, vec2 n, bool isStart) {
Vertex v = {{0},ctx->curColor,{0,0,-1}};
- VKVG_IBO_INDEX_TYPE firstIdx = (VKVG_IBO_INDEX_TYPE)(ctx->vertCount - ctx->curVertOffset);
+ VKVG_IBO_INDEX_TYPE firstIdx = (VKVG_IBO_INDEX_TYPE)(ctx->vertCount - ctx->curVertOffset);
if (isStart){
vec2 vhw = vec2_mult(n,hw);
iL = curPathPointIdx++;
}
-bool _process_stroke (VkvgContext ctx) {
+void vkvg_stroke_preserve (VkvgContext ctx)
+{
+ if (ctx->pathPtr == 0 && _current_path_is_empty(ctx))//nothing to stroke
+ return;
+ _finish_path(ctx);
+
+ LOG(VKVG_LOG_INFO, "STROKE: ctx = %p; path ptr = %d;\n", ctx, ctx->pathPtr);
+
curPathPointIdx = lastPathPointIdx = ptrPath = iL = iR = 0;
float hw = ctx->lineWidth / 2.0f;
totDashLength+=ctx->dashes[i];
if (totDashLength == 0){
ctx->status = VKVG_STATUS_INVALID_DASH;
- return true;
+ return;
}
/*if (ctx->dashOffset == 0)
curDashOffset = 0;
}else
_draw_stoke_cap (ctx, hw, ctx->points[curPathPointIdx], vec2_line_norm(ctx->points[curPathPointIdx-1], ctx->points[curPathPointIdx]), false);
- if (ctx->vertCount - ctx->curVertOffset > VKVG_IBO_MAX)
- return false;
+ /*if (ctx->vertCount - ctx->curVertOffset > VKVG_IBO_MAX) {
+ _check_vao_size (ctx);
+ _ensure_renderpass_is_started(ctx);
+
+ //split triangle emission into batch adressable by VKVG_IBO_MAX (index type)
+ VKVG_IBO_INDEX_TYPE indexMax = VKVG_IBO_MAX - VKVG_IBO_MAX % 3;
+ uint32_t vxTot = ctx->vertCount;
+ uint32_t idxTot = ctx->indCount;
+ ctx->indCount = ctx->curIndStart;
+
+
+ while (ctx->curVertOffset < vxTot) {
+ while (ctx->indexCache[ctx->indCount] < indexMax)
+ ctx->indCount++;
+ ctx->indCount -= ctx->indCount % 3;
+ uint32_t minInd =
+ uint32_t newVertOffset = ctx->indexCache[ctx->indCount-1];
+
+ _emit_draw (ctx);
+ }
+
+ } */
curPathPointIdx = firstPathPointIdx + pathPointCount;
ptrPath++;
}
-
-
-
- return true;
-}
-
-void vkvg_stroke_preserve (VkvgContext ctx)
-{
- if (ctx->pathPtr == 0 && _current_path_is_empty(ctx))//nothing to stroke
- return;
- _finish_path(ctx);
-
- LOG(VKVG_LOG_INFO, "STROKE: ctx = %p; path ptr = %d;\n", ctx, ctx->pathPtr);
-
- uint32_t tmpVxCount = ctx->vertCount;
- uint32_t tmpIxCount = ctx->indCount;
-
- if (!_process_stroke(ctx)) {
- ctx->vertCount = tmpVxCount;
- ctx->indCount = tmpIxCount;
- _flush_undrawn_vertices(ctx);//limit draw call to addressable vx with choosen index type
- _process_stroke(ctx);
- }
}
void vkvg_paint (VkvgContext ctx){
if (ctx->pathPtr || ctx->segmentPtr){//path to fill
}
void vkvg_translate (VkvgContext ctx, float dx, float dy){
- _flush_undrawn_vertices(ctx);
+ _emit_draw_cmd_undrawn_vertices(ctx);
vkvg_matrix_translate (&ctx->pushConsts.mat, dx, dy);
_set_mat_inv_and_vkCmdPush (ctx);
}
void vkvg_scale (VkvgContext ctx, float sx, float sy){
- _flush_undrawn_vertices(ctx);
+ _emit_draw_cmd_undrawn_vertices(ctx);
vkvg_matrix_scale (&ctx->pushConsts.mat, sx, sy);
_set_mat_inv_and_vkCmdPush (ctx);
}
void vkvg_rotate (VkvgContext ctx, float radians){
- _flush_undrawn_vertices(ctx);
+ _emit_draw_cmd_undrawn_vertices(ctx);
vkvg_matrix_rotate (&ctx->pushConsts.mat, radians);
_set_mat_inv_and_vkCmdPush (ctx);
}
void vkvg_transform (VkvgContext ctx, const vkvg_matrix_t* matrix) {
- _flush_undrawn_vertices(ctx);
+ _emit_draw_cmd_undrawn_vertices(ctx);
vkvg_matrix_t res;
vkvg_matrix_multiply (&res, &ctx->pushConsts.mat, matrix);
ctx->pushConsts.mat = res;
_set_mat_inv_and_vkCmdPush (ctx);
}
void vkvg_identity_matrix (VkvgContext ctx) {
- _flush_undrawn_vertices(ctx);
+ _emit_draw_cmd_undrawn_vertices(ctx);
vkvg_matrix_t im = VKVG_IDENTITY_MATRIX;
ctx->pushConsts.mat = im;
_set_mat_inv_and_vkCmdPush (ctx);
}
void vkvg_set_matrix (VkvgContext ctx, const vkvg_matrix_t* matrix){
- _flush_undrawn_vertices(ctx);
+ _emit_draw_cmd_undrawn_vertices(ctx);
ctx->pushConsts.mat = (*matrix);
_set_mat_inv_and_vkCmdPush (ctx);
}
vkvg_rel_line_to (cr, 51.2f, 51.2f);
vkvg_set_line_join (cr, VKVG_LINE_JOIN_ROUND);
vkvg_stroke (cr);
+
+ /* draw helping lines */
+ vkvg_set_source_rgb (cr, 1, 0.2f, 0.2f);
+ vkvg_set_line_width (cr, 2.56f);
+ vkvg_set_line_join (cr, VKVG_LINE_JOIN_MITER);
+ vkvg_move_to (cr, 76.8f, 84.48f);
+ vkvg_rel_line_to (cr, 51.2f, -51.2f);
+ vkvg_rel_line_to (cr, 51.2f, 51.2f);
+ vkvg_move_to (cr, 76.8f, 161.28f);
+ vkvg_rel_line_to (cr, 51.2f, -51.2f);
+ vkvg_rel_line_to (cr, 51.2f, 51.2f);
+ vkvg_move_to (cr, 76.8f, 238.08f);
+ vkvg_rel_line_to (cr, 51.2f, -51.2f);
+ vkvg_rel_line_to (cr, 51.2f, 51.2f);
+
+ vkvg_stroke (cr);
+
}
void cairo_print_arc (VkvgContext cr) {
float xc = 128.0f;