summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-12-09 19:00:54 +0900
committerCedric BAIL <cedric@osg.samsung.com>2016-01-04 01:12:19 +0100
commitf990092d5d0d90b61eebba25990be59e9de2de02 (patch)
treea7ada8d1edc9d440b1f7e83d7853334a0fbe91cf
parent94de0c418d2b51e39093f9bab2343d067cafd531 (diff)
downloadefl-f990092d5d0d90b61eebba25990be59e9de2de02.tar.gz
ector: remove offset from Ector.Buffer.{map,unmap}
It just makes things a bit more complicated and doesn't correspond to a classic "map" operation anyways. Also return void* instead of uint8_t*. This is more correct and avoid extra casts.
-rw-r--r--src/lib/ector/ector_generic_buffer.eo4
-rw-r--r--src/lib/ector/software/ector_software_buffer.c16
2 files changed, 8 insertions, 12 deletions
diff --git a/src/lib/ector/ector_generic_buffer.eo b/src/lib/ector/ector_generic_buffer.eo
index 7b8a3edae6..8f98108bfa 100644
--- a/src/lib/ector/ector_generic_buffer.eo
+++ b/src/lib/ector/ector_generic_buffer.eo
@@ -43,7 +43,6 @@ mixin Ector.Generic.Buffer
fetch data from the GPU if needed.
]]
params {
- @out offset: int; [[Byte offset to the first requested pixel]]
@out length: uint; [[Accessible buffer size in bytes]]
@in mode: Ector.Buffer.Access_Flag;
@in x: uint;
@@ -53,13 +52,12 @@ mixin Ector.Generic.Buffer
@in cspace: Efl.Gfx.Colorspace; [[Requested colorspace. If difference from the internal cspace, map may either fail or convert slowly]]
@out stride: uint; [[Optional]]
}
- return: uint8* @warn_unused; [[Top-left pixel is at offset bytes after this address. Returns $null in case of failure]]
+ return: void* @warn_unused; [[Pointer to the top-left pixel data. Returns $null in case of failure]]
}
unmap {
[[Unmap a region of this buffer, and upload data to the GPU (if needed).]]
params {
@in data: void*; [[Data pointer returned by a previous call to map]]
- @in offset: int;
@in length: uint;
}
}
diff --git a/src/lib/ector/software/ector_software_buffer.c b/src/lib/ector/software/ector_software_buffer.c
index cd558ecd4e..4618fb7f59 100644
--- a/src/lib/ector/software/ector_software_buffer.c
+++ b/src/lib/ector/software/ector_software_buffer.c
@@ -108,7 +108,7 @@ _ector_software_buffer_base_ector_generic_buffer_pixels_set(Eo *obj, Ector_Softw
}
else
{
- pd->pixels.u8 = malloc(stride * (height + t + b));
+ pd->pixels.u8 = calloc(stride * (height + t + b), 1);
pd->nofree = EINA_FALSE;
pd->writable = EINA_TRUE;
}
@@ -124,10 +124,9 @@ _ector_software_buffer_base_ector_generic_buffer_pixels_set(Eo *obj, Ector_Softw
return EINA_TRUE;
}
-EOLIAN static uint8_t *
+EOLIAN static void *
_ector_software_buffer_base_ector_generic_buffer_map(Eo *obj EINA_UNUSED, Ector_Software_Buffer_Base_Data *pd,
- int *offset, unsigned int *length,
- Ector_Buffer_Access_Flag mode EINA_UNUSED,
+ unsigned int *length, Ector_Buffer_Access_Flag mode EINA_UNUSED,
unsigned int x, unsigned int y, unsigned int w, unsigned int h,
Efl_Gfx_Colorspace cspace EINA_UNUSED, unsigned int *stride)
{
@@ -143,20 +142,19 @@ _ector_software_buffer_base_ector_generic_buffer_map(Eo *obj EINA_UNUSED, Ector_
pd->map_count++;
off = _min_stride_calc(x + pd->generic->l, pd->generic->cspace) + (pd->stride * (y + pd->generic->t));
- if (offset) *offset = off;
- if (length) *length = (pd->stride * pd->generic->h) - off;
+ if (length) *length = (pd->stride * h) - off;
if (stride) *stride = pd->stride;
- return pd->pixels.u8;
+ return pd->pixels.u8 + off;
on_fail:
- if (offset) *offset = 0;
if (length) *length = 0;
if (stride) *stride = 0;
return NULL;
}
EOLIAN static void
-_ector_software_buffer_base_ector_generic_buffer_unmap(Eo *obj EINA_UNUSED, Ector_Software_Buffer_Base_Data *pd, void *data, int offset EINA_UNUSED, unsigned int length EINA_UNUSED)
+_ector_software_buffer_base_ector_generic_buffer_unmap(Eo *obj EINA_UNUSED, Ector_Software_Buffer_Base_Data *pd,
+ void *data, unsigned int length EINA_UNUSED)
{
if (!data) return;
if (data != pd->pixels.u8)