Process for implementing a double buffer on Wayland

Mike Johnson mikeyj001 at hotmail.com
Wed Nov 25 08:51:45 PST 2015



> Date: Wed, 25 Nov 2015 16:18:52 +0000
> Subject: Re: Process for implementing a double buffer on Wayland
> From: daniel at fooishbar.org
> To: mikeyj001 at hotmail.com
> CC: wayland-devel at lists.freedesktop.org
> 
> Hi Mike,
> 
> On 25 November 2015 at 16:06, Mike Johnson <mikeyj001 at hotmail.com> wrote:
> > I've created 2 buffers of the same size (800x600 pixels).  So I want the
> > input buffer to get filled off-screen, while the output buffer will show the
> > content on-screen.
> >
> > First of all what sort of content could be used to illustrate this
> > technique, and secondly, what mechanisms are available to:
> >
> > a) Notify that the input buffer is full
> > b) Copy the content to the output buffer so that it shows on-screen
> 
> It's quite simple. wl_surface_attach(surf, buf) +
> wl_surface_commit(surf) will display 'buf' for that surface. At that
> point, the compositor owns that buffer, so you should stop drawing on
> it. When the compositor has finished with a buffer, it will send you a
> wl_buffer.release event. You can sync your paint clock to the
> compositor's repaint loop with wl_surface_frame.
> 
> So, the normal workflow is:
>   - create surface S, buffer A, buffer B
>   - draw first frame into buffer A
>   - call wl_surface_frame(S) + wl_surface_attach(S, A) +
> wl_surface_commit(S) + wl_display_flush()
>   - go to sleep
>   - receive completion for wl_surface_frame callback
>   - draw second frame into buffer B
>   - call wl_surface_frame(S) + wl_surface_attach(S, B) +
> wl_surface_commit(S) + wl_display_flush()
>   - compositor now owns both buffers, so don't touch any
>   - receive wl_buffer.release event for buffer A - now unused
>   - receive completion for wl_surface_frame callback
>   - draw third frame into buffer A
>   - ...
> 
> Hope that helps. You can see the weston-simple-shm client for a pretty
> straightforward example.
> 
> Cheers,
> Daniel

Hi Daniel,

Many thanks for the detailed and quick response.  You've shown me a couple of functions I hadn't thought of using.

I'll give it a go.

Kind regards
Mike
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20151125/f7427ea7/attachment-0001.html>


More information about the wayland-devel mailing list