MirResizeEvent's width/height fields are not useful, even dangerous.
This is because they represent the latest dimensions of a surface. However, due to compositing and frame scheduling, MirResizeEvent arrives a significant time before the client gets any buffers with the new dimensions. So if the client actually tries to use the width/height provided in MirResizeEvent, it will render incorrectly with ugly artefacts.
Clients should always be using the latest _buffer_ dimensions, and not the latest surface dimensions. As demonstrated in examples/* the latest buffer dimensions are available via:
mir_buffer_usage_software: Use the width/height returned by mir_surface_get_graphics_region().
mir_buffer_usage_hardware: Use the actual buffer dimensions as accurately reported by EGL as soon as you get a new buffer from eglSwapBuffers:
This is current best practice, and will result in smooth client resizing. Unfortunately it means the width/height fields in the MirResizeEvent structure should be ignored. Perhaps we need to deprecate them, or perhaps we should enhance them to represent buffer dimensions instead...
MirResizeEvent's width/height fields are not useful, even dangerous.
This is because they represent the latest dimensions of a surface. However, due to compositing and frame scheduling, MirResizeEvent arrives a significant time before the client gets any buffers with the new dimensions. So if the client actually tries to use the width/height provided in MirResizeEvent, it will render incorrectly with ugly artefacts.
Clients should always be using the latest _buffer_ dimensions, and not the latest surface dimensions. As demonstrated in examples/* the latest buffer dimensions are available via:
mir_buffer_ usage_software: Use the width/height returned by mir_surface_ get_graphics_ region( ).
mir_buffer_ usage_hardware: Use the actual buffer dimensions as accurately reported by EGL as soon as you get a new buffer from eglSwapBuffers:
eglSwapBuff ers(egldisplay, eglsurface);
if (eglQuerySurfac e(egldisplay, eglsurface, EGL_WIDTH, &width) &&
eglQuerySurfac e(egldisplay, eglsurface, EGL_HEIGHT, &height))
glViewport( 0, 0, width, height);
{
}
This is current best practice, and will result in smooth client resizing. Unfortunately it means the width/height fields in the MirResizeEvent structure should be ignored. Perhaps we need to deprecate them, or perhaps we should enhance them to represent buffer dimensions instead...