summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qwidgetrepaintmanager_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Compose render-to-texture widgets through QRhiLaszlo Agocs2022-03-111-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QPlatformTextureList holds a QRhiTexture instead of GLuint. A QPlatformBackingStore now optionally can own a QRhi and a QRhiSwapChain for the associated window. Non-GL rendering must use this QRhi everywhere, whereas GL (QOpenGLWidget) can choose to still rely on resource sharing between contexts. A widget tells that it wants QRhi and the desired configuration in a new virtual function in QWidgetPrivate returning a QPlatformBackingStoreRhiConfig. This is evaluated (among a top-level's all children) upon create() before creating the repaint manager and the QWidgetWindow. In QOpenGLWidget what do request is obvious: it will request an OpenGL-based QRhi. QQuickWidget (or a potential future QRhiWidget) will be more interesting: it needs to honor the standard Qt Quick env.vars. and QQuickWindow APIs (or, in whatever way the user configured the QRhiWidget), and so will set up the config struct accordingly. In addition, the rhiconfig and surface type is (re)evaluated when (re)parenting a widget to a new tlw. If needed, this will now trigger a destroy - create on the tlw. This should be be safe to do in setParent. When multiple child widgets report an enabled rhiconfig, the first one (the first child encountered) wins. So e.g. attempting to have a QOpenGLWidget and a Vulkan-based QQuickWidget in the same top-level window will fail one of the widgets (it likely won't render). RasterGLSurface is no longer used by widgets. Rather, the appropriate surface type is chosen. The rhi support in the backingstore is usable without widgets as well. To make rhiFlush() functional, one needs to call setRhiConfig() after creating the QBackingStore. (like QWidget does to top-level windows) Most of the QT_NO_OPENGL ifdefs are eliminated all over the place. Everything with QRhi is unconditional code at compile time, except the actual initialization. Having to plumb the widget tlw's shareContext (or, now, the QRhi) through QWindowPrivate is no longer needed. The old approach does not scale: to implement composeAndFlush (now rhiFlush) we need more than just a QRhi object, and this way we no longer pollute everything starting from the widget level (QWidget's topextra -> QWidgetWindow -> QWindowPrivate) just to send data around. The BackingStoreOpenGLSupport interface and the QtGui - QtOpenGL split is all gone. Instead, there is a QBackingStoreDefaultCompositor in QtGui which is what the default implementations of composeAndFlush and toTexture call. (overriding composeAndFlush and co. f.ex. in eglfs should continue working mostly as-is, apart from adapting to the texture list changes and getting the native OpenGL texture id out of the QRhiTexture) As QQuickWidget is way too complicated to just port as-is, an rhi manual test (rhiwidget) is introduced as a first step, in ordewr to exercise a simple, custom render-to-texture widget that does something using a (not necessarily OpenGL-backed) QRhi and acts as fully functional QWidget (modeled after QOpenGLWidget). This can also form the foundation of a potential future QRhiWidget. It is also possible to force the QRhi-based flushing always, regardless of the presence of render-to-texture widgets. To exercise this, set the env.var. QT_WIDGETS_RHI=1. This picks a platform-specific default, and can be overridden with QT_WIDGETS_RHI_BACKEND. (in sync with Qt Quick) This can eventually be extended to query the platform plugin as well to check if the platform plugin prefers to always do flushes with a 3D API. QOpenGLWidget should work like before from the user's perspective, while internally it has to do some things differently to play nice and prevent regressions with the new rendering architecture. To exercise this better, the qopenglwidget example gets a new tab-based view (that could perhaps replace the example's main window later on?). The openglwidget manual test is made compatible with Qt 6, and gets a counterpart in form of the dockedopenglwidget manual test, which is a modified version of the cube example that features dock widgets. This is relevant in particular because render-to-texture widgets within a QDockWidget has its own specific quirks, with logic taking this into account, hence testing is essential. For existing applications there are two important consequences with this patch in place: - Once the rhi-based composition is enabled, it stays active for the lifetime of the top-level window. - Dynamically creating and parenting the first render-to-texture widget to an already created tlw will destroy and recreate the tlw (and the underlying window). The visible effects of this depend on the platform. (e.g. the window may disappear and reappear on some, whereas with other windowing systems it is not noticeable at all - this is not really different from similar situtions with reparenting or when moving windows between screens, so should be acceptable in practice) - On iOS raster windows are flushed with Metal (and rhi) from now on (previously this was through OpenGL by making flush() call composeAndFlush(). Change-Id: Id05bd0f7a26fa845f8b7ad8eedda3b0e78ab7a4e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Add unit test for moving of opaque widgetsVolker Hilsheimer2021-12-081-2/+3
| | | | | | | | | | | | | | | Expose QWidgetRepaintManager's data structures so that we can write unit tests, and verify that they are correct after moving opaque widgets (which triggers the accelerated move code path). Improve the compareWidget logic to not rely on screen grabbing (which requires permissions), but instead use QPlatformBackingStore's toImage function, which is faster and more reliable, and also doesn't require us to show the UI we want to grab full screen in order to avoid issues with overlapping windows etc. Change-Id: Iff2ea419f03a390ab6baca26814fef6ff45f7470 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Use QList instead of QVector in widgetsJarek Kobus2020-07-021-3/+3
| | | | | | Task-number: QTBUG-84469 Change-Id: I3007734f8e4f164ece9dd8850ef007cbef9e12ef Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* widgets: Add logging for widget paintingTor Arne Vestbø2019-08-281-0/+3
| | | | | Change-Id: I551ec290812369e3848c1096fed7e813cd9e1cd6 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* widgets: Simplify QWidgetRepaintManager::flushTor Arne Vestbø2019-08-281-1/+1
| | | | | Change-Id: Icba88fa068aac2ac5d8bb04e46a3e3f34e279a48 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* widgets: Merge QWidgetRepaintManager::topLevelRect into callsiteTor Arne Vestbø2019-08-251-2/+0
| | | | | Change-Id: Ia9bb0c396b8175f644e337ca73086208c637ed2d Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* widgets: Remove unused QWidgetRepaintManager::dirtyRegionTor Arne Vestbø2019-08-251-1/+0
| | | | | | | It is no longer needed after qt_dirtyRegion was removed in e2a1fb901. Change-Id: I120df76b08808842b304cb8de10de23ccd0e2845 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* widgets: Clarify how widgets needing flush is trackedTor Arne Vestbø2019-08-251-2/+2
| | | | | Change-Id: Ia2c2c4b830e4441e50c66dd3fef5bc060f76551e Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* widgets: Clarify top level flush region in QWidgetRepaintManagerTor Arne Vestbø2019-08-251-1/+1
| | | | | Change-Id: I9a8d11569d33bf580bd50b710cf072952ea3626b Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* widgets: Rename markDirtyOnScreen to markNeedsFlushTor Arne Vestbø2019-08-251-3/+3
| | | | | | | | Including renaming the member touched by this function. This leaves the logic for appendDirtyOnScreenWidget, which still needs investigating. Change-Id: I405a5e3757f0a79992f88d9f70867aeb7b9764d8 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* widgets: Share more code in appendDirtyOnScreenWidgetTor Arne Vestbø2019-08-251-1/+1
| | | | | Change-Id: I0ed936c7d8b004d498a8956b1ba246ade41ce43d Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* widgets: Class initialize QWidgetRepaintManager membersTor Arne Vestbø2019-08-251-6/+11
| | | | | Change-Id: Icc06ae8f5f542810d651e4834055cbcd1c1a4e2e Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* widgets: Remove unused member in QWidgetRepaintManagerTor Arne Vestbø2019-08-251-1/+0
| | | | | Change-Id: I2f7eac2916bdcd9101e96e78a3d7c3c6c395dde7 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* widgets: Merge QPlatformTextureListWatcher into implementation fileTor Arne Vestbø2019-08-251-19/+0
| | | | | | Change-Id: Icf177a5b559bd1c108a66ee14a51fb23cd36e083 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* widgets: Clean up and reorder QWidgetRepaintManager implementationTor Arne Vestbø2019-08-221-126/+32
| | | | | | | | Group functions by related areas and order them roughly by their flow in a normal app repaint cycle. Change-Id: I7a963f612134b3fdbaf748e0432606825b8db64e Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* widgets: Merge QWidgetRepaintManager::begin/endPaint into callsiteTor Arne Vestbø2019-08-221-3/+0
| | | | | Change-Id: Iff5f78dcc8124bcecf53d42d920e74467937412a Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* widgets: Rename QWidgetRepaintManager::doSync to paintAndFlushTor Arne Vestbø2019-08-221-1/+2
| | | | | Change-Id: Ie41bb76d33d59f70eb418f845defc212396d3915 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* widgets: Don't rely on QWidget friending QWidgetRepaintManagerTor Arne Vestbø2019-08-221-52/+51
| | | | | Change-Id: Id9fc28eb62103d38eaa51261f61a2294db85e0d6 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* widgets: Simplify QWidgetRepaintManager::qt_flushTor Arne Vestbø2019-08-221-4/+1
| | | | | | | | | No longer static, so we can access the members directly instead of passing them as arguments. Renamed to flush() while we're at it. Otherwise no changes to the code, just moved the function. Change-Id: Id491a8628c8cecf7cf3b33d3458e7427f5bcd22e Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Goodbye showYellowThingTor Arne Vestbø2019-08-221-11/+2
| | | | | | | | | | The code hasn't been working for at least 5 years, and is just making the repaint manager more complex. We can always re-introduce the feature at a later point. Change-Id: Ib07c782c821f3e653f9452f6fbfe2f87effccc92 Fixes: QTBUG-36435 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* widgets: Remove unused arguments from QWidgetRepaintManager::beginPaintTor Arne Vestbø2019-08-201-2/+1
| | | | | Change-Id: I3720d8ef31e623e514fc2e382192d3c4f99fb4ed Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* widgets: Remove unused function qt_dirtyRegionTor Arne Vestbø2019-08-201-1/+0
| | | | | Change-Id: I7e6dbc4fb777a2323d65b73164d8645d6efc95a4 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* widgets: Remove dead members from BeginPaintInfoTor Arne Vestbø2019-08-201-3/+1
| | | | | | | The flags haven't been used since 2011 (6ce6b8a37) and is dead code. Change-Id: Ic5c47b30326ff70534bbf1aa37b25bae666b6b96 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Rename QWidgetBackingStore to QWidgetRepaintManagerTor Arne Vestbø2019-08-201-0/+281
Quoting a blog from 2009, "this class is responsible for figuring out which parts of the window surface needs to be updated prior to showing it to screen, so it's really a repaint manager." https://blog.qt.io/blog/2009/12/16/qt-graphics-and-performance-an-overview/ What better time to do the rename than 10 years later! Change-Id: Ibf3c3bc8c7df64ac03d72e1f71d296b62d832fee Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>