Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - help with CM when using GF: (2 Items)
   
help with CM when using GF  
Howdy

I'm converting a project from using GF only API to using the composition manager.
I was lead to believe it would be a simple matter of substituting a few init calls...but as is usually the case, it's 
more complex than that.

I understand that because I will have multiple applications requiring their own layers,  I must use KD.
Is this correct?
Ideally I'd like something like:
http://community.qnx.com/svn/repos/graphics/trunk/apps/egl/tutorials/gf-egl-vsync/gf-egl-vsync.c
But I can't get this to work with the composition manager.
Would this be becuase the concept of windows and multiple layers is one and the same?

Anywho, I have managed to get the images displayed (albeit momentarily...probably something to do with swaping buffers, 
that'll be my next challenge) by substituing gf calls with kd or egl calls eg:
gf_dev_attach and gf_display_attach() -> eglGetDisplay() eglInitialize()
gf_layer_attach() -> kdCreateWindow() kdRealizeWindow()
gf_surface_create_layer() or gf_surface_create -> eglCreateWindowSurface()

And due to not having a gf_dev_info :
gf_context_set_surface() -> gf_context_set_surface_3d() and/or eglMakeCurrent()

The issue I'm now having is finding replacements for gf_draw_blit2() and gf_draw_blitscaled() as they require gf 
surfaces, not egl surfaces?
Is there a way to cast egl surfaces to gf surfaces?

I'm currently just using the main surface for each image, and therefore all images are dumped on top of each other, 
followed by all being dumped on by a full screen white fill (not sure why the screen is turning white...again that'll be
 the challenge after the next).

Also, I haven't found a substitue for gf_surface_get_info() yet...this is required for size, format, stride...
Am I correct in thinking this would be defined by the chosen egl_conf?

The application is using the img library.
Is there a simpler way to manage these images than directly using gf blit?

Keep in mind, at this stage there are no 3D elements required, egl is only being used to increase the number of layers 
available.

Any help would be appreciated.

Cheers

Adrian
Re: help with CM when using GF  
When you look at the differences between the GF version and the same code converted to OpenKODE/EGL, you find that there
 aren't that many differences. However, making those changes, even if there are just a few, isn't always easy...

The two big differences for GF apps rendering in OpenKODE windows are:

1) no layers; that's because with GF, the only "compositing" strategy is to use display controller layers. The 
compositied windowing system that handles OpenKODE windows can use other hardware like 2D cores, VG cores, or 3D cores.

2) different surfaces; you have to use EGL surfaces and not GF surfaces.

If in the end each application has its own layer, you don't necessarily need the composited windowing system. The same 
thing can be done with plain GF. However, OpenKODE also gives you better events, delegates (which can be used to control
 other GF apps), and allows you to have multiple applications on the same layer (only one visible at any point in time).
 All of this cannot be done using GF only.

http://community.qnx.com/svn/repos/graphics/trunk/apps/kd/tutorials/gf-kd-vsync/gf-kd-vsync.c is the OpenKODE equivalent
 of http://community.qnx.com/svn/repos/graphics/trunk/apps/egl/tutorials/gf-egl-vsync/gf-egl-vsync.c

gf_draw_blit2 and gf_draw_blitscaled can still be used quite easily if one of  the surfaces (source or destination) 
isn't an EGL surface. If you need to blit from an EGL surface to another EGL surface, you have 4 options:

1) blitting can be done with a Khronos rendering API like OpenGL ES, or OpenVG. In this case, you cannot blit directly 
from an EGL surface to another EGL surface. The source must be an object like a VGImage or a GL ES texture.

2) Use the EGL_QNX_gf_surface extension which will give you the gf_surface_t corresponding to the current renderbuffer 
of an EGL surface. This obviously only works if the EGL_QNX_gf_surface extension is supported, which may not always be 
the case.

3) Use the EGL_KHR_lock_surface extension, which allows software renderers to write their output to EGL surfaces. With 
this extension, you can get a CPU accessible address, the stride, and the bit offsets of each color component of an EGL 
surface. You can use gf_surface_attach and gf_surface_reattach to wrap it as a gf_surface_t. You will have to get the 
rest of the information from other calls, i.e. eglQuerySurface to get the width and height, and eglGetConfigAttrib to 
get the pixel format. Once an EGL surface is locked, it must be unlocked before you can do things with it, like 
eglMakeCurrent or eglSwapBuffers. Each time a surface is locked, the pointer and stride returned could be different from
 the last time. This is where gf_surface_reattach becomes useful...

4) Use eglCreatePixmapSurface for offscreen renderbuffers. The native pixmap is always a GF surface, which you can use 
as argument to gf_draw_blit2 and gf_draw_blitscaled. The EGL surface can be used as argument to eglMakeCurrent, etc.

Now, getting back to square one, depending on what you are trying to do, there might be an easier approach than the 
generic solutions I have outlined here.