diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2017-04-22 15:29:49 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2017-04-22 15:29:49 -0700 |
commit | d28ceb85a6b43a503c608116798945baab0e060f (patch) | |
tree | 1a96ae21cbab1ef8fdf831d588fd2c9477fb3f92 /src/modules | |
parent | 1ff4632e895202c4485818f6e748e773b6fd2859 (diff) |
*: add module context machinery
introduces create_context() and destroy_context() methods, and adds a
'void *context' first parameter to the module methods.
If a module doesn't supply create_context() then NULL is simply passed
around as the context, so trivial modules can continue to only implement
render_fragment().
A subsequent commit will update the modules to encapsulate their global
state in module-specific contexts.
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/julia/julia.c | 4 | ||||
-rw-r--r-- | src/modules/plasma/plasma.c | 4 | ||||
-rw-r--r-- | src/modules/ray/ray.c | 4 | ||||
-rw-r--r-- | src/modules/roto/roto.c | 6 | ||||
-rw-r--r-- | src/modules/sparkler/sparkler.c | 2 | ||||
-rw-r--r-- | src/modules/stars/stars.c | 2 |
6 files changed, 11 insertions, 11 deletions
diff --git a/src/modules/julia/julia.c b/src/modules/julia/julia.c index 69d1022..3811d0d 100644 --- a/src/modules/julia/julia.c +++ b/src/modules/julia/julia.c @@ -42,7 +42,7 @@ static inline unsigned julia_iter(float real, float imag, float creal, float cim /* Prepare a frame for concurrent drawing of fragment using multiple fragments */ -static void julia_prepare_frame(unsigned n_cpus, fb_fragment_t *fragment, rototiller_frame_t *res_frame) +static void julia_prepare_frame(void *context, unsigned n_cpus, fb_fragment_t *fragment, rototiller_frame_t *res_frame) { res_frame->n_fragments = n_cpus; fb_fragment_divide(fragment, n_cpus, res_frame->fragments); @@ -59,7 +59,7 @@ static void julia_prepare_frame(unsigned n_cpus, fb_fragment_t *fragment, rototi /* Draw a morphing Julia set */ -static void julia_render_fragment(fb_fragment_t *fragment) +static void julia_render_fragment(void *context, fb_fragment_t *fragment) { static uint32_t colors[] = { /* this palette is just something I slapped together, definitely needs improvement. TODO */ diff --git a/src/modules/plasma/plasma.c b/src/modules/plasma/plasma.c index 8c3e921..9acd73f 100644 --- a/src/modules/plasma/plasma.c +++ b/src/modules/plasma/plasma.c @@ -43,7 +43,7 @@ static void init_plasma(int32_t *costab, int32_t *sintab) /* Prepare a frame for concurrent drawing of fragment using multiple fragments */ -static void plasma_prepare_frame(unsigned n_cpus, fb_fragment_t *fragment, rototiller_frame_t *res_frame) +static void plasma_prepare_frame(void *context, unsigned n_cpus, fb_fragment_t *fragment, rototiller_frame_t *res_frame) { static int initialized; @@ -61,7 +61,7 @@ static void plasma_prepare_frame(unsigned n_cpus, fb_fragment_t *fragment, rotot /* Draw a plasma effect */ -static void plasma_render_fragment(fb_fragment_t *fragment) +static void plasma_render_fragment(void *context, fb_fragment_t *fragment) { unsigned stride = fragment->stride / 4, width = fragment->width, height = fragment->height; diff --git a/src/modules/ray/ray.c b/src/modules/ray/ray.c index e79bfaf..a934c30 100644 --- a/src/modules/ray/ray.c +++ b/src/modules/ray/ray.c @@ -112,7 +112,7 @@ static float r; /* prepare a frame for concurrent rendering */ -static void ray_prepare_frame(unsigned n_cpus, fb_fragment_t *fragment, rototiller_frame_t *res_frame) +static void ray_prepare_frame(void *context, unsigned n_cpus, fb_fragment_t *fragment, rototiller_frame_t *res_frame) { /* TODO experiment with tiled fragments vs. rows */ res_frame->n_fragments = n_cpus; @@ -146,7 +146,7 @@ static void ray_prepare_frame(unsigned n_cpus, fb_fragment_t *fragment, rototill /* ray trace a simple scene into the fragment */ -static void ray_render_fragment(fb_fragment_t *fragment) +static void ray_render_fragment(void *context, fb_fragment_t *fragment) { ray_scene_render_fragment(&scene, &camera, fragment); } diff --git a/src/modules/roto/roto.c b/src/modules/roto/roto.c index b889a55..9c7ac18 100644 --- a/src/modules/roto/roto.c +++ b/src/modules/roto/roto.c @@ -154,7 +154,7 @@ static void init_roto(uint8_t texture[256][256], int32_t *costab, int32_t *sinta /* prepare a frame for concurrent rendering */ -static void roto_prepare_frame(unsigned n_cpus, fb_fragment_t *fragment, rototiller_frame_t *res_frame) +static void roto_prepare_frame(void *context, unsigned n_cpus, fb_fragment_t *fragment, rototiller_frame_t *res_frame) { static int initialized; @@ -174,7 +174,7 @@ static void roto_prepare_frame(unsigned n_cpus, fb_fragment_t *fragment, rototil /* Draw a rotating checkered 256x256 texture into fragment. (32-bit version) */ -static void roto32_render_fragment(fb_fragment_t *fragment) +static void roto32_render_fragment(void *context, fb_fragment_t *fragment) { int y_cos_r, y_sin_r, x_cos_r, x_sin_r, x_cos_r_init, x_sin_r_init, cos_r, sin_r; int x, y, stride = fragment->stride / 4, frame_width = fragment->frame_width, frame_height = fragment->frame_height; @@ -223,7 +223,7 @@ static void roto32_render_fragment(fb_fragment_t *fragment) /* Draw a rotating checkered 256x256 texture into fragment. (64-bit version) */ -static void roto64_render_fragment(fb_fragment_t *fragment) +static void roto64_render_fragment(void *context, fb_fragment_t *fragment) { int y_cos_r, y_sin_r, x_cos_r, x_sin_r, x_cos_r_init, x_sin_r_init, cos_r, sin_r; int x, y, stride = fragment->stride / 8, frame_width = fragment->frame_width, frame_height = fragment->frame_height, width = fragment->width; diff --git a/src/modules/sparkler/sparkler.c b/src/modules/sparkler/sparkler.c index 67d68cf..deb3c53 100644 --- a/src/modules/sparkler/sparkler.c +++ b/src/modules/sparkler/sparkler.c @@ -20,7 +20,7 @@ extern particle_ops_t simple_ops; /* Render a 3D particle system */ -static void sparkler_render_fragment(fb_fragment_t *fragment) +static void sparkler_render_fragment(void *context, fb_fragment_t *fragment) { static particles_t *particles; static int initialized; diff --git a/src/modules/stars/stars.c b/src/modules/stars/stars.c index f624a62..3712e33 100644 --- a/src/modules/stars/stars.c +++ b/src/modules/stars/stars.c @@ -13,7 +13,7 @@ /* Copyright (C) 2017 Philip J. Freeman <elektron@halo.nu> */ -static void stars_render_fragment(fb_fragment_t *fragment) +static void stars_render_fragment(void *context, fb_fragment_t *fragment) { static int initialized, z; static struct universe* u; |