Mir

Comment 0 for bug 1288021

Revision history for this message
Daniel van Vugt (vanvugt) wrote : MirResizeEvent's width/height fields are not useful, even dangerous

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:

    eglSwapBuffers(egldisplay, eglsurface);

    if (eglQuerySurface(egldisplay, eglsurface, EGL_WIDTH, &width) &&
        eglQuerySurface(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...