forked from enlightenment/efl
ector: add Ector.GL.Buffer.* support.
This commit is contained in:
parent
116fe3c65c
commit
e3a7f657d9
|
@ -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 \
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue