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;
@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;
}
}
}
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;
}
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,
unsigned int x, unsigned int y, unsigned int w, unsigned int h,
Efl_Gfx_Colorspace cspace EINA_UNUSED, unsigned int *stride)
{
if (!w || !h || ((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)
+ fail("can not map a read-only buffer for writing");
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)