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. Hot to copy QGraphicsPixmapItem ?
Forum Updated to NodeBB v4.3 + New Features

Hot to copy QGraphicsPixmapItem ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 614 Views 1 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.
  • M Offline
    M Offline
    mirell
    wrote on last edited by
    #1

    Hi, I have a task to draw within scene many of symbols. So I implemented pixmap array cache to draw pixmaps for all symbols with current font size. Then I added these pixmaps(about 30000) to scene using addPixmap method. But it looks like it creates a lot of copy of same pixmaps which affects on program working time. Is here exist the way to workaround this problem? I've tried to find solution to copy QGraphicsPixmapItem to prevent copy of pixmaps but still haven't found. Thanks.

    JonBJ 1 Reply Last reply
    0
    • M mirell

      Hi, I have a task to draw within scene many of symbols. So I implemented pixmap array cache to draw pixmaps for all symbols with current font size. Then I added these pixmaps(about 30000) to scene using addPixmap method. But it looks like it creates a lot of copy of same pixmaps which affects on program working time. Is here exist the way to workaround this problem? I've tried to find solution to copy QGraphicsPixmapItem to prevent copy of pixmaps but still haven't found. Thanks.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @mirell
      Although I do not think QGraphicsPixmapItem is a Qt shared object per se, the QPixmap it holds is a shared object, as per Implicit Sharing, So your pixmaps themselves should not be being copied.

      Then I added these pixmaps(about 30000)

      I am not a graphics expert, but what do you expect speed-/space-wise if you have 30,000 pixmaps? Sounds like an awful lot to me....

      1 Reply Last reply
      1
      • M Offline
        M Offline
        mirell
        wrote on last edited by
        #3

        Well if calculate asymptotics then it should not be a lot. I render FullHD image so to fill all pixels on image once(there is not collisions between letters) it takes about 2*10^6 operations while about 10^9 operations on modern processor = 1 sec. So it should be about 200 ms but I have 1 sec per frame

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi and welcome to devnet,

          Can you give more details about what you are doing ?
          Rendering 30000 unrelated symbols is not very clear.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          M 1 Reply Last reply
          0
          • SGaistS SGaist

            Hi and welcome to devnet,

            Can you give more details about what you are doing ?
            Rendering 30000 unrelated symbols is not very clear.

            M Offline
            M Offline
            mirell
            wrote on last edited by
            #5

            Hi @SGaist ok here the task:
            I'm implementing my own text editor which can render his state to FullHD image(make snapshot itself). I have 300x100 matrix of a-z symbols. I have font size and name. So user can zoom text and change its scale. With scaling process changes elements coordinates and sizes so I'm using scene object to manage a lot of glyphs and render only FullHD crop of whole scaled scene. I also use pixmap cache of pre-drawed text symbols because it's very complicated task to draw text. So I need to add a lot of pixmaps to my scene. And here problem appears: it works too slow for me ~1 sec. So I've decided that if I can copy QGraphicsPixmapItem and pass it to scene maybe it prevents dummy copping of same pixmap data :)

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              That makes things clearer but it looks a bit inefficient.

              Did you check the implementation of, for example, QTextEdit ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              M 1 Reply Last reply
              0
              • SGaistS SGaist

                That makes things clearer but it looks a bit inefficient.

                Did you check the implementation of, for example, QTextEdit ?

                M Offline
                M Offline
                mirell
                wrote on last edited by
                #7

                @SGaist yeah you catch me. I didn't. It's really hard to deep into such code, so previously I wanted to ask here advice what can I do with common framework oportunities.

                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