45
QtWayland Creating Window Compositors with the QtWayland module Andy Nichols 2012

QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

QtWayland

Creating Window Compositors with the QtWayland module

Andy Nichols2012

Page 2: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

A little about me...

● Andy Nichols

● Software Engineer at Digia

● 6 years of Qt experience

● Former Qt Support Engineer

● Maintainer of QtWayland

Page 3: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

Outline

● The past (QWS)

● What is wayland?

● The QtWayland Module

● How do you use QtWayland?

Page 4: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

In case you have not heard...

Page 5: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

QWS has been removed in Qt 5.0

Page 6: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

QWS Graphics Stack

Page 7: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

Direct Rendering with QWS

● Clients map regions of the framebuffer

● Regions are written to directly by client

Page 8: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

Accelerated Graphics in QWS

● Custom QScreen plugin

● Custom paint engine

● Custom paint device

Page 9: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

If that is the case, then why replace QWS?

Page 10: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

It works great for its original use case

Page 11: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

But we are not living in that world anymore

Page 12: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

Have you ever actually had to support OpenGL in QWS?

Page 13: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

QWS is inflexible

● Supporting new hardware● Customization of look and feel

Page 14: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

Lack of OpenGL Support

● OpenGL QScreen Plugins do exist

● Limited to particular hardware

● Require specific API's

● Limited to a single process

Page 15: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

QWS: Does it still make sense?

● Overlap with QPA

● Few QWS developers

● Protocol design is hard

Page 16: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

And then came a project called Wayland

Page 17: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

What is Wayland?

"Wayland is a protocol for a compositor to talk to its clients as well as a C library implementation of that protocol."

-wayland.freedesktop.org

Page 18: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

Wayland Compositors can be

● a standalone display server ● an X11 application ● a wayland client

Weston Compositor

Page 19: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

Wayland Clients can be

● Traditional applications

● X servers○ rootless

○ fullscreen

● other display servers

Page 20: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

How does Wayland work?

1. Input events2. Direct events to client

a. Location in scenegraphb. Inverse transform

3. Respond to UI eventsa. Render changesb. notify compositor of

changed regions4. Post composition to output

src: wayland.freedesktop.org

Page 21: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

The Wayland Compositor

● Composes output

● Handles Input devices

● Forwards input events to clients

● Coordinates client buffers

Page 22: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

The Wayland Clients

● Renders to a surface buffer○ Shared Memory buffers

○ native buffers (GPU memory)

● Notifies compositor of changes

Page 23: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

Wayland Buffer Sharing

● Shared Memory buffers○ Raster based toolkits

● GPU buffers○ shared between processes with EGL○ mapped as a texture○ no additional upload costs

● Wayland-EGL

Page 24: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

Why choose Wayland?

● Lightweight

● Fast and Smooth

● External Open Source Project

● Easy to make customized Compositor

● Protocol is extendable

Page 25: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

but the best reason is...

Page 26: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

Cross toolkit compatibility

Page 27: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

Try doing that with QWS!

Page 28: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

The QtWayland Module

● Wayland platform plugin

● QtCompositor API

Page 29: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

Running Qt Applications in a Wayland Compositor

Just add "-platform wayland"To run as a wayland client

Page 30: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

Demo Time

Page 31: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

QtCompositor API

Page 32: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

WaylandCompositor

● Subclass to create your own compositor● reimplement

○ surfaceCreated(WaylandSurface *surface)● Call frameFinished() after all surfaces are

rendered.

Page 33: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

WaylandSurface

● Emits signals when client's state has

changed○ mapped

○ unmapped

○ damaged

● Contains data needed to render surface

Page 34: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland
Page 35: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

WaylandSurface data

Page 36: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

WaylandInputDevice

● Get instance from:

WaylandCompositor::defaultInputDevice()

● Forward events to Wayland clients.

● Focus management

Page 37: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

QWindow Compositor Demo

Page 38: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

WaylandSurfaceItem

● QtQuick 2.0 Item for WaylandSurface

Page 39: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

QML Compositor Demo

Page 40: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

QtWayland on new hardware

● Wayland-EGL● Hardware Integrations

○ Client■ QWaylandGLIntegration■ native window surface■ native OpenGL Context

○ Server■ GraphicsHardwareIntegration■ native buffer■ how to map native buffer to texture

Page 41: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

Hardware without OpenGL

● No native GPU buffers are used

● No QtQuick 2.0

● Mesa + LLVM software rendered OpenGL

possible

Page 42: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

Compositor Creativity Demo

Page 43: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

The Future of QtWayland

● Full wayland 1.0.0 spec support

● Proper client side decorations

● qt-wayland-scanner

● Fullscreen direct rendering

Page 44: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

Questions?

Page 45: QtWayland module Creating Window Compositors with the · 2015. 3. 24. · b. notify compositor of changed regions 4. Post composition to output src: wayland.freedesktop.org. The Wayland

Thanks for coming!

email: [email protected] irc: nezticle