美文网首页
Qml界面渲染机制

Qml界面渲染机制

作者: 技术喵 | 来源:发表于2019-07-09 07:31 被阅读0次

渲染层次:

0_1531798264848_48a56a99-a2a7-4a1e-8d0e-f12d889d74a1-image.png

渲染循环分三种,basic, windows, and threaded,其中Basic和Windows是单线程的,threaded在单独线程里面渲染场景,qt会根据平台自动选择一种,我电脑上已经验证是threaded

qt.scenegraph.general: threaded render loop qt.scenegraph.general: Using sg animation driver qt.scenegraph.general: Animation Driver: using vsync: 16.67 ms

同时可以知道画面垂直同步是16.67 ms,理论60Hz

线程渲染循环中如何完成一帧

0_1531798407892_935d0c1f-554a-4cbb-999a-a0966484548d-image.png
  1. A change occurs in the QML scene, causing QQuickItem::update() to be called. This can be the result of for instance an animation or user input. An event is posted to the render thread to initiate a new frame.
  2. The render thread prepares to draw a new frame and makes the OpenGL context current and initiates a block on the GUI thread.
  3. While the render thread is preparing the new frame, the GUI thread calls QQuickItem::updatePolish() to do final touch-up of items before they are rendered.
  4. GUI thread is blocked.
  5. The QQuickWindow::beforeSynchronizing() signal is emitted. Applications can make direct connections (using Qt::DirectConnection) to this signal to do any preparation required before calls to QQuickItem::updatePaintNode().
  6. Synchronization of the QML state into the scene graph. This is done by calling the QQuickItem::updatePaintNode() function on all items that have changed since the previous frame. This is the only time the QML items and the nodes in the scene graph interact.
  7. GUI thread block is released.
  8. The scene graph is rendered:
  9. The QQuickWindow::beforeRendering() signal is emitted. Applications can make direct connections (using Qt::DirectConnection) to this signal to use custom OpenGL calls which will then stack visually beneath the QML scene.
  10. Items that have specified QSGNode::UsePreprocess, will have their QSGNode::preprocess() function invoked.
  11. The renderer processes the nodes and calls OpenGL functions.
  12. The QQuickWindow::afterRendering() signal is emitted. Applications can make direct connections (using Qt::DirectConnection) to this signal to use custom OpenGL calls which will then stack visually over the QML scene.
  13. The rendered frame is swapped and QQuickWindow::frameSwapped() is emitted.
  14. While the render thread is rendering, the GUI is free to advance animations, process events, etc.
    The threaded renderer is currently used by default on Windows with opengl32.dll, Linux with non-Mesa based drivers, macOS, mobile platforms, and Embedded Linux with EGLFS but this is subject to change. It is possible to force use of the threaded renderer by setting QSG_RENDER_LOOP=threaded in the environment.

非线程渲染

0_1531798434302_91612780-f2cf-4fdb-b5a1-aeb004a1e7a2-image.png

查看渲染方式:

QLoggingCategory::setFilterRules(QStringLiteral("qt.scenegraph.general=true")); qSetMessagePattern("%{category}: %{message}");

相关文章

  • Qml界面渲染机制

    渲染层次: 渲染循环分三种,basic, windows, and threaded,其中Basic和Window...

  • PyQt5

    用QML渲染界面 第一种: 通过QQickView 注意: QQickView的main.qml根节点不能是App...

  • 官方提供的基础指南一

    1.Hello World 程序 2.QML 实现GUI界面 QML 使用声明式语法实现GUI界面,要使用QML实...

  • iOS界面渲染机制

    iOS渲染视图的核心是Core Animation 从中可以看到,界面显示的整体流程如下:1、CoreAnimat...

  • QML基础信息

    QML 学习 基本概念 QT C++ 跨平台C++用户界面应用程序框架,一种面向对象框架,支持2D,3D渲染,支...

  • iOS 事件处理机制与图像渲染过程

    iOS 事件处理机制与图像渲染过程iOS开发-视图渲染与性能优化iOS 保持界面流畅的技巧YYAsyncLayer...

  • 自底向上—iOS界面优化(第一话)

    交互式图形显示系统渲染机制 对iOS应用进行界面响应速度上的优化,首先需要了解iOS系统的渲染机制,本文是本系列文...

  • Qt Quick 学习笔记(二) QML与C++双向对接

    QML→C++的对接 信号槽机制 大部分情况下,用户对QML的操作,需要调用对应的C++函数进行处理。QML上的操...

  • iOS面试题大全

    iOS面试题大全-点亮你iOS技能树 iOS 事件处理机制与图像渲染过程 iOS界面渲染流程分析 wechat ...

  • QML 美化界面

    1、设置应用图标 1、需要图为.ico 格式 ;2、RC_ICONS = image/logo.ico (相对路...

网友评论

      本文标题:Qml界面渲染机制

      本文链接:https://www.haomeiwen.com/subject/xryihctx.html