Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Does QQuickImageProvider use QPixmapCache ?
Qt 6.11 is out! See what's new in the release blog

Does QQuickImageProvider use QPixmapCache ?

Scheduled Pinned Locked Moved QML and Qt Quick
15 Posts 2 Posters 6.0k 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.
  • slettaS Offline
    slettaS Offline
    sletta
    wrote on last edited by
    #6

    IIRC, changing the source explicitly evicts the image element from the cache, so you want to avoid that as much as possible. What you want is to create one Image element for each of the sources and alternate between which one is visible: true.

    For instance:

    @
    // ImageFlipper.qml
    Item {
    id: root
    property int index: 0;
    Image { source: "source1.png"; visible: root.index == 0 }
    Image { source: "source2.png"; visible: root.index == 1 }
    Image { source: "source3.png"; visible: root.index == 2 }
    Image { source: "source4.png"; visible: root.index == 3 }
    Image { source: "source5.png"; visible: root.index == 4 }
    }
    @

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #7

      Does it makse sense to increase the cache_limit to 20 MB if I have an embedded device with 0.5 GB RAM and I want more images to be kept in cache ?

      1 Reply Last reply
      0
      • slettaS Offline
        slettaS Offline
        sletta
        wrote on last edited by
        #8

        No, changing the size doesn't make much sense. The cache is for unreferenced stuff. What you want is to explicitly reference your images.

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #9

          I saw on qquickpixmapcache.cpp that if the QQuickImageProvider image type is QQuickImageProvider::Pixmap, the createPixmapDataSync function convert the pixmap to QImage.
          Is it better to use QQuickImageProvider::Image as the image type of the QQuickImageProvider ?

          1 Reply Last reply
          0
          • slettaS Offline
            slettaS Offline
            sletta
            wrote on last edited by
            #10

            The default implementation of QPixmap is based on QImage, so the conversion cost between the two is negligible.

            QPixmap has some code making sure the format is somewhat more optimal though, such as keeping the image in ARGB32_Premultiplied and maybe discarding the alpha channel of pngs which in practice have no alpha, so you are probably better off using Pixmap.

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #11

              If I have 16 bit display. Is it better to convert the image to QImage::Format_ARGB8565_Premultiplied instead of ARGB32_Premultiplied ?

              1 Reply Last reply
              0
              • slettaS Offline
                slettaS Offline
                sletta
                wrote on last edited by
                #12

                The texture atlas uses 32 bit textures, so unless you reimplement that using a custom scene graph adaptation layer, you are better of using ARGB32_PM.

                1 Reply Last reply
                0
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #13

                  Do you know where is the convertion from the 32 bit texture to the physical 16 bit display takes place ?

                  1 Reply Last reply
                  0
                  • slettaS Offline
                    slettaS Offline
                    sletta
                    wrote on last edited by
                    #14

                    That depends on your setup. If you have a 32 bit rendering target, the conversion happens when the frame is presented, if you have a 16 bit rendering context, the conversion most likely happens in the GPU as part of rasterization.

                    1 Reply Last reply
                    0
                    • ? Offline
                      ? Offline
                      A Former User
                      wrote on last edited by
                      #15

                      How can I determine if my rendering target is 32 bit or 16 bit ?

                      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
                      • Unsolved