Speed up invert colors effect
ClosedPublic

Authored by andreagenor on Apr 7 2019, 5:53 AM.

Details

Summary

Signed-off-by: André Agenor <andreagenor@icloud.com>
If all channels are selected a native Qt function is called, it is faster than calculating all channels and pixels in a loop
This is 97% faster than before

Diff Detail

Repository
R374 KolourPaint
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
andreagenor requested review of this revision.Apr 7 2019, 5:53 AM
andreagenor created this revision.
andreagenor edited the summary of this revision. (Show Details)Apr 7 2019, 7:17 AM
pino added a subscriber: pino.Apr 7 2019, 7:26 AM

The API documentation of kpEffectInvert::applyEffect() says:

// Inverts the colours of each pixel in the given image.
// These functions differ from QImage::invertPixels() in the following ways:
//
// 1. for 8-bit images, it inverts the colours of the Colour Table
//    (this means that you would get visually similar results to inversion
//     at higher bit depths - rather than a "random-looking" inversion
//     depending on the contents of the Colour Table)
// 2. never inverts the Alpha Buffer

Did you check that the change does not invalidate these? (especially point 1)

imagelib/effects/kpEffectInvert.cpp
44

coding style, the opening curly bracket goes on its own line

45

coding style, missing space before opening bracket

In D20334#445058, @pino wrote:

The API documentation of kpEffectInvert::applyEffect() says:

// Inverts the colours of each pixel in the given image.
// These functions differ from QImage::invertPixels() in the following ways:
//
// 1. for 8-bit images, it inverts the colours of the Colour Table
//    (this means that you would get visually similar results to inversion
//     at higher bit depths - rather than a "random-looking" inversion
//     depending on the contents of the Colour Table)
// 2. never inverts the Alpha Buffer

Did you check that the change does not invalidate these? (especially point 1)

Yes, I tested with all kind of images, from 1 to 32 bits. Everything works the same as before.
The changes affect only if all channels are selected, the conversion is faster than before in this case.

andreagenor updated this revision to Diff 55632.Apr 7 2019, 8:11 AM
  • Fix code style
This revision is now accepted and ready to land.May 6 2019, 12:21 PM
This revision was automatically updated to reflect the committed changes.