For consistency.
static void
_save_image(void *data, const Efl_Event *ev EINA_UNUSED)
{
- Eina_Size2D sz;
Eo *win = data;
Eo *snap;
// This is a special case handled by snapshot for the purpose of taking
// screenshots like this. This is useful only if the button click has no
// animation on screen and there is no spinning wheel either.
- sz = efl_gfx_size_get(snap);
- efl_gfx_buffer_update_add(snap, 0, 0, sz.w, sz.h);
+ efl_gfx_buffer_update_add(snap, NULL);
}
static void
#ifdef USE_EO_IMAGE
Eina_Rw_Slice slice;
- if (!efl_gfx_buffer_map(source, &slice, EFL_GFX_BUFFER_ACCESS_MODE_WRITE, 0, 0, 0, 0,
+ if (!efl_gfx_buffer_map(source, &slice, EFL_GFX_BUFFER_ACCESS_MODE_WRITE, NULL,
EFL_GFX_COLORSPACE_ARGB8888, 0, &stride))
return EINA_TRUE;
pixels = slice.mem;
#ifdef USE_EO_IMAGE
efl_gfx_buffer_unmap(source, &slice);
- efl_gfx_buffer_update_add(source, 0, 0, IMG_WIDTH, IMG_HEIGHT);
+ efl_gfx_buffer_update_add(source, NULL);
#else
evas_object_image_data_set(source, pixels);
evas_object_image_data_update_add(source, 0, 0, IMG_WIDTH, IMG_HEIGHT);
/* Add a background image. */
#ifdef USE_EO_IMAGE
source = efl_add(EFL_CANVAS_IMAGE_CLASS, evas);
- efl_gfx_buffer_copy_set(source, NULL, IMG_WIDTH, IMG_HEIGHT, 0, EFL_GFX_COLORSPACE_ARGB8888, 0);
+ efl_gfx_buffer_copy_set(source, NULL, EINA_SIZE2D(IMG_WIDTH, IMG_HEIGHT), 0, EFL_GFX_COLORSPACE_ARGB8888, 0);
efl_gfx_position_set(source, EINA_POSITION2D((WIDTH / 2), (HEIGHT / 2)));
efl_gfx_size_set(source, EINA_SIZE2D((WIDTH / 2), (HEIGHT / 2)));
efl_gfx_visible_set(source, EINA_TRUE);
}
get {}
values {
- w: int; [[Width in pixels.]]
- h: int; [[Height in pixels.]]
+ sz: Eina.Size2D; [[Size of the buffer in pixels.]]
}
}
@property colorspace {
image object to be updated (redrawn) at the next rendering cycle.
]]
params {
- @in x: int; [[X-offset of the region to be updated.]]
- @in y: int; [[Y-offset of the region to be updated.]]
- @in w: int; [[Width of the region to be updated.]]
- @in h: int; [[Height of the region to be updated.]]
+ @in region: const(ptr(Eina.Rect)) @optional; [[The updated region.]]
}
}
@out slice: Eina.Rw_Slice; [[Pointer to the top-left pixel data.]]
@in mode: Efl.Gfx.Buffer.Access_Mode; [[Specifies whether to map for read-only,
write-only or read-write access (OR combination of flags).]]
- @in x: int @optional; [[X position of the top-left pixel to map, defaults to 0.]]
- @in y: int @optional; [[Y position of the top-left pixel to map, defaults to 0.]]
- @in w: int @optional; [[If 0, defaults to the buffer width.]]
- @in h: int @optional; [[If 0, defaults to the buffer height.]]
+ @in region: const(ptr(Eina.Rect)) @optional; [[The region to map.]]
@in cspace: Efl.Gfx.Colorspace @optional; [[Requested colorspace. If different from the internal cspace,
map should try to convert the data into a new buffer.
argb8888 by default.]]
]]
params {
@in slice: ptr(const(Eina.Slice)) @nullable; [[If $null, allocates an empty buffer]]
- @in width: int; [[Width]]
- @in height: int; [[Height]]
+ @in size: Eina.Size2D; [[The size in pixels.]]
@in stride: int @optional; [[If 0, automatically guessed from the $width.]]
@in cspace: Efl.Gfx.Colorspace @optional; [[argb8888 by default.]]
@in plane: int @optional; [[Plane ID. 0 by default. Useful for planar formats only.]]
]]
params {
@in slice: ptr(const(Eina.Slice)) @nullable; [[If $null, detaches the previous buffer.]]
- @in width: int; [[Width]]
- @in height: int; [[Height]]
+ @in size: Eina.Size2D; [[The size in pixels.]]
@in stride: int @optional; [[If 0, automatically guessed from the $width.]]
@in cspace: Efl.Gfx.Colorspace @optional; [[argb8888 by default.]]
@in plane: int @optional; [[Plane ID. 0 by default. Useful for planar formats only.]]
if (efl_isa(image, EFL_CANVAS_IMAGE_CLASS))
{
+ Eina_Rect rect = {};
+
unmap = EINA_TRUE;
- efl_gfx_buffer_size_get(image, &w, &h);
+ rect.size = efl_gfx_buffer_size_get(image);
efl_gfx_buffer_map(image, &sl, EFL_GFX_BUFFER_ACCESS_MODE_READ,
- 0, 0, w, h, EFL_GFX_COLORSPACE_ARGB8888, 0,
+ &rect, EFL_GFX_COLORSPACE_ARGB8888, 0,
&stride);
+ w = rect.w;
+ h = rect.h;
}
else
{
return _evas_image_animated_frame_get(eo_obj);
}
-EOLIAN static void
-_efl_canvas_image_efl_gfx_buffer_buffer_size_get(Eo *eo_obj, void *_pd EINA_UNUSED EINA_UNUSED, int *w, int *h)
+EOLIAN static Eina_Size2D
+_efl_canvas_image_efl_gfx_buffer_buffer_size_get(Eo *eo_obj, void *_pd EINA_UNUSED EINA_UNUSED)
{
Evas_Image_Data *o = efl_data_scope_get(eo_obj, EFL_CANVAS_IMAGE_INTERNAL_CLASS);
- if (w) *w = o->cur->image.w;
- if (h) *h = o->cur->image.h;
+ return EINA_SIZE2D(o->cur->image.w, o->cur->image.h);
}
static Eina_Bool
if (resized)
evas_object_inform_call_image_resize(obj->object);
- efl_gfx_buffer_update_add(obj->object, 0, 0, w, h);
+ efl_gfx_buffer_update_add(obj->object, NULL);
return ret;
}
EOLIAN static Eina_Bool
_efl_canvas_image_efl_gfx_buffer_buffer_managed_set(Eo *eo_obj, void *_pd EINA_UNUSED,
const Eina_Slice *slice,
- int w, int h, int stride,
+ Eina_Size2D size, int stride,
Efl_Gfx_Colorspace cspace,
int plane)
{
Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
Evas_Image_Data *o = efl_data_scope_get(eo_obj, EFL_CANVAS_IMAGE_INTERNAL_CLASS);
- return _image_pixels_set(obj, o, slice, w, h, stride, cspace, plane, EINA_FALSE);
+ return _image_pixels_set(obj, o, slice, size.w, size.h, stride, cspace, plane, EINA_FALSE);
}
EOLIAN static Eina_Bool
_efl_canvas_image_efl_gfx_buffer_buffer_copy_set(Eo *eo_obj, void *_pd EINA_UNUSED,
- const Eina_Slice *slice, int w, int h, int stride,
+ const Eina_Slice *slice, Eina_Size2D size, int stride,
Efl_Gfx_Colorspace cspace, int plane)
{
Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
Evas_Image_Data *o = efl_data_scope_get(eo_obj, EFL_CANVAS_IMAGE_INTERNAL_CLASS);
- return _image_pixels_set(obj, o, slice, w, h, stride, cspace, plane, EINA_TRUE);
+ return _image_pixels_set(obj, o, slice, size.w, size.h, stride, cspace, plane, EINA_TRUE);
}
EOLIAN static Eina_Bool
_efl_canvas_image_efl_gfx_buffer_buffer_map(Eo *eo_obj, void *_pd EINA_UNUSED,
Eina_Rw_Slice *slice,
Efl_Gfx_Buffer_Access_Mode mode,
- int x, int y, int w, int h,
+ const Eina_Rect *region,
Efl_Gfx_Colorspace cspace,
int plane, int *stride)
{
Evas_Image_Data *o = efl_data_scope_get(eo_obj, EFL_CANVAS_IMAGE_INTERNAL_CLASS);
int s = 0, width = 0, height = 0;
Eina_Bool ret = EINA_FALSE;
+ int x, y, w, h;
EINA_SAFETY_ON_NULL_RETURN_VAL(slice, EINA_FALSE);
goto end;
}
- if (!w) w = width;
- if (!h) h = height;
+ if (region)
+ {
+ x = region->x;
+ y = region->y;
+ w = region->w;
+ h = region->h;
+ }
+ else
+ {
+ x = y = 0;
+ w = width;
+ h = height;
+ }
- if ((x < 0) || (y < 0) || ((x + w) > width) || ((y + h) > height))
+ if ((x < 0) || (y < 0) || (w <= 0) || (h <= 0) || ((x + w) > width) || ((y + h) > height))
{
ERR("Invalid map dimensions: %dx%d +%d,%d. Image is %dx%d.",
w, h, x, y, width, height);
_efl_canvas_proxy_efl_gfx_buffer_buffer_map(Eo *eo_obj, void *_pd EINA_UNUSED,
Eina_Rw_Slice *slice,
Efl_Gfx_Buffer_Access_Mode mode,
- int x, int y, int w, int h,
+ const Eina_Rect *region,
Efl_Gfx_Colorspace cspace, int plane,
int *stride)
{
Evas_Image_Data *o = efl_data_scope_get(eo_obj, EFL_CANVAS_IMAGE_INTERNAL_CLASS);
int s = 0, width = 0, height = 0;
Eina_Bool ret = EINA_FALSE;
+ int x, y, w, h;
void *image;
EINA_SAFETY_ON_NULL_RETURN_VAL(slice, EINA_FALSE);
goto end;
}
- if (!w) w = width;
- if (!h) h = height;
+ if (region)
+ {
+ x = region->x;
+ y = region->y;
+ w = region->w;
+ h = region->h;
+ }
+ else
+ {
+ x = y = 0;
+ w = width;
+ h = height;
+ }
- if ((x < 0) || (y < 0) || ((x + w) > width) || ((y + h) > height))
+ if ((x < 0) || (y < 0) || (w <= 0) || (h <= 0) || ((x + w) > width) || ((y + h) > height))
{
ERR("Invalid map dimensions: %dx%d +%d,%d. Image is %dx%d.",
w, h, x, y, width, height);
_efl_canvas_scene3d_efl_gfx_buffer_buffer_map(Eo *eo_obj, void *_pd EINA_UNUSED,
Eina_Rw_Slice *slice,
Efl_Gfx_Buffer_Access_Mode mode,
- int x, int y, int w, int h,
+ const Eina_Rect *region,
Efl_Gfx_Colorspace cspace, int plane,
int *stride)
{
Evas_Canvas3D_Scene_Data *pd_scene;
int width = -1, height = -1, ntex = -1;
unsigned char *pixels = NULL;
+ int x, y, w, h;
size_t len = 0;
EINA_SAFETY_ON_NULL_RETURN_VAL(slice, EINA_FALSE);
pd_scene->surface, &width, &height);
}
- if ((x < 0) || (y < 0) || ((x + w) > width) || ((y + h) > height))
+ if (region)
+ {
+ x = region->x;
+ y = region->y;
+ w = region->w;
+ h = region->h;
+ }
+ else
+ {
+ x = y = 0;
+ w = width;
+ h = height;
+ }
+
+ if ((x < 0) || (y < 0) || (w <= 0) || (h <= 0) || ((x + w) > width) || ((y + h) > height))
{
ERR("Invalid map dimensions : %dx%d +%d,%d. Image is %dx%d.",
w, h, x, y, width, height);
EAPI void
evas_object_image_data_update_add(Evas_Object *obj, int x, int y, int w, int h)
{
+ Eina_Rect r;
+
EVAS_IMAGE_API(obj);
- efl_gfx_buffer_update_add(obj, x, y, w, h);
+ r = EINA_RECT(x, y, w, h);
+ efl_gfx_buffer_update_add(obj, &r);
}
EAPI void
}
EOLIAN static void
-_efl_canvas_image_internal_efl_gfx_buffer_buffer_update_add(Eo *eo_obj, Evas_Image_Data *o, int x, int y, int w, int h)
+_efl_canvas_image_internal_efl_gfx_buffer_buffer_update_add(Eo *eo_obj, Evas_Image_Data *o, const Eina_Rect *region)
{
Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
Eina_Rectangle *r;
+ int x, y, w, h;
int cnt;
+ if (region)
+ {
+ x = region->x;
+ y = region->y;
+ w = region->w;
+ h = region->h;
+ }
+ else
+ {
+ x = y = 0;
+ w = o->cur->image.w;
+ h = o->cur->image.h;
+ }
+
RECTS_CLIP_TO_RECT(x, y, w, h, 0, 0, o->cur->image.w, o->cur->image.h);
if ((w <= 0) || (h <= 0)) return;
if (obj->cur->snapshot)
}
o->written = EINA_TRUE;
}
- efl_gfx_buffer_update_add(eo_obj, 0, 0, o->cur->image.w, o->cur->image.h);
+ efl_gfx_buffer_update_add(eo_obj, NULL);
EVAS_OBJECT_WRITE_IMAGE_FREE_FILE_AND_KEY(o);
}