Redesign client buffer management
With the current design, both kwayland-server and kwin are involved in getting opengl textures from client buffers. This is somewhat goes against the purpose of kwayland-server, which is to simplify writing wayland compositors. Dealing with EGLImage or linux dmabuf buffers is not difficult, but it involves a lot of boilerplate code, which ideally needs to be in a library. Another confusing thing about our current buffer abstractions is that referenced buffers can be destroyed. It makes some parts of kwin hard to understand. The whole purpose of the ref'ing is to ensure that nothing will be destroyed while it's being used by the compositor. Furthermore, buffers are not automatically ref'ed/unref'ed. In order to keep things extensible and less error prone, this change rewrite the buffer management bits so the compositors don't have to implement their own code path for getting OpenGL textures from client buffers. This is also a necessary step towards asynchronous uploading of data from shared memory buffers to textures and proper implementation of the linux explicit synchronization protocol. With the new design, the most important classes are ClientBufferRef and ClientBuffer. The ClientBuffer is an internal type, and it represents the actual buffer. The ClientBufferRef is a reference to a ClientBuffer. As long as there is a reference, the associated buffer cannot be modified by the client. ClientBufferRef acts as a "smart pointer." It will keep the reference count up to date as you copy or move ClientBufferRefs objects. If the refcount reaches 0, the buffer will be released automatically. In the event of the underlying buffer resource getting destroyed, for example if the app has crashed, the corresponding ClientBuffer will not be destroyed. All existing references will remain valid. Some plugins, e.g. linux-dmabuf-v1, need an EGLDisplay or a way to get notified when a graphical reset has occurred. For this particular reason the RendererInterface class has been introduced that acts as a bridge between the renderer and the rest of buffer management. Note that the wayland-eglstream plugin is licensed under GPL-2.0+ because some of its code was copied from kwin.
Showing with 423 additions and 198 deletions