aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickshapes/qquickshapegenericrenderer.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Add trimming functionality to ShapePathEirik Aavitsland2025-03-241-5/+0
| | | | | | | | | | Allows specifying a subsection of the defined path to be displayed. This mirrors the recently added trimmed() method of QPainterPath. [ChangeLog][QtQuick][Shapes] Add path trimming functionality Change-Id: I76371832df07cbab9d81a557b25a6fd53150630e Reviewed-by: Eskil Abrahamsen Blomfeldt <[email protected]>
* QuickShapes: Handle removals of ShapePaths correctlyEirik Aavitsland2025-01-311-0/+12
| | | | | | | | | | | | | | | | | | | Removing paths other than the last could put the the renderers out of sync, since the path items would change their place in the list. Fix by ensuring that all items added to the list are marked as dirty. This works since removals are implemented as list clearing followed by adding back the unremoved items. In addition, the curve renderer did not remove the scene graph nodes when the path list shrinks. Same for the geometry renderer when the list shrinks to empty. So removed paths would still be visible. Fix by implementing handling of these cases. Fixes: QTBUG-133230 Fixes: QTBUG-133231 Pick-to: 6.9 6.8 Change-Id: Ie871e480b99c6b22be9efbceb1e3a4f828f868e7 Reviewed-by: Eskil Abrahamsen Blomfeldt <[email protected]>
* QuickShapes: Unify the renderers' handling of 0 strokeWidthEirik Aavitsland2024-07-121-3/+3
| | | | | | | | | | | | | | | A stroke of zero width should not be visible: that seems to be the intuitively expected behavior, and corresponds to what SVG does. However, in Qt Quick shapes, only the curve renderer backend behaved like that. The geometry and software renderers would behave differently, and different to each other. This commit standardizes on the SVG behavior. Fixes: QTBUG-126819 Pick-to: 6.8 Change-Id: I63410a732066facfad0a5f6e0565e2e80becb397 Reviewed-by: Matthias Rauter <[email protected]> Reviewed-by: Hatem ElKharashy <[email protected]>
* Add QPainterPath API to all quick shape renderersMatthias Rauter2024-07-111-1/+6
| | | | | | | | | | CurveRenderer can render a QPainterPath directly, while its sister classes require a QQuickPainterPath. This patch adds the same API to the generic shape renderer and the software renderer. Pick-to: 6.8 Change-Id: Ib0b4a6739d21f7d27c38df2d93f2394be23eced8 Reviewed-by: Paul Olav Tvete <[email protected]>
* Texture fill for shapesEskil Abrahamsen Blomfeldt2024-05-271-6/+235
| | | | | | | | | | | This introduces a "fillItem" property to ShapePath. Similar to gradient, this enables filling a shape with any texture provider item, such as an image, a ShaderEffectSource or a layer-enabled item. Fixes: QTBUG-104121 Change-Id: I8748a90c825e8eb4655a4ac90648c6ae74420527 Reviewed-by: Eirik Aavitsland <[email protected]>
* Add fillTransform property to ShapePathEirik Aavitsland2024-05-141-18/+54
| | | | | | | This adds functionality corresponding to QBrush transform to QuickShapes. Change-Id: I2b5903f8c228adec65a6f5be64e3816143879302 Reviewed-by: Eskil Abrahamsen Blomfeldt <[email protected]>
* scenegraph: Add plumbing for enabling multiviewLaszlo Agocs2024-01-151-32/+44
| | | | | | | | | This will be used in RenderMode3D only in practice, where Qt Quick 3D is going to pass in multiple matrices to the QSGRenderer. Task-number: QTBUG-114871 Change-Id: Icae7f05958729d9e51948e1f38621ec4a541192d Reviewed-by: Andy Nichols <[email protected]>
* Introduce a CurveRendering backend for textEskil Abrahamsen Blomfeldt2023-11-111-13/+15
| | | | | | | | | | | 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 <[email protected]>
* Adapt to the RHI API conceptLaszlo Agocs2023-05-221-1/+1
| | | | | | | | | | | | | | | Besides following the header naming changes, make the obvious API changes that are based on data that is already there but was hidden previously due to not wanting anything QRhi to shine through in the public API. This kind of hiding is no longer needed, even if qrhi.h and similar still cannot be included from a public header. Forward declarations are now perfectly fine however. Task-number: QTBUG-113331 Change-Id: I9a114082cf9218edc487df50956f5793d6b8bdb4 Reviewed-by: Volker Hilsheimer <[email protected]>
* Fix Shape stroke color when changing alpha from 0 to non-0Laszlo Agocs2023-01-171-0/+4
| | | | | | | | | | | | | | The handling of the stroke color lacks the extra checks that are performed when setting the fill color. Switching from "transparent" to another color involves setting not just the color-dirty flag but also the geometry-dirty since alpha == 0 may skip operations such as triangulating, meaning the work has to be performed later when once again switching to an alpha > 0 color. Change-Id: Ibd6d762cfcb07ca8b9c852553c979bcb4ee9fa21 Fixes: QTBUG-109882 Pick-to: 6.5 6.4 6.2 5.15 Reviewed-by: Christian Strømme <[email protected]>
* shapes: Privately expose the tringulator scaleLaszlo Agocs2023-01-011-18/+29
| | | | | | | | | | | | | | | | | | For many typical uses in Qt Quick the hardcoded TRI_SCALE = 1 was just fine. However, this is not quite sufficient for Qt Location's purposes since the triangulator in QtGui may run out of precision when zooming in a map and having to deal with large coordinates. To overcome this one would pass in a transform with a < 1 scale to the triangulator and then apply the same scaling in reverse to the generated vertex positions (e.g. this is what the OpenGL paint engine does). But to allow doing this, there needs to be an internal way at least, so that one can send the desired scale down to the default Shape rendering backend. Pick-to: 6.5 Change-Id: I4e7f72b79d317ebc31e9d661f4a93723854e3504 Reviewed-by: Volker Hilsheimer <[email protected]>
* Port to new Q_UNREACHABLE_RETURN()Marc Mutz2022-10-201-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator to convert sequences of Q_UNREACHABLE() + return into Q_UNREACHABLE_RETURN(), newly added to qtbase. 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)); a.k.a qt-use-unreachable-return. subStmt() and nextStmt() are non-standard matchers. There was one false positive, suppressed it with NOLINTNEXTLINE. It's not really a false positiive, 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. Change-Id: I3855b2dc8523db1ea860f72ad9818738162495c6 Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Fabian Kosmale <[email protected]>
* Port from container::count() and length() to size() - V5Marc Mutz2022-10-131-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); except that on() was replaced with a matcher that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Change-Id: I58e1b41b91c34d2e860dbb5847b3752edbfc6fc9 Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Ulf Hermann <[email protected]>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-071-1/+1
| | | | | | | | | | | | | | 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. Task-number: QTBUG-99313 Change-Id: I601bf70f020f511019ed28731ba53b14b765dbf0 Reviewed-by: Shawn Rutledge <[email protected]>
* Port from container::count() and length() to size()Marc Mutz2022-10-071-5/+5
| | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), 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', with the extended set of container classes recognized. Change-Id: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7 Reviewed-by: Fabian Kosmale <[email protected]>
* Fix casts in qquickshapegenericrendererLaszlo Agocs2022-09-261-4/+4
| | | | | | | | | | Works anyway because the data layout (a single m_node member) is the same for all the materials, but let's correct the casts. Pick-to: 6.4 6.3 6.2 Fixes: QTBUG-106824 Change-Id: I84038b04ca03339bdefc61d5780b35309fcf6670 Reviewed-by: Andy Nichols <[email protected]>
* 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 <[email protected]>
* QuickShapesPrivate: includemocsMarc Mutz2022-04-291-0/+2
| | | | | | | | | | | 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-102948 Change-Id: Ifd2eff233a07bf8e5b42f46b8658caa56bf0e58c Reviewed-by: Mårten Nordheim <[email protected]>
* Avoid unnecessary color format conversionJiDe Zhang2021-10-291-4/+6
| | | | | | | | | | | | If a color is not the rgb format, when QColor::red() QColor::blue() QColor::green() is used continuously to obtain the values of different channels, three times color conversions will occur. Therefore, use QColor::toRgb() before that to ensure that only one conversion is performed at most. Not only rgb, the conversion of other formats is the same. Change-Id: Ia969e1ca6f1524ad5d7e8dec915bcbc407875c66 Reviewed-by: Shawn Rutledge <[email protected]>
* Regenerate Shape fill geometry when alpha changes to non-zeroLaszlo Agocs2021-01-131-0/+4
| | | | | | | | | | An alpha of 0 removes the scenegraph node for the fill. If the alpha changes to non-zero afterwards, the geometry needs to be regenerated. Pick-to: 6.0 5.15 Fixes: QTBUG-85103 Change-Id: I180b9eb78bd98b99bc87c4d960108b95eb6ae723 Reviewed-by: Andy Nichols <[email protected]>
* Shapes: only call update() when something changedLaszlo Agocs2020-09-071-1/+4
| | | | | | | | | | | | Shapes has an unusual setup where changing properties (or properties of the Path objects) does not lead to calling update() on the Shape item. That's why it was done in updatePolish() but that can be made less heavy by only doing it when the shape found that something got changed. Task-number: QTBUG-86089 Change-Id: I74f708a960a29f26eb003ac160d2b1258b9ae50f Reviewed-by: Andy Nichols <[email protected]>
* Clean up QT_CONFIG(opengl)Paul Olav Tvete2020-06-171-49/+11
| | | | | | | | | | Accelerated graphics is now possible without OpenGL support. With this change, a Qt build with -no-opengl can still run Qt Quick with a Vulkan, Metal, or Direct3D backend. Fixes: QTBUG-84027 Change-Id: Ib63c733d28cfdf7de16b138df136fa7628e1747b Reviewed-by: Laszlo Agocs <[email protected]>
* Anisotropic antialiasing for distance field textEskil Abrahamsen Blomfeldt2020-06-151-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For perspective transforms, we need to find the sample range in the glyph cache per pixel. We can do this by getting the gradient of the distance field at the specific pixel. This will ensure proper antialiasing with any projection, but has the limitation that when glyph contours become thinner than a pixel, they may disappear or become too emphasized, because the hardware-gradient - based on neighbouring fragments - is not reliable at that scale. So we should only default to this when we detect that the text is child of a 3D scene. To make this smooth, we need to know the mode of the renderer when creating the shader. So QSGMaterial::createShader() now takes a render mode that we can use to customize behavior based on whether it is rendering into a 2D or 3D scene. [ChangeLog][QtQuick] The QSGMaterial::createShader() virtual function has been extended to take a render mode argument, which can be used for any customizations needed in the case where the shader will be used in combination with 3D perspective transformations. Fixes: QTBUG-84695 Change-Id: I5a18a4edbdfa07e8f9d506c42bb20e8eb580927d Reviewed-by: Laszlo Agocs <[email protected]>
* Make QSGMaterialRhiShader become QSGMaterialShaderLaszlo Agocs2020-06-021-176/+3
| | | | | | | | | | | | | | | | After a symbiotic relationship in Qt 5.14 and 5.15, it is time for QSGMaterialRhiShader to devour its older sibling and take its place. This makes the direct OpenGL rendering path disfunctional. All QSGMaterial Qt 6 TODOs are solved, the API is clean and straightforward again: a QSGMaterial creates a QSGMaterialShader, no special flags and options needed. (it's just that QSGMaterialShader now has a slightly different API) Task-number: QTBUG-79268 Task-number: QTBUG-82997 Change-Id: I545ca8d796c5535e81957c706e7832133be15b7d Reviewed-by: Eirik Aavitsland <[email protected]>
* Move updateRhiTexture and co. to QSGTextureLaszlo Agocs2020-04-281-3/+3
| | | | | | | | | | | | | | | | | | | Use a more descriptive name, commitTextureOperations() in order to avoid confusion with QSGDynamicTexture::updateTexture() which has nothing to do with this. With this the QSGTexture interface has all 5.14 pending changes done (changes that were plumbed via ugly hacks due to having had to deal with binary compatibility). The awful enforcing of subclassing QSGTexturePrivate for each and every QSGTexture subclass is now eliminated. Purging the direct OpenGL code path will involve removing QSGTexture functions like textureId(), bind(), updateBindOptions(). With this patch we now we have all the equivalents (or, in some cases, spiritual successors) in place. Task-number: QTBUG-82997 Change-Id: I7a831f982070c52abc7a36604130a1110d14ff9c Reviewed-by: Andy Nichols <[email protected]>
* shapes: Avoid upsetting Mesa on eglfs with kmsLaszlo Agocs2020-04-211-1/+9
| | | | | | | | | | | | We need to either ensure the context is destroyed before the offscreen surface, or make sure the context is not current (and so the surface is not associated with it anymore) when it is destroyed. We choose the latter here. Change-Id: If4424b98c4d8a718aa49d99285360ded6a5e128e Fixes: QTBUG-82371 Pick-to: 5.15 Reviewed-by: Andy Nichols <[email protected]>
* Quick: Don't qualify OpenGL includesUlf Hermann2020-01-271-1/+1
| | | | | | | | | | | | | The headers are moving from QtGui to QtOpenGL. By avoiding the qualification we can keep them compiling either way. Also, add opengl-private to make the types available. Also removed the QGraphicsRotation hack to get access to the projected rotation function of QMatrix4x4. The function is public now. Task-number: QTBUG-74409 Change-Id: I216e8ca09f8e247f96627b081308e3a57c55c29c Reviewed-by: Ulf Hermann <[email protected]>
* Avoid initializing QFlags with 0 or nullptr in further casesFriedemann Kleint2019-11-251-3/+3
| | | | | | | Amends 744e77b841878fb017c0f2d60607090008f28180. Change-Id: I16e37aaf503eb62f67fca0e48be4c92c4a72ae46 Reviewed-by: Ulf Hermann <[email protected]>
* Change const ref to ref in QSGMaterialRhiShader as per API reviewLaszlo Agocs2019-09-231-6/+6
| | | | | | Change-Id: I7783ed26a66f03ebe3b26bcba2f42f9fff45a417 Reviewed-by: Lars Knoll <[email protected]> Reviewed-by: Christian Strømme <[email protected]>
* Add the graphics api independent scenegraph portLaszlo Agocs2019-07-041-30/+271
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]>
* Do qtVectorPathForPath before starting thread poolUlf Hermann2019-06-141-0/+6
| | | | | | | | | | This avoids the race condition created by calling it the first time inside the threads. Fixes: QTBUG-76338 Fixes: QTBUG-76069 Change-Id: I6108526eb6f5b5ba9c3334437102fc5959f53030 Reviewed-by: Laszlo Agocs <[email protected]>
* Enable Qt Quick path and shapes for the no-thread configurationMorten Johan Sørvig2018-09-121-1/+17
| | | | | | | | | | | | Force synchronous rendering in QQuickShapGenericRenderer. (In theory, we could support async also for no-thread by running the tasks on the Gui thread, but there would perhaps be little gain from doing this.) Change-Id: I0fb7526fdaa56d3c609c83c8d4790b4352d782fd Reviewed-by: Lorn Potter <[email protected]> Reviewed-by: Simon Hausmann <[email protected]>
* Move QtQuick.Shapes implementation to qtquickshapes, privately exportedPaolo Angelelli2018-06-211-0/+1007
This change moves the implementation of QtQuick.Shapes into an own qt module, where classes are privately exported. In this way Shapes QML types can be internally (= from other Qt modules) instantiated also from cpp. Change-Id: I428f981f0a1f3083e6571cbeaffa706fd8ef7254 Reviewed-by: Shawn Rutledge <[email protected]> Reviewed-by: Laszlo Agocs <[email protected]>