forked from enlightenment/efl
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.
This commit is contained in:
parent
7d81a16cdb
commit
1a5e307f73
|
@ -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 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_set(Ecore_Wl2_Buffer *buffer, int age);
|
||||||
EAPI void ecore_wl2_buffer_age_inc(Ecore_Wl2_Buffer *buffer);
|
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 Ecore_Wl2_Surface *ecore_wl2_surface_create(Ecore_Wl2_Window *win, Eina_Bool alpha);
|
||||||
EAPI void ecore_wl2_surface_destroy(Ecore_Wl2_Surface *surface);
|
EAPI void ecore_wl2_surface_destroy(Ecore_Wl2_Surface *surface);
|
||||||
|
|
|
@ -711,6 +711,23 @@ ecore_wl2_buffer_age_inc(Ecore_Wl2_Buffer *buffer)
|
||||||
buffer->age++;
|
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 *
|
static Ecore_Wl2_Buffer *
|
||||||
_ecore_wl2_buffer_partial_create(int w, int h, Eina_Bool alpha)
|
_ecore_wl2_buffer_partial_create(int w, int h, Eina_Bool alpha)
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,14 +38,9 @@ _evas_dmabuf_surface_reconfigure(Ecore_Wl2_Surface *s, int w, int h, uint32_t fl
|
||||||
if ((!w) || (!h)) return;
|
if ((!w) || (!h)) return;
|
||||||
EINA_LIST_FOREACH_SAFE(s->buffers, l, tmp, b)
|
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);
|
ecore_wl2_buffer_destroy(b);
|
||||||
s->buffers = eina_list_remove_list(s->buffers, l);
|
s->buffers = eina_list_remove_list(s->buffers, l);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue