Re: save, restore and *_preserve
- From: creak ml <creak ml gmail com>
- To: Ian Martin <martin_id vodafone co nz>
- Cc: gtkmm-list gnome org
- Subject: Re: save, restore and *_preserve
- Date: Sun, 24 Nov 2013 22:34:37 -0600
Thanks for the review!
I'd argue your first problem is here. Simple rule: when using a Cairo::Context, encase everything you do
in save/ restore. If you don't, you have to manually keep track of the context state, which is difficult/
practically impossible in many cases.
You're perfectly right!
And again, why not save() here, so that you can return to the Context within a loop as many times as
required? You'll keep the current clip area within that save(), and probably could set the Pango::Layout
outside this loop so you can reuse it instead of redefining it every time you enter the loop.
Right again! ;)
If you aren't going to use the path again, why are you preserving it? That's a waste of memory because
you're keeping track of something you no longer need.
I'm not sure clipping speeds up things that much in this scenario. You've still got to draw the entire
scene; if it's a static picture, then you may as well draw it all at once, and clipping will require
greater resources than just drawing. I can see a point in clipping ot prevent offscreen elements from
being computed, but not for onscreen... but could easily be wrong on that.
Actually I preserve the stroke path for the next clipping. And I do
the clip because I don't want my text to be drawn out of the box, it's
not an optimization in this case.
Thanks again for your reply!
I'll correct my code right away!
--
Romain "Creak" Failliot
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]