User avatar
cheery
Posts: 219
Joined: Wed Jan 25, 2012 9:39 pm

libgdev: Resize surface made by eglCreateGlobalImageBRCM?

Sun Nov 11, 2012 2:33 am

I'm developing an utility library libgdev, which helps people who want to write desktop environments. It's supposed to become portable over multiple systems.

How can I resize pixbuffers that I can create with eglCreateGlobalImageBRCM?

Can I get a handle to the pixbuffer before I need to eglChooseConfig anything?

dakerfp
Posts: 7
Joined: Thu Nov 29, 2012 2:34 pm

Re: libgdev: Resize surface made by eglCreateGlobalImageBRCM

Thu Nov 29, 2012 2:38 pm

cheery, do you have any example code that can use images created by eglCreateGlobalImageBRCM?
I can't find any documentation or example working in the pi.
Can you help me?

User avatar
cheery
Posts: 219
Joined: Wed Jan 25, 2012 9:39 pm

Re: libgdev: Resize surface made by eglCreateGlobalImageBRCM

Thu Nov 29, 2012 4:19 pm

You could read from my repositories, but let me paste here something that should work out:

Code: Select all

EGLConfig config;
int global_image[5];
int width;
int height;

EGLint pixel_format = EGL_PIXEL_FORMAT_ARGB_8888_BRCM;
EGLint rt;
eglGetConfigAttrib(display, config, EGL_RENDERABLE_TYPE, &rt);

if (rt & EGL_OPENGL_ES_BIT) {
        pixel_format |= EGL_PIXEL_FORMAT_RENDER_GLES_BRCM;
        pixel_format |= EGL_PIXEL_FORMAT_GLES_TEXTURE_BRCM;
}
if (rt & EGL_OPENGL_ES2_BIT) {
        pixel_format |= EGL_PIXEL_FORMAT_RENDER_GLES2_BRCM;
        pixel_format |= EGL_PIXEL_FORMAT_GLES2_TEXTURE_BRCM;
}
if (rt & EGL_OPENVG_BIT) {
        pixel_format |= EGL_PIXEL_FORMAT_RENDER_VG_BRCM;
        pixel_format |= EGL_PIXEL_FORMAT_VG_IMAGE_BRCM;
}
if (rt & EGL_OPENGL_BIT) {
        pixel_format |= EGL_PIXEL_FORMAT_RENDER_GL_BRCM;
}

global_image[0] = 0;
global_image[1] = 0;
global_image[2] = width;
global_image[3] = height;
global_image[4] = pixel_format;

eglCreateGlobalImageBRCM( width, height, pixel_format, 0, width*4, global_image );

EGLint attrs[] = {
    EGL_VG_COLORSPACE, EGL_VG_COLORSPACE_sRGB,
    EGL_VG_ALPHA_FORMAT, pixel_format & EGL_PIXEL_FORMAT_ARGB_8888_PRE_BRCM ? EGL_VG_ALPHA_FORMAT_PRE : EGL_VG_ALPHA_FORMAT_NONPRE,
    EGL_NONE
};
surface = eglCreatePixmapSurface(display, config, (EGLNativePixmapType)global_image, attrs);
For accessing the pixmap, you can write:

Code: Select all

int e;
e = eglQueryGlobalImageBRCM(global_image, global_image+2);
assert(e);
EGLImageKHR egi = (EGLImageKHR)eglCreateImageKHR(display, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, (EGLClientBuffer)global_image, NULL);

// with the new texture
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, egi);

eglDestroyImageKHR(display, image);
If you can't get along with that alone, you could look into: https://github.com/shirro/compositing-example

I'm still looking for couple APIs myself. But I'm starting to worry these APIs I'm looking for aren't existing.

dakerfp
Posts: 7
Joined: Thu Nov 29, 2012 2:34 pm

Re: libgdev: Resize surface made by eglCreateGlobalImageBRCM

Thu Nov 29, 2012 5:34 pm

Have you ever tried to share these pixmaps between processes?

User avatar
cheery
Posts: 219
Joined: Wed Jan 25, 2012 9:39 pm

Re: libgdev: Resize surface made by eglCreateGlobalImageBRCM

Thu Nov 29, 2012 5:50 pm

dakerfp wrote:Have you ever tried to share these pixmaps between processes?
If you mean passing the global_image -handle to another process and reading from it - yes. That should work fine.

dakerfp
Posts: 7
Joined: Thu Nov 29, 2012 2:34 pm

Re: libgdev: Resize surface made by eglCreateGlobalImageBRCM

Tue Dec 04, 2012 11:10 pm

cheery wrote: If you mean passing the global_image -handle to another process and reading from it - yes. That should work fine.
I did showed a surface in a process in another as a texture. It worked fine.
However, I would like to update the texture in the second process whenever I swap the buffers in the first process.

The code is attached.
Can you help me to figure out how to do it, or if I am doing something wrong.

Thanks.
Attachments
texture-sharing.zip
(5.92 KiB) Downloaded 222 times

User avatar
cheery
Posts: 219
Joined: Wed Jan 25, 2012 9:39 pm

Re: libgdev: Resize surface made by eglCreateGlobalImageBRCM

Wed Dec 05, 2012 3:52 pm

That's some pleasantly written code!

Put eglFlushBRCM(); before eglSwapBuffers(); in write.c. Apparently that's required for eglSwapBuffers() to take effect.

dakerfp
Posts: 7
Joined: Thu Nov 29, 2012 2:34 pm

Re: libgdev: Resize surface made by eglCreateGlobalImageBRCM

Wed Dec 05, 2012 10:04 pm

I've tried to put flush in every place. It simply didn't work.
Do you have any other working code where I can look at?
Thanks a lot for the attention.

User avatar
cheery
Posts: 219
Joined: Wed Jan 25, 2012 9:39 pm

Re: libgdev: Resize surface made by eglCreateGlobalImageBRCM

Wed Dec 05, 2012 10:37 pm

I tried your code on my raspberry pi and found few errors. The fixed version is in: https://gist.github.com/2006cace39058cdb65f0 I also pointed out where to put the eglFlushBRCM(); and what's the possible effect of including it.

You had an input loop that made it to ask 4 times too many values for the handle. The effect was that it delayed until you gave all those extra values. The read.c also seemed to show only 1000 frames before closing. Apparently you were looking for something like that anyway.

Return to “Graphics programming”

Who is online

Users browsing this forum: No registered users and 3 guests