diff options
Diffstat (limited to 'examples/quick')
-rw-r--r-- | examples/quick/imageelements/doc/src/imageelements.qdoc | 4 | ||||
-rw-r--r-- | examples/quick/scenegraph/fboitem/doc/images/fboitem-example.jpg (renamed from examples/quick/scenegraph/textureinsgnode/doc/images/textureinsgnode-example.jpg) | bin | 25863 -> 25863 bytes | |||
-rw-r--r-- | examples/quick/scenegraph/fboitem/doc/src/fboitem.qdoc (renamed from examples/quick/scenegraph/textureinsgnode/doc/src/textureinsgnode.qdoc) | 4 | ||||
-rw-r--r-- | examples/quick/scenegraph/fboitem/fboinsgrenderer.cpp (renamed from examples/quick/scenegraph/textureinsgnode/fboinsgrenderer.cpp) | 0 | ||||
-rw-r--r-- | examples/quick/scenegraph/fboitem/fboinsgrenderer.h (renamed from examples/quick/scenegraph/textureinsgnode/fboinsgrenderer.h) | 0 | ||||
-rw-r--r-- | examples/quick/scenegraph/fboitem/fboitem.pro (renamed from examples/quick/scenegraph/textureinsgnode/textureinsgnode.pro) | 4 | ||||
-rw-r--r-- | examples/quick/scenegraph/fboitem/fboitem.qrc (renamed from examples/quick/scenegraph/textureinsgnode/textureinsgnode.qrc) | 2 | ||||
-rw-r--r-- | examples/quick/scenegraph/fboitem/main.cpp (renamed from examples/quick/scenegraph/textureinsgnode/main.cpp) | 2 | ||||
-rw-r--r-- | examples/quick/scenegraph/fboitem/main.qml (renamed from examples/quick/scenegraph/textureinsgnode/main.qml) | 0 | ||||
-rw-r--r-- | examples/quick/scenegraph/metaltextureimport/metaltextureimport.mm | 8 | ||||
-rw-r--r-- | examples/quick/scenegraph/metalunderqml/metalsquircle.mm | 8 | ||||
-rw-r--r-- | examples/quick/scenegraph/rendernode/metalrenderer.mm | 8 | ||||
-rw-r--r-- | examples/quick/scenegraph/scenegraph.pro | 2 | ||||
-rw-r--r-- | examples/quick/scenegraph/vulkanunderqml/vulkansquircle.cpp | 16 | ||||
-rw-r--r-- | examples/quick/shapes/content/interactive.qml | 113 |
15 files changed, 115 insertions, 56 deletions
diff --git a/examples/quick/imageelements/doc/src/imageelements.qdoc b/examples/quick/imageelements/doc/src/imageelements.qdoc index 2c6490fb2c..4c00915e56 100644 --- a/examples/quick/imageelements/doc/src/imageelements.qdoc +++ b/examples/quick/imageelements/doc/src/imageelements.qdoc @@ -38,12 +38,12 @@ \section1 Scaling with BorderImage - \e BorderImage shows off the various scaling modes of the \l BorderImage + \e BorderImage shows the various scaling modes of the \l BorderImage type by setting its horizontalTileMode and verticalTileMode properties. \section1 Image Fill - \e Image shows off the various fill modes of the \l Image type. + \e Image shows the various fill modes of the \l Image type. \section1 Shadow Effects diff --git a/examples/quick/scenegraph/textureinsgnode/doc/images/textureinsgnode-example.jpg b/examples/quick/scenegraph/fboitem/doc/images/fboitem-example.jpg Binary files differindex 306b8bab20..306b8bab20 100644 --- a/examples/quick/scenegraph/textureinsgnode/doc/images/textureinsgnode-example.jpg +++ b/examples/quick/scenegraph/fboitem/doc/images/fboitem-example.jpg diff --git a/examples/quick/scenegraph/textureinsgnode/doc/src/textureinsgnode.qdoc b/examples/quick/scenegraph/fboitem/doc/src/fboitem.qdoc index c1c830338b..b5add02991 100644 --- a/examples/quick/scenegraph/textureinsgnode/doc/src/textureinsgnode.qdoc +++ b/examples/quick/scenegraph/fboitem/doc/src/fboitem.qdoc @@ -26,11 +26,11 @@ ****************************************************************************/ /*! - \example scenegraph/textureinsgnode + \example scenegraph/fboitem \title Scene Graph - Rendering FBOs \ingroup qtquickexamples \brief Shows how to use FramebufferObjects with Qt Quick. - \image textureinsgnode-example.jpg + \image fboitem-example.jpg */ diff --git a/examples/quick/scenegraph/textureinsgnode/fboinsgrenderer.cpp b/examples/quick/scenegraph/fboitem/fboinsgrenderer.cpp index 8ba5bddb2a..8ba5bddb2a 100644 --- a/examples/quick/scenegraph/textureinsgnode/fboinsgrenderer.cpp +++ b/examples/quick/scenegraph/fboitem/fboinsgrenderer.cpp diff --git a/examples/quick/scenegraph/textureinsgnode/fboinsgrenderer.h b/examples/quick/scenegraph/fboitem/fboinsgrenderer.h index 1b92b56851..1b92b56851 100644 --- a/examples/quick/scenegraph/textureinsgnode/fboinsgrenderer.h +++ b/examples/quick/scenegraph/fboitem/fboinsgrenderer.h diff --git a/examples/quick/scenegraph/textureinsgnode/textureinsgnode.pro b/examples/quick/scenegraph/fboitem/fboitem.pro index 238e20a553..e40e5f4cf8 100644 --- a/examples/quick/scenegraph/textureinsgnode/textureinsgnode.pro +++ b/examples/quick/scenegraph/fboitem/fboitem.pro @@ -7,9 +7,9 @@ INCLUDEPATH += ../shared HEADERS += ../shared/logorenderer.h SOURCES += ../shared/logorenderer.cpp -RESOURCES += textureinsgnode.qrc +RESOURCES += fboitem.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/quick/scenegraph/textureinsgnode +target.path = $$[QT_INSTALL_EXAMPLES]/quick/scenegraph/fboitem INSTALLS += target OTHER_FILES += \ diff --git a/examples/quick/scenegraph/textureinsgnode/textureinsgnode.qrc b/examples/quick/scenegraph/fboitem/fboitem.qrc index 9ecf0ada1c..9d9db70654 100644 --- a/examples/quick/scenegraph/textureinsgnode/textureinsgnode.qrc +++ b/examples/quick/scenegraph/fboitem/fboitem.qrc @@ -1,5 +1,5 @@ <RCC> - <qresource prefix="/scenegraph/textureinsgnode"> + <qresource prefix="/scenegraph/fboitem"> <file>main.qml</file> </qresource> </RCC> diff --git a/examples/quick/scenegraph/textureinsgnode/main.cpp b/examples/quick/scenegraph/fboitem/main.cpp index 6358a1d75b..056bf24ade 100644 --- a/examples/quick/scenegraph/textureinsgnode/main.cpp +++ b/examples/quick/scenegraph/fboitem/main.cpp @@ -62,7 +62,7 @@ int main(int argc, char **argv) QQuickView view; view.setResizeMode(QQuickView::SizeRootObjectToView); - view.setSource(QUrl("qrc:///scenegraph/textureinsgnode/main.qml")); + view.setSource(QUrl("qrc:///scenegraph/fboitem/main.qml")); view.show(); return app.exec(); diff --git a/examples/quick/scenegraph/textureinsgnode/main.qml b/examples/quick/scenegraph/fboitem/main.qml index 92fa99e847..92fa99e847 100644 --- a/examples/quick/scenegraph/textureinsgnode/main.qml +++ b/examples/quick/scenegraph/fboitem/main.qml diff --git a/examples/quick/scenegraph/metaltextureimport/metaltextureimport.mm b/examples/quick/scenegraph/metaltextureimport/metaltextureimport.mm index 6bb68dac44..66a39083f7 100644 --- a/examples/quick/scenegraph/metaltextureimport/metaltextureimport.mm +++ b/examples/quick/scenegraph/metaltextureimport/metaltextureimport.mm @@ -281,7 +281,7 @@ void CustomTextureNode::sync() m_vs = compileShaderFromSource(m_vert, m_vertEntryPoint); m_fs = compileShaderFromSource(m_frag, m_fragEntryPoint); - const int framesInFlight = m_window->graphicsStateInfo()->framesInFlight; + const int framesInFlight = m_window->graphicsStateInfo().framesInFlight; m_vbuf = [m_device newBufferWithLength: sizeof(vertices) options: MTLResourceStorageModeShared]; void *p = [m_vbuf contents]; @@ -348,8 +348,8 @@ void CustomTextureNode::render() Q_ASSERT(cb); id<MTLRenderCommandEncoder> encoder = [cb renderCommandEncoderWithDescriptor: renderpassdesc]; - const QQuickWindow::GraphicsStateInfo *stateInfo = m_window->graphicsStateInfo(); - void *p = [m_ubuf[stateInfo->currentFrameSlot] contents]; + const QQuickWindow::GraphicsStateInfo &stateInfo(m_window->graphicsStateInfo()); + void *p = [m_ubuf[stateInfo.currentFrameSlot] contents]; memcpy(p, &m_t, 4); MTLViewport vp; @@ -361,7 +361,7 @@ void CustomTextureNode::render() vp.zfar = 1; [encoder setViewport: vp]; - [encoder setFragmentBuffer: m_ubuf[stateInfo->currentFrameSlot] offset: 0 atIndex: 0]; + [encoder setFragmentBuffer: m_ubuf[stateInfo.currentFrameSlot] offset: 0 atIndex: 0]; [encoder setVertexBuffer: m_vbuf offset: 0 atIndex: 1]; [encoder setRenderPipelineState: m_pipeline]; [encoder drawPrimitives: MTLPrimitiveTypeTriangleStrip vertexStart: 0 vertexCount: 4 instanceCount: 1 baseInstance: 0]; diff --git a/examples/quick/scenegraph/metalunderqml/metalsquircle.mm b/examples/quick/scenegraph/metalunderqml/metalsquircle.mm index 8a1a03dc68..5ca6daa01a 100644 --- a/examples/quick/scenegraph/metalunderqml/metalsquircle.mm +++ b/examples/quick/scenegraph/metalunderqml/metalsquircle.mm @@ -215,7 +215,7 @@ void SquircleRenderer::frameStart() prepareShader(FragmentStage); if (!m_initialized) - init(m_window->graphicsStateInfo()->framesInFlight); + init(m_window->graphicsStateInfo().framesInFlight); } static const float vertices[] = { @@ -233,7 +233,7 @@ void SquircleRenderer::mainPassRecordingStart() // the scenegraph's main renderpass. It does not create its own passes, // rendertargets, etc. so no synchronization is needed. - const QQuickWindow::GraphicsStateInfo *stateInfo = m_window->graphicsStateInfo(); + const QQuickWindow::GraphicsStateInfo &stateInfo(m_window->graphicsStateInfo()); QSGRendererInterface *rif = m_window->rendererInterface(); id<MTLRenderCommandEncoder> encoder = (id<MTLRenderCommandEncoder>) rif->getResource( @@ -242,7 +242,7 @@ void SquircleRenderer::mainPassRecordingStart() m_window->beginExternalCommands(); - void *p = [m_ubuf[stateInfo->currentFrameSlot] contents]; + void *p = [m_ubuf[stateInfo.currentFrameSlot] contents]; float t = m_t; memcpy(p, &t, 4); @@ -255,7 +255,7 @@ void SquircleRenderer::mainPassRecordingStart() vp.zfar = 1; [encoder setViewport: vp]; - [encoder setFragmentBuffer: m_ubuf[stateInfo->currentFrameSlot] offset: 0 atIndex: 0]; + [encoder setFragmentBuffer: m_ubuf[stateInfo.currentFrameSlot] offset: 0 atIndex: 0]; [encoder setVertexBuffer: m_vbuf offset: 0 atIndex: 1]; [encoder setRenderPipelineState: m_pipeline]; [encoder drawPrimitives: MTLPrimitiveTypeTriangleStrip vertexStart: 0 vertexCount: 4 instanceCount: 1 baseInstance: 0]; diff --git a/examples/quick/scenegraph/rendernode/metalrenderer.mm b/examples/quick/scenegraph/rendernode/metalrenderer.mm index 11db276f37..b83dc62c48 100644 --- a/examples/quick/scenegraph/rendernode/metalrenderer.mm +++ b/examples/quick/scenegraph/rendernode/metalrenderer.mm @@ -131,7 +131,7 @@ void MetalRenderNodeResourceBuilder::build() g.fs = compileShaderFromSource(g.fsSource, QByteArrayLiteral("main0")); } - const int framesInFlight = m_window->graphicsStateInfo()->framesInFlight; + const int framesInFlight = m_window->graphicsStateInfo().framesInFlight; // For simplicity's sake we use shared mode (something like host visible + // host coherent) for everything. @@ -258,9 +258,9 @@ void MetalRenderNode::releaseResources() void MetalRenderNode::render(const RenderState *state) { Q_ASSERT(m_window); - const QQuickWindow::GraphicsStateInfo *stateInfo = m_window->graphicsStateInfo(); - id<MTLBuffer> vbuf = g.vbuf[stateInfo->currentFrameSlot]; - id<MTLBuffer> ubuf = g.ubuf[stateInfo->currentFrameSlot]; + const QQuickWindow::GraphicsStateInfo &stateInfo(m_window->graphicsStateInfo()); + id<MTLBuffer> vbuf = g.vbuf[stateInfo.currentFrameSlot]; + id<MTLBuffer> ubuf = g.ubuf[stateInfo.currentFrameSlot]; QPointF p0(m_width - 1, m_height - 1); QPointF p1(0, 0); diff --git a/examples/quick/scenegraph/scenegraph.pro b/examples/quick/scenegraph/scenegraph.pro index e05e1ddb44..5fea3b974a 100644 --- a/examples/quick/scenegraph/scenegraph.pro +++ b/examples/quick/scenegraph/scenegraph.pro @@ -5,7 +5,7 @@ qtConfig(opengl(es1|es2)?) { graph \ simplematerial \ sgengine \ - textureinsgnode \ + fboitem \ openglunderqml \ textureinthread \ twotextureproviders diff --git a/examples/quick/scenegraph/vulkanunderqml/vulkansquircle.cpp b/examples/quick/scenegraph/vulkanunderqml/vulkansquircle.cpp index 59e9606e7b..21f46a25c1 100644 --- a/examples/quick/scenegraph/vulkanunderqml/vulkansquircle.cpp +++ b/examples/quick/scenegraph/vulkanunderqml/vulkansquircle.cpp @@ -212,7 +212,7 @@ void SquircleRenderer::frameStart() prepareShader(FragmentStage); if (!m_initialized) - init(m_window->graphicsStateInfo()->framesInFlight); + init(m_window->graphicsStateInfo().framesInFlight); } static const float vertices[] = { @@ -230,10 +230,10 @@ void SquircleRenderer::mainPassRecordingStart() // the scenegraph's main renderpass. It does not create its own passes, // rendertargets, etc. so no synchronization is needed. - const QQuickWindow::GraphicsStateInfo *stateInfo = m_window->graphicsStateInfo(); + const QQuickWindow::GraphicsStateInfo &stateInfo(m_window->graphicsStateInfo()); QSGRendererInterface *rif = m_window->rendererInterface(); - VkDeviceSize ubufOffset = stateInfo->currentFrameSlot * m_allocPerUbuf; + VkDeviceSize ubufOffset = stateInfo.currentFrameSlot * m_allocPerUbuf; void *p = nullptr; VkResult err = m_devFuncs->vkMapMemory(m_dev, m_ubufMem, ubufOffset, m_allocPerUbuf, 0, &p); if (err != VK_SUCCESS || !p) @@ -259,7 +259,7 @@ void SquircleRenderer::mainPassRecordingStart() VkDeviceSize vbufOffset = 0; m_devFuncs->vkCmdBindVertexBuffers(cb, 0, 1, &m_vbuf, &vbufOffset); - uint32_t dynamicOffset = m_allocPerUbuf * stateInfo->currentFrameSlot; + uint32_t dynamicOffset = m_allocPerUbuf * stateInfo.currentFrameSlot; m_devFuncs->vkCmdBindDescriptorSets(cb, VK_PIPELINE_BIND_POINT_GRAPHICS, m_pipelineLayout, 0, 1, &m_ubufDescriptor, 1, &dynamicOffset); @@ -362,13 +362,13 @@ void SquircleRenderer::init(int framesInFlight) } } } - if (memTypeIndex < 0) + if (memTypeIndex == uint32_t(-1)) qFatal("Failed to find host visible and coherent memory type"); allocInfo.memoryTypeIndex = memTypeIndex; err = m_devFuncs->vkAllocateMemory(m_dev, &allocInfo, nullptr, &m_vbufMem); if (err != VK_SUCCESS) - qFatal("Failed to allocate vertex buffer memory of size %llu: %d", allocInfo.allocationSize, err); + qFatal("Failed to allocate vertex buffer memory of size %u: %d", uint(allocInfo.allocationSize), err); void *p = nullptr; err = m_devFuncs->vkMapMemory(m_dev, m_vbufMem, 0, allocInfo.allocationSize, 0, &p); @@ -412,14 +412,14 @@ void SquircleRenderer::init(int framesInFlight) } } } - if (memTypeIndex < 0) + if (memTypeIndex == uint32_t(-1)) qFatal("Failed to find host visible and coherent memory type"); allocInfo.allocationSize = framesInFlight * m_allocPerUbuf; allocInfo.memoryTypeIndex = memTypeIndex; err = m_devFuncs->vkAllocateMemory(m_dev, &allocInfo, nullptr, &m_ubufMem); if (err != VK_SUCCESS) - qFatal("Failed to allocate uniform buffer memory of size %llu: %d", allocInfo.allocationSize, err); + qFatal("Failed to allocate uniform buffer memory of size %u: %d", uint(allocInfo.allocationSize), err); err = m_devFuncs->vkBindBufferMemory(m_dev, m_ubuf, m_ubufMem, 0); if (err != VK_SUCCESS) diff --git a/examples/quick/shapes/content/interactive.qml b/examples/quick/shapes/content/interactive.qml index 55a1d16299..78413db3f9 100644 --- a/examples/quick/shapes/content/interactive.qml +++ b/examples/quick/shapes/content/interactive.qml @@ -170,14 +170,45 @@ Rectangle { property variant resizers: [] property variant funcs + property Component mouseArea: Component { + Rectangle { + id: rr + + property variant obj + property string xprop + property string yprop + + width: 20 + height: 20 + + MouseArea { + property bool a: false + + anchors.fill: parent + hoverEnabled: true + onEntered: color = "yellow" + onExited: color = rr.color + onPressed: a = true + onReleased: a = false + onPositionChanged: { + if (a) { + var pt = mapToItem(rr.parent, mouse.x, mouse.y); + rr.obj[rr.xprop] = pt.x + rr.obj[rr.yprop] = pt.y + rr.x = pt.x - 10 + rr.y = pt.y - 10 + } + } + } + } + } + function genResizer(obj, x, y, xprop, yprop, color) { - var ma = Qt.createQmlObject('import QtQuick 2.9; import QtQuick.Shapes 1.0; Rectangle { id: rr; property variant obj; color: "' + color + '"; width: 20; height: 20;'+ - 'MouseArea { anchors.fill: parent; hoverEnabled: true;' + - 'onEntered: color = "yellow"; onExited: color = "' + color + '";' + - 'property bool a: false; onPressed: a = true; onReleased: a = false; ' + - 'onPositionChanged: if (a) { var pt = mapToItem(rr.parent, mouse.x, mouse.y);' + - 'obj.' + xprop + ' = pt.x; obj.' + yprop + ' = pt.y; rr.x = pt.x - 10; rr.y = pt.y - 10; } } }', - canvas, "resizer_item"); + var ma = mouseArea.createObject(canvas, { + color: color, + xprop: xprop, + yprop: yprop + }); ma.visible = root.showResizers; ma.obj = obj; ma.x = x - 10; @@ -186,15 +217,55 @@ Rectangle { return ma; } + property Component linePath: Component { + ShapePath { + id: lineShapePath + strokeColor: "black" + strokeWidth: widthSlider.value + fillColor: "transparent" + PathLine { + x: lineShapePath.startX + 1 + y: lineShapePath.startY + 1 + } + } + } + + property Component cubicPath: Component { + ShapePath { + id: cubicShapePath + strokeColor: "black" + strokeWidth: widthSlider.value + fillColor: root.fill ? 'green' : 'transparent' + PathCubic { + x: cubicShapePath.startX + 1 + y: cubicShapePath.startY + 1 + control1X: cubicShapePath.startX + 50; + control1Y: cubicShapePath.startY + 50; + control2X: cubicShapePath.startX + 150; + control2Y: cubicShapePath.startY + 50; + } + } + } + + property Component quadPath: Component { + ShapePath { + id: quadShapePath + strokeColor: "black" + strokeWidth: widthSlider.value + fillColor: root.fill ? 'green' : 'transparent' + PathQuad { + x: quadShapePath.startx + 1 + y: quadShapePath.startY + 1 + controlX: quadShapePath.startX + 50 + controlY: quadShapePath.startY + 50 + } + } + } + Component.onCompleted: { funcs = [ { "start": function(x, y) { - var p = Qt.createQmlObject('import QtQuick 2.9; import QtQuick.Shapes 1.0; ShapePath {' + - 'strokeColor: "black"; fillColor: "transparent";'+ - 'strokeWidth: ' + widthSlider.value + ';' + - 'startX: ' + x + '; startY: ' + y + ';' + - 'PathLine { x: ' + x + ' + 1; y: ' + y + ' + 1 } }', - root, "dynamic_visual_path"); + var p = linePath.createObject(root, { startX: x, startY: y }); shape.data.push(p); activePath = p; }, "move": function(x, y) { @@ -211,13 +282,7 @@ Rectangle { } }, { "start": function(x, y) { - var p = Qt.createQmlObject('import QtQuick 2.9; import QtQuick.Shapes 1.0; ShapePath {' + - 'strokeColor: "black"; fillColor: "' + (root.fill ? 'green' : 'transparent') + '";'+ - 'strokeWidth: ' + widthSlider.value + ';' + - 'startX: ' + x + '; startY: ' + y + ';' + - 'PathCubic { x: ' + x + ' + 1; y: ' + y + ' + 1;' + - 'control1X: ' + x + ' + 50; control1Y: ' + y + ' + 50; control2X: ' + x + ' + 150; control2Y: ' + y + ' + 50; } }', - root, "dynamic_visual_path"); + var p = cubicPath.createObject(root, { startX: x, startY: y }); shape.data.push(p); activePath = p; }, "move": function(x, y) { @@ -236,13 +301,7 @@ Rectangle { } }, { "start": function(x, y) { - var p = Qt.createQmlObject('import QtQuick 2.9; import QtQuick.Shapes 1.0; ShapePath {' + - 'strokeColor: "black"; fillColor: "' + (root.fill ? 'green' : 'transparent') + '";'+ - 'strokeWidth: ' + widthSlider.value + ';' + - 'startX: ' + x + '; startY: ' + y + ';' + - 'PathQuad { x: ' + x + ' + 1; y: ' + y + ' + 1;' + - 'controlX: ' + x + ' + 50; controlY: ' + y + ' + 50 } }', - root, "dynamic_visual_path"); + var p = quadPath.createObject(root, { startX: x, startY: y }); shape.data.push(p); activePath = p; }, "move": function(x, y) { |