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

a paint device is recreated on every update

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • 6.4.3
    • Quick: Other
    • None
    • Linux e5-2620v2 6.2.7-arch1-1 #1 SMP PREEMPT_DYNAMIC Sat, 18 Mar 2023 01:06:36 +0000 x86_64 GNU/Linux

    • Linux/X11

    Description

      While implementing cairo support for Qt Quick applications, I've noticed that a paint device is always recreated for a QPaintedItem, even when the dimension of the item haven't changed. In other words, a QImage, with associated storage, which may be considerable, is recreated at every update. In code:

      https://github.com/user1095108/cairowidget/blob/master/CairoPaintedItem.cpp

      void CairoPaintedItem::paint(QPainter* const p)
      {
      auto cr(cr_);

      auto const w(width()), h(height());

      {
      auto const img(static_cast<QImage*>(p->device()));

      if (auto const d(img->bits()); (d != d_) || (w != w_) || (h != h_))
      {
      d_ = d; w_ = w; h_ = h;
      //...

      If you add qDebug() calls you will see that d is pretty much different every time update() on the item is called. QImage instances could be reused, making rendering faster.

      Also see:
      https://github.com/user1095108/cairowidget/blob/master/example7.cpp

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            janezzabc Janez Žemva
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes