summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-12-16 16:44:57 -0800
committerJean-Philippe Andre <jp.andre@samsung.com>2016-01-05 15:43:44 +0900
commite3a7f657d91631d0d3828e70d092b94429ead098 (patch)
tree92d8b1cc6db81be7f963149a134b072929292ce4
parent116fe3c65cd541b85623820605e237c4076024f2 (diff)
ector: add Ector.GL.Buffer.* support.
-rw-r--r--src/Makefile_Ector.am1
-rw-r--r--src/lib/ector/ector_buffer.h11
-rw-r--r--src/lib/ector/gl/Ector_GL.h2
-rw-r--r--src/lib/ector/gl/ector_gl_buffer.c43
-rw-r--r--src/lib/ector/gl/ector_gl_buffer_base.c59
-rw-r--r--src/lib/ector/gl/ector_gl_buffer_base.eo54
-rw-r--r--src/lib/ector/gl/ector_gl_private.h2
-rw-r--r--src/lib/ector/software/ector_software_buffer.c4
8 files changed, 119 insertions, 57 deletions
diff --git a/src/Makefile_Ector.am b/src/Makefile_Ector.am
index e404df3402..1d1b35ee55 100644
--- a/src/Makefile_Ector.am
+++ b/src/Makefile_Ector.am
@@ -134,6 +134,7 @@ lib/ector/gl/ector_renderer_gl_gradient_radial.c \
134lib/ector/gl/ector_renderer_gl_shape.c \ 134lib/ector/gl/ector_renderer_gl_shape.c \
135lib/ector/gl/ector_renderer_gl_base.c \ 135lib/ector/gl/ector_renderer_gl_base.c \
136lib/ector/gl/ector_gl_buffer.c \ 136lib/ector/gl/ector_gl_buffer.c \
137lib/ector/gl/ector_gl_buffer_base.c \
137lib/ector/gl/ector_gl_surface.c \ 138lib/ector/gl/ector_gl_surface.c \
138lib/ector/gl/ector_gl_private.h \ 139lib/ector/gl/ector_gl_private.h \
139lib/ector/gl/shader/ector_gl_shaders.x \ 140lib/ector/gl/shader/ector_gl_shaders.x \
diff --git a/src/lib/ector/ector_buffer.h b/src/lib/ector/ector_buffer.h
index 0e12c79f68..9399b17214 100644
--- a/src/lib/ector/ector_buffer.h
+++ b/src/lib/ector/ector_buffer.h
@@ -12,16 +12,19 @@
12 */ 12 */
13typedef Ector_Generic_Buffer Ector_Buffer; 13typedef Ector_Generic_Buffer Ector_Buffer;
14 14
15typedef struct _Ector_Generic_Buffer_Data 15typedef struct _Ector_Generic_Buffer_Data Ector_Generic_Buffer_Data;
16typedef struct _Ector_Software_Buffer_Base_Data Ector_Software_Buffer_Base_Data;
17
18struct _Ector_Generic_Buffer_Data
16{ 19{
17 Ector_Buffer *eo; 20 Ector_Buffer *eo;
18 unsigned int w, h; 21 unsigned int w, h;
19 unsigned char l, r, t, b; 22 unsigned char l, r, t, b;
20 Efl_Gfx_Colorspace cspace; 23 Efl_Gfx_Colorspace cspace;
21 Eina_Bool immutable : 1; // pixels_set is forbidden 24 Eina_Bool immutable : 1; // pixels_set is forbidden
22} Ector_Generic_Buffer_Data; 25};
23 26
24typedef struct _Ector_Software_Buffer_Base_Data 27struct _Ector_Software_Buffer_Base_Data
25{ 28{
26 Ector_Generic_Buffer_Data *generic; /* ugly */ 29 Ector_Generic_Buffer_Data *generic; /* ugly */
27 union { 30 union {
@@ -35,6 +38,6 @@ typedef struct _Ector_Software_Buffer_Base_Data
35 } internal; 38 } internal;
36 Eina_Bool writable : 1; // pixels can be written to 39 Eina_Bool writable : 1; // pixels can be written to
37 Eina_Bool nofree : 1; // pixel data should not be free()'ed 40 Eina_Bool nofree : 1; // pixel data should not be free()'ed
38} Ector_Software_Buffer_Base_Data; 41};
39 42
40#endif 43#endif
diff --git a/src/lib/ector/gl/Ector_GL.h b/src/lib/ector/gl/Ector_GL.h
index df49421813..dc6c37fba1 100644
--- a/src/lib/ector/gl/Ector_GL.h
+++ b/src/lib/ector/gl/Ector_GL.h
@@ -13,8 +13,8 @@ typedef Eo Ector_Cairo_Surface;
13typedef unsigned int GLuint; 13typedef unsigned int GLuint;
14typedef short GLshort; 14typedef short GLshort;
15 15
16#include "gl/ector_gl_buffer.eo.h"
17#include "gl/ector_gl_buffer_base.eo.h" 16#include "gl/ector_gl_buffer_base.eo.h"
17#include "gl/ector_gl_buffer.eo.h"
18#include "gl/ector_gl_surface.eo.h" 18#include "gl/ector_gl_surface.eo.h"
19#include "gl/ector_renderer_gl_base.eo.h" 19#include "gl/ector_renderer_gl_base.eo.h"
20#include "gl/ector_renderer_gl_shape.eo.h" 20#include "gl/ector_renderer_gl_shape.eo.h"
diff --git a/src/lib/ector/gl/ector_gl_buffer.c b/src/lib/ector/gl/ector_gl_buffer.c
index e3732b9c74..19840f77b0 100644
--- a/src/lib/ector/gl/ector_gl_buffer.c
+++ b/src/lib/ector/gl/ector_gl_buffer.c
@@ -1,50 +1,14 @@
1#ifdef HAVE_CONFIG_H 1#ifdef HAVE_CONFIG_H
2# include "config.h" 2# include "config.h"
3#else
4# define EFL_BETA_API_SUPPORT
5#endif 3#endif
6 4
7#include <Eo.h> 5#include <Ector.h>
8#include "Ector_GL.h" 6#include "Ector_GL.h"
9#include "ector_private.h" 7#include "ector_private.h"
10#include "ector_gl_private.h" 8#include "ector_gl_private.h"
11#include "ector_generic_buffer.eo.h" 9#include "ector_buffer.h"
12#include "ector_gl_buffer_base.eo.h"
13 10
14typedef struct _Ector_GL_Buffer_Base_Data Ector_GL_Buffer_Base_Data; 11#define MY_CLASS ECTOR_GL_BUFFER_CLASS
15struct _Ector_GL_Buffer_Base_Data
16{
17};
18
19static Ector_Buffer_Flag
20_ector_gl_buffer_base_ector_generic_buffer_flags_get(Eo *obj, Ector_GL_Buffer_Base_Data *pd)
21{
22}
23
24static Eina_Bool
25_ector_gl_buffer_base_ector_generic_buffer_pixels_set(Eo *obj, Ector_GL_Buffer_Base_Data *pd, void *pixels, int width, int height, int stride, Efl_Gfx_Colorspace cspace, Eina_Bool writable, unsigned char l, unsigned char r, unsigned char t, unsigned char b)
26{
27}
28
29static uint8_t *
30_ector_gl_buffer_base_ector_generic_buffer_span_get(Eo *obj, Ector_GL_Buffer_Base_Data *pd, int x, int y, unsigned int w, Efl_Gfx_Colorspace cspace, unsigned int *length)
31{
32}
33
34static void
35_ector_gl_buffer_base_ector_generic_buffer_span_free(Eo *obj, Ector_GL_Buffer_Base_Data *pd, uint8_t *data)
36{
37}
38
39static uint8_t *
40_ector_gl_buffer_base_ector_generic_buffer_map(Eo *obj, Ector_GL_Buffer_Base_Data *pd, int *offset, unsigned int *length, Ector_Buffer_Access_Flag mode, unsigned int x, unsigned int y, unsigned int w, unsigned int h, Efl_Gfx_Colorspace cspace, unsigned int *stride)
41{
42}
43
44static void
45_ector_gl_buffer_base_ector_generic_buffer_unmap(Eo *obj, Ector_GL_Buffer_Base_Data *pd, void *data, int offset, unsigned int length)
46{
47}
48 12
49static Eo_Base * 13static Eo_Base *
50_ector_gl_buffer_eo_base_constructor(Eo *obj, void *pd) 14_ector_gl_buffer_eo_base_constructor(Eo *obj, void *pd)
@@ -57,4 +21,3 @@ _ector_gl_buffer_eo_base_destructor(Eo *obj, void *pd)
57} 21}
58 22
59#include "ector_gl_buffer.eo.c" 23#include "ector_gl_buffer.eo.c"
60#include "ector_gl_buffer_base.eo.c"
diff --git a/src/lib/ector/gl/ector_gl_buffer_base.c b/src/lib/ector/gl/ector_gl_buffer_base.c
new file mode 100644
index 0000000000..81cd302d44
--- /dev/null
+++ b/src/lib/ector/gl/ector_gl_buffer_base.c
@@ -0,0 +1,59 @@
1#define EFL_BETA_API_SUPPORT
2#include <Eo.h>
3
4#include "Ector_GL.h"
5#include "ector_gl_private.h"
6#include "ector_buffer.h"
7#include "ector_gl_buffer_base.eo.h"
8
9#define MY_CLASS ECTOR_GL_BUFFER_BASE_MIXIN
10
11typedef struct
12{
13 Ector_Generic_Buffer_Data *generic;
14 int texid;
15 int fboid;
16 int w, h; // Texture size, not the atlas
17 struct {
18 // x,y offset within the atlas
19 // w,h size of the atlas itself
20 int x, y, w, h;
21 } atlas;
22 Eina_Bool whole : 1;
23} Ector_GL_Buffer_Base_Data;
24
25EOLIAN static int
26_ector_gl_buffer_base_texture_get(Eo *obj EINA_UNUSED, Ector_GL_Buffer_Base_Data *pd)
27{
28 return pd->texid;
29}
30
31EOLIAN static int
32_ector_gl_buffer_base_fbo_get(Eo *obj EINA_UNUSED, Ector_GL_Buffer_Base_Data *pd)
33{
34 return pd->fboid;
35}
36
37EOLIAN static Eina_Bool
38_ector_gl_buffer_base_whole_get(Eo *obj EINA_UNUSED, Ector_GL_Buffer_Base_Data *pd)
39{
40 return pd->whole;
41}
42
43EOLIAN static void
44_ector_gl_buffer_base_size_get(Eo *obj EINA_UNUSED, Ector_GL_Buffer_Base_Data *pd, int *w, int *h)
45{
46 if (w) *w = pd->w;
47 if (h) *h = pd->h;
48}
49
50EOLIAN static void
51_ector_gl_buffer_base_vertices_get(Eo *obj EINA_UNUSED, Ector_GL_Buffer_Base_Data *pd, double *x, double *y, double *w, double *h)
52{
53 if (x) *x = (double) pd->atlas.x / pd->atlas.w;
54 if (y) *y = (double) pd->atlas.y / pd->atlas.h;
55 if (w) *w = (double) pd->w / pd->atlas.w;
56 if (h) *h = (double) pd->h / pd->atlas.h;
57}
58
59#include "ector_gl_buffer_base.eo.c"
diff --git a/src/lib/ector/gl/ector_gl_buffer_base.eo b/src/lib/ector/gl/ector_gl_buffer_base.eo
index 441f7814fe..36562aeb8d 100644
--- a/src/lib/ector/gl/ector_gl_buffer_base.eo
+++ b/src/lib/ector/gl/ector_gl_buffer_base.eo
@@ -1,14 +1,50 @@
1mixin Ector.GL.Buffer.Base (Ector.Generic.Buffer) 1mixin Ector.GL.Buffer.Base (Ector.Generic.Buffer)
2{ 2{
3 [[A buffer in Ector GL is a readable & optionally writable image]]
4 eo_prefix: ector_gl_buffer;
5 legacy_prefix: null; 3 legacy_prefix: null;
4 methods {
5 @property texture {
6 get {}
7 values {
8 texid: int; [[GL texture ID]]
9 }
10 }
11 @property fbo {
12 get {}
13 values {
14 fboid: int; [[GL framebuffer ID, 0 if there is no FBO]]
15 }
16 }
17 @property whole {
18 [[If $true, the image is covering the entire GL texture, ie. it's not
19 part of an atlas.
20 ]]
21 get {}
22 values {
23 is_whole: bool;
24 }
25 }
26 @property size {
27 [[The size in pixels of this image.
28
29 If the image is whole, then this is equal to the atlas size.
30 ]]
31 get {}
32 values {
33 w: int;
34 h: int;
35 }
36 }
37 @property vertices {
38 [[Returns the texture vertices to use to map this image with no rotation]]
39 get {}
40 values {
41 x: double; [[X position of this image inside the texture atlas, from 0 to 1]]
42 y: double; [[Y position of this image inside the texture atlas, from 0 to 1]]
43 w: double; [[Width of this image inside the texture atlas, from 0 to 1]]
44 h: double; [[Height of this image inside the texture atlas, from 0 to 1]]
45 }
46 }
47 }
6 implements { 48 implements {
7 Ector.Generic.Buffer.flags.get; 49 }
8 Ector.Generic.Buffer.pixels_set;
9 Ector.Generic.Buffer.span_get;
10 Ector.Generic.Buffer.span_free;
11 Ector.Generic.Buffer.map;
12 Ector.Generic.Buffer.unmap;
13 }
14} 50}
diff --git a/src/lib/ector/gl/ector_gl_private.h b/src/lib/ector/gl/ector_gl_private.h
index 0362e7e723..e67b4d1e4f 100644
--- a/src/lib/ector/gl/ector_gl_private.h
+++ b/src/lib/ector/gl/ector_gl_private.h
@@ -1,6 +1,8 @@
1#ifndef ECTOR_GL_PRIVATE_H_ 1#ifndef ECTOR_GL_PRIVATE_H_
2# define ECTOR_GL_PRIVATE_H_ 2# define ECTOR_GL_PRIVATE_H_
3 3
4#include "ector_private.h"
5
4#define SHADER_FLAG_SAM_BITSHIFT 3 6#define SHADER_FLAG_SAM_BITSHIFT 3
5#define SHADER_FLAG_MASKSAM_BITSHIFT 6 7#define SHADER_FLAG_MASKSAM_BITSHIFT 6
6 8
diff --git a/src/lib/ector/software/ector_software_buffer.c b/src/lib/ector/software/ector_software_buffer.c
index 376228f5c8..b846761de1 100644
--- a/src/lib/ector/software/ector_software_buffer.c
+++ b/src/lib/ector/software/ector_software_buffer.c
@@ -166,9 +166,7 @@ _ector_software_buffer_base_ector_generic_buffer_map(Eo *obj EINA_UNUSED, Ector_
166 166
167 if (!pd->pixels.u8 || !pd->stride) 167 if (!pd->pixels.u8 || !pd->stride)
168 fail("Buffer has no pixel data yet"); 168 fail("Buffer has no pixel data yet");
169 if (cspace != pd->generic->cspace) 169 if (((x + w) > pd->generic->w) || (y + h > pd->generic->h))
170 fail("Invalid colorspace");
171 if (!w || !h || ((x + w) > pd->generic->w) || (y + h > pd->generic->h))
172 fail("Invalid region requested: wanted %u,%u %ux%u but image is %ux%u", 170 fail("Invalid region requested: wanted %u,%u %ux%u but image is %ux%u",
173 x, y, w, h, pd->generic->w, pd->generic->h); 171 x, y, w, h, pd->generic->w, pd->generic->h);
174 if ((mode & ECTOR_BUFFER_ACCESS_FLAG_WRITE) && !pd->writable) 172 if ((mode & ECTOR_BUFFER_ACCESS_FLAG_WRITE) && !pd->writable)