aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/qsgcontext.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Improve hash strategy for font cachesEskil Abrahamsen Blomfeldt2023-12-051-0/+14
| | | | | | | | | | | | We were using a string key for font lookups instead of creating a proper type for this. This was a quick fix which has grown over time and is inconvenient and slow. Instead we now introduce a FontKey type which uses Qt 6's qHashMulti() for this, also making it automatically adapt to changes in the FaceId as well. Change-Id: I32dfe3b809710e3d76896a5ddef03649bb4da0d5 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Introduce a CurveRendering backend for textEskil Abrahamsen Blomfeldt2023-11-111-0/+10
| | | | | | | | | | | This moves the internals of the curve renderer out from Qt Quick Shapes and into a more centralized location in Qt Quick, so that we can use the same code to create a new text backend for rendering large scale text without artifacts. Change-Id: I3f7e6f7961c1bbe230fcb531c0ca028e038c1afd Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Export QQuickPixmapKey and (renamed) QQuickPixmapCache for autotestsShawn Rutledge2023-09-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | We need to be able to do a leak check in tst_qquickpixmapcache. So we also need to use the singleton pattern rather than Q_GLOBAL_STATIC. Since it gets more exposed this way, make the badly-encapsulated parts of API available only to friends. It's always been bothersome that various other places in the code are including qquickpixmapcache_p.h to get QQuickPixmap, and qquickpixmapcache_p.h also does not include any class called QQuickPixmapCache as you'd expect; while arguably, QQuickPixmapStore is the cache. Often in comments I've needed to refer to "the code in qquickpixmapcache.cpp" because it's a very private, inbred family of related classes that don't match the header name. So now we split the headers: qquickpixmapcache_p.h is for the cache, which is now called QQuickPixmapCache; and qquickpixmap_p.h is the header most often needed in other places. Most classes in qquickpixmap_p.h are exported, but QQuickPixmapCache itself is not (except for autotests). It cannot be defined in the header that gets included in Particles for example: then it wouldn't link, because the implementation is not (and shouldn't be) exported, and that's not what Particles needs anyway. Task-number: QTBUG-81266 Task-number: QTBUG-114953 Change-Id: Ifd7f253b8bbaa130eb52d5546f342754f99f47bb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Make text node scenegraph API publicEskil Abrahamsen Blomfeldt2023-09-011-0/+11
| | | | | | | | | | | | | | A lot of functionality is hidden underneath this, so exposing this API will make it possible to build custom text-based components for Qt Quick. [ChangeLog][Text] Added QSGTextNode and QQuickWindow::createTextNode() for creating scene graph nodes containing text. This can be useful when building custom Qt Quick items with text. Fixes: QTBUG-72773 Change-Id: I4810589cc28eb1cdfe91c9d8b66f4c6fe52a0c6a Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Remove QML_LEAK_CHECKShawn Rutledge2023-08-211-0/+3
| | | | | | | | | | | Using an env var to enable specific debug output has been obsolete ever since we added categorized logging. [ChangeLog][QtQuick][SceneGraph] The environment variable QML_LEAK_CHECK is replaced by the logging category qt.scenegraph.leaks. Change-Id: I33b6f100df99eb558e2715d39d833e813ecde20d Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Fix memory leak when invalidating NativeRendering fontsEskil Abrahamsen Blomfeldt2023-06-151-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When NativeRendering is used, we keep a reference to all the font engines currently in use to make sure they stay alive, and then dereference them when the scenegraph is invalidated, typically when the window closes. There was always a controlled leak here: If you loaded new font assets continuously, then we would retain the old ones in memory. Due to the bug in QTBUG-100697, we would keep them even if they were application fonts that were removed. However, when QTBUG-100697 was fixed, a side effect was that the memory leak became more visible: It no longer only happens when loading new fonts, but just loading and unloading the same two application fonts and setting them on a text item in a loop would cause us to continuously create new font engines, give them a font cache and then add them to the m_fontEnginesToClean list. The fix is to match the registerFontEngineToClean() with an unregister function and then clean up the font engines that no longer have any references during the synchronization step, similar to how we clean up distance field caches that are no longer in use. Note that this removes a bogus qDeleteAll() from the software backend: This was added blindly by f1b188df132c42da62197055725e5f7eebcc4249. Since the set will be empty, it doesn't cause a crash, but is not the correct way to delete font engines, so to avoid future confusion or cargo-culting, we just replace it with an assert that the set is empty. [ChangeLog][Text] Fixed a controlled memory leak with Text.NativeRendering where loading and unloading the same application fonts could cause memory usage to increase indefinitely and not be regained until the window was closed. Pick-to: 6.5 6.6 Fixes: QTBUG-113714 Change-Id: I34c60e647bf63a0d203f752066f1cbfaeb049bcf Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Have a way to always use an elapsed time based animation driverLaszlo Agocs2023-02-081-15/+110
| | | | | | | | | | | | | | | | | | | | Set QSG_USE_SIMPLE_ANIMATION_DRIVER=1 to get an alternative animation driver. (applies when using the threaded render loop) This behaves like the fallback mode (TimerMode) of the other one: it advances based on whatever delta the QElapsedTimer reports. Thus there is no dependency on vsync-based throttling whatsoever, and a big chunk of the workaround infrastructure (such as needing to fall back to QTimer with multiple windows) is simply not needed. It should be evaluated going forward if this should become the default. For now, in order to avoid any surprises, it is only opt-in. Pick-to: 6.5 Task-number: QTBUG-84328 Change-Id: I8e466caa08ba5f0471d767b1600d198ba787d8e5 Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io> Reviewed-by: Robert Griebl <robert.griebl@qt.io> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Fix several more improperly placed #include mocThiago Macieira2022-07-281-2/+2
| | | | | | | | | | | | | | Like commit qtbase/638893bea083b619b73b33a7dd5589fb2c4c4242. Script to find them: git grep -l '#include.*moc' \*.cpp \*.mm | \ xargs awk '/QT_BEGIN_NAMESPACE/ { i=1 } /QT_END_NAMESPACE/ { i=0 } /#include.*moc/ && i { print ARGV[ARGIND], $0 }' Pick-to: 6.4 Change-Id: I6f936da6f6e84d649f70fffd17058fd05cfc5c6d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-111-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. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* scenegraph: Remove beginNext[Rhi]Frame differentiationLaszlo Agocs2022-04-211-23/+0
| | | | | | | | One set of functions is enough, no need for a separate set of "Rhi" ones. Change-Id: I58600c539734d5f8a767926eb9649d9968bab08a Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* Support to custom the render target on the software rendererJiDe Zhang2022-04-191-7/+6
| | | | | | | | | | | | | | Add QQuickRenderTarget::fromPaintDevice, aollow to get a QQuickRendererTarget from the QPaintDevice object. [ChangeLog][QtQuick] Added QQuickRenderTarget::fromPaintDevice, Allowed to set the render target of QQuickWindow on the software renderer. Task-number: QTBUG-94075 Change-Id: I4946c25d2a6315cd8f9c12a7ac7ac4cf71d95361 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Invalidate text when application fonts are added or removedEskil Abrahamsen Blomfeldt2022-04-081-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We had multiple related issues due to application fonts being added or removed during the application lifetime. 1. If a text had font family "foo" set, and this font did not exist at the time, then loading "foo" at a later stage would not update the text to use the correct font, since the result of the previous request had been cached. 2. A variation of #1 was if the font "foo" was loaded by a FontLoader in the scene and referred to by name in the text component. In this case, there was a race condition, where the font lookup would sometimes yield different results on the main thread and on the render thread, and text would be garbled. 3. When a font was removed from the font database, then references to it would remain in the caches (glyph cache + font cache) in the render thread. With certain backends (DirectWrite, CoreText) this caused errors or even crashes, as the cached font engines would be referring to data that had been removed. The work-around for #1 and #2 was merely to avoid hardcoding names for fonts, but instead getting them from the FontLoader. This way, you can avoid requesting the font family before it is available (and thus avoid caching the wrong result). However, for #3 there is no known work-around. This patch fixes all three (together with a smaller patch for qtbase) by invalidating all text and related caches in Qt Quick when fonts are either added or removed from the font database. This does add some overhead if font loading happens during runtime, but the alternative is broken behavior and dangling pointers. This is done during the synchronization step. Before synchronization, the font cache is flushed and all text components are marked for update, so that fonts are re-requested against the new font database. After synchronization, we delete all distance field glyph caches which are not currently in use, to avoid having references to stale application font data in the list. [ChangeLog][Text] Fix multiple issues with usage of application fonts when they are added or removed during the lifetime of the application. Task-number: QTBUG-100697 Task-number: QDS-1142 Change-Id: Ib309e54e0ee97b6be6d2a7211964043fd51c9ec5 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* sg: combine logic in fallback timer and animation driverLaszlo Agocs2022-01-201-5/+25
| | | | | | | | | | Use the animation driver subclass as the only place that calculates the vsync interval. Do not replicate (in a slightly different way) the same logic in the threaded render loop. Make it possible to query this value via the context interface. Also fix up some types. Change-Id: I80257499ad95d3c043f5467c0b8d5b107f0c06a1 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Doc: Capitalize "GUI" correctlySze Howe Koh2020-08-301-3/+3
| | | | | | Pick-to: 5.15 Change-Id: I2230e2dcb7bc2497b5dbe71a22c21d84176b5e57 Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
* Add renderTypeQuality property to Text elementEskil Abrahamsen Blomfeldt2020-08-171-1/+1
| | | | | | | | | | | | | | | | | | | | | For large scale text, the default distance field size gives artifacts on certain font features. We already have an environment variable which overrides this on an application level, but this will cause all distance fields to be rendered at the high resolution, whereas you may just want it for one particular text field. Since this becomes an especially important use case now that we can embed the text fields in a 3D scene, we add a property which can be used to tweak the base font size used for generating the distance fields. [ChangeLog][QtQuick][Text] Added "renderTypeQuality" property, which can be used in cases of very large fonts, where Qt's font rasterization may show some rendering artifacts when using the default quality. Fixes: QTBUG-84696 Change-Id: Ie4205e82cf441562dcc65a8e432a941a3baeddf3 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Make it possible to specify device extensions in a future proof mannerLaszlo Agocs2020-06-191-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follow the pattern of QQuickRenderTarget and QQuickGraphicsDevice. This makes it possible to integrate with real world frameworks, such as OpenXR, that, especially with Vulkan, expect this level of configurability. (i.e. one pulls the list of extensions to be enabled on the device, that then needs to be taken into account by Quick, otherwise it will end up with a VkDevice that is not usable by OpenXR) Same goes when integrating native Vulkan rendering into an application: if certain extensions need to be enabled on the VkDevice, today that can only be done with an environment variable which is not entirely ideal. These issues are now solved by a new simple (and extensible) container QQuickGraphicsConfiguration, which is associated with the QQuickWindow. When applicable, the scene graph will then pick up the relevant settings. Expand the related docs everywhere. Also rename the vulkanInstance() to defaultVulkanInstance() to emphasize that it is the instance that is used for normal QQuickWindows, and is not provided when redirecting via QQuickRenderControl. While we are at it, include another obvious candidate: the use-depth-buffer flag. It turns out that Quick3D's Overlay render mode can be pretty problematic if Quick writes to the depth buffer. In order to avoid relying on environment variables (QSG_NO_DEPTH_BUFFER), we now provide a proper API for controlling that as well. Change-Id: Iefdb62c1f53de8bd34e3f0d393b00c5020d6188a Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Get rid of preprocess in QQuickTextEskil Abrahamsen Blomfeldt2020-06-151-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Preprocessing in the scene graph is actually pretty expensive, so we want to avoid using it for something like text, where you can often have a lot of nodes in a UI. For text it was previously used for two purposes: 1. To make sure the distance field glyph cache was updated with potential new glyphs before the frame was rendered, but *after* all new glyph nodes had been created (this is an optimization to avoid having to resize the cache multiple times in one frame, but rather wait until we know the exact amount of new glyphs that need to be added) 2. Update the coordinates of the glyph based on their position in the glyph cache if the glyph cache says they have moved (or if they have just been added for the first time). Point #1 can actually be handled a lot simpler, by having a separate loop for the existing glyph caches where we ask them to preprocess. There is typically only a few glyph caches, but can be hundreds of glyph nodes in a scene, so in the previous code we would be calling the update() functions on the same glyph cache over and over again every frame. Point #2 does not need preprocessing every frame, but can be reduced to only preprocess when the geometry is marked as dirty. We then do a pass on the glyph node in question to update its geometry and turn the flag off again so that we don't pay the cost every frame. Pick-to: 5.15 Fixes: QTBUG-84351 Change-Id: If8c492acaef9c512c2db61b64bcab2103db2d997 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Do not depend on removed openglContext getterLaszlo Agocs2020-06-091-1/+1
| | | | | | | | ...and remove Angle special case. Task-number: QTBUG-84623 Change-Id: Icf3eb4ef4508519aa2144b667220d33155569b7f Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* rhi: Fix crashing Controls autotests due to shadereffect lifetime issuesLaszlo Agocs2020-05-131-1/+1
| | | | | | | | | | | | | | | | | | | | | Make the QSGShaderEffectNode base class a QObject, the subclass (QSGRhiShaderEffectNode) is already a QObject so we lose nothing. This way we can get rid of the textureChanged() signal from the shadereffectmanager (the object living on the gui thread), and so the node (living on the render thread) does not need to do emit m_mgr->textureChanged() on the render thread. The signal emission in itself was perfectly fine, except when m_mgr happened to be destroyed already in case the node outlived the gui thread's item (and m_mgr). After the change we have something that is closer to what the direct OpenGL implementation did - and some of the interfaces in QSGContext get a lot cleaner in fact because the node can be instantiated on its own, without the involving the shadereffectmanager object that does not even live on the render thread. Change-Id: Ibb918cc3eaa08faddb8b8e5dfa3e34b212161703 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* rhi: Enable layer updateTexture(), and so grabs, in the sync phaseLaszlo Agocs2020-03-181-1/+2
| | | | | | | | | | | | | | | | | | | | Calling updateTexture() from an updatePaintNode() implementation means we are still in the synchronization phase, with the render step (as in QQuickWindow::renderSceneGraph()) not started yet. Make sure the QRhiCommandBuffer is sent around early enough, so it is usable by QSGRhiLayer already during sync. There is no use case for this in Qt Quick itself since all standard items invoke updateTexture() from QSGNode::preprocess() (which is part of the render, not the sync, step), but Qt Quick 3D relies on this in Texture.sourceItem. This should fix the sourceitem manual test in Qt Quick 3D, so that it will not crash anymore when running with RHI enabled. Task-number: QTBUG-82927 Change-Id: I38adf512e49b1c6eef4730cd23663d351725d6cd Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Fix device pixel ratio with QRhi for native textLaszlo Agocs2019-10-031-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Calculating values based on the dpr is not possible in the sync phase, because the strictly correct dpr (that takes redirections into textures into account) is not known until QQuickWindowPrivate::renderSceneGraph(). The text material implementation attempts to dig out something directly from the context's associated surface, but this does not match the way QQuickWindow calculates the value (although it would work without causing any trouble in many cases). This is of course incompatible with the QRhi-based abstraction since neither the context nor the associated window (if there is one even) is known to materials. To solve this, create a proper solution that makes the QQuickWindow-calculated dpr available already in the sync phase (so in updatePaintNode() implementations): have QQuickWindow calculate calculate the dpr in syncSceneGraph(), and pass it down via the rendercontext. Only the rhi-based code path is touched in this patch. The direct OpenGL path could be fixed in a similar manner (by migrating to rc->devicePixelRatio() in the sync phase and state.devicePixelRatio() in the render phase), but that is left as a future exercise. Task-number: QTBUG-78610 Change-Id: Id9d9d4b1fd5b9730a64834fbbf61c74af4a8ed07 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Make openglunderqml functional with and without the rhiLaszlo Agocs2019-07-041-6/+22
| | | | | | | | | | It has to be written following the new split approach (beforeRendering for resource setup, beforeRenderPassRecording to issue the actual underlay draw calls), but it will then work both with and without QSG_RHI=1. Change-Id: I9b7b35434aa0caec543cae268064b2684256382d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Add the graphics api independent scenegraph portLaszlo Agocs2019-07-041-2/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Opt in via environment variables: QSG_RHI=1 -> enable using QRhi instead of GL QSG_RHI_BACKEND -> set to vulkan, metal, d3d11, gl to override the default (the default is d3d11 on Windows, metal on Mac, gl elsewhere) Or force a given rhi backend via the existing QQuickWindow::setSceneGraphBackend(). Otherwise the default behavior is the same as before, the rhi code path is never active by default. -no-opengl builds are supported in the sense that they work and default to the software backend. However, the rhi code path cannot currently be used in such builds, even though QRhi from qtbase is fully functional with Vulkan, D3D, or Metal even when qtbase was configured with -no-opengl. This cannot be utilized by Quick atm due to OpenGL usage being all over the place in the sources corresponding to the default backend, and those host the rhi code path as well. This will be cleaned up hopefully in Qt 6, with the removal all direct OpenGL usage. Other env.vars.: QSG_RHI_DEBUG_LAYER=1 -> enable D3D debug or Vulkan validation layer (assuming the system is set up for this) QSG_RHI_SHADEREFFECT_DEBUG=1 -> print stuff from ShaderEffect QSG_SAMPLES=1,2,4,... -> MSAA sample count (but QSurfaceFormat works too) QT_D3D_ADAPTER_INDEX=0,1,... -> D3D adapter index QT_VK_PHYSICAL_DEVICE_INDEX=0,1,... -> Vulkan physical device index QSG_RHI_UINT32_INDEX=1 -> always use uint index data (both merged/unmerged, convert when needed - with some rhi backends this is implicit) QSG_RENDER_LOOP -> to override the render loop as usual. The default with RHI is threaded for Metal, threaded for Vulkan on Windows, basic for Vulkan on Linux and Android (to be checked later), while the existing rules apply for OpenGL. Not supported when running with QRhi: - particles - compressed atlases (though this is transparent to the apps) - QSGRenderNode - QQuickRenderControl - QQuickFramebufferObject - certain QQuickWindow functionality that depends directly on OpenGL - anisotropic filtering for textures - native text may lack some gamma correction - QSGEngine applicability unclear - some QML profiler logs may be incorrect or irrelevant Change-Id: I7822e99ad79e342e4166275da6e9e66498d76521 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Avoid illegal downcasts in texture and shader handlingAllan Sandfeld Jensen2019-05-151-1/+1
| | | | | | | | | | Fixes bad type-cast during destruction when objects no longer has the full type they used to. Detected by UBSAN. Change-Id: I4867091901d70d5a882656834eb97a704def1751 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* use nullptr consistently (clang-tidy)Shawn Rutledge2018-02-261-1/+1
| | | | | | | | | | | | | From now on we prefer nullptr instead of 0 to clarify cases where we are assigning or testing a pointer rather than a numeric zero. Also, replaced cases where 0 was passed as Qt::KeyboardModifiers with Qt::NoModifier (clang-tidy replaced them with nullptr, which waas wrong, so it was just as well to make the tests more readable rather than to revert those lines). Change-Id: I4735d35e4d9f42db5216862ce091429eadc6e65d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* doc: Fix remaining "Can't tie this..." errorsMartin Smith2018-02-231-7/+0
| | | | | | | | This update mostly removes qdoc comment markers from comments that should not have been qdoc comments. Change-Id: I8ccaa7fd4ae610371e25066e048fcba6cfba8038 Reviewed-by: Martin Smith <martin.smith@qt.io>
* Basic working compressed texture atlasMichael Brasser2018-01-311-0/+14
| | | | | | | | | | | | | This adds experimental automatic atlasing of ETC-compressed textures (to be expanded to additional formats), similar to existing atlas support of QImages. It is off by default, and can be enabled with QSG_ENABLE_COMPRESSED_ATLAS=1. [ChangeLog] Add experimental automatic atlasing of ETC-compressed textures (can be enabled with QSG_ENABLE_COMPRESSED_ATLAS=1) Change-Id: Ia66971f51299d082a569bdfaadb662a3e522bd79 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Replace Q_DECL_OVERRIDE with overrideKevin Funk2017-09-251-3/+3
| | | | | Change-Id: I176f91a8c51e81a2df3fe91733118261491223ee Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QSGContext: Remove some dead codeRobin Burchell2017-05-111-8/+0
| | | | | | | Unused since 906d5c5c40183468f9521277c6244a6c46730de6 (2013! :-)) Change-Id: Ie9e2326948279a46ddc933881a66847de66d51a9 Reviewed-by: Gunnar Sletta <gunnar@crimson.no>
* Merge remote-tracking branch 'origin/5.9' into devLars Knoll2017-05-021-0/+1
|\ | | | | | | Change-Id: I71275a2076c3d32ee2896571be882067320a2e9e
| * Run includemocs in qtdeclarativeThiago Macieira2017-04-261-0/+1
| | | | | | | | | | Change-Id: I84e363d735b443cb9beefffd14b8c023a37aa489 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Remove QSGDistanceFieldGlyphCacheManagerRobin Burchell2017-03-211-1/+0
|/ | | | | | | | | After the previous cleanups, it became clear that this didn't serve much of a purpose, so let's remove it and simplify the implementation as a result. Change-Id: Iae2ff9c46762f0c7bdf4225a2c4df93bc8253902 Reviewed-by: Yoann Lopes <yoann.lopes@qt.io>
* Merge remote-tracking branch 'origin/5.7' into 5.8Liang Qi2016-10-101-4/+0
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/quick/quickwidgets/quickwidget/main.cpp src/qml/jsruntime/qv4jsonobject.cpp src/qml/jsruntime/qv4qobjectwrapper.cpp src/qml/jsruntime/qv4qobjectwrapper_p.h src/qml/qml/qqmlengine.cpp src/qml/qml/qqmlpropertycache.cpp src/qml/qml/qqmlpropertycache_p.h src/quick/items/qquickanimatedsprite.cpp src/quick/items/qquickitem.cpp src/quick/items/qquickitem.h src/quick/items/qquickitem_p.h src/quick/items/qquickview_p.h src/quick/scenegraph/qsgcontext.cpp src/quick/scenegraph/qsgdefaultrendercontext.cpp Change-Id: I172c6fbff97208f21ed4c8b6db3d1747a889f22b
| * Merge "Merge remote-tracking branch 'origin/5.6' into 5.7" into refs/staging/5.7J-P Nurmi2016-09-301-3/+3
| |\
| | * Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-09-301-3/+3
| | |\ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: tests/auto/quick/qquicktext/tst_qquicktext.cpp Change-Id: I241cd418bb7e7b95e0a0a2ee4c465d48be2a5582
| | | * QSGRenderContext: Add null-checks for stringsFlorian Bruhin2016-09-261-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On some systems, glGetString returns null for some reason, which causes a segfault here. Let's assume it's not one of the broken configurations and hope for the best instead. Task-number: QTCREATORBUG-15992 Task-number: QTBUG-56165 Change-Id: I83867e42f0fd8f576bf51ac0a2213e1348111ffd Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Michael Brüning <michael.bruning@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
| * | | Remove dead codeJake Petroules2016-09-301-4/+0
| |/ / | | | | | | | | | | | | | | | | | | | | | Qt 5.7 only deploys to macOS 10.8, so this code is never executed. Also, QSysInfo will be deprecated in Qt 5.9 so this will fix a warning. Change-Id: Iecebdb2aed3b0e31b0540621b16aa958031a8e81 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | Make QSGRenderContext::invalidate a no-opLaszlo Agocs2016-07-011-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Calling invalidate() from the destructor is a bad idea since what we get is the QSGRenderContext implementation, not the one from the more-derived class. (it could have been intentional as well - it is confusing in any case and unnecessary). There is no adaptation relying in this anyways - invalidate() is always invoked manually, typically from windowDestroyed. This is very good since it avoids the at first less-than-obvious trouble with emitting invalidated() from the rendercontext dtor. (that can in turn can trigger random amount of code potentially calling back into the rendercontext and rely on virtuals which are not functional anymore due to the vtable not there for the functions in the more-derived class) Change-Id: I44d78c5a819230f7006d33d4341eff45d8f77c88 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* | | Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-06-301-1/+1
|\| | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/quick/items/context2d/qquickcanvasitem.cpp src/quickwidgets/qquickwidget.cpp tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp Change-Id: Idf279cb88e0df2a383489af5b6afdf04d04ae611
| * | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-06-291-1/+1
| |\| | | | | | | | | | Change-Id: I70c0c672708522f7157849365cc53ee271d8e460
| | * Rename qt.scenegraph.info to qt.scenegraph.generalKai Koehne2016-06-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If configured with logging rules (QT_LOGGING_RULES=), qt.scenegraph.info=true will be interpreted as enabling QtInfoMsg for the qt.scenegraph category and subcategories. [ChangeLog][QtQuick] qt.scenegraph.info logging category got renamed to qt.scenegraph.general. Task-number: QTBUG-54238 Change-Id: I7601e522697c3b4b00b6e9866b803d91f72e76fc Reviewed-by: Gunnar Sletta <gunnar@sletta.org> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* | | Unify ShaderEffect property settingLaszlo Agocs2016-06-291-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | rendererInterface() should not require isSceneGraphInitialized() to be true - the API and language queries like graphicsApi() have no need for the scenegraph, they only need the plugin to be loaded, i.e. that the QQuickWindow is constructed. This is the key to be able to make GraphicsInfo report graphicsApi and shaderType with the correct values as early as possible - meaning as soon as the item is associated with a window. The initialization of the scenegraph (the exact timing of which varies backend to backend) does not matter here. The fragment and vertex shader property setting is now unified in the two ShaderEffect implementations: - If the component is complete, the shader is attempted to be processed right from the setter. - Otherwise the item will trigger processing once the component is complete. - If there is no window when processing is trigerred, it is deferred via polish. To implement item polish handling we need a new virtual in QQuickItemPrivate since we cannot intrdouce virtuals into the public classes. This way one can write a condition (and later potentially use file selectors) like this: fragmentShader: GraphicsInfo.shaderType == GraphicsInfo.GLSL ? "..." : ... without having to worry about getting an unintended value processed due to GraphicsInfo not yet reporting an up-to-date value. parseLog() forces, for GL at least, shader processing to prevent autotests from breaking. Change-Id: If55c69d746c29cd07348ddad2d6b0f2b5dd7f3a2 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* | | Add cross-backend simple rect, texture, and ninepatch nodesLaszlo Agocs2016-06-221-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QSGSimpleRectNode is deprecated -> use QSGRectangleNode via QQuickWindow::createRectangleNode() instead. QSGSimpleTextureNode is deprecated -> use QSGImageNode via QQuickWindow::createImageNode() instead. The OpenGL version of the simple rectangle node is switched over to the vertex color material instead of flat, to allow for better batching. Use the same concept for nine patch nodes. The "style" node from Quick Controls 1 is now QSGNinePatchNode in order to provide a proper cross-backend solution which is already necessary due to the software backend, but now generalize it to apply to the accelerated backends with proper materials as well. QC can now simply call createNinePatchNode() without further ado. Also fixes a bug with the D3D12 texture material not enabling blending when needed. When it comes to the internal class names, QSGRectangleNode and QSGImageNode get the Internal prefix in the adaptation layer in order to differentiate from the public API. This involves quite a lot of renaming, but results in a nice and clean public API. Change-Id: Iddf9f9412377843ea6d652bcf25e68d1d74659ea Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
* | | Change graphicsAPI to graphicsApiLaszlo Agocs2016-06-011-1/+1
| | | | | | | | | | | | | | | Change-Id: I065f17abd1cb71cd8d6ead76abf7a544eb7a99c0 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* | | Adaptable shader effect enablersLaszlo Agocs2016-04-291-1/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The D3D12 node implementation is mostly missing. The rest of the enablers should be in place now however. Importing QtQuick 2.8 provides new properties for ShaderEffect: - shaderType can be used to decide which language should be used - shaderCompilationType tells if compilation is runtime or offline - shaderSourceType tells if the vertex/fragmentShader properties refer to source strings or source files or pre-compiled bytecode files The last two are bitmasks. In practice however we will support only one approach per backend for now (runtime + source string for OpenGL, offline + bytecode for D3D12). In addition to QSGShaderEffectNode, introduce the QSGGuiThreadShaderEffectManager interface. This provides the gui thread bits for the above and performs shader reflection. Backends that use the new ShaderEffect system must provide both. For each ShaderEffect item there will be a manager (on the gui thread) and a node (on the render thread). Reflection is expected to be done via standard helper libs (d3d12shader + D3DReflect from d3dcompiler for the D3D12 backend), or via manually inspecting SPIR-V, or parsing the source (like the GL path does now), or by using some 3rd party library (not recommended). In any case we require that reflection is doable on the gui thread without dependencies to the actual graphics API. The ShaderEffect documentation is greatly extended, covering HLSL and the new properties. The test app uses manually compiled shaders on its HLSL path for now. This is because there is no story yet for build system integration for public use (the internal HLSL -> bytecode in C header rule is only suitable for the d3d12 plugin itself, apps need something different). Change-Id: Id112104906fbcb26b9902a35f19d8d509b340d1b Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* | | Make rendernode suitable for public consumptionLaszlo Agocs2016-04-201-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For non-OpenGL APIs the primary (and likely the only) way to add custom rendering into the Qt Quick scene is via the render node. Other approaches,like the before/afterRendering signals, QQuickFramebufferObject, remain OpenGL-only. (although QQuickFramebufferObject may get a multi-API replacement based on QSGRenderNode at a later time) Note that this is not a generic 3D content integration enabler. It targets creating 2D and 2.5D Quick items with custom rendering via the graphics API in use. Make QSGRenderNode public, enhance the docs a bit and add a releaseResources(). Add a QSGRendererInterface with a query function in QQuickWindow and QSGEngine. The scenegraph adaptation can then return a custom implementation of the interface. This will be necessary to query API-specific values, f.ex. the ID3D12Device and ID3D12CommandList when running with the d3d12 backend. The interface allows querying the API and void* resources. Resources that we know about in advance are enum-based to prevent the QPlatformNativeInterface-like ugliness of string keys. Support is there in the batch renderer already, fix this up according to the new public API, and implement the corresponding bits for the D3D12 renderer. For D3D12, fix also an issue with QSGNode destruction where graphics resources in use were attempted to be final-released without a proper wait. The semantics of changedStates() in QSGRenderNode is changed so that it can be called at any time, including before render(). This is very useful since we can implement some state restoring in a more efficient manner. Added a new example as well. Documentation for QSGRenderNode is heavily expanded. Change-Id: I4c4a261c55791d0e38743a784bc4c05a53b3462d Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* | | Enable building Qt Quick module with QT_NO_OPENGL definedAndy Nichols2016-03-221-475/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently the Qt Quick module depends on either the OpenGL or OpenGLES headers being available at build time. Since we are adding support for adaptations that do not depend on OpenGL, it should be possible to build Qt Quick in environments that do not have OpenGL development headers. This does present many challenges though because in some cases GL types, and classes that require OpenGL are part of the public APIs. However since these classes were never available when QT_NO_OPENGL was defined, it should be possible to redefine the function signatures under this scenario, since it's not possible to break binary compatibility if there never were any binaries to break compatibility with. One of the bigger changes that was necessary to facilitate this change is creating interfaces out of QSGContext and QSGRenderContext. Here the default behavior was usage of OpenGL directly, even though subclasses could override all OpenGL usage. Making them interfaces should bring QSGContext and QSGRenderContext more in line with the other classes present in the adaptation layer. Change-Id: Iaa54dc0f6cfd18d2da1d059548abf509bd71f200 Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
* | | Allow fixed animation step in QSGGuiThreadRenderLoopAram So2016-03-071-2/+2
|/ / | | | | | | | | | | | | | | | | This patch allows to enable the fixed animation step in QSGGuiThreadRenderLoop if QSG_FIXED_ANIMATION_STEP is set. Change-Id: I87ff26120283d93e9b8d08286a16990cf6d649ce Reviewed-by: Gunnar Sletta <gunnar@sletta.org> Reviewed-by: Aram So <aram.so@lge.com>
* / Updated license headersJani Heikkinen2016-01-191-14/+20
|/ | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: Ic36f1a0a1436fe6ac6eeca8c2375a79857e9cb12 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Quick: Sanitize reading environment variables.Friedemann Kleint2015-10-261-16/+19
| | | | | | | | | | | | | | Where possible, use qEnvironmentVariableIsSet()/ qEnvironmentVariableIsEmpty() instead of checking on the return value of qgetenv(). Where the value is required, add a check using one of qEnvironmentVariableIsSet()/Empty(). Move QSGAtlasTexture::qsg_envInt() to qsgrenderer.cpp for reuse as qt_sg_envInt() and add qt_sg_envFloat(). Change-Id: I4c93f16c228d4f537154f389a0fa1427654485f7 Reviewed-by: Gunnar Sletta <gunnar@sletta.org>