When painting an image on a surface that have already some content without clipping the paint with a path or a clipping operation, the alpha channel of the whole target surface is affected, and set to 0 even where the source surface is no drawn, making previous content invisible (colors are still present, but alpha is 0)
The following code reproduce the problem:
VkvgContext ctx = vkvg_create(surf);
VkvgSurface imgSurf = vkvg_surface_create_from_image(device, imgPath);
VkvgSurface imgSurf2 = vkvg_surface_create_from_image(device, imgPath3);
vkvg_set_source_surface(ctx, imgSurf, 0, 0);
vkvg_paint(ctx);
vkvg_set_source_surface(ctx, imgSurf2, 50, 50);
vkvg_paint(ctx);
vkvg_surface_destroy(imgSurf2);
vkvg_surface_destroy(imgSurf);
vkvg_destroy(ctx);
A simple workaround for now is to clip the drawing either with a path or a clipping operation:
VkvgContext ctx = vkvg_create(surf);
VkvgSurface imgSurf = vkvg_surface_create_from_image(device, imgPath);
VkvgSurface imgSurf2 = vkvg_surface_create_from_image(device, imgPath3);
vkvg_set_source_surface(ctx, imgSurf, 0, 0);
vkvg_paint(ctx);
vkvg_set_source_surface(ctx, imgSurf2, 50, 50);
vkvg_rectangle(ctx, 50,50,200,200);//Image paint is clipped inside this path
vkvg_paint(ctx);
vkvg_surface_destroy(imgSurf2);
vkvg_surface_destroy(imgSurf);
vkvg_destroy(ctx);
On screen, the problem should not appear, because swapchain's images have no alpha channel, but when saving to png with vkvg_surface_write_to_png(surf, "test.png"); the problem appears.
I'm not completely sure this should be considered as a bug. Paint(ctx) calls do full surface painting, if VKVG_EXTEND_* are used, affecting the whole target is the expected behavior. Default image extend is VKVG_EXTEND_NONE, if preventing affecting the whole alpha channel imply small or easy changes, this could be corrected. If not, the current behavior should be explained in documentation.
When painting an image on a surface that have already some content without clipping the paint with a path or a clipping operation, the alpha channel of the whole target surface is affected, and set to 0 even where the source surface is no drawn, making previous content invisible (colors are still present, but alpha is 0)
The following code reproduce the problem:
A simple workaround for now is to clip the drawing either with a path or a clipping operation:
On screen, the problem should not appear, because swapchain's images have no alpha channel, but when saving to png with
vkvg_surface_write_to_png(surf, "test.png");the problem appears.I'm not completely sure this should be considered as a bug.
Paint(ctx)calls do full surface painting, ifVKVG_EXTEND_*are used, affecting the whole target is the expected behavior. Default image extend isVKVG_EXTEND_NONE, if preventing affecting the whole alpha channel imply small or easy changes, this could be corrected. If not, the current behavior should be explained in documentation.