Sub-pixel positioning

Roger Larsson roger.larsson at norran.net
Tue Mar 16 21:02:55 CET 2004


On Tuesday 16 March 2004 15.48, Adrian Page wrote:
> On Tuesday 16 March 2004 10:58 am, Boudewijn Rempt wrote:
> > Maybe it's an idea,
> > if it's too slow, to disable it for the expensive brushes like the pipe
> > brushes or the colour brushes, and just use it for the simple masks?
>
> Could do. See how it goes once it's properly integrated.
>
> computeDab() is currently the slow part of the paint procedure, with its
> single pixel writes. That gets hit every time the pressure changes, or each
> dab paint for pipe brushes. I think there's plenty of scope for
> optimisation there.

A non tiled format here would simplify other stuff later...
But I do not think that all tools really gains anything by precomputing a dab.

Suppose you have a circular brush.
	float dx, dy; // for antialiasing
	alpha = k*sqrt(dx*dx + dy*dy)
Then it would be much better to precompute
	for (dd=0; dd < max_distance*aliasing; dd++)
		table[dd] = k*sqrt(dd);
and later use it as
	draw_on(RGB &pixel, float dx, float dy, RGB draw_with_color)
	{
		float sq_distance = dx*dx, dy*dy;
		if (sq_distance < max_distance*max_distance)
		{
			float alpha = table[aliasing*sq_distance];
			return (...)
		}
		return pixel;
	}

The "draw" could be a method in a class where table could be stored...

>
> Using valgrind to profile KisToolBrush::mouseMove() with a pipe brush,
> about 80-90% of the time is spent in computeDab(), and around 10% in
> compositeCopy() and compositeOver(). The compositing code also has plenty
> of room for improvement, part of which would be using premultiplied alpha
> for the RGBA buffers. We can also replace division by shifts and optimise
> for each channel depth we support.

Yea but how much time is spent in X because of what Krita does?
(I had 60%...)

Please try with my patch (for brushes). I have tried to fix some of the
comments I got. Some stuff did not improve like:
	kis_notify_limit
It should probably be replaced by a direct constant instead.

/RogerL

-- 
Roger Larsson
Skellefteå
Sweden
-------------- next part --------------
A non-text attachment was scrubbed...
Name: krita_tools.patch
Type: text/x-diff
Size: 3326 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kimageshop/attachments/20040316/f2ea2c8c/krita_tools.bin


More information about the kimageshop mailing list