[Calc] Bad rendering performance of "selected copy" snake/circulation animation

Kohei Yoshida libreoffice at kohei.us
Mon Oct 5 05:57:57 PDT 2015

Hi Sylvain,

> On October 3, 2015 at 2:48 AM Sylvain R <ross_dev at hotmail.com> wrote:

> 1. I am not sure if the method itself is very slow. Using a for loop around
> the call in the following code
> https://github.com/ereslibre/x11/blob/master/xrender/xrhello.c I am able to
> basically time a call at 0.16 ms on my current machine. It may be alright for
> a few calls, but if we have to show a few 100s of dashes, it's not surprising
> sluggishness effects can be seen.
> 2. If I change ScOverlayDashedBorder::createOverlayObjectPrimitive2DSequence()
> to return a PolygonStrokePrimitive2D instead of a
> PolyPolygonMarkerPrimitive2D, I get a solid line instead of a dashed line, but
> no performance problem at all.
> 3. If I just comment out the call to XRenderCompositeTrapezoids in the
> XRenderPeer, the dashed line does not show anymore but pretty much everything
> else work without any problem, and no performance problems at all.
> 4. When I just "return false;" at the first line of the bool
> X11SalGraphicsImpl::drawFilledTrapezoids( const ::basegfx::B2DTrapezoid*
> pB2DTraps, int nTrapCount, double fTransparency ) implementation, I assume
> that it triggers a fallback rendering implementation. The performance is
> definitely better, though I can still feel the sluggishness when I do very
> wide (and wild) selection copy (i.e. select a few cells veritcally, press
> shift space, and then Ctrl+C).
> No idea what is the code path for the fall back implementation...
> #3 and #4 leads me to think that the numerous calls to
> XRenderCompositeTrapezoids are costly on some machines.

So, repeated calls to this method indicate that what's causing the performance
problem is (as Thorsten's answer implies) the process of applying anti-aliasing
to the dashed borders.  You can toggle this option to see if the perf problem
goes away.

> FYI I have a ATI Radeon HD 7700/7800 running the RADEON X driver at home, but
> use a Nvidia NVS 510 video card with the proprietary nvidia driver at work. I
> experience the performance issues with selected copy both at home and at work,
> despite the different graphical configuration.
> Anyway, I am not sure how the performance could be drastically improved.

The right solution IMO is to unconditionally disable anti-aliasing for these
animated dashed borders while the rest of the drawing objects are still drawn
anti-aliased (when the option is on).  Anti-aliasing makes no sense for
perfectly horizontal or vertical lines anyway, not to mention the performance
problem it incurs.

I've done something very similar to that when rendering cell borders i.e. cell
borders are never anti-aliased, not necessarily because of performance (though
it could have caused performance issue in retrospect) but because of aesthetics.

Having said that, selectively turning off anti-aliasing is, though certainly
doable, a bit hard to achieve.  But if you are interested, I can dig in the code
and give you some code pointers.


Kohei Yoshida, LibreOffice Calc hacker

More information about the LibreOffice mailing list