This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch crop-showcase
in repository expedite.

View the commit online.

commit eecff54d45c4d368adc1ccda2437a6ca788bb94f
Author: Cedric BAIL <[email protected]>
AuthorDate: Sat Aug 8 10:45:30 2026 -0600

    add an Image Crop Pan Zoom test
    
    Showcases Efl.Gfx.Image.buffer_crop, which selects a sub-rectangle of the
    pixel buffer that is then scaled into the area the whole buffer would have
    filled.
    
    Sixteen tiles each hold a fixed box on screen and animate only the source
    rectangle, so the content pans and magnifies inside a frame that never
    moves or resizes. That is the part worth showing: a clipper cannot do it,
    because clipping restricts which canvas pixels are painted and never
    changes which source pixels are sampled. The zoom sweeps all the way out
    to the full buffer, so each cycle passes through the uncropped image on
    its way to a deep magnification.
    
    It is also a real workload for the scaler, which sees a different source
    rectangle and a different scale factor on every object every frame, with
    none of it served from a cached scaling of the whole image.
    
    Needs an EFL carrying buffer_crop; it is not in any release yet.
    
    Co-Authored-By: Claude Opus 5 <[email protected]>
---
 src/bin/Makefile.am           |   1 +
 src/bin/image_crop_pan_zoom.c | 123 ++++++++++++++++++++++++++++++++++++++++++
 src/bin/meson.build           |   1 +
 src/bin/tests.h               |   1 +
 4 files changed, 126 insertions(+)

diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
index c84619c..70252df 100644
--- a/src/bin/Makefile.am
+++ b/src/bin/Makefile.am
@@ -51,6 +51,7 @@ image_blend_solid_middle_border.c \
 image_blend_solid_border.c \
 image_blend_solid_stretch.c \
 image_blend_solid_9patch.c \
+image_crop_pan_zoom.c \
 image_blend_border_recolor.c \
 image_map_rotate.c \
 image_map_solid_rotate.c \
diff --git a/src/bin/image_crop_pan_zoom.c b/src/bin/image_crop_pan_zoom.c
new file mode 100644
index 0000000..f2cee33
--- /dev/null
+++ b/src/bin/image_crop_pan_zoom.c
@@ -0,0 +1,123 @@
+#undef FNAME
+#undef NAME
+#undef ICON
+
+/* metadata */
+#define FNAME image_crop_pan_zoom_start
+#define NAME "Image Crop Pan Zoom"
+#define ICON "blend.png"
+
+#ifndef PROTO
+# ifndef UI
+#  include "main.h"
+
+/* standard var */
+static int done = 0;
+
+/* im1.png */
+#define SRC_W 720
+#define SRC_H 420
+
+#define GRID_W 4
+#define GRID_H 4
+#define CROP_OBNUM (GRID_W * GRID_H)
+
+/* private data */
+static Evas_Object *o_images[CROP_OBNUM];
+
+/* setup */
+static void _setup(void)
+{
+   int i;
+   Evas_Object *o;
+
+   for (i = 0; i < CROP_OBNUM; i++)
+     {
+        o = efl_add(EFL_CANVAS_IMAGE_CLASS, evas);
+        o_images[i] = o;
+        efl_file_simple_load(o, build_path("im1.png"), NULL);
+        efl_gfx_entity_visible_set(o, EINA_TRUE);
+     }
+   done = 0;
+}
+
+/* cleanup */
+static void _cleanup(void)
+{
+   int i;
+   for (i = 0; i < CROP_OBNUM; i++) efl_del(o_images[i]);
+}
+
+/* loop - do things */
+static void _loop(double t, int f)
+{
+   int i;
+   Evas_Coord x, y, w, h;
+
+   /* Every object keeps a fixed box on screen. Only the source rectangle
+    * moves, so the content pans and magnifies inside a frame that never
+    * changes -- which is what tells crop apart from clipping. The zoom
+    * sweeps all the way out to the whole buffer, so the two ends of the
+    * cycle show the uncropped image and a deep magnification. */
+   w = win_w / GRID_W;
+   h = win_h / GRID_H;
+
+   for (i = 0; i < CROP_OBNUM; i++)
+     {
+        double phase, zoom, px, py;
+        int cx, cy, cw, ch;
+
+        x = (i % GRID_W) * w;
+        y = (i / GRID_W) * h;
+        efl_gfx_entity_position_set(o_images[i], EINA_POSITION2D(x, y));
+        efl_gfx_entity_size_set(o_images[i], EINA_SIZE2D(w, h));
+        efl_gfx_fill_set(o_images[i], EINA_RECT(0, 0, w, h));
+
+        phase = f + (i * 11);
+
+        /* 0.15 (deep zoom) .. 1.0 (the whole buffer) */
+        zoom = 0.15 + (0.425 * (1.0 + cos(phase / (30.0 * SLOW))));
+        cw = SRC_W * zoom;
+        ch = SRC_H * zoom;
+
+        /* Pan the window over whatever room the zoom leaves, so the crop
+         * always stays inside the buffer and never has to be clamped. */
+        px = 0.5 + (0.5 * sin(phase / (23.0 * SLOW)));
+        py = 0.5 + (0.5 * cos(phase / (17.0 * SLOW)));
+        cx = (SRC_W - cw) * px;
+        cy = (SRC_H - ch) * py;
+
+        efl_gfx_image_buffer_crop_set(o_images[i], EINA_RECT(cx, cy, cw, ch));
+     }
+   FPS_STD(NAME);
+}
+
+/* prepend special key handlers if interactive (before STD) */
+static void _key(const char *key)
+{
+   KEY_STD;
+}
+
+/* template stuff - ignore */
+# endif
+#endif
+
+#ifdef UI
+_ui_menu_item_add(ICON, NAME, FNAME);
+#endif
+
+#ifdef PROTO
+void FNAME(void);
+#endif
+
+#ifndef PROTO
+# ifndef UI
+void FNAME(void)
+{
+   ui_func_set(_key, _loop, _setup);
+}
+# endif
+#endif
+#undef FNAME
+#undef NAME
+#undef ICON
diff --git a/src/bin/meson.build b/src/bin/meson.build
index 672e82d..c39a3e7 100644
--- a/src/bin/meson.build
+++ b/src/bin/meson.build
@@ -40,6 +40,7 @@ expedite_sources = [ 'main.c',
 	'image_blend_solid_border.c',
 	'image_blend_solid_stretch.c',
 	'image_blend_solid_9patch.c',
+	'image_crop_pan_zoom.c',
 	'image_blend_border_recolor.c',
 	'image_map_rotate.c',
 	'image_map_solid_rotate.c',
diff --git a/src/bin/tests.h b/src/bin/tests.h
index 55c3aa6..783a4c1 100644
--- a/src/bin/tests.h
+++ b/src/bin/tests.h
@@ -33,6 +33,7 @@
 #include "image_blend_solid_border.c"
 #include "image_blend_solid_stretch.c"
 #include "image_blend_solid_9patch.c"
+#include "image_crop_pan_zoom.c"
 #include "image_blend_border_recolor.c"
 #include "image_map_rotate.c"
 #include "image_map_solid_rotate.c"

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to