[cairo] Could I use cairo with opengles in android?

Alexandros Frantzis alexandros.frantzis at linaro.org
Mon May 21 02:26:03 PDT 2012


On Mon, May 21, 2012 at 04:20:17AM -0400, Jihe Wei wrote:
> Hi,Henry
> i found the implementation  of the  method cairo_egl_device_create(display,
> context)
> is very strange,as below:
> 1. init attribs with EGL_WIDTH=1and EGL_HEIGHT=1
> 2. init config use eglChooseConfig method
> 3. create EGLSurface use eglCreatePbufferSurface method
> 4. then use eglMakeCurrent to release
> 5. last, return as &ctx->base.base
> problems:
> 1.EGLSurface's width and height both were set to 1
>    but the method cairo_gl_surface_create supply two parameters for setting
> width and height

The code in cairo_egl_device_create() is not related to any surface that
you will be using for rendering. Its only purpose is to allow us to make a
valid surface current in order to perform the device initialization.

> another thing, the code i send before
> should  set  EGL_SURFACE_TYPE=EGL_PUBUFFER_BIT
> not EGL_SURFACE_TYPE=EGL_WINDOW_BIT

It shouldn't make a difference in this case: cairo surfaces that are
created by cairo_gl_surface_create() are backed by textures, not by any
type of EGL surface.

> 
> but still nothing display in my phone.
> 

> >>    surface = cairo_gl_surface_create(device, CAIRO_CONTENT_ALPHA,
> >> info->width,
> >>            info->height);//return CAIRO_SURFACE_TYPE_GL type

I don't know what you are trying to achieve, so this may be way off
base, but is CAIRO_CONTENT_ALPHA what you want here? Perhaps you need
CAIRO_CONTENT_COLOR_ALPHA? Even if you actually need
CAIRO_CONTENT_ALPHA, it's worth trying out a simpler example first to
get a better feeling of what may be wrong.

Also are you sure you are actually painting correctly to the gl surface?

What happens if instead of a gl surface you use, e.g., an image surface?
Do you get any output then?

Thanks,
Alexandros


More information about the cairo mailing list