1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
/* Fixture for test_shader_plugin.py: a shader plugin with nothing to it.
*
* Built twice — once as itself, once with -DBAD_ABI to produce a library that
* announces a version we do not speak, which is the case that has to fail
* safely rather than crash.
*/
#include "shader_abi.h"
#ifdef BAD_ABI
#undef SLOSH_SHADER_ABI
#define SLOSH_SHADER_ABI 9999
#endif
/* Paints every cell's background the configured colour, at full strength when
* amount is 255. Deterministic and position-independent, so the test can
* assert one cell and mean it. */
static void sh_fill(const shader_t *sh, const shade_ctx_t *ctx, cell_t *c) {
(void)ctx;
if (!sh->amount) return;
c->bg = sh->color;
}
/* Uses param, so the test can prove a plugin sees the config's number. */
static void sh_stripe(const shader_t *sh, const shade_ctx_t *ctx, cell_t *c) {
uint16_t n = sh->param ? sh->param : 2;
if (ctx->x % n) return;
c->bg = sh->color;
}
static const shader_def_t SHADERS[] = {
{"testfill", sh_fill},
{"teststripe", sh_stripe},
};
SLOSH_SHADER_PLUGIN("test-fixture", SHADERS)
|