This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch evas-buffer-damage-after-norender
in repository efl.
View the commit online.
commit ef0929016b9a1c0ca94228e23ba925b46866c413
Author: Cedric BAIL <[email protected]>
AuthorDate: Wed Dec 2 10:40:41 2026 -0600
evas:buffer: only redraw what changed when the buffer persists
The buffer engine reports MODE_FULL when it has no switch_buffer
callback, so every frame redraws the whole canvas and
evas_render_updates() and EVAS_CALLBACK_RENDER_POST report the whole
canvas as updated. Without switch_buffer the caller's destination is
the same memory every frame and keeps what was drawn, which is what
MODE_COPY means. A compositor that renders its desktop into a buffer
canvas and feeds the updated area to a remote desktop encoder gets
whole-screen damage for a blinking caret, and recomposites all of it.
MODE_FULL was not a deliberate choice. Before bef09531c1 the plain path
(no switch_buffer) drew the damage only and freed its rectangle list
once the last one was handed out; only switch_buffer users got a full
first frame, to seed their buffers. The move to the generic software
infrastructure returned MODE_FULL, and left first_frame set but unused.
Three things come with the switch:
- A destination the engine has not drawn into is stale. A new
dest_buffer of the same size does not mark the output changed, and
the output is recreated with an empty damage list, so nothing forced
a full frame. first_frame is now wired to the generic
outbuf_region_first_rect hook, which makes the first frame after
evas_engine_info_set() or a reconfigure a whole one. This now applies
to every user, not only to switch_buffer ones as before bef09531c1.
Resizes already redrew everything.
- The generic engine frees the rectangles of a frame when the frame is
flushed. A canvas asked for its updates without drawing, as
evas_norender_with_updates() does, is never flushed, so in COPY mode
the stale list hid the damage of every later frame. The elementary
tests drive all their windows that way, and elm_image_test_gif
stopped seeing updates. The buffer engine now drops the list once it
has handed it out; nothing in it reads it afterwards.
- The drop is in the buffer engine and not in software_generic because
other engines read the list at flush time: gl_x11's eng_outbuf_flush()
walks buffer_damage, which is that list, so it cannot go early for
every engine. The engines that keep the stuck-after-
evas_norender_with_updates() behaviour (software_x11, wayland_shm,
drm and the GL engines) are left as they are: nothing in the tree
calls it on them.
Behaviour change for programs that use the installed buffer engine:
- A caller that modifies or clears the destination between frames no
longer gets it repainted; it has to damage what it touched with
evas_damage_rectangle_add().
- new_update_region() callbacks get the real x, y, w and h of each
damaged region, instead of always (0, 0, w, h).
- Areas hidden behind obscuring objects are no longer redrawn.
- EVAS_CALLBACK_RENDER_POST and evas_render_updates() report the
smaller areas.
The other software engines (software_x11, wayland_shm, drm, fb) already
work this way.
evas_textgrid_test_bg_engine_image_dropped wiped the whole canvas and
relied on the whole-canvas redraw. It now wipes the grid only, so it
still shows that dropping the engine images makes the grid damage and
redraw itself.
In-tree users of the buffer engine, checked for reliance on a whole
redraw each frame:
- ecore_evas_buffer.c (ecore_evas_buffer_new,
ecore_evas_buffer_allocfunc_new, ecore_evas_object_image_new): the
resize and alpha paths reallocate the pixels and call
evas_engine_info_set(), now a full frame. The image canvas forwards
updated_area to evas_object_image_data_update_add(), so its parent
gets smaller updates as well.
- ecore_evas_extn and ecore_evas_sdl set switch_buffer and stay in
MODE_DOUBLE.
- elementary (efl_ui_win screenshots), ethumb, edje_cc and
ecore_evas_convert render once into a new canvas.
- ecore_evas_ews does not use the buffer engine.
Tests: the Buffer Damage case in the evas suite moves a small
rectangle on ARGB32, RGB32, BGRA32, padded RGB32, RGB24 and padded
BGR24 destinations (the updates cover the change, are not the whole
canvas, leave a marker pixel alone, and the buffer ends identical to a
one-frame render), uses update region callbacks, replaces the
destination and resizes, and asks a canvas for its updates without
drawing. Against the parent commit 10 of its 11 tests fail; only
evas_buffer_damage_resize passes there, as a canvas resize was already
a whole frame.
Numbers, from the Buffer Damage cases of evas_bench added by the
parent (1920x1080, 48 opaque rectangles and one 32x32 rectangle moving
each frame), plus the Textgrid and Map cases for the workloads that
redraw their whole area. One release build tree (gcc, 16 cores); the
parent's libbuffer.so and this commit's were swapped in the build tree
and run alternately, four runs each, medians below. Totals include
setup and the first full frame; the per-frame figure is the slope
between the 50 and 200 frame points, which leaves both out.
move-rgb32, 200 frames 27.7 ms before 1.6 ms after
move-argb32, 200 frames 33.5 ms before 1.5 ms after
per frame, before about 130 us (rgb32 129, argb32 137)
per frame, after below what the bench resolves (a few us; the
slope is dominated by run-to-run noise of
the setup, so no ratio is claimed beyond the
totals, about 20 times less at 200 frames)
Textgrid palette-render 728.2 ms before 723.4 ms after
Textgrid truecolor 741.9 ms before 748.9 ms after
Map anti-alias-angled 261.6 / 260.9 anti-alias 288.0 / 283.5
Map sampled-angled 268.1 / 265.6 sampled 254.4 / 259.4
Map smooth-angled 266.4 / 267.4 smooth 258.8 / 258.6
(before / after, 400 frames per case, all within the 2 percent spread
of the runs themselves.)
Co-Authored-By: Claude Fable 5.2 <[email protected]>
---
src/modules/evas/engines/buffer/evas_engine.c | 26 +-
src/modules/evas/engines/buffer/evas_engine.h | 1 +
src/modules/evas/engines/buffer/evas_outbuf.c | 13 +-
src/tests/evas/evas_suite.c | 1 +
src/tests/evas/evas_suite.h | 1 +
src/tests/evas/evas_test_buffer_damage.c | 521 ++++++++++++++++++++++++++
src/tests/evas/evas_test_textgrid.c | 9 +-
src/tests/evas/meson.build | 1 +
8 files changed, 568 insertions(+), 5 deletions(-)
diff --git a/src/modules/evas/engines/buffer/evas_engine.c b/src/modules/evas/engines/buffer/evas_engine.c
index 68af1773b4..0326e57e58 100644
--- a/src/modules/evas/engines/buffer/evas_engine.c
+++ b/src/modules/evas/engines/buffer/evas_engine.c
@@ -78,7 +78,7 @@ eng_output_setup(void *engine, void *in, unsigned int w, unsigned int h)
evas_buffer_outbuf_buf_swap_mode_get,
evas_buffer_outbuf_buf_rot_get,
evas_buffer_outbuf_reconfigure,
- NULL,
+ evas_buffer_outbuf_buf_region_first_rect,
NULL,
evas_buffer_outbuf_buf_new_region_for_update,
evas_buffer_outbuf_buf_push_updated_region,
@@ -117,6 +117,29 @@ eng_output_free(void *engine, void *data)
}
}
+/* The generic engine hands the rectangles of a frame out one by one and
+ * frees them when the frame is flushed. A canvas asked for its updates
+ * without drawing, as evas_norender_with_updates() does, is never flushed:
+ * the rectangles would stay and hide the damage of every later frame.
+ * Nothing in the buffer engine reads them once handed out. */
+static void *
+eng_output_redraws_next_update_get(void *engine, void *data,
+ int *x, int *y, int *w, int *h,
+ int *cx, int *cy, int *cw, int *ch)
+{
+ Render_Engine *re = data;
+ void *surface;
+
+ surface = pfunc.output_redraws_next_update_get(engine, data, x, y, w, h,
+ cx, cy, cw, ch);
+ if (!surface && re->rects)
+ {
+ evas_common_tilebuf_free_render_rects(re->rects);
+ re->rects = NULL;
+ }
+ return surface;
+}
+
static Eina_Bool
eng_canvas_alpha_get(void *data)
{
@@ -152,6 +175,7 @@ module_open(Evas_Module *em)
ORD(output_setup);
ORD(canvas_alpha_get);
ORD(output_free);
+ ORD(output_redraws_next_update_get);
/* now advertise out own api */
em->functions = (void *)(&func);
diff --git a/src/modules/evas/engines/buffer/evas_engine.h b/src/modules/evas/engines/buffer/evas_engine.h
index f319b17ae2..a242421f11 100644
--- a/src/modules/evas/engines/buffer/evas_engine.h
+++ b/src/modules/evas/engines/buffer/evas_engine.h
@@ -87,6 +87,7 @@ void *evas_buffer_outbuf_buf_new_region_for_update (Outbuf *buf, int x,
void evas_buffer_outbuf_buf_free_region_for_update (Outbuf *buf, RGBA_Image *update);
void evas_buffer_outbuf_buf_push_updated_region (Outbuf *buf, RGBA_Image *update, int x, int y, int w, int h);
void evas_buffer_outbuf_buf_switch_buffer (Outbuf *buf, Tilebuf_Rect *surface_damage, Tilebuf_Rect *buffer_damage, Evas_Render_Mode render_mode);
+Eina_Bool evas_buffer_outbuf_buf_region_first_rect (Outbuf *buf);
Render_Output_Swap_Mode evas_buffer_outbuf_buf_swap_mode_get(Outbuf *buf);
int evas_buffer_outbuf_buf_rot_get (Outbuf *buf);
diff --git a/src/modules/evas/engines/buffer/evas_outbuf.c b/src/modules/evas/engines/buffer/evas_outbuf.c
index 8a6faafdb3..96f1765a9e 100644
--- a/src/modules/evas/engines/buffer/evas_outbuf.c
+++ b/src/modules/evas/engines/buffer/evas_outbuf.c
@@ -423,11 +423,22 @@ evas_buffer_outbuf_reconfigure(Outbuf *ob, int w, int h, int rot EINA_UNUSED, Ou
switch_data);
}
+/* Only what changed is drawn from one frame to the next, so a destination
+ * the engine was just given has nothing to keep and gets drawn whole. */
+Eina_Bool
+evas_buffer_outbuf_buf_region_first_rect(Outbuf *ob)
+{
+ Eina_Bool first_frame = ob->first_frame;
+
+ ob->first_frame = 0;
+ return first_frame;
+}
+
Render_Output_Swap_Mode
evas_buffer_outbuf_buf_swap_mode_get(Outbuf *ob)
{
if (ob->func.switch_buffer) return MODE_DOUBLE;
- return MODE_FULL;
+ return MODE_COPY;
}
int
diff --git a/src/tests/evas/evas_suite.c b/src/tests/evas/evas_suite.c
index 9e5810ee78..fd4ba4c123 100644
--- a/src/tests/evas/evas_suite.c
+++ b/src/tests/evas/evas_suite.c
@@ -23,6 +23,7 @@ static const Efl_Test_Case etc[] = {
{ "Images", evas_test_image_object2 },
{ "Buffer Scale", evas_test_image_buffer_scale },
{ "Buffer Region", evas_test_buffer_region },
+ { "Buffer Damage", evas_test_buffer_damage },
{ "Masking", evas_test_mask },
{ "Evas GL", evas_test_evasgl },
{ "Object Smart", evas_test_object_smart },
diff --git a/src/tests/evas/evas_suite.h b/src/tests/evas/evas_suite.h
index aae326980f..71c8ba5582 100644
--- a/src/tests/evas/evas_suite.h
+++ b/src/tests/evas/evas_suite.h
@@ -17,6 +17,7 @@ void evas_test_filters(TCase *tc);
void evas_test_image_object(TCase *tc);
void evas_test_image_buffer_scale(TCase *tc);
void evas_test_buffer_region(TCase *tc);
+void evas_test_buffer_damage(TCase *tc);
void evas_test_image_object2(TCase *tc);
void evas_test_mask(TCase *tc);
void evas_test_evasgl(TCase *tc);
diff --git a/src/tests/evas/evas_test_buffer_damage.c b/src/tests/evas/evas_test_buffer_damage.c
new file mode 100644
index 0000000000..0645ea4b2b
--- /dev/null
+++ b/src/tests/evas/evas_test_buffer_damage.c
@@ -0,0 +1,521 @@
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#ifdef BUILD_ENGINE_BUFFER
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <Eina.h>
+#include <Evas.h>
+#include <Evas_Engine_Buffer.h>
+
+#include "evas_suite.h"
+
+/* A buffer canvas without a switch_buffer callback draws into the same
+ * memory every frame, so what was drawn before is still there and only the
+ * changed area has to be redrawn. The areas evas_render_updates() returns
+ * are what a remote desktop encoder gets to look at, so they have to cover
+ * the change and not be the whole canvas.
+ *
+ * Every test builds the scene a second time in a fresh canvas that renders
+ * it in one frame, and compares the two buffers byte for byte. */
+#define CANVAS_W 200
+#define CANVAS_H 120
+
+#define MOVER_W 16
+#define MOVER_H 16
+#define MOVER_X 20
+#define MOVER_Y 80
+#define MOVER_NEW_X 150
+#define MOVER_NEW_Y 90
+
+/* A pixel nothing draws on, used to see whether it is redrawn */
+#define SENTINEL_X (CANVAS_W - 1)
+#define SENTINEL_Y 2
+
+typedef struct _Damage_Canvas Damage_Canvas;
+typedef struct _Damage_Variant Damage_Variant;
+
+struct _Damage_Canvas
+{
+ Evas *e;
+ Evas_Object *mover;
+ unsigned char *pixels;
+ int w;
+ int h;
+ int row_bytes;
+};
+
+struct _Damage_Variant
+{
+ int depth_type;
+ int bytes_per_pixel;
+ int row_padding;
+ Eina_Bool alpha : 1;
+};
+
+static const Damage_Variant _argb32 = { EVAS_ENGINE_BUFFER_DEPTH_ARGB32, 4, 0, EINA_TRUE };
+static const Damage_Variant _rgb32 = { EVAS_ENGINE_BUFFER_DEPTH_RGB32, 4, 0, EINA_FALSE };
+static const Damage_Variant _rgb32_padded = { EVAS_ENGINE_BUFFER_DEPTH_RGB32, 4, 12, EINA_FALSE };
+static const Damage_Variant _rgb24 = { EVAS_ENGINE_BUFFER_DEPTH_RGB24, 3, 0, EINA_FALSE };
+static const Damage_Variant _bgr24_padded = { EVAS_ENGINE_BUFFER_DEPTH_BGR24, 3, 7, EINA_FALSE };
+static const Damage_Variant _bgra32 = { EVAS_ENGINE_BUFFER_DEPTH_BGRA32, 4, 0, EINA_FALSE };
+
+static void
+_buffer_attach(Damage_Canvas *dc, const Damage_Variant *variant, int w, int h)
+{
+ Evas_Engine_Info_Buffer *einfo;
+
+ dc->w = w;
+ dc->h = h;
+ dc->row_bytes = (w * variant->bytes_per_pixel) + variant->row_padding;
+ dc->pixels = malloc(dc->row_bytes * h);
+ fail_if(!dc->pixels);
+ /* what a fresh buffer holds is up to the caller; make it recognisable */
+ memset(dc->pixels, 0x5a, dc->row_bytes * h);
+
+ einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(dc->e);
+ fail_if(!einfo);
+ einfo->info.depth_type = variant->depth_type;
+ einfo->info.dest_buffer = dc->pixels;
+ einfo->info.dest_buffer_row_bytes = dc->row_bytes;
+ einfo->info.use_color_key = 0;
+ einfo->info.alpha_threshold = 0;
+ einfo->info.func.new_update_region = NULL;
+ einfo->info.func.free_update_region = NULL;
+ einfo->info.func.switch_buffer = NULL;
+ fail_if(!evas_engine_info_set(dc->e, (Evas_Engine_Info *)einfo));
+}
+
+static void
+_scene_populate(Damage_Canvas *dc, const Damage_Variant *variant,
+ int mover_x, int mover_y, int mover_color)
+{
+ Evas_Object *o;
+
+ if (!variant->alpha)
+ {
+ o = evas_object_rectangle_add(dc->e);
+ evas_object_color_set(o, 30, 60, 90, 255);
+ evas_object_move(o, 0, 0);
+ evas_object_resize(o, dc->w, dc->h);
+ evas_object_show(o);
+ }
+
+ o = evas_object_rectangle_add(dc->e);
+ evas_object_color_set(o, 200, 30, 10, 255);
+ evas_object_move(o, 10, 10);
+ evas_object_resize(o, 40, 40);
+ evas_object_show(o);
+
+ o = evas_object_rectangle_add(dc->e);
+ evas_object_color_set(o, 0, 100, 0, 100);
+ evas_object_move(o, 100, 50);
+ evas_object_resize(o, 60, 30);
+ evas_object_show(o);
+
+ dc->mover = evas_object_rectangle_add(dc->e);
+ evas_object_color_set(dc->mover, 0, 0, mover_color, mover_color);
+ evas_object_move(dc->mover, mover_x, mover_y);
+ evas_object_resize(dc->mover, MOVER_W, MOVER_H);
+ evas_object_show(dc->mover);
+}
+
+static void
+_canvas_new(Damage_Canvas *dc, const Damage_Variant *variant,
+ int mover_x, int mover_y, int mover_color)
+{
+ int method;
+
+ memset(dc, 0, sizeof(*dc));
+ method = evas_render_method_lookup("buffer");
+ fail_if(method <= 0);
+ dc->e = evas_new();
+ fail_if(!dc->e);
+ evas_output_method_set(dc->e, method);
+ evas_output_size_set(dc->e, CANVAS_W, CANVAS_H);
+ evas_output_viewport_set(dc->e, 0, 0, CANVAS_W, CANVAS_H);
+ _buffer_attach(dc, variant, CANVAS_W, CANVAS_H);
+ _scene_populate(dc, variant, mover_x, mover_y, mover_color);
+}
+
+static void
+_canvas_free(Damage_Canvas *dc)
+{
+ evas_free(dc->e);
+ free(dc->pixels);
+}
+
+static int
+_updates_area(const Eina_List *updates)
+{
+ const Eina_List *l;
+ const Eina_Rectangle *r;
+ int area = 0;
+
+ EINA_LIST_FOREACH(updates, l, r)
+ area += r->w * r->h;
+ return area;
+}
+
+static Eina_Bool
+_updates_cover(const Eina_List *updates, int x, int y, int w, int h)
+{
+ int px, py;
+
+ for (py = y; py < y + h; py++)
+ for (px = x; px < x + w; px++)
+ {
+ const Eina_List *l;
+ const Eina_Rectangle *r;
+ Eina_Bool covered = EINA_FALSE;
+
+ EINA_LIST_FOREACH(updates, l, r)
+ if ((px >= r->x) && (px < r->x + r->w) &&
+ (py >= r->y) && (py < r->y + r->h))
+ {
+ covered = EINA_TRUE;
+ break;
+ }
+ if (!covered) return EINA_FALSE;
+ }
+ return EINA_TRUE;
+}
+
+static Eina_Bool
+_updates_touch(const Eina_List *updates, int x, int y)
+{
+ return _updates_cover(updates, x, y, 1, 1);
+}
+
+/* Compare the visible pixels only: what sits in the row padding is nobody's
+ * business. */
+static void
+_buffers_same(const Damage_Canvas *a, const Damage_Canvas *b,
+ const Damage_Variant *variant)
+{
+ int y;
+
+ ck_assert_int_eq(a->w, b->w);
+ ck_assert_int_eq(a->h, b->h);
+ for (y = 0; y < a->h; y++)
+ {
+ const unsigned char *ra = a->pixels + (y * a->row_bytes);
+ const unsigned char *rb = b->pixels + (y * b->row_bytes);
+ int x;
+
+ for (x = 0; x < a->w * variant->bytes_per_pixel; x++)
+ if (ra[x] != rb[x])
+ ck_abort_msg("pixel byte %d,%d differs: %02x instead of %02x",
+ x, y, ra[x], rb[x]);
+ }
+}
+
+/* The first frame draws everything; after that moving and recoloring the
+ * small rectangle must redraw about that and keep the rest of the buffer. */
+static void
+_partial_update_check(const Damage_Variant *variant)
+{
+ Damage_Canvas dc, ref;
+ Eina_List *updates;
+ unsigned char *sentinel;
+ unsigned char sentinel_before[4];
+
+ _canvas_new(&dc, variant, MOVER_X, MOVER_Y, 255);
+
+ updates = evas_render_updates(dc.e);
+ ck_assert_int_eq(eina_list_count(updates), 1);
+ fail_unless(_updates_cover(updates, 0, 0, CANVAS_W, CANVAS_H));
+ evas_render_updates_free(updates);
+
+ /* Nothing redraws this pixel when only the rectangle changes. A marker
+ * left in it shows whether the frame touched it. */
+ sentinel = dc.pixels + (SENTINEL_Y * dc.row_bytes) +
+ (SENTINEL_X * variant->bytes_per_pixel);
+ memcpy(sentinel_before, sentinel, variant->bytes_per_pixel);
+ memset(sentinel, 0xc3, variant->bytes_per_pixel);
+
+ evas_object_move(dc.mover, MOVER_NEW_X, MOVER_NEW_Y);
+ evas_object_color_set(dc.mover, 0, 0, 128, 128);
+ updates = evas_render_updates(dc.e);
+
+ fail_unless(_updates_cover(updates, MOVER_X, MOVER_Y, MOVER_W, MOVER_H));
+ fail_unless(_updates_cover(updates, MOVER_NEW_X, MOVER_NEW_Y,
+ MOVER_W, MOVER_H));
+ fail_if(_updates_touch(updates, SENTINEL_X, SENTINEL_Y));
+ fail_unless(_updates_area(updates) < (CANVAS_W * CANVAS_H) / 4);
+ evas_render_updates_free(updates);
+
+ ck_assert_int_eq(sentinel[0], 0xc3);
+ memcpy(sentinel, sentinel_before, variant->bytes_per_pixel);
+
+ _canvas_new(&ref, variant, MOVER_NEW_X, MOVER_NEW_Y, 128);
+ updates = evas_render_updates(ref.e);
+ evas_render_updates_free(updates);
+ _buffers_same(&dc, &ref, variant);
+
+ /* A frame with nothing to draw stays that way */
+ updates = evas_render_updates(dc.e);
+ ck_assert_int_eq(eina_list_count(updates), 0);
+ evas_render_updates_free(updates);
+
+ _canvas_free(&ref);
+ _canvas_free(&dc);
+}
+
+EFL_START_TEST(evas_buffer_damage_argb32)
+{
+ _partial_update_check(&_argb32);
+}
+EFL_END_TEST
+
+EFL_START_TEST(evas_buffer_damage_rgb32)
+{
+ _partial_update_check(&_rgb32);
+}
+EFL_END_TEST
+
+EFL_START_TEST(evas_buffer_damage_bgra32)
+{
+ _partial_update_check(&_bgra32);
+}
+EFL_END_TEST
+
+/* The row is wider than the canvas, so the engine cannot draw in place and
+ * copies each region. The copy has to land at the region's column. */
+EFL_START_TEST(evas_buffer_damage_rgb32_padded)
+{
+ _partial_update_check(&_rgb32_padded);
+}
+EFL_END_TEST
+
+EFL_START_TEST(evas_buffer_damage_rgb24)
+{
+ _partial_update_check(&_rgb24);
+}
+EFL_END_TEST
+
+EFL_START_TEST(evas_buffer_damage_bgr24_padded)
+{
+ _partial_update_check(&_bgr24_padded);
+}
+EFL_END_TEST
+
+/* The engine API has no user data for the region callbacks, so the buffer
+ * they hand out is a global of the test. */
+static unsigned char *_region_pixels;
+static int _region_row_bytes;
+static int _region_requests;
+static int _region_released;
+static int _region_area;
+
+static void *
+_region_new(int x, int y, int w, int h, int *row_bytes)
+{
+ _region_requests++;
+ _region_area += w * h;
+ *row_bytes = _region_row_bytes;
+ return _region_pixels + (y * _region_row_bytes) + (x * 4);
+}
+
+static void
+_region_free(int x EINA_UNUSED, int y EINA_UNUSED, int w EINA_UNUSED,
+ int h EINA_UNUSED, void *region EINA_UNUSED)
+{
+ _region_released++;
+}
+
+/* The caller hands out the memory of each region. It has to be asked for the
+ * changed region only, and be given the pixels of that region. */
+EFL_START_TEST(evas_buffer_damage_update_region_callbacks)
+{
+ Damage_Canvas dc, ref;
+ Evas_Engine_Info_Buffer *einfo;
+ Eina_List *updates;
+
+ _canvas_new(&dc, &_rgb32_padded, MOVER_X, MOVER_Y, 255);
+ _region_pixels = dc.pixels;
+ _region_row_bytes = dc.row_bytes;
+ einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(dc.e);
+ fail_if(!einfo);
+ einfo->info.func.new_update_region = _region_new;
+ einfo->info.func.free_update_region = _region_free;
+ fail_if(!evas_engine_info_set(dc.e, (Evas_Engine_Info *)einfo));
+
+ updates = evas_render_updates(dc.e);
+ evas_render_updates_free(updates);
+ ck_assert_int_eq(_region_requests, _region_released);
+
+ _region_requests = 0;
+ _region_released = 0;
+ _region_area = 0;
+ evas_object_move(dc.mover, MOVER_NEW_X, MOVER_NEW_Y);
+ evas_object_color_set(dc.mover, 0, 0, 128, 128);
+ updates = evas_render_updates(dc.e);
+ evas_render_updates_free(updates);
+ fail_unless(_region_requests > 0);
+ ck_assert_int_eq(_region_requests, _region_released);
+ fail_unless(_region_area < (CANVAS_W * CANVAS_H) / 4);
+
+ _canvas_new(&ref, &_rgb32_padded, MOVER_NEW_X, MOVER_NEW_Y, 128);
+ updates = evas_render_updates(ref.e);
+ evas_render_updates_free(updates);
+ _buffers_same(&dc, &ref, &_rgb32_padded);
+
+ _canvas_free(&ref);
+ _canvas_free(&dc);
+}
+EFL_END_TEST
+
+/* A new destination buffer holds nothing of what was drawn before, so the
+ * next frame has to be a whole one. */
+static void
+_destination_change_check(const Damage_Variant *variant)
+{
+ Damage_Canvas dc, ref;
+ Eina_List *updates;
+ unsigned char *old_pixels;
+
+ _canvas_new(&dc, variant, MOVER_X, MOVER_Y, 255);
+ updates = evas_render_updates(dc.e);
+ evas_render_updates_free(updates);
+
+ old_pixels = dc.pixels;
+ _buffer_attach(&dc, variant, CANVAS_W, CANVAS_H);
+ free(old_pixels);
+ evas_object_move(dc.mover, MOVER_NEW_X, MOVER_NEW_Y);
+ updates = evas_render_updates(dc.e);
+ fail_unless(_updates_cover(updates, 0, 0, CANVAS_W, CANVAS_H));
+ evas_render_updates_free(updates);
+
+ _canvas_new(&ref, variant, MOVER_NEW_X, MOVER_NEW_Y, 255);
+ updates = evas_render_updates(ref.e);
+ evas_render_updates_free(updates);
+ _buffers_same(&dc, &ref, variant);
+ _canvas_free(&ref);
+
+ /* and from there on only what changes is drawn again */
+ evas_object_move(dc.mover, MOVER_X, MOVER_Y);
+ updates = evas_render_updates(dc.e);
+ fail_unless(_updates_area(updates) < (CANVAS_W * CANVAS_H) / 4);
+ evas_render_updates_free(updates);
+ _canvas_new(&ref, variant, MOVER_X, MOVER_Y, 255);
+ updates = evas_render_updates(ref.e);
+ evas_render_updates_free(updates);
+ _buffers_same(&dc, &ref, variant);
+
+ _canvas_free(&ref);
+ _canvas_free(&dc);
+}
+
+EFL_START_TEST(evas_buffer_damage_destination_change_argb32)
+{
+ _destination_change_check(&_argb32);
+}
+EFL_END_TEST
+
+EFL_START_TEST(evas_buffer_damage_destination_change_rgb24)
+{
+ _destination_change_check(&_rgb24);
+}
+EFL_END_TEST
+
+/* A different size comes with a new buffer: one whole frame at the new size */
+EFL_START_TEST(evas_buffer_damage_resize)
+{
+ Damage_Canvas dc, ref;
+ Eina_List *updates;
+ unsigned char *old_pixels;
+ const int new_w = CANVAS_W + 40;
+ const int new_h = CANVAS_H - 20;
+
+ _canvas_new(&dc, &_argb32, MOVER_X, MOVER_Y, 255);
+ updates = evas_render_updates(dc.e);
+ evas_render_updates_free(updates);
+
+ old_pixels = dc.pixels;
+ evas_output_size_set(dc.e, new_w, new_h);
+ evas_output_viewport_set(dc.e, 0, 0, new_w, new_h);
+ _buffer_attach(&dc, &_argb32, new_w, new_h);
+ free(old_pixels);
+ updates = evas_render_updates(dc.e);
+ fail_unless(_updates_cover(updates, 0, 0, new_w, new_h));
+ evas_render_updates_free(updates);
+
+ memset(&ref, 0, sizeof(ref));
+ ref.e = evas_new();
+ fail_if(!ref.e);
+ evas_output_method_set(ref.e, evas_render_method_lookup("buffer"));
+ evas_output_size_set(ref.e, new_w, new_h);
+ evas_output_viewport_set(ref.e, 0, 0, new_w, new_h);
+ _buffer_attach(&ref, &_argb32, new_w, new_h);
+ _scene_populate(&ref, &_argb32, MOVER_X, MOVER_Y, 255);
+ updates = evas_render_updates(ref.e);
+ evas_render_updates_free(updates);
+ _buffers_same(&dc, &ref, &_argb32);
+
+ _canvas_free(&ref);
+ _canvas_free(&dc);
+}
+EFL_END_TEST
+
+/* Asking for the updates of a frame without drawing it, as the elementary
+ * tests do to run their layout and events, must not make the canvas forget
+ * what changes next. The frame that was not drawn leaves the buffer as it
+ * was, so the next one has to erase the mover where the last real frame
+ * drew it. */
+EFL_START_TEST(evas_buffer_damage_after_norender_with_updates)
+{
+ Damage_Canvas dc, ref;
+ Eina_List *updates;
+
+ _canvas_new(&dc, &_rgb32, MOVER_X, MOVER_Y, 255);
+ updates = evas_render_updates(dc.e);
+ evas_render_updates_free(updates);
+
+ evas_object_move(dc.mover, MOVER_NEW_X, MOVER_NEW_Y);
+ evas_norender_with_updates(dc.e);
+
+ evas_object_move(dc.mover, 60, 30);
+ updates = evas_render_updates(dc.e);
+ fail_unless(_updates_cover(updates, 60, 30, MOVER_W, MOVER_H));
+ fail_unless(_updates_cover(updates, MOVER_X, MOVER_Y, MOVER_W, MOVER_H));
+ fail_unless(_updates_area(updates) < (CANVAS_W * CANVAS_H) / 4);
+ evas_render_updates_free(updates);
+
+ _canvas_new(&ref, &_rgb32, 60, 30, 255);
+ updates = evas_render_updates(ref.e);
+ evas_render_updates_free(updates);
+ _buffers_same(&dc, &ref, &_rgb32);
+
+ _canvas_free(&ref);
+ _canvas_free(&dc);
+}
+EFL_END_TEST
+
+void
+evas_test_buffer_damage(TCase *tc)
+{
+ tcase_add_test(tc, evas_buffer_damage_argb32);
+ tcase_add_test(tc, evas_buffer_damage_rgb32);
+ tcase_add_test(tc, evas_buffer_damage_bgra32);
+ tcase_add_test(tc, evas_buffer_damage_rgb32_padded);
+ tcase_add_test(tc, evas_buffer_damage_rgb24);
+ tcase_add_test(tc, evas_buffer_damage_bgr24_padded);
+ tcase_add_test(tc, evas_buffer_damage_update_region_callbacks);
+ tcase_add_test(tc, evas_buffer_damage_destination_change_argb32);
+ tcase_add_test(tc, evas_buffer_damage_destination_change_rgb24);
+ tcase_add_test(tc, evas_buffer_damage_resize);
+ tcase_add_test(tc, evas_buffer_damage_after_norender_with_updates);
+}
+
+#else
+
+void
+evas_test_buffer_damage(TCase *tc EINA_UNUSED)
+{
+}
+
+#endif
diff --git a/src/tests/evas/evas_test_textgrid.c b/src/tests/evas/evas_test_textgrid.c
index 7fb79de411..768fb2a0b3 100644
--- a/src/tests/evas/evas_test_textgrid.c
+++ b/src/tests/evas/evas_test_textgrid.c
@@ -691,16 +691,19 @@ EFL_START_TEST(evas_textgrid_test_bg_engine_image_dropped)
Evas_Object *tg = _textgrid_new(e);
Model model;
unsigned int *pix;
- int i;
+ int i, y;
evas_object_textgrid_truecolor_set(tg, EINA_TRUE);
_model_fill(model, GRID_W, GRID_H);
_model_apply(tg, model, 0, 0, GRID_W - 1, GRID_H - 1);
_model_snapshot_check(ee, model, GRID_W, GRID_H);
- /* Wipe what the canvas shows: only a redraw can bring it back */
+ /* Wipe what the grid shows: only a redraw can bring it back. A buffer
+ * canvas keeps its pixels and redraws what is damaged, so the grid has
+ * to damage itself when its images are dropped. */
pix = (unsigned int *)ecore_evas_buffer_pixels_get(ee);
- for (i = 0; i < CANVAS_W * CANVAS_H; i++) pix[i] = 0x55aa55aa;
+ for (y = 0; y < ch * GRID_H; y++)
+ for (i = 0; i < cw * GRID_W; i++) pix[(y * CANVAS_W) + i] = 0x55aa55aa;
_evas_canvas_image_data_regenerate(_evas_canvas_image_data_unset(e));
_model_snapshot_check(ee, model, GRID_W, GRID_H);
diff --git a/src/tests/evas/meson.build b/src/tests/evas/meson.build
index d538977e71..ca1153df65 100644
--- a/src/tests/evas/meson.build
+++ b/src/tests/evas/meson.build
@@ -17,6 +17,7 @@ evas_suite_src = [
'evas_test_image.c',
'evas_test_buffer_scale.c',
'evas_test_buffer_region.c',
+ 'evas_test_buffer_damage.c',
'evas_test_mask.c',
'evas_test_evasgl.c',
'evas_test_focus.c',
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.