Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QPainterPath Performance
Forum Updated to NodeBB v4.3 + New Features

QPainterPath Performance

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 655 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Runner111
    wrote on last edited by Runner111
    #1

    Now I use QpainterPath to draw a mesh in QImage, like this:
    2f549b14-c310-4c71-bcb6-154bb37024b6-image.png

    Code:

    QBrush* bs = new QBrush(*(pInfo->pImg));
                bs->setStyle(Qt::TexturePattern);
    pait->setBrush(*bs);
                pait->setBrushOrigin(pInfo->rect.x(), pInfo->rect.y());
                QPainterPath path;
    
                for (int i = pInfo->degree_start; i <= pInfo->degree_end; i += 2) {
                    if (i > pInfo->pList->length - 4) {
                        continue;
                    }
                    path.moveTo(QPointF(pInfo->pList->vtx[i].x, pInfo->pList->vtx[i].y));
                    path.lineTo(QPointF(pInfo->pList->vtx[i + 1].x, pInfo->pList->vtx[i + 1].y));
                    path.lineTo(QPointF(pInfo->pList->vtx[i + 3].x, pInfo->pList->vtx[i + 3].y));
                    path.lineTo(QPointF(pInfo->pList->vtx[i + 2].x, pInfo->pList->vtx[i + 2].y));
                    path.lineTo(QPointF(pInfo->pList->vtx[i].x, pInfo->pList->vtx[i].y));
                }
                pait->fillPath(path, *bs);
                delete bs;
    

    But I found when the points more than 1000, the drawing is very very slow. It need more than 20 seconds. My CPU is i5-9400F 2.9G. How to optimize it?

    1 Reply Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by Kent-Dorfman
      #2

      Maybe move the render to the opengl api and ditch QPainterPath altogether? It is reasonable that QPainterPath is for small discrete objects and not for complex meshes of many primitives. Alternately split it into multiple QPainterPaths and test. I'm not sure how easy it is to map an opengl render to QImage though.

      R 1 Reply Last reply
      0
      • Kent-DorfmanK Kent-Dorfman

        Maybe move the render to the opengl api and ditch QPainterPath altogether? It is reasonable that QPainterPath is for small discrete objects and not for complex meshes of many primitives. Alternately split it into multiple QPainterPaths and test. I'm not sure how easy it is to map an opengl render to QImage though.

        R Offline
        R Offline
        Runner111
        wrote on last edited by
        #3

        @Kent-Dorfman So do I, I want to know how to use opengl in QPainterPath.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved