diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h index 86cf12389a..d3c5f40f23 100644 --- a/src/lib/ecore_wl2/Ecore_Wl2.h +++ b/src/lib/ecore_wl2/Ecore_Wl2.h @@ -689,6 +689,25 @@ EAPI void ecore_wl2_subsurface_place_below(Ecore_Wl2_Subsurface *subsurface, str */ EAPI void ecore_wl2_subsurface_sync_set(Ecore_Wl2_Subsurface *subsurface, Eina_Bool sync); +/** + * Set an opaque region for the given subsurface. + * + * This is an optimization hint to the compositor to allow it avoid + * redrawing content unnecessarily. Note that marking transparent + * content as opaque will cause repaint artifacts. + * + * Use a 0x0 region size to unset the opaque region. + * + * @param subsurface the subsurface + * @param x coordinate in the parent surface + * @param y coordinate in the parent surface + * @param w width to set as opaque + * @param h height to set as opaque + * + * @ingroup Ecore_Wl2_Subsurface_Group + */ +EAPI void ecore_wl2_subsurface_opaque_region_set(Ecore_Wl2_Subsurface *subsurface, int x, int y, int w, int h); + /* # ifdef __cplusplus */ /* } */ /* # endif */ diff --git a/src/lib/ecore_wl2/ecore_wl2_subsurf.c b/src/lib/ecore_wl2/ecore_wl2_subsurf.c index 2456fd2aaa..254df53db6 100644 --- a/src/lib/ecore_wl2/ecore_wl2_subsurf.c +++ b/src/lib/ecore_wl2/ecore_wl2_subsurf.c @@ -143,3 +143,35 @@ ecore_wl2_subsurface_sync_set(Ecore_Wl2_Subsurface *subsurface, Eina_Bool sync) else wl_subsurface_set_desync(subsurface->wl.subsurface); } + +EAPI void +ecore_wl2_subsurface_opaque_region_set(Ecore_Wl2_Subsurface *subsurface, int x, int y, int w, int h) +{ + EINA_SAFETY_ON_NULL_RETURN(subsurface); + EINA_SAFETY_ON_NULL_RETURN(subsurface->wl.subsurface); + + if ((w > 0) && (h > 0)) + { + Ecore_Wl2_Window *parent; + + parent = subsurface->parent; + if (parent) + { + struct wl_region *region; + + region = + wl_compositor_create_region(parent->display->wl.compositor); + if (!region) + { + ERR("Failed to create opaque region: %m"); + return; + } + + wl_region_add(region, x, y, w, h); + wl_surface_set_opaque_region(subsurface->wl.surface, region); + wl_region_destroy(region); + } + } + else + wl_surface_set_opaque_region(subsurface->wl.surface, NULL); +}