Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-32741

Make appropriate api for drawing

    Details

    • Type: Suggestion
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Done
    • Affects Version/s: 5.1.0
    • Fix Version/s: 5.2.0
    • Labels:
      None
    • Commits:
      f58de6f8b35a823525aeb75337e0152bd9caeda0

      Description

      Before QML times we have QPainter api.
      Now we have QQuickPaintedItem class, but according to documentation:

      QQuickPaintedItem is meant to make it easier to port old code that is using the QPainter API to the QML Scene Graph API and it should be used only for that purpose.

      So how to paint now? Let's say we want draw only lines and images.
      The only thing that comes to my mind is next:
      1) According to http://doc-snapshot.qt-project.org/qt5-stable/qtquick/scenegraph-customgeometry.html make the same class but for line [LClass].
      2) Make class with QSGSimpleTextureNode to display image/texture[TClass].
      3) Make class which will add LClass and TClass into self. In other words - draw. [DrawClass]
      4) After drawing finished, make DrawClass layout.enabled:true;

      And this is works.
      BUT! It is painfully slow.
      Because there is a hundreds of QQuickItem objects, which should be added and maintained by scenegraph and seems this have big overhead.

      I made the test.
      I modified, as I said, customgeometry example to draw a line. Add it with Rereater in qml 10000 times. Add animation - and it just dies.

      Than I took https://qt-project.org/doc/qt-5.1/qtopengl/2dpainting.html example, disable native rendering. Make it draw lines, increased number of lines to 10000. And it still move smooth.
      Of course if we will render this to frameBuffer this will add some overhead, but...

      P.S. I even not talk about how hard to draw something in this way...

      Please, take a look attachments.

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            • Assignee:
              sletta Gunnar Sletta
              Reporter:
              tower120 Diduh Andrey
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Gerrit Reviews

                There are no open Gerrit changes