[mtl canvas] fix end joint not generated for paths with only 2 elements

This commit is contained in:
Martin Fouilleul 2023-04-05 09:52:12 +02:00
parent 2484cdf7b3
commit 53946a5710
3 changed files with 3 additions and 28 deletions

View File

@ -130,7 +130,7 @@ int main()
mg_set_joint(MG_JOINT_MITER);
mg_set_max_joint_excursion(20);
mg_set_cap(MG_CAP_SQUARE);
mg_set_cap(MG_CAP_NONE);
mg_move_to(200, 200);
mg_line_to(300, 300);

View File

@ -514,7 +514,7 @@ u32 mg_mtl_render_stroke_subpath(mg_mtl_encoding_context* context,
previousEndTangent = endTangent;
currentPoint = endPoint;
}
u32 subPathEltCount = eltIndex - (startIndex+1);
u32 subPathEltCount = eltIndex - startIndex;
//NOTE(martin): draw end cap / joint. We ensure there's at least two segments to draw a closing joint
if( subPathEltCount > 1
@ -525,6 +525,7 @@ u32 mg_mtl_render_stroke_subpath(mg_mtl_encoding_context* context,
{
//NOTE(martin): add a closing joint if the path is closed
mg_mtl_stroke_joint(context, endPoint, endTangent, firstTangent);
printf("closing joint for shape %i\n", context->pathIndex);
}
}
else if(attributes->cap == MG_CAP_SQUARE)

View File

@ -316,24 +316,6 @@ void mtl_segment_bin_to_tiles(thread mtl_segment_setup_context* context, device
bool crossT = (stl*str < 0);
bool crossB = (sbl*sbr < 0);
mtl_log(context->log, "tile ");
mtl_log_i32(context->log, x);
mtl_log(context->log, ", ");
mtl_log_i32(context->log, y);
mtl_log(context->log, "\n");
mtl_log(context->log, "crossL ");
mtl_log_i32(context->log, crossL);
mtl_log(context->log, "\n");
mtl_log(context->log, "crossR ");
mtl_log_i32(context->log, crossR);
mtl_log(context->log, "\n");
mtl_log(context->log, "crossT ");
mtl_log_i32(context->log, crossT);
mtl_log(context->log, "\n");
mtl_log(context->log, "crossB ");
mtl_log_i32(context->log, crossB);
mtl_log(context->log, "\n");
float2 s0, s1;
if(seg->config == MG_MTL_TL||seg->config == MG_MTL_BR)
{
@ -355,14 +337,6 @@ void mtl_segment_bin_to_tiles(thread mtl_segment_setup_context* context, device
&& s1.y >= tileBox.y
&& s1.y < tileBox.w;
mtl_log(context->log, "s0Inside ");
mtl_log_i32(context->log, s0Inside ? 1 : 0);
mtl_log(context->log, "\n");
mtl_log(context->log, "s1Inside ");
mtl_log_i32(context->log, s1Inside ? 1 : 0);
mtl_log(context->log, "\n");
if(crossL || crossR || crossT || crossB || s0Inside || s1Inside)
{
int tileOpIndex = atomic_fetch_add_explicit(context->tileOpCount, 1, memory_order_relaxed);