Following the example of implementing blend2d with SDL2 in this sample , I came to a possible bug that can be produced through the example below.
#include <SDL2/SDL.h>
#include "blend2d.h"
int main(){
SDL_Window * window;
SDL_Renderer * renderer;
if(SDL_Init(SDL_INIT_VIDEO) != 0){
error("Unable to init sdl");
}
if(!(window = SDL_CreateWindow("win", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 600, 600, SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE))){
error("Unable to create sdl window");
}
if(!(renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC))){
error("Unable to create sdl renderer");
}
SDL_Event e;
SDL_Texture * texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, 500, 500);
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
BLImage img = BLImage(500, 500, BL_FORMAT_PRGB32);
BLContext ctx = BLContext(img);
ctx.setCompOp(BL_COMP_OP_CLEAR);
ctx.fillAll();
ctx.setCompOp(BL_COMP_OP_SRC_OVER);
ctx.setFillStyle(BLRgba32(0xFFFEFEFE));
ctx.fillRoundRect(50, 50, 400, 400, 50);
ctx.end();
img.writeToFile("img.png");
BLImageData data;
img.getData(&data);
SDL_UpdateTexture(texture, NULL, data.pixelData, int(data.stride));
SDL_Rect rect = {50,50,500,500};
while (true) {
while (SDL_PollEvent(&e) != 0) {
if(e.type == SDL_QUIT)
exit(0);
}
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, texture, nullptr, &rect);
SDL_RenderPresent(renderer);
}
}
Which results in:
The problem is that lines (that do not exist in the image generated by the context) appear in the curved regions of the Paths (in the SDL2 texture).
(Translated by Google)