Krita useable for Blender movies

Thomas Zander zander at kde.org
Fri Oct 23 14:04:00 CEST 2009


On Friday 23. October 2009 13.47.54 Dmitry Kazakov wrote:
> 2) To make bitBlt'ing more faster we should solve another one issue:
> compositeOps constants in pigment.
>
> I don't know how it happened, but all the compositeOp constants (like
> COMPOSITE_OVER) are strings! And for every stride of the image (there might
> be more than 1000 strides per image) we do a string comparison! More than
> that, we do many string comparisons on every composition! See [1].
>
> I don't know where COMPOSITE_OVER and COMPOSITE_ALPHA_DARKEN are
> implemented, maybe their application is optimized a bit, but most of the
> others should suffer from this comparison.
>
> Of course, Qt may smooth this comparison procedure a bit with shared
> internal data, but nevertheless integer switch should be much faster than
> that.
>
> What do i suggest?
> Change all these constants' type to qint32 and create separate function
> that would show their name using integers. This chain of if() constrictions
> in [1] could be replaced with a simple 'switch' construction.
> Theoretically, a compiler can optimize this switch with a jump table at asm
> level.

My suggestion would be to avoid this lookup altogether; use the strategy 
design pattern and instead of having an Id (either string or integer) you can 
just store a pointer to the method/class that implements your code.

http://en.wikipedia.org/wiki/Strategy_pattern

> [1] libs/pigment/colorspaces/KoRgbU8CompositeOp.cpp:65

A quick optimization for this would be to cache the qstring at the start of 
the method and not call id() every time.
Sorting on most used composite op to be at top helps too, I'd guess that 
  if (id() == COMPOSITE_UNDEF)
is called a lot more than needed...

-- 
Thomas Zander


More information about the kimageshop mailing list