Skip to content

Cache and copy circle texture instead of redrawing

I hope it's ok for me to open this MR without a preceding issue. It seemed like something where having the code is required in order to be able to have a discussion.

With this change, only the first circle is computed and drawn into a texture. When continuing to type, further circles are rendered by simply copying the cached texture into the dipslay.

I "measured" the impact of this change by looking at a CPU monitor while holding a key down. Before this commit, CPU usage was steady at around 30% while holding the key. With this commit applied, CPU usage went down to about 10%. Here's a small annotated screenshot:

cpu

  • 1: make (before this commit)
  • 2: Hold key for a few seconds, delete everything, hold key again, ...
  • 3: make (with this commit)
  • 4: Hold key for a few seconds, delete everything, hold key again, ...

While the observation makes sense logically (because a cached texture can be copied on the GPU directly) this obviously isn't proper profiling. I tried using gprof but all the processing time were too low so most of the time no time sums showed up.

I'm curious if anyone has other ideas for how to properly profile this.

As a side effect, this also fixes #109 (closed).

Edited by Johannes Marbach

Merge request reports