Details
-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
6.4.3
-
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
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