From 1a5e307f7304ab998837fc2969a34811ccbec7c1 Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Thu, 25 Jan 2018 17:01:23 -0600 Subject: [PATCH] ecore_wl2: Add buffer_fit API and use it from surface code This tries to resize the buffer's useable area to fit the specified size - this is possible if the stride of the buffer is larger than the current width. --- src/lib/ecore_wl2/Ecore_Wl2.h | 1 + src/lib/ecore_wl2/ecore_wl2_buffer.c | 17 +++++++++++++++++ src/lib/ecore_wl2/ecore_wl2_surface.c | 9 ++------- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h index c1ae6f0542..1f2729e35f 100644 --- a/src/lib/ecore_wl2/Ecore_Wl2.h +++ b/src/lib/ecore_wl2/Ecore_Wl2.h @@ -2012,6 +2012,7 @@ EAPI void ecore_wl2_buffer_busy_set(Ecore_Wl2_Buffer *buffer); EAPI int ecore_wl2_buffer_age_get(Ecore_Wl2_Buffer *buffer); EAPI void ecore_wl2_buffer_age_set(Ecore_Wl2_Buffer *buffer, int age); EAPI void ecore_wl2_buffer_age_inc(Ecore_Wl2_Buffer *buffer); +EAPI Eina_Bool ecore_wl2_buffer_fit(Ecore_Wl2_Buffer *b, int w, int h); EAPI Ecore_Wl2_Surface *ecore_wl2_surface_create(Ecore_Wl2_Window *win, Eina_Bool alpha); EAPI void ecore_wl2_surface_destroy(Ecore_Wl2_Surface *surface); diff --git a/src/lib/ecore_wl2/ecore_wl2_buffer.c b/src/lib/ecore_wl2/ecore_wl2_buffer.c index eefb0e91f3..1a9c5c5af9 100644 --- a/src/lib/ecore_wl2/ecore_wl2_buffer.c +++ b/src/lib/ecore_wl2/ecore_wl2_buffer.c @@ -711,6 +711,23 @@ ecore_wl2_buffer_age_inc(Ecore_Wl2_Buffer *buffer) buffer->age++; } +EAPI Eina_Bool +ecore_wl2_buffer_fit(Ecore_Wl2_Buffer *b, int w, int h) +{ + int stride; + + EINA_SAFETY_ON_NULL_RETURN_VAL(b, EINA_FALSE); + + stride = b->stride; + if ((w >= b->w) && (w <= stride / 4) && (h == b->h)) + { + b->w = w; + return EINA_TRUE; + } + + return EINA_FALSE; +} + static Ecore_Wl2_Buffer * _ecore_wl2_buffer_partial_create(int w, int h, Eina_Bool alpha) { diff --git a/src/lib/ecore_wl2/ecore_wl2_surface.c b/src/lib/ecore_wl2/ecore_wl2_surface.c index ae4e8099ae..bb0d87c4ae 100644 --- a/src/lib/ecore_wl2/ecore_wl2_surface.c +++ b/src/lib/ecore_wl2/ecore_wl2_surface.c @@ -38,14 +38,9 @@ _evas_dmabuf_surface_reconfigure(Ecore_Wl2_Surface *s, int w, int h, uint32_t fl if ((!w) || (!h)) return; EINA_LIST_FOREACH_SAFE(s->buffers, l, tmp, b) { - int stride = b->stride; + if (!force && ecore_wl2_buffer_fit(b, w, h)) + continue; - /* If stride is a little bigger than width we still fit */ - if (!force && (w >= b->w) && (w <= stride / 4) && (h == b->h)) - { - b->w = w; - continue; - } ecore_wl2_buffer_destroy(b); s->buffers = eina_list_remove_list(s->buffers, l); }