<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'><div>Kohei,</div><div><br></div>Thanks a lot for your patient answer.<div><br></div><div>I spent a few hours tracking down where was the bottleneck for my performance issues. Fascinating browsing of code.</div><div><br></div><div>Anyway, it looks like the culprit is the numerous calls to X11's XRenderCompositeTrapezoids in vcl/unx/generic/gdi/xrender_peer.hxx.</div><div><br></div><div>For some reasons that I ignore, the "selection border for copied cell range" uses a special graphical-to-be-rendered object that, at the end of the day, invokes this <span style="font-size: 12pt;">XRenderCompositeTrapezoids method many many times (I guess one call per dash).</span></div><div><span style="font-size: 12pt;"><br></span></div><div><span style="font-size: 12pt;">A few things to note:</span></div><div><span style="font-size: 12pt;"><br></span></div><div>1. I am not sure if the method itself is very slow. Using a for loop around the call in the following code <a href="https://github.com/ereslibre/x11/blob/master/xrender/xrhello.c" target="_blank" style="font-size: 12pt;">https://github.com/ereslibre/x11/blob/master/xrender/xrhello.c</a> 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.</div><div><br></div><div><div>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.</div></div><div><br></div><div>3. If I just comment out the call to <span style="font-size: 12pt;">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.</span></div><div><span style="font-size: 12pt;"><br></span></div><div><span style="font-size: 12pt;">4. When I just "return false;" at the first line of the </span>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).</div><div><br></div><div>No idea what is the code path for the fall back implementation...</div><div><br></div><div><span style="font-size: 12pt;"><br></span></div><div><span style="font-size: 12pt;">#3 and #4 leads me to think that the numerous calls to </span><span style="font-size: 12pt;">XRenderCompositeTrapezoids are costly on some machines.</span></div><div><span style="font-size: 12pt;"><br></span></div><div><span style="font-size: 12pt;"><br></span></div><div><span style="font-size: 12pt;">FYI I have a ATI </span>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.</div><div><br></div><div><br></div><div>Anyway, I am not sure how the performance could be drastically improved. I feel just running a "personally built Libreoffice" on my machine which just replace the <span style="font-size: 12pt;">PolyPolygonMarkerPrimitive2D with a </span><span style="font-size: 12pt;">PolygonStrokePrimitive2D in </span><span style="font-size: 12pt;">ScOverlayDashedBorder::createOverlayObjectPrimitive2DSequence() is a last resort option. Obviously I'd love to get a proper solution in the Libreoffice trunk.</span></div><div><span style="font-size: 12pt;"><br></span></div><div><span style="font-size: 12pt;"><br></span></div><div><span style="font-size: 12pt;">Any comments?</span></div><div><br></div><div><br></div><div>S<br><br><div>> Date: Wed, 30 Sep 2015 08:49:22 -0400<br>> From: libreoffice@kohei.us<br>> To: ross_dev@hotmail.com; libreoffice@lists.freedesktop.org<br>> Subject: Re: [Calc] Bad rendering performance of "selected copy" snake/circulation animation<br>> <br>> <br>> <br>> > On September 29, 2015 at 12:25 AM Sylvain R <ross_dev@hotmail.com> wrote:<br>> > <br>> > <br>> > Hi,<br>> > Sorry in advance if this is the wrong mailing list, I am basically trying to<br>> > find a tiny bit of help to fix a rendering problem I have and hopefully submit<br>> > a patch for it, or at least discuss the problem.<br>> > I am having some serious rendering performance problems when I perform a copy<br>> > of cells, for some time now, which is a problem as I use Libreoffice calc<br>> > pretty much every day as part of my job (running Libreoffice<br>> > 1:5.0.2~rc2-0ubuntu1~trusty2 on Ubuntu 14.04 64bit).<br>> > I decided I could try to fix this problem myself as I am familiar with C++.<br>> <br>> Excellent!  We appreciate your willingness to dive into the code.<br>> <br>> > I am basically looking for a pointer as to where is the code that render the<br>> > "copy cell circling effect". I am not sure how it is called, but this is what<br>> > I am talking about at http://s14.postimg.org/6u32kqdq9<br>> <br>> We (at least I) call it selection border for copied cell range.<br>> <br>> > What I am trying to figure out:- Where is the code in charge of the rendering<br>> > of the circulating selecion?- Where is the code that receives/handles the<br>> > scrolling?<br>> <br>> The state of this border is stored in ScGridWindow, as mpOOSelectionBorder data<br>> member, which itself is an instance of ScOverlayDashedBorder.  All of these are<br>> in the sc module.  You can run git grep for find these guys.<br>> <br>> Now, the lower level rendering is done some place else, and you'll likely have<br>> to move between svx (where the Sdr* classes live), basegfx and drawinglayer.<br>>  And eventually the code path will reach in vcl to do the actual rendering.<br>>  This is a high level overview of how drawing objects are rendered.<br>> <br>> > <br>> > I am really just looking for pointers (i.e. a class name or two) for where to<br>> > start.<br>> <br>> Hopefully the above is a good staring point.  If you encounter more specific<br>> questions in some of these drawing layer code, feel free to post more questions.<br>> <br>> Thanks!<br>> <br>> Kohei<br>> <br>> --<br>> Kohei Yoshida, LibreOffice Calc hacker<br>> _______________________________________________<br>> LibreOffice mailing list<br>> LibreOffice@lists.freedesktop.org<br>> http://lists.freedesktop.org/mailman/listinfo/libreoffice<br></div></div>                                     </div></body>
</html>