summaryrefslogtreecommitdiffstats
path: root/src/opengl
Commit message (Collapse)AuthorAgeFilesLines
* rhi: Make it a QPA-style private but semi-public APILaszlo Agocs2023-05-212-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qrhi.h, qshader.h, qshaderdescription.h (and qshaderbaker.h from shadertools; done separately) become "RHI APIs", following the concept of QPA APIs. Mirror completely what is done for QPA headers, but using the "rhi" prefix for the headers. This involves updating syncqt to handle the new category of headers. (a note on the regex: matching everything starting with "qrhi" is not acceptable due to incorrectly matching existing and future headers, hence specifying the four header names explicitly) There is going to be one difference to QPA: the documentation for everything RHI is going to be public and part of the regular docs, not hidden with \internal. In addition to the header renaming and adding the comments and documentation notes and warnings, there is one significant change here: there is no longer a need to do API-specific includes, such as qrhid3d11[_p].h, qrhivulkan[_p].h, etc. These are simply merged into a single header that is then included from qrhi.h. This means that users within Qt, and any future applications can just do #include <rhi/qrhi.h> (or rhi/qshader.h if the QRhi stuff is not relevant), no other headers are needed. There are no changes to functionality in this patch. Only the documentation is expanded, quite a lot, to eliminate all qdoc warnings and make the generated API docs complete. An example, with a quite extensive doc page is added as well. Task-number: QTBUG-113331 Change-Id: I91c749826348f14320cb335b1c83e9d1ea2b1d8b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Clarify module changes in Qt6Jaishree Vyas2023-05-091-1/+1
| | | | | | | | | Changed Briefs for better understanding Fixes: QTBUG-109324 Pick-to: 6.5 Change-Id: I15b0c0dc12b1bf96626fb8ea4ad16d04b2b118ca Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* gl: Check for image validity in readbackLaszlo Agocs2023-04-251-6/+12
| | | | | | | | | | | Returning a null QImage is preferable over passing a null bits() to glReadPixels. (matters when QImage's malloc() gives null, thus 'd' is null -> isNull() == true) Fixes: QTBUG-113127 Pick-to: 6.5 6.4 6.2 5.15 Change-Id: Ieca4d91eefdea47da5251dabe77cc31b48eb0e28 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Use Qt CMake APIs to exclude files from Unity BuildAmir Masoud Abdol2023-04-031-8/+7
| | | | | | | | | | | | | | | | | | | | This is a bit of a cleanup, mainly around unity build, and a few other minor things: - I replaced the direct inclusion of sources files using `set_source_files_properties`, and instead used `NO_UNITY_BUILD_SOURCES` when possible. In most cases, they are being excluded in their respective `qt_internal_extend_target` but sometimes I had to make a new extension. - In few cases, we had to manually exclude the NO_PCH files, so, I instead passed them directly to the NO_PCH_SOURCES which also exclude them from the unity build as well. - Removed a few unnecessary "" Pick-to: 6.5 Task-number: QTBUG-109394 Change-Id: I466576592c1d115a2da4d88672c1e4b9f995f2ed Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Add QImage null check when QOpenGLTexture convertsLaszlo Agocs2023-03-211-1/+6
| | | | | | | | | | | ...the image to RGBA8888. Just mirror the first null check that is done for the user-provided QImage. The same should be done for the result of convertToFormat(). Pick-to: 6.5 6.5 6.2 5.15 Fixes: QTBUG-68884 Change-Id: I77091d7a2bc6e32d2aa292dc7650c1af091fcec1 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* QOpenGLTexture: Add a doc note about the unavoidable conversionLaszlo Agocs2023-03-161-0/+6
| | | | | | | | | | | As requested by users. Explicitly stated in the docs that the QImage is going to be converted, to avoid surprises. Pick-to: 6.5 6.2 5.15 Fixes: QTBUG-105364 Change-Id: Ia6a8930bcee8bd3cdbef016083599bd435b37a09 Reviewed-by: Kristoffer Skau <kristoffer.skau@qt.io> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Add QOpenGLWindow/Widget doc note about depth/stencilLaszlo Agocs2023-03-161-0/+17
| | | | | | | | Pick-to: 6.5 6.2 5.15 Fixes: QTBUG-108050 Change-Id: If011d6efff996870ff23eff3c2d1cf455d31b7a6 Reviewed-by: Kristoffer Skau <kristoffer.skau@qt.io> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Avoid incomplete textures in GL paint engineLaszlo Agocs2023-03-024-31/+68
| | | | | | | | | | | | | | | | | | | | | | ...which can happen if the OpenGL implementation reuses IDs so that a glGenTextures results in the same ID that was used by a texture destroyed by glDeleteTextures just before. In this case the lastTextureUsed tracking needs to be aware and invalidate, otherwise the newly created texture is assumed to be already existing (the ID is the same as before after all), and so operations such as setting the minification filter is skipped (which is fatal with OpenGL given that we do not use mipmaps). This is exercised in practice by the drawPixmapFragments test introduced in the previous patch. On Intel graphics it would work, but it does not render correctly with NVIDIA due to how the driver's internal ID handling works. Pick-to: 6.5.0 6.5 6.4 6.2 Change-Id: Ic2771fe9a2dec7da4aa3804d8498dd89e3c18415 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* GL paint engine: Fix drawPixmapFragments when using buffer objectsLaszlo Agocs2023-03-021-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Until recently the buffer object-based code path (so not client-side pointers) was only hit with a core profile context. This changed at some point in 6.4 and later to support WebGL (that has no client-side pointers, unlike OpenGL ES 2.0 it is based on). Now buffer objects are preferred over client-side pointers, always. Problem is, drawPixmapFragment() was never functional on this code path, it seems. Expecting that transferMode() does all the uploadData() needed is wrong. transferMode() bails out if the mode is the same as before, and that's exactly what happens when an application calls drawPixmapFragments() on the painter twice, after each other. How exactly this works with client-side pointers is not fully clear, but presumably the data buffer address stays the same so all pointers passed in to the glVertexAttribPointer calls are valid, and it sources the data for each draw call (probably), thus the rendering is all correct even though only the first, not the second, drawPixmapFragment() led to calling uploadData() internally. Amends e487b07e18f1cb7ff126744be57b2ae1b9839c6c although this patch on its own is just as applicable pre-6.4 as well (to fix drawPixmapFragments when using a core profile context). Pick-to: 6.5.0 6.5 6.4 6.2 Fixes: QTBUG-111416 Change-Id: I2ad358424e613192a51b99b937aef7660f5dbe08 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Increase cache size for QOpenGLTextureCacheKristoffer Skau2023-02-281-1/+11
| | | | | | | | | | | | Currently images that does not fit in the cache will be destroyed, which is unfortunate. 256 MB cache is too small for todays standards, so increasing it to 1 GB. Also adding an environment variable so that it is changeable if required. Fixes: QTBUG-111498 Pick-to: 6.5 Change-Id: I70c65cad6219a59102b16abc50f098aa0b017314 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Doc: Remove duplicate wordsAndreas Eliasson2023-02-281-1/+1
| | | | | | Change-Id: Ia7a38a1035bd34d00f20351a0adc3927e473b2e7 Pick-to: 6.5 6.4 6.2 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Add some exclusions for CMake Unity (Jumbo) buildsFriedemann Kleint2023-02-161-0/+8
| | | | | | | | | | | | | Add exclusions for issues that are likely not fixable (3rd party code, X11 define clashes, etc) in 3rd party, tools and plugins. Pick-to: 6.5 Task-number: QTBUG-109394 Done-with: Amir Masoud Abdol <amir.abdol@qt.io> Change-Id: I698c004201a76a48389271c130e44fba20f5adf7 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* src: Remove remains of qmake conversion from CMakeLists.txt filesFriedemann Kleint2023-02-101-3/+0
| | | | | | Pick-to: 6.5 Change-Id: Id644d322a602038403bb7f46c532744575fbf6d3 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* trace: Remove unused tracepoint filesAntti Määttä2023-02-101-12/+0
| | | | | | | | | | These can be removed now that the modules use tracepointgen tool. Pick-to: 6.5 Change-Id: I265e019f99e1ccc557a284ff53b110073066e530 Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io> Reviewed-by: Hatem ElKharashy <hatem.elkharashy@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
* Trace: Convert qtopengl module to use tracepointgen toolAntti Määttä2023-02-104-18/+27
| | | | | | | | Pick-to: 6.5 Change-Id: I441455a4d49a559fb591ea5c8cffb97af66fb2b1 Reviewed-by: Hatem ElKharashy <hatem.elkharashy@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io> Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
* QtOpenGL: Disambiguate class name QTextureBinderFriedemann Kleint2023-01-131-5/+5
| | | | | | | | | It occurs twice, causing a clash in CMake Unity (Jumbo) builds. Task-number: QTBUG-109394 Pick-to: 6.5 Change-Id: I39341af72cfa406d80c598a56db9e02f80c61a9b Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* eglfs: Improve z-order handlingSérgio Martins2022-10-291-4/+18
| | | | | | | | | | | | | | In 9ccbbeecbd we've added basic z-order handling, so main window always stacks behind tool windows. After extensive testing we found more basic cases to be handled: - Modal windows go on top - Qt::Popup goes on top of Qt::Tool Fixes: QTBUG-105707 Pick-to: 6.4 Change-Id: I00eba330864c7abc31652226d55f66f4b7f44dc0 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Do not use client-side data pointers in qopenglpaintengineMikolaj Boc2022-10-212-63/+43
| | | | | | | | | | Buffers can be uploaded - no need to keep these in client memory. Decouple uploading of buffers from the creation of vao. Pick-to: 6.4 6.4.0 Fixes: QTBUG-107539 Change-Id: Idf75bd80033a44c34af6837cd4d65b75c183d886 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Replace usages of Q_CLANG_QDOC with Q_QDOCLuca Di Sera2022-10-212-2/+2
| | | | | | | | | | | | | | | | | | | | | | | To allow the user to customize the C++ code that QDoc sees, so as to be able to work-around some limitations on QDoc itself, QDoc defines two symbols: Q_QDOC and Q_CLANG_QDOC, both of which are "true" during an entire execution of QDoc. At a certain point in time, QDoc allowed the user the choice between a custom C++ parser and a Clang based one. The Q_QDOC symbol would always be defined while the Q_CLANG_QDOC symbol would be defined only when the Clang based parser was chosen. In more recent times, QDoc always uses a Clang based parser, such that both Q_CLANG_QDOC and Q_QDOC are always defined, making them equivalent. To avoid using different symbols, and the possible confusion and fragmentation that derives from it, all usages of Q_CLANG_QDOC are now replaced by the equivalent usages of Q_QDOC. Change-Id: I5810abb9ad1016a4c5bbea99acd03381b8514b3f Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Long live Q_UNREACHABLE_RETURN()!Marc Mutz2022-10-152-12/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a combination of Q_UNREACHABLE() with a return statement. ATM, the return statement is unconditionally included. If we notice that some compilers warn about return after __builtin_unreachable(), then we can map Q_UNREACHABLE_RETURN(...) to Q_UNREACHABLE() without having to touch all the code that uses explicit Q_UNREACHABLE() + return. The fact that Boost has BOOST_UNREACHABLE_RETURN() indicates that there are compilers that complain about a lack of return after Q_UNREACHABLE (we know that MSVC, ICC, and GHS are among them), as well as compilers that complained about a return being present (Coverity). Take this opportunity to properly adapt to Coverity, by leaving out the return statement on this compiler. Apply the macro around the code base, using a clang-tidy transformer rule: const std::string unr = "unr", val = "val", ret = "ret"; auto makeUnreachableReturn = cat("Q_UNREACHABLE_RETURN(", ifBound(val, cat(node(val)), cat("")), ")"); auto ignoringSwitchCases = [](auto stmt) { return anyOf(stmt, switchCase(subStmt(stmt))); }; makeRule( stmt(ignoringSwitchCases(stmt(isExpandedFromMacro("Q_UNREACHABLE")).bind(unr)), nextStmt(returnStmt(optionally(hasReturnValue(expr().bind(val)))).bind(ret))), {changeTo(node(unr), cat(makeUnreachableReturn, ";")), // TODO: why is the ; lost w/o this? changeTo(node(ret), cat(""))}, cat("use ", makeUnreachableReturn)) ); where nextStmt() is copied from some upstream clang-tidy check's private implementation and subStmt() is a private matcher that gives access to SwitchCase's SubStmt. A.k.a. qt-use-unreachable-return. There were some false positives, suppressed them with NOLINTNEXTLINE. They're not really false positiives, it's just that Clang sees the world in one way and if conditonal compilation (#if) differs for other compilers, Clang doesn't know better. This is an artifact of matching two consecutive statements. I haven't figured out how to remove the empty line left by the deletion of the return statement, if it, indeed, was on a separate line, so post-processed the patch to remove all the lines matching ^\+ *$ from the diff: git commit -am meep git reset --hard HEAD^ git diff HEAD..HEAD@{1} | sed '/^\+ *$/d' | recountdiff - | patch -p1 [ChangeLog][QtCore][QtAssert] Added Q_UNREACHABLE_RETURN() macro. Change-Id: I9782939f16091c964f25b7826e1c0dbd13a71305 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-113-4/+4
| | | | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace, with manual unstaging of the actual definition and documentation in dist/, src/corelib/doc/ and src/corelib/global/. Task-number: QTBUG-99313 Change-Id: I4c7114444a325ad4e62d0fcbfd347d2bbfb21541 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Fix broken Text rendering when noantialiased NativeRendering is usedDominik Holland2022-10-111-1/+4
| | | | | | | | | | | In case antialiasing is disabled the QFontEngine::Format_Mono is used to render in the glyph cache. In this format the padding needs to be 8-bit aligned. Fixes: QTBUG-107038 Pick-to: 6.4 6.3 6.2 5.15 Change-Id: Icf69150b6b446099ad05d706ddcab0a57f8fe0c0 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Port from container.count()/length() to size()Marc Mutz2022-10-044-14/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix QtOpenGL tracepointsRafael Roquetto2022-09-153-5/+14
| | | | | | | | | | Make use of supported types only. As such, QOpenGL2PaintEngineExPrivate_drawTexture_entry has to be adjusted so that it does not exceed the maximum number of supported parameters by LTTNG, and thus the 'pattern' argument had to be dropped. Change-Id: I8d1c1dea7de82063926502d77dde1063b2096b73 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Defer creating the special shaders in the texture blitterLaszlo Agocs2022-09-141-18/+57
| | | | | | | | | | | | | | | | | | Port of the 5.15 change. It is not strictly required for Qt 6 since the immediate problem of failing to compile some of the shaders with some drivers will pop up much more rarely in practice, because neither Multimedia nor the backing store compositor for QOpenGLWidget/QQuickWidget use QOpenGLTextureBlitter in 6.4 and newer. To maintain the internal behavior between 5 and 6, the patch is nonetheless ported to Qt 6. It also has a performance benefit for the users of the blitter, because now the special shader variants (for rectangle or external textures) are only created when needed. Task-number: QTBUG-101396 Change-Id: I1cf4bec0c74045f4b6f94765563254026bf0b7d8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Move qopengltimerquery.h to a common sources of the QtOpenGL moduleAlexey Edelev2022-09-131-1/+2
| | | | | | | | | | | | qopengltimerquery.h contains platform-specific guards inside the file and can be processed for any platform. Fix the issue by adding it to a commong source tree but not the header usage used since it's easier and public header can be used by user-projects directly. Task-number: QTBUG-103196 Task-number: QTBUG-87480 Change-Id: Ic01a7f2d0de56da946c2ed699a8b183f70d5f9d0 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Apply Q_CONSTINIT where beneficialSona Kurazyan2022-09-011-1/+1
| | | | | | | | | | Applied Q_CONSTINIT to variables with static storage duration, but skipped the POD types with core constant initializers. Task-number: QTBUG-100486 Change-Id: Iaabf824e9cb0f29a405a149912200d4e4b3573c1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-08-232-2/+2
| | | | | | | Task-number: QTBUG-105718 Change-Id: I5d3ef70a31235868b9be6cb479b7621bf2a8ba39 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* eglfs: Ensure correct z-order of windowsSérgio Martins2022-08-042-3/+52
| | | | | | | | | | | - The main window needs to be at the back always, since it's fullscreen. If the root window gets in front then there's no way to retrieve the secondary windows. - Qt::Tool and transient child windows go to front as in other QPAs Change-Id: I4a2793628250756bc07daaee0763ea7174a7bebd Pick-to: 6.3 6.4 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Add license headers to cmake filesLucie Gérard2022-08-032-0/+6
| | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Existing copyright statements remain intact Task-number: QTBUG-88621 Change-Id: I3b98cdc55ead806ec81ce09af9271f9b95af97fa Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QOpenGLBuffer: add move-SMFs and swap()sMarc Mutz2022-07-202-2/+39
| | | | | | | | | | | | | | | | | | - add move special member functions (docs copied from QHostInfo) - add member swap - use move-and-swap, not pure-swap, because these objects hold resources (handles) other than just memory - Q_DECLARE_SHARED (it's not implicitly shared, but explicitly) - adds ADL swap and Q_DECLARE_TYPEINFO [ChangeLog][QtOpenGL][QOpenGLBuffer] Added member-swap(), move constructor, move assignment operator. Change-Id: I22dc92108bdd393fff4361db23e94eaf3d7ea9cc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QOpenGLBuffer: remove unused include of QScopedPointerMarc Mutz2022-07-201-1/+0
| | | | | | | | | | Nothing in this class uses one. Pick-to: 6.4 Task-number: QTBUG-97601 Change-Id: I09397ec55ef87ddb5ab05d51c705bab83d6995fc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Gui: mark types Q_PRIMITIVE_TYPE when they're held in QDataBufferMarc Mutz2022-07-081-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QDataBuffer assumes that its template argument is a POD, iow: it's ok to not run ctors and dtors and assign a value into uninitialized memory. In Qt, we call that Q_PRIMITIVE_TYPE. Asserting that the QDataBuffer value_type is not QTypeInfo::isComplex, however, has shown that a large number of types had not been marked as such, sometimes for good reason, e.g. because their default constructor doesn't value-initialize all members, but sets some of them to -1. Since QDataBuffer doesn't memset the memory to zero, it doesn't matter, as the code obviously has to have worked before, with uninitialized memory, and all-zeros is just a special, if common, form of uninitialized memory. I also tried to assert is_pod in QDataBuffer (working around the fact that that particular trait is deprecated), but found that almost none of the types in question were, in fact, trivial. We should fix this, because it means the compiler is generating code that's less efficient than it could be, but that's for another patch. All types marked as Q_PRIMITIVE_TYPE in this patch are private API, so this doesn't affect users. For PathSimplifier::Event, had to shorten the unnamed namespace to not include the member functions, because Q_DECLARE_TYPEINFO cannot appear in a namespace other than the Qt one. Pick-to: 6.4 6.3 Change-Id: I4431a2f269ec1ac4804a87ea71f983eaa34ef867 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Lars Knoll <lars.knoll@gmail.com>
* Avoid including qopenglfunctions header files if Qt is built with GLES2Alexey Edelev2022-06-281-2/+5
| | | | | Change-Id: I3a7a69f5eef604408713934811efb984e78d68dd Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Fix typos in docs and commentsKai Köhne2022-06-155-8/+8
| | | | | | | | | Found by codespell Pick-to: 6.4 Change-Id: Ie3e301a23830c773a2e9aff487c702a223d246eb Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Make rhiFlush() support custom source DPRMorten Sørvig2022-06-142-0/+3
| | | | | | | | | | | | | | | | | | | | | | | The rhiFlush() implementation currently assumes that QWindow->devicePixelRatio() is the correct scale factor for transforming device independent window geometry to source geometry. However, this assumption does not hold if/when we add support for drawing to a rounded-up DPR, with a downscale later in the rhiFlush implementation. Fix this by adding a sourceDevicePixelRatio argument to rhiFlush(), which is set to either QWindow::devicePixelRatio() or QWidget::devicePixelRatio(), depending on from where it is used. Change deviceRect() and friends in qbackingstoredefualtcompositor.cpp to be scale*() functions instead which take a scale factor instead of a QWindow. Update call sites to use srouceDevicePixelRatio where that makes sense. Pick-to: 6.4 Change-Id: Idb7b1e2f36816a201e00f0defe100d2dc079cb17 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Support cosmetic brush patterns in the pdf and opengl paint enginesEirik Aavitsland2022-06-041-5/+20
| | | | | | | | | | | | | | | | | | This implements the recent functionality extension of painting cosmetic (untransformed) brush patterns, and the corresponding NonCosmeticBrushPatterns render hint, in the pdf and opengl paint engines. As part of the implementation it also fixes a couple of pre-existing bugs in the opengl engine, relating to updating the brush after changes in transformation or brush origin. As a driveby, it also includes a minor fix for the lance testing tool: request stencil buffer, as that is needed and not always provided by default. This echoes a recent fix done to tst_baseline_painting. Change-Id: Ia8811477e015eebeb40ed138bca96643ce1ab0dc Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-16124-4723/+332
| | | | | | | | | | | | | 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>
* Add missing header files to the module sourcesAlexey Edelev2022-05-121-1/+1
| | | | | | | | | All module header files should be listed in the corresponding sections of modules SOURCEs to be accessible in CMake routines. Task-number: QTBUG-103196 Change-Id: Ieb77ae70557e35e546a5b00387e1e0aa40338239 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* QtOpenGL: includemocsMarc Mutz2022-04-296-0/+12
| | | | | | | | | | | Including moc files directly into their classes' TU tends to improve codegen and enables extended compiler warnings, e.g. about unused private functions or fields. Pick-to: 6.3 6.2 5.15 Task-number: QTBUG-102886 Change-Id: I60fb8c22a310dfd10cd3611fb603e2175ac6dbcc Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Revive eglfs' raster window supportLaszlo Agocs2022-04-274-37/+41
| | | | | | | | | | | | | | | | | | | A number of consequences of the new rhi-based backingstore composition were not handled. Most importantly, the fact that RasterGLSurface is not a thing anymore in practice causes challenges because we can no longer decide just based on the surfaceType what a QWindow with OpenGLSurface would be. (a plain GL window or a GL window with a backing store?) Also, the backingstore needs to be able to initialize its backing QRhi by itself, because with eglfs going through OpenGL is the only way. Amends 68a4c5da9a080101cccd8a3b2edb1c908da0ca8e Fixes: QTBUG-102750 Change-Id: Ia1ca59d01e3012264a76b50e591612fdcc2a0bd6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* OpenGL: port away from QLatin1StringSona Kurazyan2022-04-263-15/+15
| | | | | | | | | | | | Replace the uses of QLatin1String with corresponding string literals where applies, or with QLatin1StringView. As a drive-by, fix formatting of a warning message in qopenglengineshadermanager.cpp. Task-number: QTBUG-98434 Change-Id: I12f4479637a8fe265138f240a1310d2d576454a7 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Doc: Revise OpenGL module landing pageAndreas Eliasson2022-04-251-19/+22
| | | | | | | | | | Add the new qdocinc cmake and qmake snippets and reorganize some of the sections structure. Task-number: QTBUG-100369 Pick-to: 6.3 Change-Id: Iafa31856500e458c14feeb92bee660f44a65ffa9 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QtOpenGL: Fix build with GCC 12: qt_imageForBrush is in QtGuiThiago Macieira2022-04-221-1/+1
| | | | | | | | /usr/bin/ld: lib/libQt6OpenGL.t.so.6.4.0: protected symbol `_Z16qt_imageForBrushib' isn't defined Pick-to: 6.2 6.3 Change-Id: If05aeeb7176e4f13af9afffd16e845af9638337b Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Rest of QtBase: sweep Q_DECLARE_METATYPE → QT_DECL_METATYPE_EXTERNMarc Mutz2022-04-072-1/+3
| | | | | | | | | | | | | | | | It's one of our best tools to improve compile times. In some places, we can't do the change, yet, because there's no .cpp file for the header file. Also mark Q_DECLARE_METATYPE macros that are in the wrong place. We shouldn't have Q_D_M markup for public classes in .cpp or _p.h files. Fixes: QTBUG-102206 Change-Id: Iec0a39e4745571b24d07dacc87593321967c10e3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Misc: Do not depend on transitive includesFabian Kosmale2022-03-172-0/+2
| | | | | | | | As a drive-by, remove superfluous includes from qnetworkmanagerservice.h and obey the coding conventions for includes in a few more places. Change-Id: I65b68c0cef7598d06a125e97637040392d4be9ff Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Rest of QtBase: compile-optimize inline swap functionsMarc Mutz2022-03-171-1/+1
| | | | | | | | | | | | | | | | Instead of using the overly-generic qSwap() monster, use - qt_ptr_swap() for swapping raw pointers - member-swap for swapping smart pointers and owning containers In QtCore, this has proven to give a nice reduction in compile time for Qt users, cf. b1b0c2970e480ef460a61f37fa430dc443390358. Pick-to: 6.3 6.2 Task-number: QTBUG-97601 Change-Id: I53e031a021031d53a74a712cd0f5e6bb8bf800bd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Compose render-to-texture widgets through QRhiLaszlo Agocs2022-03-117-572/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Fix deprecated uses of QScopedPointerMårten Nordheim2022-03-082-8/+10
| | | | | | | | | By changing it to unique_ptr. Pick-to: 6.2 6.3 Change-Id: I91abb69445b537d4c95983ae735341882352b29d Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix painting clipping glitches with fractional scalingEirik Aavitsland2022-03-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In QPainter, clipping can only be done on whole pixels. The various ways of specifying a clipping rectangle to the QPainter API have been inconsistent in how fractional rectangles (either specified directly, or as a result of fractional scaling) are mapped (rounded) to integer coordinates. Also, the mappings have not made sure to keep the edge-to-edge property of clip rects under scaling. This is particularly important when scaling QRegions with multiple rects, as QRegion is designed on the assumption that an area can be described as a set of edge-to-edge rects. The fix rounds a clip rect identically with a fill rect. (Indeed, a followup plan would be to merge QRasterPaintEngine's toNormalizedFillRect() with the rectangle rounding function in this commit). Notably, a QRectF clip is now interpreted the same as a QPainterPath clip describing the same area. This modifies d9cc1499954829faf9486fb72056e29f1bad58e3 Task-number: QTBUG-100329 Fixes: QTBUG-95957 Task-number: QTBUG-100343 Pick-to: 6.3 Change-Id: Iaae6464b9b17f8bf3adc69007f6ef8d623bf2c80 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>