Does Mir have to pretend to be SurfaceFlinger?

Christopher James Halse Rogers chris at cooperteam.net
Fri Sep 9 00:13:32 UTC 2016


On Fri, Sep 9, 2016 at 4:18 AM, Cemil Azizoglu 
<cemil.azizoglu at canonical.com> wrote:
>> 
>> We quite literally cast MirRenderSurface* to EGLNativeWindowSurface 
>> in the current WIP:
>> http://bazaar.launchpad.net/%7Ecemil-azizoglu/mir/mir-render-surface-v3/view/head:/playground/eglflash_render_surface.c#L112
> 
> ​Perhaps, I should point out that our EGLNativeWindowType is not 
> (and cannot be) 'MirRenderSurface'. It's void*.​ This is because we 
> (have to) pretend to be other platforms (Android).

Hm, this got me thinking.

*Does* Mir need to pretend to be SurfaceFlinger?

As I understand it, the only relevant constraint is that we need to be 
able to bring up Unity8 and USC using unmodified Android drivers.
 - This means we need to use Android libEGL at *some* point in the 
stack.
 - We (as in Ubuntu) control what libEGL.so.1 resolves to.
  + This does *not* have to be Android's libEGL - indeed, it's 
currently *not* Android's libEGL, it's libhybris' wrapper.
 - This means we have the opportunity to interpose code between 
EGL-using clients and Android's EGL.

I looked at the code in platforms/android/client, and there doesn't 
appear to be any code there that can *only* be implemented inside a 
platform module. Indeed, it looks like the NBS API was basically 
designed to allow code linking against libmirclient to do exactly what 
is done inside the EGLNativeWindow producing bits of the Android 
platform.

So I think we *could* #define EGLNativeWindowType MirRenderSurface* 
(and likewise #define EGLNativeDisplayType MirConnection*) without a 
great deal of effort required. Mostly this would require moving code 
from platforms/android/client into a new libEGL that implements 
eglGetDisplay() and eglCreateWindowSurface() and links to the hybris 
libEGL to satisfy all other EGL symbols.

This would make Mir look like all other EGL platforms. To create an 
EGLDisplay you'd eglGetDisplay(connection); to create an EGLSurface 
you'd eglCreateWindowSurface(render_surface, ...).

I'm not sure if this is worth doing, but it does not appear that it 
would be terribly difficult to do.




More information about the Mir-devel mailing list