GNOME Bugzilla – Bug 598695
[timeoverlay] use much CPU ressource compare to previous version
Last modified: 2012-06-18 16:35:46 UTC
timeoverlay (0.10.25) use much CPU than a previous version 0.10.18. On my PC add timeoverlay in a graph add +10% of CPU usage. With version 0.10.18 it is only 1 or 2% of CPU usage.
Could you check where it takes that long, for example with callgrind. This could in theory be a result of switching from pango-ft2 to pango-cairo... but (also in theory) cairo should be faster.
Created attachment 145768 [details] callgrind file callgrind trace for version 0.10.24 of gst-plugins-base
Created attachment 145769 [details] callgrind traces callgrind traces for gst-plugins-base 0.10.25
a quick analyze in callgrind show that gst_text_overlay_render_text takes 55% process time in version 0.10.25 mainly by calling cairo_stroke function.
After test I seem that CPU charge is related to the dash style selected in gsttextoverlay. with double dash = 2.0; cairo_set_dash (cr_shadow, &dash, 1, 0.0); the CPU usage stay in correct values. I not to happy to fix that like that, so maybe we can add a property to set the dash style, or add a property "low-CPU" to have a configuration for small CPU.
I can't confirm what you said about dashing, it's both slow. The problem here is, that pango_cairo_show_layout() internally does all kinds of caching and optimizations that are lost when just converting the pango layout to a cairo path and filling/stroking that. The cairo developers said, that the solution would be to use user fonts, unfortunately pango has no support for them yet. Idea would be, to draw shadow/outlint in the render_glyph_func. Pango bug for this is #347237.
In my cairo stuff, I've been calling pango_cairo_show_layout() twice, once drawing it in black as a shadow with some pixel(s) offset and once drawing it in white. This avoids having to stroke the text and is also quick with acceleration. I'm not sure if people would consider it visible enough. I certainly do.
That's not the intended effect though, what we really want is a black outline (and additionally the shadow). For normal subtitles all this should be no problem btw, only for timeoverlay and clockoverlay or anything else that has text changes very often. As suggested elsewhere the solution for timeoverlay/clockoverlay would be to cache the few characters a single time (whenever the font/etc changes) and then only copy them onto the buffer. Not sure how to do it properly though, especially the correct spacing of characters. Any ideas? Also the way the pango plugin works needs to be changed for this
I'm tempted to WONTFIX this unless someone is willing to work on that.