jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=e3a7f657d91631d0d3828e70d092b94429ead098

commit e3a7f657d91631d0d3828e70d092b94429ead098
Author: Jean-Philippe Andre <jp.an...@samsung.com>
Date:   Wed Dec 16 16:44:57 2015 -0800

    ector: add Ector.GL.Buffer.* support.
---
 src/Makefile_Ector.am                          |  1 +
 src/lib/ector/ector_buffer.h                   | 11 +++--
 src/lib/ector/gl/Ector_GL.h                    |  2 +-
 src/lib/ector/gl/ector_gl_buffer.c             | 43 ++-----------------
 src/lib/ector/gl/ector_gl_buffer_base.c        | 59 ++++++++++++++++++++++++++
 src/lib/ector/gl/ector_gl_buffer_base.eo       | 54 +++++++++++++++++++----
 src/lib/ector/gl/ector_gl_private.h            |  2 +
 src/lib/ector/software/ector_software_buffer.c |  4 +-
 8 files changed, 119 insertions(+), 57 deletions(-)

diff --git a/src/Makefile_Ector.am b/src/Makefile_Ector.am
index e404df3..1d1b35e 100644
--- a/src/Makefile_Ector.am
+++ b/src/Makefile_Ector.am
@@ -134,6 +134,7 @@ lib/ector/gl/ector_renderer_gl_gradient_radial.c \
 lib/ector/gl/ector_renderer_gl_shape.c \
 lib/ector/gl/ector_renderer_gl_base.c \
 lib/ector/gl/ector_gl_buffer.c \
+lib/ector/gl/ector_gl_buffer_base.c \
 lib/ector/gl/ector_gl_surface.c \
 lib/ector/gl/ector_gl_private.h \
 lib/ector/gl/shader/ector_gl_shaders.x \
diff --git a/src/lib/ector/ector_buffer.h b/src/lib/ector/ector_buffer.h
index 0e12c79..9399b17 100644
--- a/src/lib/ector/ector_buffer.h
+++ b/src/lib/ector/ector_buffer.h
@@ -12,16 +12,19 @@
  */
 typedef Ector_Generic_Buffer Ector_Buffer;
 
-typedef struct _Ector_Generic_Buffer_Data
+typedef struct _Ector_Generic_Buffer_Data Ector_Generic_Buffer_Data;
+typedef struct _Ector_Software_Buffer_Base_Data 
Ector_Software_Buffer_Base_Data;
+
+struct _Ector_Generic_Buffer_Data
 {
    Ector_Buffer       *eo;
    unsigned int        w, h;
    unsigned char       l, r, t, b;
    Efl_Gfx_Colorspace  cspace;
    Eina_Bool            immutable : 1; // pixels_set is forbidden
-} Ector_Generic_Buffer_Data;
+};
 
-typedef struct _Ector_Software_Buffer_Base_Data
+struct _Ector_Software_Buffer_Base_Data
 {
    Ector_Generic_Buffer_Data *generic; /* ugly */
    union {
@@ -35,6 +38,6 @@ typedef struct _Ector_Software_Buffer_Base_Data
    } internal;
    Eina_Bool            writable : 1; // pixels can be written to
    Eina_Bool            nofree : 1; // pixel data should not be free()'ed
-} Ector_Software_Buffer_Base_Data;
+};
 
 #endif
diff --git a/src/lib/ector/gl/Ector_GL.h b/src/lib/ector/gl/Ector_GL.h
index df49421..dc6c37f 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;
 typedef unsigned int GLuint;
 typedef short        GLshort;
 
-#include "gl/ector_gl_buffer.eo.h"
 #include "gl/ector_gl_buffer_base.eo.h"
+#include "gl/ector_gl_buffer.eo.h"
 #include "gl/ector_gl_surface.eo.h"
 #include "gl/ector_renderer_gl_base.eo.h"
 #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 e3732b9..19840f7 100644
--- a/src/lib/ector/gl/ector_gl_buffer.c
+++ b/src/lib/ector/gl/ector_gl_buffer.c
@@ -1,50 +1,14 @@
 #ifdef HAVE_CONFIG_H
 # include "config.h"
-#else
-# define EFL_BETA_API_SUPPORT
 #endif
 
-#include <Eo.h>
+#include <Ector.h>
 #include "Ector_GL.h"
 #include "ector_private.h"
 #include "ector_gl_private.h"
-#include "ector_generic_buffer.eo.h"
-#include "ector_gl_buffer_base.eo.h"
+#include "ector_buffer.h"
 
-typedef struct _Ector_GL_Buffer_Base_Data Ector_GL_Buffer_Base_Data;
-struct _Ector_GL_Buffer_Base_Data
-{
-};
-
-static Ector_Buffer_Flag
-_ector_gl_buffer_base_ector_generic_buffer_flags_get(Eo *obj, 
Ector_GL_Buffer_Base_Data *pd)
-{
-}
-
-static Eina_Bool
-_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)
-{
-}
-
-static uint8_t *
-_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)
-{
-}
-
-static void
-_ector_gl_buffer_base_ector_generic_buffer_span_free(Eo *obj, 
Ector_GL_Buffer_Base_Data *pd, uint8_t *data)
-{
-}
-
-static uint8_t *
-_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)
-{
-}
-
-static void
-_ector_gl_buffer_base_ector_generic_buffer_unmap(Eo *obj, 
Ector_GL_Buffer_Base_Data *pd, void *data, int offset, unsigned int length)
-{
-}
+#define MY_CLASS ECTOR_GL_BUFFER_CLASS
 
 static Eo_Base *
 _ector_gl_buffer_eo_base_constructor(Eo *obj, void *pd)
@@ -57,4 +21,3 @@ _ector_gl_buffer_eo_base_destructor(Eo *obj, void *pd)
 }
 
 #include "ector_gl_buffer.eo.c"
-#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 0000000..81cd302
--- /dev/null
+++ b/src/lib/ector/gl/ector_gl_buffer_base.c
@@ -0,0 +1,59 @@
+#define EFL_BETA_API_SUPPORT
+#include <Eo.h>
+
+#include "Ector_GL.h"
+#include "ector_gl_private.h"
+#include "ector_buffer.h"
+#include "ector_gl_buffer_base.eo.h"
+
+#define MY_CLASS ECTOR_GL_BUFFER_BASE_MIXIN
+
+typedef struct
+{
+   Ector_Generic_Buffer_Data *generic;
+   int texid;
+   int fboid;
+   int w, h; // Texture size, not the atlas
+   struct {
+      // x,y offset within the atlas
+      // w,h size of the atlas itself
+      int x, y, w, h;
+   } atlas;
+   Eina_Bool whole : 1;
+} Ector_GL_Buffer_Base_Data;
+
+EOLIAN static int
+_ector_gl_buffer_base_texture_get(Eo *obj EINA_UNUSED, 
Ector_GL_Buffer_Base_Data *pd)
+{
+   return pd->texid;
+}
+
+EOLIAN static int
+_ector_gl_buffer_base_fbo_get(Eo *obj EINA_UNUSED, Ector_GL_Buffer_Base_Data 
*pd)
+{
+   return pd->fboid;
+}
+
+EOLIAN static Eina_Bool
+_ector_gl_buffer_base_whole_get(Eo *obj EINA_UNUSED, Ector_GL_Buffer_Base_Data 
*pd)
+{
+   return pd->whole;
+}
+
+EOLIAN static void
+_ector_gl_buffer_base_size_get(Eo *obj EINA_UNUSED, Ector_GL_Buffer_Base_Data 
*pd, int *w, int *h)
+{
+   if (w) *w = pd->w;
+   if (h) *h = pd->h;
+}
+
+EOLIAN static void
+_ector_gl_buffer_base_vertices_get(Eo *obj EINA_UNUSED, 
Ector_GL_Buffer_Base_Data *pd, double *x, double *y, double *w, double *h)
+{
+   if (x) *x = (double) pd->atlas.x / pd->atlas.w;
+   if (y) *y = (double) pd->atlas.y / pd->atlas.h;
+   if (w) *w = (double) pd->w / pd->atlas.w;
+   if (h) *h = (double) pd->h / pd->atlas.h;
+}
+
+#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 441f781..36562ae 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 @@
 mixin Ector.GL.Buffer.Base (Ector.Generic.Buffer)
 {
-   [[A buffer in Ector GL is a readable & optionally writable image]]
-   eo_prefix: ector_gl_buffer;
    legacy_prefix: null;
+   methods {
+      @property texture {
+         get {}
+         values {
+            texid: int; [[GL texture ID]]
+         }
+      }
+      @property fbo {
+         get {}
+         values {
+            fboid: int; [[GL framebuffer ID, 0 if there is no FBO]]
+         }
+      }
+      @property whole {
+         [[If $true, the image is covering the entire GL texture, ie. it's not
+           part of an atlas.
+         ]]
+         get {}
+         values {
+            is_whole: bool;
+         }
+      }
+      @property size {
+         [[The size in pixels of this image.
+
+           If the image is whole, then this is equal to the atlas size.
+         ]]
+         get {}
+         values {
+            w: int;
+            h: int;
+         }
+      }
+      @property vertices {
+         [[Returns the texture vertices to use to map this image with no 
rotation]]
+         get {}
+         values {
+            x: double; [[X position of this image inside the texture atlas, 
from 0 to 1]]
+            y: double; [[Y position of this image inside the texture atlas, 
from 0 to 1]]
+            w: double; [[Width of this image inside the texture atlas, from 0 
to 1]]
+            h: double; [[Height of this image inside the texture atlas, from 0 
to 1]]
+         }
+      }
+   }
    implements {
-      Ector.Generic.Buffer.flags.get;
-      Ector.Generic.Buffer.pixels_set;
-      Ector.Generic.Buffer.span_get;
-      Ector.Generic.Buffer.span_free;
-      Ector.Generic.Buffer.map;
-      Ector.Generic.Buffer.unmap;
-   }                
+   }
 }
diff --git a/src/lib/ector/gl/ector_gl_private.h 
b/src/lib/ector/gl/ector_gl_private.h
index 0362e7e..e67b4d1 100644
--- a/src/lib/ector/gl/ector_gl_private.h
+++ b/src/lib/ector/gl/ector_gl_private.h
@@ -1,6 +1,8 @@
 #ifndef ECTOR_GL_PRIVATE_H_
 # define ECTOR_GL_PRIVATE_H_
 
+#include "ector_private.h"
+
 #define SHADER_FLAG_SAM_BITSHIFT 3
 #define SHADER_FLAG_MASKSAM_BITSHIFT 6
 
diff --git a/src/lib/ector/software/ector_software_buffer.c 
b/src/lib/ector/software/ector_software_buffer.c
index 376228f..b846761 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_
 
    if (!pd->pixels.u8 || !pd->stride)
      fail("Buffer has no pixel data yet");
-   if (cspace != pd->generic->cspace)
-     fail("Invalid colorspace");
-   if (!w || !h || ((x + w) > pd->generic->w) || (y + h > pd->generic->h))
+   if (((x + w) > pd->generic->w) || (y + h > pd->generic->h))
      fail("Invalid region requested: wanted %u,%u %ux%u but image is %ux%u",
           x, y, w, h, pd->generic->w, pd->generic->h);
    if ((mode & ECTOR_BUFFER_ACCESS_FLAG_WRITE) && !pd->writable)

-- 


Reply via email to