navit-project.org

forum for navit navigation tool
It is currently 24 Jun 2017, 19:08
View unanswered posts | View active topics


All times are UTC


Forum rules


Feel free to ask anything here related to the development process - coding, creating new features, fixing bugs and custom changes of Navit.

Note: For reporting bugs, use the bug tracker.



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Why do some OSD items use an "overlay" for drawing?
PostPosted: 29 Nov 2014, 15:58 
Offline

Joined: 23 Jun 2013, 20:15
Posts: 65
Location: Essen, Germany
Some OSD items use an "overlay" for drawing: Instead of being drawn directly, they seem to create a special buffer to draw into. The item is then drawn into that buffer, and the buffer in turn is drawn into the main window.

The graphics system has the method graphics_overlay_new to make this possible. The OSD code uses this from osd_set_std_graphic, which is used by the _init methods of some OSD items (e.g. by toggle_announcer_init).

However, not all OSD items use this "overlay" mechanism. Some (at least "button" and "scale") even let you select whether to use it or not through the attribute "use_overlay".

What I dont quite understand is: Why this is even used?

It makes the code considerably harder to understand, and it does not seem to work properly: The OSD button does not render its image correctly with use_overlay=1, and the bug #1270 also seems to be caused by the toggle_announcer using an overlay.

So: What is the point of this mechanism?
I'd be grateful for any pointers/explanations.


 Profile  
 
 Post subject: Re: Why do some OSD items use an "overlay" for drawing?
PostPosted: 29 Nov 2014, 22:40 
Offline

Joined: 09 Jul 2013, 17:41
Posts: 82
Hi!

I see the only purpose for use_overlay option: it makes possible to hide OSD elements drawn with this option while moving the map bitmap.

By default navit attempts to re-render the map from its vector representation on each move, and it may take a few seconds on certain regions with certain layouts, so becoming non-interactive. When there's an option drag_bitmap="1" specified in <navit> element, movements are drawn by displaying the main overlay bitmap at different offsets.

So OSDs drawn into the only existing overlay (i.e. do not enable use_overlay), are moved with the map, which looks unnatural. OSDs drawn with use_overlay simply disappear till the map is completely redrawn after dragging finishes.

My guess is that use_overlay option was introduced when it became clear that some navit graphics modules do not fully support overlay mode.

tryagain


 Profile  
 
 Post subject: Re: Why do some OSD items use an "overlay" for drawing?
PostPosted: 30 Nov 2014, 15:40 
Offline

Joined: 23 Jun 2013, 20:15
Posts: 65
Location: Essen, Germany
tryagain wrote:
Hi!
I see the only purpose for use_overlay option: it makes possible to hide OSD elements drawn with this option while moving the map bitmap.


Interesting, thanks for the information. I didn't know navit even supported moving the map bitmap instead of redrawing it.

Still, I wonder: Couldn't you get the same result more easily by just redrawing the map without the OSD items when dragging starts? I'll have a look at the code to figure out what exactly it is doing.

Incidentally, I just found out that if you comment out the line
Code:
graphics_overlay_disable(this_->gra, 1);

in navit.c:navit_motion_timeout and enable bitmap_drag, then the overlay OSD items will actually stay in place while the map moves "underneath". This may have been the original motivation for using overlays. Still, I wonder why overlays are currently disabled during panning.


 Profile  
 
 Post subject: Re: Why do some OSD items use an "overlay" for drawing?
PostPosted: 22 Dec 2014, 22:46 
Offline

Joined: 23 Jun 2013, 20:15
Posts: 65
Location: Essen, Germany
Reading some more Navit code, and GTK+/GDK docs, I think I now understand why these "overlays" are used.

The OSD items are supposed to be (partially) transparent, so the map is still visible underneath. However, GTK+/GDK do not support transparency - mainly because they are (or were originally) closely modeled on the X11 protocol, which does not support transparency either.

The only way to use (limited) transparency is to put the desired graphics into a GdkPixbuf (which does support transparency), then draw that - which is just what the code does.

So the "overlay" trick is only to make transparent OSDs possible.


 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Silver Orange 2.0.6 for IPB Designed by Skins and Hosting
Converted for phpBB3, based on Royal Blue template by BigB © 2007 2008 AEON KINGS