diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2019-01-30 13:14:38 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2019-03-14 21:51:27 +0000 |
commit | 77a4915bf900aac0c96260018c0a4ccfbdd7c094 (patch) | |
tree | 07398f665b0340b4d1ed9596512d23a95c8d05bd /src/gui/kernel/qplatformgraphicsbuffer.h | |
parent | 097bf6fdd234ca7e5707610edfd3c804b3ba2a52 (diff) |
macOS: Add IOSurface based backingstore for layer-backed views
The naïve approach used for layer-backing in the past caused a detach
of the backingstore QImage on each beginPaint, since the image was
assigned to the layer via a CGImageRef that participated in the
QImage implicit sharing (and had to, so we couldn't get around that).
We now use IOSurfaces, wrapped in a QPlatformGraphicsBuffer abstraction.
The surfaces can be assigned to the layer's content the same way images
could, but allows us to reason more closely about whether or a buffer
is in use, and increases the chance that we will have a zero-copy path
to the screen.
Unless the window has requested a surface format with single buffering
we use a dynamic swap chain of buffers. In most situations there will
be two buffers in play, one assigned to the layer and one ready to
paint to, but during resize and some other situations the buffers
will grow temporarily to accommodate the increased back-pressure.
Since QBackingStore is documented as having single-buffer behavior,
we take care to persist content between the buffers before every
swap. By doing this before swapping, instead of before each paint,
we can avoid preserving areas that will be painted to anyways, and
will in many situations (such as blinking cursors e.g.) end up not
persisting anything.
The RasterGL surface case is handled by reading out the buffer data
and doing a manual texture upload. In the future we can support
direct texture access via CGLTexImageIOSurface2D, but this requires
QPlatformBackingStore::composeAndFlush to learn how to support other
targets than GL_TEXTURE_2D, as CGLTexImageIOSurface2D only works with
GL_TEXTURE_RECTANGLE_ARB targets.
Fixes: QTBUG-48763
Fixes: QTBUG-72360
Fixes: QTBUG-71162
Change-Id: Ica12f69b244e54d0fd31c929730d15657c286af8
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/gui/kernel/qplatformgraphicsbuffer.h')
-rw-r--r-- | src/gui/kernel/qplatformgraphicsbuffer.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/gui/kernel/qplatformgraphicsbuffer.h b/src/gui/kernel/qplatformgraphicsbuffer.h index 0aeef946e6..11566e1201 100644 --- a/src/gui/kernel/qplatformgraphicsbuffer.h +++ b/src/gui/kernel/qplatformgraphicsbuffer.h @@ -71,12 +71,14 @@ public: TextureAccess = 0x04, HWCompositor = 0x08 }; + Q_ENUM(AccessType); Q_DECLARE_FLAGS(AccessTypes, AccessType); enum Origin { OriginBottomLeft, OriginTopLeft }; + Q_ENUM(Origin); virtual ~QPlatformGraphicsBuffer(); |