Linked Questions

Popular Questions

QPainter is responsible to drawing and compositing in Qt. There is a section in the documentation that talks about performance. My question is regarding the bolded sentence from the following paragraph.

Raster - This backend implements all rendering in pure software and is always used to render into QImages. For optimal performance only use the format types QImage::Format_ARGB32_Premultiplied, QImage::Format_RGB32 or QImage::Format_RGB16. Any other format, including QImage::Format_ARGB32, has significantly worse performance. This engine is used by default for QWidget and QPixmap.

I understand that multiplying the color channels by the alpha is something that is done in the source-over operation. This multiplication can be done ahead-of-time to avoid doing it in the compositor. Performing this multiplication involves multiplying the RGB channels by the alpha and then dividing by 255 (or multiplying by some magic number that overflows in the right way to mimick the division). That's six integer multiplications per pixel. Surely performing an extra six integer multiplications does not have "significantly worse performance"?

Is the alpha multiplication really that slow? Perhaps they are merely stating that they don't try to optimize that code path as much as the other so there are no guarantees as to how it performs?

Related Questions