jpeg pushed a commit to branch master.

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

commit 952f27507d6c2a968dfdb67c259ba95a1bdc8a0c
Author: Jean-Philippe Andre <jp.an...@samsung.com>
Date:   Wed Dec 9 19:00:54 2015 +0900

    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.
---
 src/lib/ector/ector_generic_buffer.eo          |  4 +---
 src/lib/ector/software/ector_software_buffer.c | 18 +++++++++---------
 2 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/src/lib/ector/ector_generic_buffer.eo 
b/src/lib/ector/ector_generic_buffer.eo
index 7b8a3ed..8f98108 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 cd558ec..89a2cc1 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,
                                                      unsigned int x, unsigned 
int y, unsigned int w, unsigned int h,
                                                      Efl_Gfx_Colorspace cspace 
EINA_UNUSED, unsigned int *stride)
 {
@@ -140,23 +139,24 @@ _ector_software_buffer_base_ector_generic_buffer_map(Eo 
*obj EINA_UNUSED, Ector_
    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)

-- 


Reply via email to