From 4837f3244307f45a812342e114e2a98bc5436743 Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Thu, 5 Apr 2018 14:59:26 -0500 Subject: [PATCH] ecore_wl2: Share same region between input and opaque when possible If input and opaque region are the same (they usually are) we can use the same region for both. --- src/lib/ecore_wl2/ecore_wl2_window.c | 59 +++++++++++++++------------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/src/lib/ecore_wl2/ecore_wl2_window.c b/src/lib/ecore_wl2/ecore_wl2_window.c index c86ea27f03..dee8b0a972 100644 --- a/src/lib/ecore_wl2/ecore_wl2_window.c +++ b/src/lib/ecore_wl2/ecore_wl2_window.c @@ -1545,43 +1545,49 @@ _region_create(struct wl_compositor *comp, int x, int y, int w, int h) } static void -_input_set(Ecore_Wl2_Window *window) +_regions_set(Ecore_Wl2_Window *window) { - struct wl_region *region; + struct wl_region *region = NULL; - if (window->type == ECORE_WL2_WINDOW_TYPE_DND) return; + if (window->pending.opaque) + { + if (window->opaque_set) + { + region = _region_create(window->display->wl.compositor, + window->opaque.x, window->opaque.y, + window->opaque.w, window->opaque.h); + if (!region) return; + } + wl_surface_set_opaque_region(window->surface, region); + } + + if (!window->pending.input) goto out; + if (window->type == ECORE_WL2_WINDOW_TYPE_DND) goto out; if (!window->input_set) { wl_surface_set_input_region(window->surface, NULL); - return; + goto out; } + if (region && (window->opaque.x == window->input_rect.x) && + (window->opaque.y == window->input_rect.y) && + (window->opaque.w == window->input_rect.w) && + (window->opaque.h == window->input_rect.h)) + { + wl_surface_set_input_region(window->surface, region); + goto out; + } + if (region) wl_region_destroy(region); + region = _region_create(window->display->wl.compositor, window->input_rect.x, window->input_rect.y, window->input_rect.w, window->input_rect.h); if (!region) return; wl_surface_set_input_region(window->surface, region); - wl_region_destroy(region); -} -static void -_opaque_set(Ecore_Wl2_Window *window) -{ - struct wl_region *region; - - if (!window->opaque_set) - { - wl_surface_set_opaque_region(window->surface, NULL); - return; - } - - region = _region_create(window->display->wl.compositor, - window->opaque.x, window->opaque.y, - window->opaque.w, window->opaque.h); - if (!region) return; - wl_surface_set_opaque_region(window->surface, region); - wl_region_destroy(region); +out: + if (region) wl_region_destroy(region); } EAPI void @@ -1619,11 +1625,8 @@ ecore_wl2_window_commit(Ecore_Wl2_Window *window, Eina_Bool flush) window->set_config.geometry.w, window->set_config.geometry.h); } - if (window->pending.opaque) - _opaque_set(window); - - if (window->pending.input) - _input_set(window); + if (window->pending.opaque || window->pending.input) + _regions_set(window); if (window->pending.maximized) _maximized_set(window);