Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Photon drawing on 6.4 vs 6.3.x: (3 Items)
   
Photon drawing on 6.4 vs 6.3.x  
Hi all.  

We use QNX/Photon since a while on normal PC computer and we start to move from 6.3 to 6.4 for some newer project. Most 
of the programs without code modification and even without re-compiling still work no problem. Exept some program that 
do drawing, e.g. that use PtRaw or PtImage widget. 

Like if we want to implement a kind of Oscilloscope inside a PtRaw and we have to refresh the drawing every few 
millisecond using an offscreen context and redraw completly from a PtTimer, it draw properly on QNX 6.3 (even in 6.21 
before). But when trying it on QNX 6.4 (after recompiling or not). the drawing is offset and it seems not seems to be a 
consistent offset, it's depend on the program. I have the feeling that it's depend what widget was on focus or was draw 
the last. When I force a redraw switching workspace back and forth, it's appear on the right place, but get offset again
 later after doing any interaction with the GUI. 

So after this observation, I tried to convert the program to draw only from the DrawFunction of the PtRAw and to force a
 refresh by calling PtDamageWidget on the PtRaw from the PtTimer, and that way it works. But Not all our program are 
easy to convert that way. But anyway, I think it should work as on 6.3. 

And I guess we are not alone on that situation, I've notice the same problem on GVim compiled with FEAT_GUI_PHOTON.  I 
tried an old version that I'm was using before on 6.3 and I also try to recompile the latest version from Vim CVS and I 
saw the same problem.

Someone saw this problem, is there a work around or is it plan to be fixed on next release ?

-- 
Martin
Re: Photon drawing on 6.4 vs 6.3.x  
Martin,

Photon widget library guaranties that your default rendering context is setup properly (clipping and translation) when 
your widget’s draw function is called by it. When you render outside of “draw” cycle – you are on your own. You need
 to make sure that you setup the source region id, translation and clipping correctly before you start rendering (in a 
timer callback for example). I understand that it happened to work in the past, but it was never guarantied. 

I can recommend changing your code to use the “proper” approach (just as you suggested): 
•	PtDamageWidget() or PtDamageExtent()
•	render by your RenderFunction.

If this is not possible, and you need to render outside the “draw” cycle, make sure that you setup your draw context 
before you draw. The setup should look something like this:
	PhGC_t gc = PgGetGC();
	PgSetRegion( your_window’s_rid or your widget’s rid );
	PgClearClippingsCx( gc );
	PgClearTranslationCx( gc );
// this part is only if you use your window’s rid
	PtWidgetOffset( your_widget, &offset );
	PgSetTranslationCx( gc, &offset, 0 );

	…Do your drawing…

Best regards,
-Misha.

Re: Photon drawing on 6.4 vs 6.3.x  
Thanks you very much... 

I got Gvim to work in photon properly by modifiying a little bit gui_ph_draw_start() function according to your example 
and it work perfectly..

They were doing something similar but without using the PgGetGC() and the PgClearClipping/PgClearTranslationCx ... By 
adding this.. it fix it.. 

I'll try that in our project soon.. for those that will be harder to convert using only a DrawFunction..

-- 
Martin