From: Jean-Philippe Bruyère Date: Wed, 26 Jan 2022 22:51:29 +0000 (+0100) Subject: add multihreaded test direct draw on main surface X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=refs%2Fheads%2Fmultithreading;p=jp%2Fvkvg.git add multihreaded test direct draw on main surface --- diff --git a/tests/multithreading/multithreaded2.c b/tests/multithreading/multithreaded2.c new file mode 100644 index 0000000..ab55761 --- /dev/null +++ b/tests/multithreading/multithreaded2.c @@ -0,0 +1,72 @@ +#include "test.h" +#include "tinycthread.h" + +#define THREAD_COUNT 8 + + +static int finishedThreadCount = 0; +static mtx_t* pmutex; + +void drawRandomRect (VkvgContext ctx, float s) { + float w = (float)test_width; + float h = (float)test_height; + randomize_color(ctx); + + float x = truncf(w*rndf()); + float y = truncf(h*rndf()); + + vkvg_rectangle(ctx, x, y, s, s); +} +void _before_submit (void* data) { + mtx_lock((mtx_t*)data); +} +void _after_submit (void* data) { + mtx_unlock((mtx_t*)data); +} + +int drawRectsThread () { + VkvgContext ctx = vkvg_create(surf); + for (uint32_t i=0; i