summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-03-11 16:04:15 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-03-15 11:11:59 +0900
commit97c9ced648ec1e25f1e6b997652c6c235bab1c74 (patch)
tree155b3618de2d9c0af5cdd216eb83f8e8806be258 /src
parent055ea6445a08941dc6b8739fbdef6230cdfdbef9 (diff)
Efl.Gfx.Buffer: Simplify data_get/set
Remove alpha, l, r, t, b and output length. Those are simply too many parameters, making the function too inconvenient to use.
Diffstat (limited to 'src')
-rw-r--r--src/lib/efl/interfaces/efl_gfx_buffer.eo35
-rw-r--r--src/lib/evas/canvas/evas_object_image.c48
2 files changed, 19 insertions, 64 deletions
diff --git a/src/lib/efl/interfaces/efl_gfx_buffer.eo b/src/lib/efl/interfaces/efl_gfx_buffer.eo
index 0b19b98ec1..f176b6afa9 100644
--- a/src/lib/efl/interfaces/efl_gfx_buffer.eo
+++ b/src/lib/efl/interfaces/efl_gfx_buffer.eo
@@ -94,6 +94,8 @@ interface Efl.Gfx.Buffer ()
94 } 94 }
95 } 95 }
96 96
97 /* FIXME: not bindable to JS, potentially tricky to bind to Lua */
98
97 /* FIXME: split into read-only and writeable methods? */ 99 /* FIXME: split into read-only and writeable methods? */
98 /* FIXME: This was copy pasta from ector generic buffer. changed a bit. */ 100 /* FIXME: This was copy pasta from ector generic buffer. changed a bit. */
99 buffer_map { 101 buffer_map {
@@ -133,7 +135,7 @@ interface Efl.Gfx.Buffer ()
133 } 135 }
134 /* note: not a property because the refcount needs to be explicit 136 /* note: not a property because the refcount needs to be explicit
135 * between set and get */ 137 * between set and get */
136 /* FIXME: not bindable to JS, potentially tricky to bind to Lua */ 138 /* FIXME: do we need writable flag? */
137 buffer_set { 139 buffer_set {
138 [[Set the pixels for this buffer, or allocate a new memory region. 140 [[Set the pixels for this buffer, or allocate a new memory region.
139 141
@@ -163,12 +165,6 @@ interface Efl.Gfx.Buffer ()
163 @in height: int; 165 @in height: int;
164 @in stride: int @optional; [[If 0, automatically guessed from the $width.]] 166 @in stride: int @optional; [[If 0, automatically guessed from the $width.]]
165 @in cspace: Efl.Gfx.Colorspace @optional; [[argb8888 by default.]] 167 @in cspace: Efl.Gfx.Colorspace @optional; [[argb8888 by default.]]
166 @in alpha: bool; [[$true if the alpha channel is used.]]
167 @in l: uint @optional; [[Left border pixels, usually 0 or 1. Not supported yet!]]
168 @in r: uint @optional; [[Right border pixels, usually 0 or 1. Not supported yet!]]
169 @in t: uint @optional; [[Top border pixels, usually 0 or 1. Not supported yet!]]
170 @in b: uint @optional; [[Bottom border pixels, usually 0 or 1. Not supported yet!]]
171 /* FIXME: do we need writable flag? */
172 } 168 }
173 return: bool @warn_unused; [[This function returns $false in case of failure.]] 169 return: bool @warn_unused; [[This function returns $false in case of failure.]]
174 } 170 }
@@ -201,11 +197,6 @@ interface Efl.Gfx.Buffer ()
201 @in height: int; 197 @in height: int;
202 @in stride: int @optional; [[If 0, automatically guessed from the $width.]] 198 @in stride: int @optional; [[If 0, automatically guessed from the $width.]]
203 @in cspace: Efl.Gfx.Colorspace @optional; [[argb8888 by default.]] 199 @in cspace: Efl.Gfx.Colorspace @optional; [[argb8888 by default.]]
204 @in alpha: bool; [[$true if the alpha channel is used.]]
205 @in l: uint @optional; [[Left border pixels, usually 0 or 1. Not supported yet!]]
206 @in r: uint @optional; [[Right border pixels, usually 0 or 1. Not supported yet!]]
207 @in t: uint @optional; [[Top border pixels, usually 0 or 1. Not supported yet!]]
208 @in b: uint @optional; [[Bottom border pixels, usually 0 or 1. Not supported yet!]]
209 } 200 }
210 return: bool @warn_unused; [[This function returns $false in case of failure.]] 201 return: bool @warn_unused; [[This function returns $false in case of failure.]]
211 } 202 }
@@ -213,32 +204,24 @@ interface Efl.Gfx.Buffer ()
213 [[Get a direct pointer to the internal pixel data. 204 [[Get a direct pointer to the internal pixel data.
214 205
215 This will increment an internal reference counter on the internal 206 This will increment an internal reference counter on the internal
216 buffer. 207 buffer. If $to_write is $true, this may trigger a copy of the
217 208 internal pixel data, and return a writable memory block.
218 If $to_write is $true, this may trigger a copy of the internal
219 pixel data, and return a writable memory block.
220 209
221 Call @.buffer_size.get and @.buffer_borders.get to determine the 210 Call @.buffer_size.get to know the value of $width and $height.
222 value of width, height and l, r, t, b. 211 The memory buffer length in bytes is defined as $height x $stride.
223 212
224 Warning: @.buffer_set MUST be called as soon as possible after 213 Warning: @.buffer_set MUST be called as soon as possible after
225 calling @.buffer_get. @.buffer_update_add should be called after 214 calling @.buffer_get. @.buffer_update_add should be called after
226 @.buffer_set if $to_write was $true and the pixel data has been 215 @.buffer_set if $to_write was $true and the pixel data has been
227 modified. Once @.buffer_set is called, the pointer return from 216 modified. Once @.buffer_set is called, the pointer returned by
228 @.buffer_get is not valid anymore. 217 @.buffer_get is not valid anymore.
229 ]] 218 ]]
230 params { 219 params {
231 @in to_write: bool; [[If $true, requests write access]] 220 @in to_write: bool; [[If $true, requests write access]]
232 @out length: uint @optional; [[Size of the buffer in bytes.]]
233 @out width: int @optional; 221 @out width: int @optional;
234 @out height: int @optional; 222 @out height: int @optional;
235 @out stride: int @optional; [[Returns the length of one row of pixels in bytes.]] 223 @out stride: int @optional; [[Returns the length of one row of pixels in bytes, so that length = $height x $stride.]]
236 @out cspace: Efl.Gfx.Colorspace @optional; [[Pixel encoding of the returned buffer.]] 224 @out cspace: Efl.Gfx.Colorspace @optional; [[Pixel encoding of the returned buffer.]]
237 @out alpha: bool; [[$true if the alpha channel is used.]]
238 @out l: uint @optional; [[Left border pixels, usually 0 or 1. Not supported yet!]]
239 @out r: uint @optional; [[Right border pixels, usually 0 or 1. Not supported yet!]]
240 @out t: uint @optional; [[Top border pixels, usually 0 or 1. Not supported yet!]]
241 @out b: uint @optional; [[Bottom border pixels, usually 0 or 1. Not supported yet!]]
242 } 225 }
243 return: void* @warn_unused; 226 return: void* @warn_unused;
244 } 227 }
diff --git a/src/lib/evas/canvas/evas_object_image.c b/src/lib/evas/canvas/evas_object_image.c
index 4666d6a659..8972f56641 100644
--- a/src/lib/evas/canvas/evas_object_image.c
+++ b/src/lib/evas/canvas/evas_object_image.c
@@ -4036,13 +4036,12 @@ _evas_object_image_surface_get(Evas_Object *eo, Evas_Object_Protected_Data *obj)
4036 4036
4037EOLIAN static void * 4037EOLIAN static void *
4038_evas_image_efl_gfx_buffer_buffer_get(Eo *eo_obj, Evas_Image_Data *o, 4038_evas_image_efl_gfx_buffer_buffer_get(Eo *eo_obj, Evas_Image_Data *o,
4039 Eina_Bool to_write, unsigned int *length_out, 4039 Eina_Bool to_write,
4040 int *width, int *height, int *stride_out, 4040 int *width, int *height, int *stride_out,
4041 Efl_Gfx_Colorspace *cspace, Eina_Bool *alpha, 4041 Efl_Gfx_Colorspace *cspace)
4042 unsigned int *l, unsigned int *r, unsigned int *t, unsigned int *b)
4043{ 4042{
4044 Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS); 4043 Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
4045 int stride = 0, length = 0; 4044 int stride = 0;
4046 void *data; 4045 void *data;
4047 4046
4048 // use the old api - same behaviour with more return info 4047 // use the old api - same behaviour with more return info
@@ -4052,25 +4051,13 @@ _evas_image_efl_gfx_buffer_buffer_get(Eo *eo_obj, Evas_Image_Data *o,
4052 // FIXME: length needs to be properly checked with the engine 4051 // FIXME: length needs to be properly checked with the engine
4053 // as we just ignore l,r,t,b here 4052 // as we just ignore l,r,t,b here
4054 ENFN->image_stride_get(ENDT, o->engine_data, &stride); 4053 ENFN->image_stride_get(ENDT, o->engine_data, &stride);
4055 if (stride) 4054 if (!stride)
4056 length = stride * o->cur->image.h; 4055 stride = _evas_common_rgba_image_surface_size(o->cur->image.w, 1, o->cur->cspace, NULL, NULL, NULL, NULL);
4057 else
4058 {
4059 length = _evas_common_rgba_image_surface_size(o->cur->image.w, o->cur->image.h, o->cur->cspace, NULL, NULL, NULL, NULL);
4060 stride = _evas_common_rgba_image_surface_size(o->cur->image.w, 1, o->cur->cspace, NULL, NULL, NULL, NULL);
4061 }
4062 4056
4063end: 4057end:
4064 // TODO: support duplicated borders
4065 if (l) *l = 0;
4066 if (r) *r = 0;
4067 if (t) *t = 0;
4068 if (b) *b = 0;
4069 if (alpha) *alpha = o->cur->has_alpha;
4070 if (width) *width = o->cur->image.w; 4058 if (width) *width = o->cur->image.w;
4071 if (height) *height = o->cur->image.h; 4059 if (height) *height = o->cur->image.h;
4072 if (cspace) *cspace = (Efl_Gfx_Colorspace) o->cur->cspace; 4060 if (cspace) *cspace = (Efl_Gfx_Colorspace) o->cur->cspace;
4073 if (length_out) *length_out = length;
4074 if (stride_out) *stride_out = stride; 4061 if (stride_out) *stride_out = stride;
4075 return data; 4062 return data;
4076} 4063}
@@ -4078,20 +4065,11 @@ end:
4078static Eina_Bool 4065static Eina_Bool
4079_evas_image_buffer_set_common(Eo *obj, Evas_Image_Data *o, void *pixels, 4066_evas_image_buffer_set_common(Eo *obj, Evas_Image_Data *o, void *pixels,
4080 int width, int height, int stride, 4067 int width, int height, int stride,
4081 Efl_Gfx_Colorspace cspace, Eina_Bool alpha, 4068 Efl_Gfx_Colorspace cspace, Eina_Bool copy)
4082 unsigned int l, unsigned int r, unsigned int t, unsigned int b,
4083 Eina_Bool copy)
4084{ 4069{
4085 Evas_Colorspace cs = (Evas_Colorspace) cspace; 4070 Evas_Colorspace cs = (Evas_Colorspace) cspace;
4086 int stride_min; 4071 int stride_min;
4087 4072
4088 if (l || r || t || b)
4089 {
4090 // TODO
4091 ERR("Buffer borders are not supported yet!");
4092 return EINA_FALSE;
4093 }
4094
4095 stride_min = _evas_common_rgba_image_surface_size(width, 1, cs, NULL, NULL, NULL, NULL); 4073 stride_min = _evas_common_rgba_image_surface_size(width, 1, cs, NULL, NULL, NULL, NULL);
4096 if (!stride) stride = stride_min; 4074 if (!stride) stride = stride_min;
4097 if (stride < stride_min) 4075 if (stride < stride_min)
@@ -4111,10 +4089,6 @@ _evas_image_buffer_set_common(Eo *obj, Evas_Image_Data *o, void *pixels,
4111 if ((width != o->cur->image.w) || (height != o->cur->image.h)) 4089 if ((width != o->cur->image.w) || (height != o->cur->image.h))
4112 evas_object_image_size_set(obj, width, height); 4090 evas_object_image_size_set(obj, width, height);
4113 4091
4114 alpha = !!alpha;
4115 if (alpha != o->cur->has_alpha)
4116 evas_object_image_alpha_set(obj, alpha);
4117
4118 if (!pixels) 4092 if (!pixels)
4119 evas_object_image_data_set(obj, NULL); 4093 evas_object_image_data_set(obj, NULL);
4120 else if (!copy) 4094 else if (!copy)
@@ -4128,19 +4102,17 @@ _evas_image_buffer_set_common(Eo *obj, Evas_Image_Data *o, void *pixels,
4128EOLIAN static Eina_Bool 4102EOLIAN static Eina_Bool
4129_evas_image_efl_gfx_buffer_buffer_set(Eo *obj, Evas_Image_Data *o, void *pixels, 4103_evas_image_efl_gfx_buffer_buffer_set(Eo *obj, Evas_Image_Data *o, void *pixels,
4130 int width, int height, int stride, 4104 int width, int height, int stride,
4131 Efl_Gfx_Colorspace cspace, Eina_Bool alpha, 4105 Efl_Gfx_Colorspace cspace)
4132 unsigned int l, unsigned int r, unsigned int t, unsigned int b)
4133{ 4106{
4134 return _evas_image_buffer_set_common(obj, o, pixels, width, height, stride, cspace, alpha, l, r, t, b, EINA_FALSE); 4107 return _evas_image_buffer_set_common(obj, o, pixels, width, height, stride, cspace, EINA_FALSE);
4135} 4108}
4136 4109
4137EOLIAN static Eina_Bool 4110EOLIAN static Eina_Bool
4138_evas_image_efl_gfx_buffer_buffer_copy_set(Eo *obj, Evas_Image_Data *o, const void *pixels, 4111_evas_image_efl_gfx_buffer_buffer_copy_set(Eo *obj, Evas_Image_Data *o, const void *pixels,
4139 int width, int height, int stride, 4112 int width, int height, int stride,
4140 Efl_Gfx_Colorspace cspace, Eina_Bool alpha, 4113 Efl_Gfx_Colorspace cspace)
4141 unsigned int l, unsigned int r, unsigned int t, unsigned int b)
4142{ 4114{
4143 return _evas_image_buffer_set_common(obj, o, (void *) pixels, width, height, stride, cspace, alpha, l, r, t, b, EINA_TRUE); 4115 return _evas_image_buffer_set_common(obj, o, (void *) pixels, width, height, stride, cspace, EINA_TRUE);
4144} 4116}
4145 4117
4146/* Legacy deprecated functions */ 4118/* Legacy deprecated functions */