blob: 7898ff84698c10402cf83b5bf4307da1727250a5 (
plain) (
blame)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
/* See LICENSE file for copyright and license details. */
#include "common.h"
#ifndef TEST
LIBGLITTER_RENDER_CONTEXT *
libglitter_create_render_context(size_t noutputs, size_t rowsize, size_t widthmul, size_t heightmul,
const uint8_t *cellmap, const uint8_t *ncellvalues)
{
struct libglitter_render_context *this;
size_t i;
this = calloc(1, sizeof(*this));
if (!this)
return NULL;
this->cellmap = cellmap;
this->ncellvalues = ncellvalues;
this->noutputs = noutputs;
this->widthmul = widthmul;
this->heightmul = heightmul;
this->cellweights_double = calloc(noutputs, sizeof(*this->cellweights_double));
if (!this->cellweights_double)
goto fail;
this->cellweights_float = calloc(noutputs, sizeof(*this->cellweights_float));
if (!this->cellweights_float)
goto fail;
this->render_method =
(noutputs == 3 && widthmul == 3 && heightmul == 1) ? RENDER_METHOD_VSTRIPS :
(noutputs == 3 && widthmul == 1 && heightmul == 3) ? RENDER_METHOD_HSTRIPS :
(noutputs == 3 && ncellvalues[0] <= 2 && ncellvalues[1] <= 2 && ncellvalues[2] <= 2) ? RENDER_METHOD_SIMPLE :
RENDER_METHOD_GENERIC;
for (i = 0; i < noutputs; i++) {
this->cellweights_double[i] = 1 / (double)ncellvalues[i];
this->cellweights_float[i] = 1 / (float)ncellvalues[i];
}
libglitter_update_render_context(this, rowsize);
return this;
fail:
libglitter_free_render_context(this);
return NULL;
}
#else
int
main(void)
{
return 0; /* TODO add test */
}
#endif
|