forked from enlightenment/efl
Efl.Gfx.Buffer: Simplify data_get/set
Remove alpha, l, r, t, b and output length. Those are simply too many parameters, making the function too inconvenient to use.
This commit is contained in:
parent
055ea6445a
commit
97c9ced648
|
@ -94,6 +94,8 @@ interface Efl.Gfx.Buffer ()
|
|||
}
|
||||
}
|
||||
|
||||
/* FIXME: not bindable to JS, potentially tricky to bind to Lua */
|
||||
|
||||
/* FIXME: split into read-only and writeable methods? */
|
||||
/* FIXME: This was copy pasta from ector generic buffer. changed a bit. */
|
||||
buffer_map {
|
||||
|
@ -133,7 +135,7 @@ interface Efl.Gfx.Buffer ()
|
|||
}
|
||||
/* note: not a property because the refcount needs to be explicit
|
||||
* between set and get */
|
||||
/* FIXME: not bindable to JS, potentially tricky to bind to Lua */
|
||||
/* FIXME: do we need writable flag? */
|
||||
buffer_set {
|
||||
[[Set the pixels for this buffer, or allocate a new memory region.
|
||||
|
||||
|
@ -163,12 +165,6 @@ interface Efl.Gfx.Buffer ()
|
|||
@in height: int;
|
||||
@in stride: int @optional; [[If 0, automatically guessed from the $width.]]
|
||||
@in cspace: Efl.Gfx.Colorspace @optional; [[argb8888 by default.]]
|
||||
@in alpha: bool; [[$true if the alpha channel is used.]]
|
||||
@in l: uint @optional; [[Left border pixels, usually 0 or 1. Not supported yet!]]
|
||||
@in r: uint @optional; [[Right border pixels, usually 0 or 1. Not supported yet!]]
|
||||
@in t: uint @optional; [[Top border pixels, usually 0 or 1. Not supported yet!]]
|
||||
@in b: uint @optional; [[Bottom border pixels, usually 0 or 1. Not supported yet!]]
|
||||
/* FIXME: do we need writable flag? */
|
||||
}
|
||||
return: bool @warn_unused; [[This function returns $false in case of failure.]]
|
||||
}
|
||||
|
@ -201,11 +197,6 @@ interface Efl.Gfx.Buffer ()
|
|||
@in height: int;
|
||||
@in stride: int @optional; [[If 0, automatically guessed from the $width.]]
|
||||
@in cspace: Efl.Gfx.Colorspace @optional; [[argb8888 by default.]]
|
||||
@in alpha: bool; [[$true if the alpha channel is used.]]
|
||||
@in l: uint @optional; [[Left border pixels, usually 0 or 1. Not supported yet!]]
|
||||
@in r: uint @optional; [[Right border pixels, usually 0 or 1. Not supported yet!]]
|
||||
@in t: uint @optional; [[Top border pixels, usually 0 or 1. Not supported yet!]]
|
||||
@in b: uint @optional; [[Bottom border pixels, usually 0 or 1. Not supported yet!]]
|
||||
}
|
||||
return: bool @warn_unused; [[This function returns $false in case of failure.]]
|
||||
}
|
||||
|
@ -213,32 +204,24 @@ interface Efl.Gfx.Buffer ()
|
|||
[[Get a direct pointer to the internal pixel data.
|
||||
|
||||
This will increment an internal reference counter on the internal
|
||||
buffer.
|
||||
buffer. If $to_write is $true, this may trigger a copy of the
|
||||
internal pixel data, and return a writable memory block.
|
||||
|
||||
If $to_write is $true, this may trigger a copy of the internal
|
||||
pixel data, and return a writable memory block.
|
||||
|
||||
Call @.buffer_size.get and @.buffer_borders.get to determine the
|
||||
value of width, height and l, r, t, b.
|
||||
Call @.buffer_size.get to know the value of $width and $height.
|
||||
The memory buffer length in bytes is defined as $height x $stride.
|
||||
|
||||
Warning: @.buffer_set MUST be called as soon as possible after
|
||||
calling @.buffer_get. @.buffer_update_add should be called after
|
||||
@.buffer_set if $to_write was $true and the pixel data has been
|
||||
modified. Once @.buffer_set is called, the pointer return from
|
||||
modified. Once @.buffer_set is called, the pointer returned by
|
||||
@.buffer_get is not valid anymore.
|
||||
]]
|
||||
params {
|
||||
@in to_write: bool; [[If $true, requests write access]]
|
||||
@out length: uint @optional; [[Size of the buffer in bytes.]]
|
||||
@out width: int @optional;
|
||||
@out height: int @optional;
|
||||
@out stride: int @optional; [[Returns the length of one row of pixels in bytes.]]
|
||||
@out stride: int @optional; [[Returns the length of one row of pixels in bytes, so that length = $height x $stride.]]
|
||||
@out cspace: Efl.Gfx.Colorspace @optional; [[Pixel encoding of the returned buffer.]]
|
||||
@out alpha: bool; [[$true if the alpha channel is used.]]
|
||||
@out l: uint @optional; [[Left border pixels, usually 0 or 1. Not supported yet!]]
|
||||
@out r: uint @optional; [[Right border pixels, usually 0 or 1. Not supported yet!]]
|
||||
@out t: uint @optional; [[Top border pixels, usually 0 or 1. Not supported yet!]]
|
||||
@out b: uint @optional; [[Bottom border pixels, usually 0 or 1. Not supported yet!]]
|
||||
}
|
||||
return: void* @warn_unused;
|
||||
}
|
||||
|
|
|
@ -4036,13 +4036,12 @@ _evas_object_image_surface_get(Evas_Object *eo, Evas_Object_Protected_Data *obj)
|
|||
|
||||
EOLIAN static void *
|
||||
_evas_image_efl_gfx_buffer_buffer_get(Eo *eo_obj, Evas_Image_Data *o,
|
||||
Eina_Bool to_write, unsigned int *length_out,
|
||||
Eina_Bool to_write,
|
||||
int *width, int *height, int *stride_out,
|
||||
Efl_Gfx_Colorspace *cspace, Eina_Bool *alpha,
|
||||
unsigned int *l, unsigned int *r, unsigned int *t, unsigned int *b)
|
||||
Efl_Gfx_Colorspace *cspace)
|
||||
{
|
||||
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
|
||||
int stride = 0, length = 0;
|
||||
int stride = 0;
|
||||
void *data;
|
||||
|
||||
// use the old api - same behaviour with more return info
|
||||
|
@ -4052,25 +4051,13 @@ _evas_image_efl_gfx_buffer_buffer_get(Eo *eo_obj, Evas_Image_Data *o,
|
|||
// FIXME: length needs to be properly checked with the engine
|
||||
// as we just ignore l,r,t,b here
|
||||
ENFN->image_stride_get(ENDT, o->engine_data, &stride);
|
||||
if (stride)
|
||||
length = stride * o->cur->image.h;
|
||||
else
|
||||
{
|
||||
length = _evas_common_rgba_image_surface_size(o->cur->image.w, o->cur->image.h, o->cur->cspace, NULL, NULL, NULL, NULL);
|
||||
stride = _evas_common_rgba_image_surface_size(o->cur->image.w, 1, o->cur->cspace, NULL, NULL, NULL, NULL);
|
||||
}
|
||||
if (!stride)
|
||||
stride = _evas_common_rgba_image_surface_size(o->cur->image.w, 1, o->cur->cspace, NULL, NULL, NULL, NULL);
|
||||
|
||||
end:
|
||||
// TODO: support duplicated borders
|
||||
if (l) *l = 0;
|
||||
if (r) *r = 0;
|
||||
if (t) *t = 0;
|
||||
if (b) *b = 0;
|
||||
if (alpha) *alpha = o->cur->has_alpha;
|
||||
if (width) *width = o->cur->image.w;
|
||||
if (height) *height = o->cur->image.h;
|
||||
if (cspace) *cspace = (Efl_Gfx_Colorspace) o->cur->cspace;
|
||||
if (length_out) *length_out = length;
|
||||
if (stride_out) *stride_out = stride;
|
||||
return data;
|
||||
}
|
||||
|
@ -4078,20 +4065,11 @@ end:
|
|||
static Eina_Bool
|
||||
_evas_image_buffer_set_common(Eo *obj, Evas_Image_Data *o, void *pixels,
|
||||
int width, int height, int stride,
|
||||
Efl_Gfx_Colorspace cspace, Eina_Bool alpha,
|
||||
unsigned int l, unsigned int r, unsigned int t, unsigned int b,
|
||||
Eina_Bool copy)
|
||||
Efl_Gfx_Colorspace cspace, Eina_Bool copy)
|
||||
{
|
||||
Evas_Colorspace cs = (Evas_Colorspace) cspace;
|
||||
int stride_min;
|
||||
|
||||
if (l || r || t || b)
|
||||
{
|
||||
// TODO
|
||||
ERR("Buffer borders are not supported yet!");
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
stride_min = _evas_common_rgba_image_surface_size(width, 1, cs, NULL, NULL, NULL, NULL);
|
||||
if (!stride) stride = stride_min;
|
||||
if (stride < stride_min)
|
||||
|
@ -4111,10 +4089,6 @@ _evas_image_buffer_set_common(Eo *obj, Evas_Image_Data *o, void *pixels,
|
|||
if ((width != o->cur->image.w) || (height != o->cur->image.h))
|
||||
evas_object_image_size_set(obj, width, height);
|
||||
|
||||
alpha = !!alpha;
|
||||
if (alpha != o->cur->has_alpha)
|
||||
evas_object_image_alpha_set(obj, alpha);
|
||||
|
||||
if (!pixels)
|
||||
evas_object_image_data_set(obj, NULL);
|
||||
else if (!copy)
|
||||
|
@ -4128,19 +4102,17 @@ _evas_image_buffer_set_common(Eo *obj, Evas_Image_Data *o, void *pixels,
|
|||
EOLIAN static Eina_Bool
|
||||
_evas_image_efl_gfx_buffer_buffer_set(Eo *obj, Evas_Image_Data *o, void *pixels,
|
||||
int width, int height, int stride,
|
||||
Efl_Gfx_Colorspace cspace, Eina_Bool alpha,
|
||||
unsigned int l, unsigned int r, unsigned int t, unsigned int b)
|
||||
Efl_Gfx_Colorspace cspace)
|
||||
{
|
||||
return _evas_image_buffer_set_common(obj, o, pixels, width, height, stride, cspace, alpha, l, r, t, b, EINA_FALSE);
|
||||
return _evas_image_buffer_set_common(obj, o, pixels, width, height, stride, cspace, EINA_FALSE);
|
||||
}
|
||||
|
||||
EOLIAN static Eina_Bool
|
||||
_evas_image_efl_gfx_buffer_buffer_copy_set(Eo *obj, Evas_Image_Data *o, const void *pixels,
|
||||
int width, int height, int stride,
|
||||
Efl_Gfx_Colorspace cspace, Eina_Bool alpha,
|
||||
unsigned int l, unsigned int r, unsigned int t, unsigned int b)
|
||||
Efl_Gfx_Colorspace cspace)
|
||||
{
|
||||
return _evas_image_buffer_set_common(obj, o, (void *) pixels, width, height, stride, cspace, alpha, l, r, t, b, EINA_TRUE);
|
||||
return _evas_image_buffer_set_common(obj, o, (void *) pixels, width, height, stride, cspace, EINA_TRUE);
|
||||
}
|
||||
|
||||
/* Legacy deprecated functions */
|
||||
|
|
Loading…
Reference in New Issue