summaryrefslogtreecommitdiff
path: root/src/lib/ector/software/ector_software_buffer.c
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 /src/lib/ector/software/ector_software_buffer.c
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.
Diffstat (limited to 'src/lib/ector/software/ector_software_buffer.c')
-rw-r--r--src/lib/ector/software/ector_software_buffer.c18
1 files changed, 9 insertions, 9 deletions
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)