Re: Setting a background "layer"

enc0der <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <CAEXpi5Rr9mREXbFazVCgULUy0sXNoOp2ckEkCq+7EC8ZPHAj1Q@mail.gmail.com>
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 <[email protected]> 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
> [email protected]
> https://lists.cairographics.org/mailman/listinfo/cairo
>

-- 
cairo mailing list
[email protected]
https://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.