diff --git a/include/wayland-eglsurface.h b/include/wayland-eglsurface.h index c4f0d02..5a4b41f 100644 --- a/include/wayland-eglsurface.h +++ b/include/wayland-eglsurface.h @@ -160,7 +160,9 @@ EGLBoolean wlEglQueryNativeResourceHook(EGLDisplay dpy, int *value); EGLBoolean wlEglSendDamageEvent(WlEglSurface *surface, - struct wl_event_queue *queue); + struct wl_event_queue *queue, + EGLint *rects, + EGLint n_rects); void wlEglCreateFrameSync(WlEglSurface *surface); EGLint wlEglWaitFrameSync(WlEglSurface *surface); diff --git a/src/wayland-eglsurface.c b/src/wayland-eglsurface.c index 78e1fa6..16eae97 100644 --- a/src/wayland-eglsurface.c +++ b/src/wayland-eglsurface.c @@ -161,9 +161,13 @@ EGLint wlEglWaitFrameSync(WlEglSurface *surface) } EGLBoolean -wlEglSendDamageEvent(WlEglSurface *surface, struct wl_event_queue *queue) +wlEglSendDamageEvent(WlEglSurface *surface, + struct wl_event_queue *queue, + EGLint *rects, + EGLint n_rects) { struct wl_display *wlDpy = surface->wlEglDpy->nativeDpy; + EGLint i; if (surface->ctx.wlStreamResource) { /* Attach same buffer to indicate new content for the surface is @@ -191,8 +195,21 @@ wlEglSendDamageEvent(WlEglSurface *surface, struct wl_event_queue *queue) surface->dy); } - wl_surface_damage(surface->wlSurface, 0, 0, - surface->width, surface->height); + if (n_rects > 0 && + (wl_proxy_get_version((struct wl_proxy *)surface->wlSurface) >= + WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION)) { + for (i = 0; i < n_rects; i++) { + int y = rects[i*4+1] + rects[i*4+3]; + wl_surface_damage_buffer(surface->wlSurface, + rects[i*4], + surface->height - y, + rects[i*4+2], + rects[i*4+3]); + } + } else { + wl_surface_damage(surface->wlSurface, 0, 0, UINT32_MAX, UINT32_MAX); + } + wl_surface_commit(surface->wlSurface); surface->ctx.isAttached = EGL_TRUE; @@ -257,7 +274,7 @@ damage_thread(void *args) data->egl.streamFlush(display->devDpy->eglDisplay, surface->ctx.eglStream); } - ok = wlEglSendDamageEvent(surface, queue); + ok = wlEglSendDamageEvent(surface, queue, NULL, 0); surface->ctx.framesProcessed++; } diff --git a/src/wayland-eglswap.c b/src/wayland-eglswap.c index 22d3267..74e8e3a 100644 --- a/src/wayland-eglswap.c +++ b/src/wayland-eglswap.c @@ -125,7 +125,7 @@ EGLBoolean wlEglSwapBuffersWithDamageHook(EGLDisplay eglDisplay, EGLSurface eglS if (surface->ctx.useDamageThread) { surface->ctx.framesProduced++; } else { - res = wlEglSendDamageEvent(surface, surface->wlEventQueue); + res = wlEglSendDamageEvent(surface, surface->wlEventQueue, rects, n_rects); } } wlEglCreateFrameSync(surface); @@ -285,7 +285,7 @@ EGLBoolean wlEglPostPresentExport(WlEglSurface *surface) { if (surface->ctx.useDamageThread) { surface->ctx.framesProduced++; } else { - res = wlEglSendDamageEvent(surface, surface->wlEventQueue); + res = wlEglSendDamageEvent(surface, surface->wlEventQueue, NULL, 0); } wlEglCreateFrameSync(surface);