Contents |
This page describe how the MeeGo TV Browser accelerate video by using the GDL planes.
Note: This implementation is specific to Intel CE4xxx HW. Other HW architecture will need modification of the code.
The Intel® Atom™ processors CE4xxx have four Universal Pixel Planes (UPP) for graphics and video rendering. The hardware cursor uses the UPP_D, the X window system uses the UPP_C, and the hardware accelerated video is rendered on UPP_B or UPP_A in a typical environment.
For hardware accelerated video playback, specific plug-ins such as the Adobe Flash® Player plug-in (hereafter referred to as “Flash plug-in”) or a commercial Blue-ray stack need to render the graphics overlay on the X window system and render the videos on the underlying planes. This requires that the alpha values of the graphics overlay be applied to the plane level to see through the X window system and display the videos.
Note : The Flash plug-in is not available as open source and requires specific license from Adobe®.
In MeeGo TV, mutter is the compositing window manager and provides the capability to manage the plane level alpha values. X client applications may send commands to mutter through window manager hints to make a window translucent or transparent. The commands will need to provide the XID of the window and specify a rectangle that needs to be translucent or transparent. Since all sub-windows share the same off-screen pixel buffer with the top level window, mutter only handles the XIDs that belong to a top level window.
The first thing browser needs to do is setting mutter hints to the top level window of the browser (the first level window) and apply mutter hints to it. The hint string is “meego-tv-cutout-x=0:meego-tv-cutout-y=0:meego-tv-cutout-width=0:meego-tv-cutout-height=0:meego-tv-half-trans=1:meego-tv-full-window=1”, which means the whole browser window can be translucent and the opacity is defined by alpha values (areas outside the Flash plug-in has alpha value 255, so won’t be seen through).
According to the Flash plug-in usage scenario, the Flash plug-in will use a 32 bpp surface and the pixel values including the alpha channel need to be applied to the top level window. In this way, mutter will be able to apply the 32 bpp window‘s alpha values to the hardware plane.
In windowed mode, the Flash plug-in owns its own sub-window. To apply alpha values to the top level window’s pixel buffer, all its ancestor windows need to be 32 bpp. In the Chromium browser, the window chain includes 5 layers. And in the Flash plug-in there can be several levels according to the Flash plug-in implementation.
A list of the window hierarchy in the chromium browser is shown in the following table.
| Level | Window | Function | Creation | 1 | Browser Window | This is the top most window | chrome/browser/ui/gtk/browser_window_gtk.cc | 2 | Tab Window | Each tab will create a tab window | chrome/browser/renderer_host/render_widget_host_view_gtk.cc | 3 | Plugin Container | Created for container manager use. | webkit/plugins/npapi/gtk_plugin_container_manager.cc | 4 | !GtkPlug | The top level window of plugin process and the !GtkPlug mechanism for embedding into other process | webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc | 5 | !GtkSocket | The !GtkSocket ID will be passed to plugin process | webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc |
The key modification is to change the window that is 24 bpp to 32 bpp. This can be done by getting the rgba colormap from the screen and setting the colormap to the corresponding GtkWidget. If a customer wants to apply this change to the WebKit browser, similar changes need to be made in WebKit and the WebView container.
In windowless mode, the browser provides a pixmap to the flash plugin as a canvas to draw on. If the “wmode” property is set to “opaque”, the pixmap is filled with an opaque color “0xFF000000”. If the “wmode” property is set to “transparent”, the pixmap is filled with the background image which is composed of HTML elements in the underlying layers. To enable multi-plane transparency, the browser should meet three preconditions.
The plug-in need to differentiate whether the usage scenario is hardware accelerated video. If not, everything should be rendered to the plugin window with alpha values 255 (Fully opaque). Otherwise, it needs to apply mutter translucency to render translucent graphics overlay on X window system.
A list of window hierarchy in plugin.
| Level | Window | Function | Creation | 6 | !GtkPlug | The fifth layer !GtkSocket is the window ID plugin will get. Plugin will first create a !GtkPlug widget as child of !GtkSocket and as the container for other widgets | Plugin SetWindow Function | 7 | Canvas Widget | Plugin draw everything in this widget | In the Plugin |
To apply the alpha channel of the 32bpp pixbuf to UPP_C, you have to draw the 32bpp pixel buffer to the 7th level window. This could be done by cairo graphics engine. We tried to use the gtk functions gdk_pixbuf_render_to_drawable, but the alpha channel does not apply to the 7th window level, but to the background of the widget, so do not use it.
For windowless mode, the plugin needs to draw the 32 bpp pixel buffer to the pixmap provided by a browser. And the draw operation should be a source blit instead of blending.
Please notice that any top level window created by the flash plugin does not have the mutter hints set already, and the flash plugin is responsible to set hints by itself if this window needs to apply multi-plane transparency. A good example of this scenario is the full screen playback.
1. Browser:
2. DiamondX Sample Plugin
3. Test:
Setting the browser sub-window chain to 32 bpp will cause the software version of the Flash plug-in from Adobe’s official website to fail. A simple solution is to use an environment variable to indicate to the browser which version of the Flash plug-in it’s using and have the browser base its behavior on that information.