summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-12-09 19:00:54 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-01-05 15:43:43 +0900
commit952f27507d6c2a968dfdb67c259ba95a1bdc8a0c (patch)
tree453e66b9d34b4002dd128f5b53f6b07ae17aaa6c
parent34a892dbab13b14bd01ac30474a30f230c6b135d (diff)
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.c18
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 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
43 fetch data from the GPU if needed. 43 fetch data from the GPU if needed.
44 ]] 44 ]]
45 params { 45 params {
46 @out offset: int; [[Byte offset to the first requested pixel]]
47 @out length: uint; [[Accessible buffer size in bytes]] 46 @out length: uint; [[Accessible buffer size in bytes]]
48 @in mode: Ector.Buffer.Access_Flag; 47 @in mode: Ector.Buffer.Access_Flag;
49 @in x: uint; 48 @in x: uint;
@@ -53,13 +52,12 @@ mixin Ector.Generic.Buffer
53 @in cspace: Efl.Gfx.Colorspace; [[Requested colorspace. If difference from the internal cspace, map may either fail or convert slowly]] 52 @in cspace: Efl.Gfx.Colorspace; [[Requested colorspace. If difference from the internal cspace, map may either fail or convert slowly]]
54 @out stride: uint; [[Optional]] 53 @out stride: uint; [[Optional]]
55 } 54 }
56 return: uint8* @warn_unused; [[Top-left pixel is at offset bytes after this address. Returns $null in case of failure]] 55 return: void* @warn_unused; [[Pointer to the top-left pixel data. Returns $null in case of failure]]
57 } 56 }
58 unmap { 57 unmap {
59 [[Unmap a region of this buffer, and upload data to the GPU (if needed).]] 58 [[Unmap a region of this buffer, and upload data to the GPU (if needed).]]
60 params { 59 params {
61 @in data: void*; [[Data pointer returned by a previous call to map]] 60 @in data: void*; [[Data pointer returned by a previous call to map]]
62 @in offset: int;
63 @in length: uint; 61 @in length: uint;
64 } 62 }
65 } 63 }
diff --git a/src/lib/ector/software/ector_software_buffer.c b/src/lib/ector/software/ector_software_buffer.c
index cd558ecd4e..89a2cc1995 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
108 } 108 }
109 else 109 else
110 { 110 {
111 pd->pixels.u8 = malloc(stride * (height + t + b)); 111 pd->pixels.u8 = calloc(stride * (height + t + b), 1);
112 pd->nofree = EINA_FALSE; 112 pd->nofree = EINA_FALSE;
113 pd->writable = EINA_TRUE; 113 pd->writable = EINA_TRUE;
114 } 114 }
@@ -124,10 +124,9 @@ _ector_software_buffer_base_ector_generic_buffer_pixels_set(Eo *obj, Ector_Softw
124 return EINA_TRUE; 124 return EINA_TRUE;
125} 125}
126 126
127EOLIAN static uint8_t * 127EOLIAN static void *
128_ector_software_buffer_base_ector_generic_buffer_map(Eo *obj EINA_UNUSED, Ector_Software_Buffer_Base_Data *pd, 128_ector_software_buffer_base_ector_generic_buffer_map(Eo *obj EINA_UNUSED, Ector_Software_Buffer_Base_Data *pd,
129 int *offset, unsigned int *length, 129 unsigned int *length, Ector_Buffer_Access_Flag mode,
130 Ector_Buffer_Access_Flag mode EINA_UNUSED,
131 unsigned int x, unsigned int y, unsigned int w, unsigned int h, 130 unsigned int x, unsigned int y, unsigned int w, unsigned int h,
132 Efl_Gfx_Colorspace cspace EINA_UNUSED, unsigned int *stride) 131 Efl_Gfx_Colorspace cspace EINA_UNUSED, unsigned int *stride)
133{ 132{
@@ -140,23 +139,24 @@ _ector_software_buffer_base_ector_generic_buffer_map(Eo *obj EINA_UNUSED, Ector_
140 if (!w || !h || ((x + w) > pd->generic->w) || (y + h > pd->generic->h)) 139 if (!w || !h || ((x + w) > pd->generic->w) || (y + h > pd->generic->h))
141 fail("Invalid region requested: wanted %u,%u %ux%u but image is %ux%u", 140 fail("Invalid region requested: wanted %u,%u %ux%u but image is %ux%u",
142 x, y, w, h, pd->generic->w, pd->generic->h); 141 x, y, w, h, pd->generic->w, pd->generic->h);
142 if ((mode & ECTOR_BUFFER_ACCESS_FLAG_WRITE) && !pd->writable)
143 fail("can not map a read-only buffer for writing");
143 144
144 pd->map_count++; 145 pd->map_count++;
145 off = _min_stride_calc(x + pd->generic->l, pd->generic->cspace) + (pd->stride * (y + pd->generic->t)); 146 off = _min_stride_calc(x + pd->generic->l, pd->generic->cspace) + (pd->stride * (y + pd->generic->t));
146 if (offset) *offset = off; 147 if (length) *length = (pd->stride * h) - off;
147 if (length) *length = (pd->stride * pd->generic->h) - off;
148 if (stride) *stride = pd->stride; 148 if (stride) *stride = pd->stride;
149 return pd->pixels.u8; 149 return pd->pixels.u8 + off;
150 150
151on_fail: 151on_fail:
152 if (offset) *offset = 0;
153 if (length) *length = 0; 152 if (length) *length = 0;
154 if (stride) *stride = 0; 153 if (stride) *stride = 0;
155 return NULL; 154 return NULL;
156} 155}
157 156
158EOLIAN static void 157EOLIAN static void
159_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) 158_ector_software_buffer_base_ector_generic_buffer_unmap(Eo *obj EINA_UNUSED, Ector_Software_Buffer_Base_Data *pd,
159 void *data, unsigned int length EINA_UNUSED)
160{ 160{
161 if (!data) return; 161 if (!data) return;
162 if (data != pd->pixels.u8) 162 if (data != pd->pixels.u8)