Cairo and SDL on Android

Hi,

I’ve been having some issues making Cairo work well on Android. I’ve
actually managed to make it work, but my solution is not optimal.

My first method was to just setup a window with OpenGL support, use a cairo
surface on a NPOT texture and upload this texture using OpenGL calls. This
works on Linux, and on some Android devices. Others seem to have issues
with NPOT, thus rendering a white texture.

My second method was using a POT buffer where I render with Cairo,
uploading it and then mapping the right portion of the texture on the
screen. Both these methods use OpenGL and a call to SDL_GL_SwapWindow to
update.

I also tried creating a window withouth OPENGL, then updating the pixels
via SDL_GetWindowSurface, and refresing it with SDL_UpdateWindowSurface.
This seem to cause flickering and sync issues on Android.

However, they are slow solutions. For an Android tablet, with 1280720, I
would need a 2048
2048 texture, a 16mb per frame.

What would be better solution for a fullscreen texture with Cairo?

thanks a lot!

Does Cairo have an accelerated backend? If you have to do software
rendering, then you’re kinda stuck downloading and uploading the texture
data all the time. You should either try enabling a Cairo OpenGL renderer
or finding something else that implements OpenVG.

Jonny DOn Thu, Jan 10, 2013 at 10:13 AM, ?lvaro Castro-Castilla < alvaro.castro.castilla at gmail.com> wrote:

Hi,

I’ve been having some issues making Cairo work well on Android. I’ve
actually managed to make it work, but my solution is not optimal.

My first method was to just setup a window with OpenGL support, use a
cairo surface on a NPOT texture and upload this texture using OpenGL calls.
This works on Linux, and on some Android devices. Others seem to have
issues with NPOT, thus rendering a white texture.

My second method was using a POT buffer where I render with Cairo,
uploading it and then mapping the right portion of the texture on the
screen. Both these methods use OpenGL and a call to SDL_GL_SwapWindow to
update.

I also tried creating a window withouth OPENGL, then updating the pixels
via SDL_GetWindowSurface, and refresing it with SDL_UpdateWindowSurface.
This seem to cause flickering and sync issues on Android.

However, they are slow solutions. For an Android tablet, with 1280720, I
would need a 2048
2048 texture, a 16mb per frame.

What would be better solution for a fullscreen texture with Cairo?

thanks a lot!


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

2013/1/10 ?lvaro Castro-Castilla <alvaro.castro.castilla at gmail.com>

Hi,

I’ve been having some issues making Cairo work well on Android. I’ve
actually managed to make it work, but my solution is not optimal.

My first method was to just setup a window with OpenGL support, use a
cairo surface on a NPOT texture and upload this texture using OpenGL calls.
This works on Linux, and on some Android devices. Others seem to have
issues with NPOT, thus rendering a white texture.

My second method was using a POT buffer where I render with Cairo,
uploading it and then mapping the right portion of the texture on the
screen. Both these methods use OpenGL and a call to SDL_GL_SwapWindow to
update.

I also tried creating a window withouth OPENGL, then updating the pixels
via SDL_GetWindowSurface, and refresing it with SDL_UpdateWindowSurface.
This seem to cause flickering and sync issues on Android.

However, they are slow solutions. For an Android tablet, with 1280720, I
would need a 2048
2048 texture, a 16mb per frame.

What would be better solution for a fullscreen texture with Cairo?

thanks a lot!

How do you create and render the texture? Using SDL or using OpenGL? SDL
should handle POT and NPOT textures for you depending on what the hardware
supports.–
Gabriel.

Cairo does have an experimental accelerated backend, but not really stable
AFAIK.

I create the render texture using OpenGL, actually. Maybe I should try with
SDL then. I’ve had more experience with OpenGL, that was the primary reason
for using OpenGL directly. I didn’t know SDL could handle POT or NPOT
depending on the hardware. Does it query for NPOT extension on Android
devices?

thank youOn Thu, Jan 10, 2013 at 4:30 PM, Gabriel Jacobo wrote:

2013/1/10 ?lvaro Castro-Castilla <@Alvaro_Castro-Castil>

Hi,

I’ve been having some issues making Cairo work well on Android. I’ve
actually managed to make it work, but my solution is not optimal.

My first method was to just setup a window with OpenGL support, use a
cairo surface on a NPOT texture and upload this texture using OpenGL calls.
This works on Linux, and on some Android devices. Others seem to have
issues with NPOT, thus rendering a white texture.

My second method was using a POT buffer where I render with Cairo,
uploading it and then mapping the right portion of the texture on the
screen. Both these methods use OpenGL and a call to SDL_GL_SwapWindow to
update.

I also tried creating a window withouth OPENGL, then updating the pixels
via SDL_GetWindowSurface, and refresing it with SDL_UpdateWindowSurface.
This seem to cause flickering and sync issues on Android.

However, they are slow solutions. For an Android tablet, with 1280720, I
would need a 2048
2048 texture, a 16mb per frame.

What would be better solution for a fullscreen texture with Cairo?

thanks a lot!

How do you create and render the texture? Using SDL or using OpenGL? SDL
should handle POT and NPOT textures for you depending on what the hardware
supports.


Gabriel.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

2013/1/10 ?lvaro Castro-Castilla <alvaro.castro.castilla at gmail.com>

Cairo does have an experimental accelerated backend, but not really stable
AFAIK.

I create the render texture using OpenGL, actually. Maybe I should try
with SDL then. I’ve had more experience with OpenGL, that was the primary
reason for using OpenGL directly. I didn’t know SDL could handle POT or
NPOT depending on the hardware. Does it query for NPOT extension on Android
devices?

thank you

Take a look at the examples I’ve placed here:
http://wiki.libsdl.org/moin.cgi/SDL_GL_BindTexture

I don’t have experience with Cairo, but it seems you are doing what I do
with libRocket, that is, have a OpenGL based renderer render to a texture
and then show that. If that’s the case, those examples should be exactly
what you need.–
Gabriel.

Thanks Gabriel. I’ll try this, the examples are great.On Thu, Jan 10, 2013 at 4:48 PM, Gabriel Jacobo wrote:

2013/1/10 ?lvaro Castro-Castilla <@Alvaro_Castro-Castil>

Cairo does have an experimental accelerated backend, but not really
stable AFAIK.

I create the render texture using OpenGL, actually. Maybe I should try
with SDL then. I’ve had more experience with OpenGL, that was the primary
reason for using OpenGL directly. I didn’t know SDL could handle POT or
NPOT depending on the hardware. Does it query for NPOT extension on Android
devices?

thank you

Take a look at the examples I’ve placed here:
http://wiki.libsdl.org/moin.cgi/SDL_GL_BindTexture

I don’t have experience with Cairo, but it seems you are doing what I do
with libRocket, that is, have a OpenGL based renderer render to a texture
and then show that. If that’s the case, those examples should be exactly
what you need.

Gabriel.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org