[cairo] Setting a background "layer"

enc0der enc0der at gmail.com
Tue Jan 17 03:16:11 UTC 2017


I'm not an expert either, but one thing I can think of, is if you keep
track of your text extents, you could just clear that area each frame
instead of the whole thing.  I'm sure there is an inflection point where
that will be more time if you are drawing text to too many areas.

Another option that I could imagine is switching between 2 surfaces, if you
are in an environment where you can run more than one thread, you could be
clearing one surface while using the other, then switching back and forth.
So like double buffering, but to parallelize the operation.



On Mon, Jan 16, 2017 at 9:47 PM, mike e <Toqoz at hotmail.com> wrote:

> Hello, I'm not that experienced with cairo.
>
>
> Currently I have a program that draws a background, and then draws some
> text over that background.  The text moves around over the background.  The
> image is redrawn often (multiple times a second).
>
>
> The background is generated through cairo, it is not an image or something
> like that.
>
>
> What is the most efficient way to accomplish this?  I know that I could
> set the paint operator to source and redraw everything each frame, but it
> seems inefficient.
>
> Is there a way to draw a layer, and then save that layer indefinitely (or
> have a layer dedicated to the text)?  So that then I could just clear just
> the text each time and draw it in a new location?
>
>
> I'm using Xlib and drawing to an window through
> cairo_xlib_surface_create().
>
>
> Heres what I'm basically trying to do:
>
>
>     if (firstrun) {
>
>         draw_background();
>
>     }
>
>
>     clear_text();
>
>     draw_text(new_location);
>
>
>
> --
> cairo mailing list
> cairo at cairographics.org
> https://lists.cairographics.org/mailman/listinfo/cairo
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cairographics.org/archives/cairo/attachments/20170116/471ca383/attachment.html>


More information about the cairo mailing list