diff options
author | Morten Johan Sorvig <morten.sorvig@digia.com> | 2013-08-23 09:21:26 +0200 |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@digia.com> | 2014-12-17 13:46:27 +0100 |
commit | 7ef5e2e4863bde5495cc17b60680271d3c09f78f (patch) | |
tree | 78afeb00fc67787286b264384555d2923242e9b3 /src/client/qwaylandwindow.cpp | |
parent | 198d7a51d4fc894fca691c1f8243372e876af68a (diff) |
Implement high-dpi support
Wayland 1.2 added support for display scaling, where wl_output
has a "scale" event informing the the client that the compositor
will scale the output surfaces by the given factor. The client
then has the option of providing large surfaces to match the
target pixel densety and bypass the compositor's scaling. This
is done by calling wl_surface::set_buffer_scale.
Re-use the current high-dpi support in Qt by implementing
devicePixelRatio() for QWaylandScreen and QWaylandWindow.
Provide high resolution buffers both for raster and OpenGL
graphics.
Introduce a new coordinate system: buffer coordinates, which
is related to the window coordinate system via an "int scale"
scale factor. This scale factor corresponds to Qts qreal
devicePixelRatio, but we keep the name and the type in the
QtWayland implementation.
Change-Id: Ie10d7e5b4833480a9a25d96a26ad02150eb6e83f
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
Diffstat (limited to 'src/client/qwaylandwindow.cpp')
-rw-r--r-- | src/client/qwaylandwindow.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index 9f7bdda1f..fd06972ff 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -126,6 +126,12 @@ QWaylandWindow::QWaylandWindow(QWindow *window) mShellSurface->setTopLevel(); } + // Enable high-dpi rendering. Scale() returns the screen scale factor and will + // typically be integer 1 (normal-dpi) or 2 (high-dpi). Call set_buffer_scale() + // to inform the compositor that high-resolution buffers will be provided. + if (mDisplay->compositorVersion() >= 3) + set_buffer_scale(scale()); + setOrientationMask(window->screen()->orientationUpdateMask()); setWindowFlags(window->flags()); setGeometry_helper(window->geometry()); @@ -369,7 +375,6 @@ void QWaylandWindow::requestResize() void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y) { mBuffer = buffer; - if (mBuffer) attach(mBuffer->buffer(), x, y); else @@ -707,6 +712,16 @@ bool QWaylandWindow::isExposed() const return QPlatformWindow::isExposed(); } +int QWaylandWindow::scale() const +{ + return screen()->scale(); +} + +qreal QWaylandWindow::devicePixelRatio() const +{ + return screen()->devicePixelRatio(); +} + bool QWaylandWindow::setMouseGrabEnabled(bool grab) { if (window()->type() != Qt::Popup) { |