Fixed buffer submit and callback cleanup.

* Buffer submit now ignores duplicate buffer submit again.
* Frame callback is cleaned up in the callback function now.
* Damage region is currently ignored as there are screen artifacts otherwise.
This commit is contained in:
Armin Novak 2019-01-25 10:50:07 +01:00
parent 823411c2f3
commit b1e6e232ee
2 changed files with 9 additions and 18 deletions

View File

@ -223,7 +223,6 @@ struct uwac_window {
struct wl_region *opaque_region;
struct wl_region *input_region;
struct wl_callback *frame_callback;
UwacBuffer *drawingBuffer, *pendingBuffer;
struct wl_surface *surface;
struct wl_shell_surface *shell_surface;

View File

@ -515,9 +515,6 @@ UwacReturnCode UwacDestroyWindow(UwacWindow** pwindow)
w = *pwindow;
UwacWindowDestroyBuffers(w);
if (w->frame_callback)
wl_callback_destroy(w->frame_callback);
if (w->deco)
zxdg_toplevel_decoration_v1_destroy(w->deco);
@ -607,6 +604,7 @@ static void UwacSubmitBufferPtr(UwacWindow* window, UwacBuffer* buffer)
const RECTANGLE_16* box;
#endif
wl_surface_attach(window->surface, buffer->wayland_buffer, 0, 0);
#if 0
#ifdef HAVE_PIXMAN_REGION
box = pixman_region32_rectangles(&buffer->damage, &nrects);
@ -621,12 +619,11 @@ static void UwacSubmitBufferPtr(UwacWindow* window, UwacBuffer* buffer)
(box->bottom - box->top));
#endif
if (window->frame_callback)
wl_callback_destroy(window->frame_callback);
window->frame_callback = wl_surface_frame(window->surface);
wl_callback_add_listener(window->frame_callback, &frame_listener, window);
#else
wl_surface_damage(window->surface, 0, 0, window->width, window->height);
#endif
struct wl_callback* frame_callback = wl_surface_frame(window->surface);
wl_callback_add_listener(frame_callback, &frame_listener, window);
wl_surface_commit(window->surface);
#ifdef HAVE_PIXMAN_REGION
pixman_region32_clear(&buffer->damage);
@ -640,6 +637,8 @@ static void frame_done_cb(void* data, struct wl_callback* callback, uint32_t tim
{
UwacWindow* window = (UwacWindow*)data;
UwacFrameDoneEvent* event;
wl_callback_destroy(callback);
window->pendingBuffer = NULL;
event = (UwacFrameDoneEvent*)UwacDisplayNewEvent(window->display, UWAC_EVENT_FRAME_DONE);
@ -692,14 +691,8 @@ UwacReturnCode UwacWindowSubmitBuffer(UwacWindow* window, bool copyContentForNex
UwacBuffer* drawingBuffer = window->drawingBuffer;
if (window->pendingBuffer)
{
/* we already have a pending frame. resubmit as the buffer
* might have been discarded due to focus loss */
UwacSubmitBufferPtr(window, window->pendingBuffer);
return UWAC_SUCCESS;
}
UwacSubmitBufferPtr(window, drawingBuffer);
window->pendingBuffer = window->drawingBuffer;
window->drawingBuffer = UwacWindowFindFreeBuffer(window);
@ -707,10 +700,9 @@ UwacReturnCode UwacWindowSubmitBuffer(UwacWindow* window, bool copyContentForNex
return UWAC_ERROR_NOMEMORY;
if (copyContentForNextFrame)
{
memcpy(window->drawingBuffer->data, window->pendingBuffer->data, window->stride * window->height);
}
UwacSubmitBufferPtr(window, drawingBuffer);
return UWAC_SUCCESS;
}