From 0a4130f55361ba89630d621a055c9bcc7bb10b1e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Wed, 26 Jan 2022 23:51:29 +0100 Subject: [PATCH] add multihreaded test direct draw on main surface --- tests/multithreading/multithreaded2.c | 72 +++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 tests/multithreading/multithreaded2.c 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