Cairo's slow if you're doing lots of overdraw (Porting in a turtle-graphics sample...)


Ported one of the samples from TurtleArt over to the Cairo-based test. OMG it is slow. TurtleArt is bitmap-based, so once it's drawn something it's just blitting up the bitmap next time and then continuing to render. The Cairo renderer is doing the whole rendering process every frame. Some of these samples are rendering radial gradients using massive overdraw (draw 720 lines roughly centred on a point with a wide pen).

Could likely optimise the operation by rendering to a backing buffer and only blitting onto the screen (keeping the Cairo context across rendering passes, basically the same as TA is doing).

Comments

  1. Ian McIntosh

    Ian McIntosh on 08/14/2007 12:36 a.m. #


    And a Ferrari is slow if you're pulling a boat up a hill.

  2. Mike Fletcher

    Mike Fletcher on 08/14/2007 8:25 a.m. #


    Sure, right tool, meet right job, but it means that a Cairo-backed version of Turtle-Art is not going to be able to (efficiently) render the type of code kids are being taught to create with the bitmap-backed version. There would have to be some pedagogical tool to teach them how they are different and what that difference means to their code. Without that the response would just be "this sucks", because Ferrari really doesn't make a good farm tractor.

  3. Ian McIntosh

    Ian McIntosh on 08/14/2007 11:30 a.m. #


    My point wasn't "right tool for the job" but rather that maybe you should unhitch the boat before declaring a Ferrari slow.<br />
    <br />
    Maybe implement that "likely" optimization and then post a follow-up!<br />
    <br />
    (And maybe it will still be too slow, but at least we'll have a useful comparison.)

  4. Mike Fletcher

    Mike Fletcher on 08/14/2007 7:29 p.m. #


    Ah, but I was saying explicitly what job I was doing (pulling a boat). Eliminating the boat-pulling doesn't make the system any faster at pulling boats, it just means there's a way to turn the boat into a picture of a boat so that it's easier to drag. i.e. Cairo would still be slow at the massive overdraw (boat pulling), but we'd have coded around the area it's not appropriate for (because of the slowness). Perfectly valid solution, but doesn't change the fact that the Ferrari is not a good boat-pulling machine.<br />
    <br />
    Much as OpenGL is not great at overdraw-heavy scenes (which is where I come from), Cairo is similarly not going to work well when doing overdraw-heavy graphics (because it renders all of the intermediates onto the canvas for every stroke). If you are doing overdraw in the client code a lot, you want to code around the weakness.<br />
    <br />
    No big deal, just something to keep in mind so that you don't write naive code that kills the machine.

  5. Stu

    Stu on 03/17/2011 7:50 p.m. #

    The guys on the cairo mailinglist are super helpful, and it's worth asking them - also if it's a common workflow then this can even be added to their test suite and will be more likely to be optimised for in future versions.

Comments are closed.

Pingbacks

Pingbacks are closed.