Page tree
Skip to end of metadata
Go to start of metadata

(warning)  Draft Version. Getting populated.

SurfaceFlinger :


Public header file (API)

Client APIs

Overall Graphics Architecture

ISurfaceComposer : /* This class defines the Binder IPC interface for accessing various SurfaceFlinger features */

Wayland :
GENIVI Wayland extensions :

SurfaceFlinger :

Sl NoSurfaceFlinger/ISurfaceComposer - APIFileDescriptionGENIVI Wayland ExtensionsWayland Description



1sp<IDisplayEventConnection> createDisplayEventConnection(VsyncSource vsyncSource)ISurfaceComposer.hClient calls createDisplayEventConnection() to create
an instance of IDisplayEventConnection

2virtual sp<ISurfaceComposerClient> createConnection();ISurfaceComposer.h/* create connection with surface flinger, requires
     * ACCESS_SURFACE_FLINGER permission
no explicit api available, since api is a wrapper around the wayland protocol wayland api: wl_display_connect() is used to establish connectionwl_display_connect(char * name)
Connects to the Wayland compositor. Argument name is the socket created by the compositor. If name is NULL, its value will be replaced with the WAYLAND_DISPLAY environment variable if it is set, otherwise display "wayland-0" will be used.
3    virtual sp<ISurfaceComposerClient> createScopedConnection(const sp<IGraphicBufferProducer>& gbp);ISurfaceComposer.h /* create a scoped connection with surface flinger.
     * Surfaces produced with this connection will act
     * as children of the passed in GBP. That is to say
     * SurfaceFlinger will draw them relative and confined to drawing of buffers from the layer associated with pa rent. As this is graphically equivalent in reach to just drawing pixels into the parent buffers, it requires no special permission. */ like the sub-surface protocol, where normal wayland surface can be defined to be a sub-surface from another wayland subsurface.
4    virtual sp<IBinder> createDisplay(const String8& displayName, bool secure);ISurfaceComposer.h /* create a virtual display
     * requires ACCESS_SURFACE_FLINGER permission. */

no equivalent available

5    virtual void destroyDisplay(const sp<IBinder>& display);ISurfaceComposer.h/* destroy a virtual display
     * requires ACCESS_SURFACE_FLINGER permission. */

no equivalent available
6    virtual sp<IBinder> getBuiltInDisplay(int32_t id);ISurfaceComposer.h /* get the token for the existing default displays. possible values
     * for id are eDisplayIdMain and eDisplayIdHdmi.
ilm_getScreenIDscallbacks from wl_output protocolnot really visible if the display is internal one or just a virtual one (created by waltham)
7    virtual void setTransactionState(const Vector<ComposerState>& state,            const Vector<DisplayState>& displays, uint32_t flags);ISurfaceComposer.h /* open/close transactions. requires ACCESS_SURFACE_FLINGER permission */

no equivalent available
8    virtual void bootFinished();ISurfaceComposer.h /* signal that we're done booting.
     * Requires ACCESS_SURFACE_FLINGER permission

no equivalent available
9    virtual bool authenticateSurfaceTexture(        const sp<IGraphicBufferProducer>& bufferProducer) const;ISurfaceComposer.h/* verify that an IGraphicBufferProducer was created by SurfaceFlinger.

no equivalent available
10    virtual status_t getSupportedFrameTimestamps(            std::vector<FrameEvent>* outSupported) const;ISurfaceComposer.h/* Returns the frame timestamps supported by SurfaceFlinger.

no equivalent available
11    virtual status_t captureScreen(const sp<IBinder>& display, const sp<IGraphicBufferProducer>& producer, Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,  int32_t minLayerZ, int32_t maxLayerZ,bool useIdentityTransform, ISurfaceComposer::Rotation rotation);ISurfaceComposer.h/* Capture the specified screen. requires READ_FRAME_BUFFER permission This function will fail if there is a secure window on screen */ilm_takeScreenshotivi_wm_screen_screenshotTake a screenshot of a certain layer The screenshot is saved as bmp file with the corresponding filename.
12    virtual status_t getDisplayStats(const sp<IBinder>& display,DisplayStatInfo* stats);ISurfaceComposer.h/* returns display statistics for a given display
intended to be used by the media framework to properly schedule video frames */
not available
no equivalent available
13    virtual status_t getDisplayConfigs(const sp<IBinder>& display, Vector<DisplayInfo>* configs);ISurfaceComposer.h/* returns information for each configuration of the given display intended to be used to get information about built-in displays */






callbacks from wl_output protocol

14    virtual int getActiveConfig(const sp<IBinder>& display);ISurfaceComposer.h /* indicates which of the configurations returned by getDisplayInfo is currently active */

no equivalent available
15    virtual status_t getDisplayColorModes(const sp<IBinder>& display,  Vector<android_color_mode_t>* configs);ISurfaceComposer.h

no equivalent available
16    virtual android_color_mode_t getActiveColorMode(const sp<IBinder>& display);ISurfaceComposer.h

no equivalent available
17    virtual status_t setActiveColorMode(const sp<IBinder>& display, android_color_mode_t colorMode);ISurfaceComposer.h    /* specifies which configuration (of those returned by getDisplayInfo) should be used */

no equivalent available
18    virtual void setPowerMode(const sp<IBinder>& display, int mode);ISurfaceComposer.h/* set display power mode. depending on the mode, it can either trigger
     * screen on, off or low power mode and wait for it to complete.
     * requires ACCESS_SURFACE_FLINGER permission.

no equivalent available, some proprietary interface avaialble to trigget DPMS mode explicitly
19    virtual status_t setActiveConfig(const sp<IBinder>& display, int id);ISurfaceComposer.h

no equivalent available
20    virtual status_t clearAnimationFrameStats();ISurfaceComposer.h/* Clears the frame statistics for animations.
Requires the ACCESS_SURFACE_FLINGER permission. */

no equivalent available
21    virtual status_t getAnimationFrameStats(FrameStats* outStats) const;ISurfaceComposer.h/* Gets the frame statistics for animations.
Requires the ACCESS_SURFACE_FLINGER permission.

no equivalent available
22    virtual status_t getHdrCapabilities(const sp<IBinder>& display,  HdrCapabilities* outCapabilities) const;ISurfaceComposer.h/* Gets the supported HDR capabilities of the given display Requires the ACCESS_SURFACE_FLINGER permission. */

no equivalent available
23    virtual status_t enableVSyncInjections(bool enable);ISurfaceComposer.h

no equivalent available
24    virtual status_t injectVSync(nsecs_t when);ISurfaceComposer.h

no equivalent available
25    virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const;ISurfaceComposer.h /* Gets the list of active layers in Z order for debugging purposes Requires the ACCESS_SURFACE_FLINGER permission.*/





provides only the Z-Order of layers on display and surface within layers
26status_t createSurface(const String8& name, uint32_t w, uint32_t h, PixelFormat format, uint32_t flags, const sp<IBinder>& parent, uint32_t windowType,uint32_t ownerUid, sp<IBinder>* handle, sp<IGraphicBufferProducer>* gbp)ISurfaceComposerClient.hRequires ACCESS_SURFACE_FLINGER permissionilm_surfaceCreate



ILM_SUCCESS if the method call was successful
ILM_FAILED if the client can not call the method on the service.

Not an exact same function: pixel format and size are dependent of the EGL configuration which not part of the ilm or wayland interface

27status_t destroySurface(const sp<IBinder>& handle)ISurfaceComposerClient.hRequires ACCESS_SURFACE_FLINGER permission
wl_surface : destroyDeletes the surface and invalidates its object ID

ilmErrorTypes ilm_surfaceRemove (const t_ilm_surface surfaceId) Remove a surface
ILM_SUCCESS if the method call was successful
ILM_FAILED if the client can not call the method on the service.

29status_t clearLayerFrameStats(const sp<IBinder>& handle)ISurfaceComposerClient.hRequires ACCESS_SURFACE_FLINGER permission

30status_t getLayerFrameStats(const sp<IBinder>& handle, FrameStats* outStats)ISurfaceComposerClient.hRequires ACCESS_SURFACE_FLINGER permission


status_t createLayer(const String8& name, const sp<Client>& client, uint32_t w, uint32_t h, PixelFormat format, uint32_t flags, uint32_t windowType, uint32_t ownerUid, sp<IBinder>* handle, sp<IGraphicBufferProducer>* gbp, sp<Layer>* parent);

SurfaceFlinger.hcreate a Layer instance to service the remote Surface instanceilm_layerCreateWithDimension ivi_wm_create_layout_layerCreate a layer which should be managed by the wayland service

status_t createNormalLayer(const sp<Client>& client, const String8& name, uint32_t w, uint32_t h, uint32_t flags, PixelFormat& format, sp<IBinder>* outHandle, sp<IGraphicBufferProducer>* outGbp,

sp<Layer>* outLayer);


we can create only one type of layer, but maybe logicaly we can use different surface roles to achive the same functionality

status_t createDimLayer(const sp<Client>& client, const String8& name,uint32_t w, uint32_t h, uint32_t flags, sp<IBinder>* outHandle,sp<IGraphicBufferProducer>* outGbp, sp<Layer>* outLayer);


we can create only one type of layer, but maybe logicaly we can use different surface roles to achive the same functionality
34 String8 getUniqueLayerName(const String8& name);SurfaceFlinger.h

no equivalent available but all ilm layers and ilm surfaces can be referenced by the unique ID

    status_t onLayerRemoved(const sp<Client>& client, const sp<IBinder>& handle);


called in response to the window-manager calling ISurfaceComposerClient ::destroySurface()






wayland events about changes on layers or surfaces are handled in the ilmControl library,maybe not exaclty same but we can use the callback to be notified about all ilm triggered changes: creation/destroying of layers or surfaces, modification of layers, surfaces or changes on layer render order

    status_t onLayerDestroyed(const wp<Layer>& layer);


called when all clients have released all their references to this layer meaning it is entirely safe to destroy all resources associated to this layer.

same as abovesame as abovesame comment as above

 status_t removeLayer(const sp<Layer>& layer, bool topLevelOnly = false);

SurfaceFlinger.h// remove a layer from SurfaceFlinger immediatelyilm_layerRemoveivi_wm_destroy_layout_layerRemoves a layer which is currently managed by the service

status_t addClientLayer(const sp<Client>& client,

            const sp<IBinder>& handle,

            const sp<IGraphicBufferProducer>& gbc,

            const sp<Layer>& lbc,

            const sp<Layer>& parent);

SurfaceFlinger.h// add a layer to SurfaceFlingerilm_displaySetRenderOrderloop of ivi_wm_screen_add_layeradds layer to the screen

Previous Work

Weston on Android: 

Back in 2012 some investitgation/hacking by Pekka Paalanen / Collabora: blog post, video . This directly maps Weston ("writing a new backend") to Android.  That is of course is slightly different than coming at the investigation from the Wayland protocol (implementation independent) angle.  But it should say something about the similarity and feasibility of mapping.  Since Weston is compiled and actually runs on the device and Weston acts as the implementation of the Wayland protocol, it is in essence a solution approach that provides Wayland on Android.  Further investigation work might show whether running Weston or a bespoke Android implementation of Wayland is the right approach.

  • No labels