summaryrefslogtreecommitdiff
path: root/src/lib/ector/software/ector_software_gradient.h
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2018-11-15 12:25:15 +0000
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2018-11-16 00:08:47 +0000
commitb9225fd710baeddd2ab6256e3b7b20e2e47e3633 (patch)
tree22d3a36c950cca4e50064b46c4d9b788fff4a2f2 /src/lib/ector/software/ector_software_gradient.h
parent788507961a55670c959ed5aa57e84c818bc0f4a1 (diff)
ector - fix meson build with sse3 on ix86 (32bit)
Diffstat (limited to 'src/lib/ector/software/ector_software_gradient.h')
-rw-r--r--src/lib/ector/software/ector_software_gradient.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/lib/ector/software/ector_software_gradient.h b/src/lib/ector/software/ector_software_gradient.h
new file mode 100644
index 0000000000..2cbf2f99d7
--- /dev/null
+++ b/src/lib/ector/software/ector_software_gradient.h
@@ -0,0 +1,63 @@
1#ifndef ECTOR_SOFTWARE_GRADIENT_H
2# define ECTOR_SOFTWARE_GRADIENT_H
3
4#ifdef HAVE_CONFIG_H
5#include "config.h"
6#endif
7
8#include <assert.h>
9#include <math.h>
10
11#include <software/Ector_Software.h>
12
13#include "ector_private.h"
14#include "ector_software_private.h"
15#include "draw.h"
16
17#define GRADIENT_STOPTABLE_SIZE 1024
18#define FIXPT_BITS 8
19#define FIXPT_SIZE (1<<FIXPT_BITS)
20
21static inline int
22_gradient_clamp(const Ector_Renderer_Software_Gradient_Data *data, int ipos)
23{
24 int limit;
25
26 if (data->gd->s == EFL_GFX_GRADIENT_SPREAD_REPEAT)
27 {
28 ipos = ipos % GRADIENT_STOPTABLE_SIZE;
29 ipos = ipos < 0 ? GRADIENT_STOPTABLE_SIZE + ipos : ipos;
30 }
31 else if (data->gd->s == EFL_GFX_GRADIENT_SPREAD_REFLECT)
32 {
33 limit = GRADIENT_STOPTABLE_SIZE * 2;
34 ipos = ipos % limit;
35 ipos = ipos < 0 ? limit + ipos : ipos;
36 ipos = ipos >= GRADIENT_STOPTABLE_SIZE ? limit - 1 - ipos : ipos;
37 }
38 else
39 {
40 if (ipos < 0) ipos = 0;
41 else if (ipos >= GRADIENT_STOPTABLE_SIZE)
42 ipos = GRADIENT_STOPTABLE_SIZE-1;
43 }
44 return ipos;
45}
46
47static inline uint32_t
48_gradient_pixel_fixed(const Ector_Renderer_Software_Gradient_Data *data, int fixed_pos)
49{
50 int ipos = (fixed_pos + (FIXPT_SIZE / 2)) >> FIXPT_BITS;
51
52 return data->color_table[_gradient_clamp(data, ipos)];
53}
54
55static inline uint32_t
56_gradient_pixel(const Ector_Renderer_Software_Gradient_Data *data, float pos)
57{
58 int ipos = (int)(pos * (GRADIENT_STOPTABLE_SIZE - 1) + (float)(0.5));
59
60 return data->color_table[_gradient_clamp(data, ipos)];
61}
62
63#endif