Introduce EGL/GLES and component build patches for Chromium
v3 cover Introduce EGL/GLES and component build patches for Chromium
This set of patches extends the chromium recipe to allow for EGL&GLESv2 based 2D rendering, considerably improving performance. This also adds hardware-accelerated WebGL support.
Three new PACKAGECONFIG for chromium are introduced:
* "component-build" : If set, Chromium is built in component mode. Each subsystem of Chromium ends up in a separate shared object. The alternative is the regular mode, which links everything into one big binary. Component builds are useful for development and testing, and consumes significantly less RAM during building. It is essential when building Chromium on a 32-bit OS.
* "use-egl" : Ordinarily, Chromium will try to use GLX and regular (= Desktop) OpenGL for 2D acceleration. If that fails, software rendering is used. If use-egl is set, it will use EGL instead of GLX and OpenGL ES 2.0 instead of regular OpenGL. This is very useful if the target platform provides hardware acceleration for this API. Chromium will then render all 2D components as well as WebGL contents with hardware acceleration, Canvas being an exception (see below).
* "ignore-lost-context" : Without this flag, HTML Canvas will not be accelerated, even with the "use-egl" flag set. The reason for this is a conceptual problem: HTML Canvas expects the backing store of the canvas to persist until the web page goes away. But if the backing store is a GLES texture, then in theory the associated EGL context could get lost (for example, during a power management cycle), and the texture along with it. This violates requirements for canvas. So, one has to choose: either remain fully standards compliant, and have no acceleration, or have acceleration, and risk losing the Canvas content. Note that context losses do not happen on all platforms (they haven't been observed with Vivante GPUs for example, and internals of its galcore module do not show anything that could cause a lost context). But since these recipes do not depend on a specific platform, this option must be explicitely enabled.
Carlos Rafael Giani (4):
chromium: Add component-build PACKAGECONFIG option
chromium: Add variable to contain extra command-line arguments
chromium: Add use-egl PACKAGECONFIG option
chromium: Add ignore-lost-context PACKAGECONFIG option
.../chromium/chromium/component-build.gypi | 5 ++++ recipes-browser/chromium/chromium/google-chrome | 11 +++++--- .../remove-linux-accel-canvas-from-blacklist.patch | 32 ++++++++++++++++++++++ recipes-browser/chromium/chromium_35.0.1883.0.bb | 27 ++++++++++++++++-- 4 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 recipes-browser/chromium/chromium/component-build.gypi create mode 100644 recipes-browser/chromium/chromium/remove-linux-accel-canvas-from-blacklist.patch
Signature · 1 line
1.8.3.2
PATCH v3 1/4 chromium: Add component-build PACKAGECONFIG option
In a component build, the individual Chromium components are contained in separate shared objects. This is useful when building on a system with 8 GB RAM or less (since the linker needs at least that much for link time optimization otherwise if a non-component build is done), and during development and testing of Chromium internals.
--- recipes-browser/chromium/chromium/component-build.gypi | 5 +++++ recipes-browser/chromium/chromium/google-chrome | 2 ++ recipes-browser/chromium/chromium_35.0.1883.0.bb | 13 +++++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 recipes-browser/chromium/chromium/component-build.gypi
recipes-browser/chromium/chromium/component-build.gypi new file +5 -0
@@ -0,0 +1,5 @@ +{ + 'variables': { + 'component' : 'shared_library' + }, +}
recipes-browser/chromium/chromium/google-chrome +2 -0
@@ -1,6 +1,8 @@ #!/bin/sh export CHROME_DEVEL_SANDBOX=/usr/sbin/chrome-devel-sandbox +export LD_LIBRARY_PATH=/usr/lib/chrome + if [ "${USER}" = "root" ] ; then /usr/bin/chrome/chrome --user-data-dir=${HOME}/.chromium/ $@ else
recipes-browser/chromium/chromium_35.0.1883.0.bb +11 -2
@@ -6,6 +6,7 @@ SRC_URI = "\ http://gsdview.appspot.com/chromium-browser-official/${P}.tar.xz \ file://include.gypi \ file://oe-defaults.gypi \ + ${@bb.utils.contains('PACKAGECONFIG', 'component-build', 'file://component-build.gypi', '', d)} \ file://unistd-2.patch \ file://google-chrome \ file://google-chrome.desktop \
@@ -27,6 +28,7 @@ EXTRA_OEGYP = " \ ${@base_contains('DISTRO_FEATURES', 'ld-is-gold', '', '-Dlinux_use_gold_flags=0', d)} \ -I ${WORKDIR}/oe-defaults.gypi \ -I ${WORKDIR}/include.gypi \ + ${@bb.utils.contains('PACKAGECONFIG', 'component-build', '-I ${WORKDIR}/component-build.gypi', '', d)} \ -f ninja \ " ARMFPABI_armv7a = "${@bb.utils.contains('TUNE_FEATURES', 'callconvention-hard', 'arm_float_abi=hard', 'arm_float_abi=softfp', d)}"
@@ -65,6 +67,13 @@ do_install() { install -m 0644 ${S}/out/Release/product_logo_48.png ${D}${bindir}/chrome/ install -m 0755 ${S}/out/Release/libffmpegsumo.so ${D}${bindir}/chrome/ + # Always adding this libdir (not just with component builds), because the + # LD_LIBRARY_PATH line in the google-chromium script refers to it + install -d ${D}${libdir}/chrome/ + if [ -n "${@bb.utils.contains('PACKAGECONFIG', 'component-build', 'component-build', '', d)}" ]; then + install -m 0755 ${S}/out/Release/lib/*.so ${D}${libdir}/chrome/ + fi + install -d ${D}${sbindir} install -m 4755 ${S}/out/Release/chrome_sandbox ${D}${sbindir}/chrome-devel-sandbox
@@ -72,8 +81,8 @@ do_install() { install -m 0644 ${S}/out/Release/locales/en-US.pak ${D}${bindir}/chrome/locales } -FILES_${PN} = "${bindir}/chrome/ ${bindir}/google-chrome ${datadir}/applications ${sbindir}/" -FILES_${PN}-dbg += "${bindir}/chrome/.debug/" +FILES_${PN} = "${bindir}/chrome/ ${bindir}/google-chrome ${datadir}/applications ${sbindir}/ ${libdir}/chrome/" +FILES_${PN}-dbg += "${bindir}/chrome/.debug/ ${libdir}/chrome/.debug/" PACKAGE_DEBUG_SPLIT_STYLE = "debug-without-src"
Signature · 1 line
1.8.3.2
PATCH v3 2/4 chromium: Add variable to contain extra command-line arguments
In reply to Carlos Rafael GianiWith this patch it becomes possible to add extra command line options to the "chrome" call in /usr/bin/google-chrome script .
--- recipes-browser/chromium/chromium/google-chrome | 9 +++++---- recipes-browser/chromium/chromium_35.0.1883.0.bb | 6 ++++++ 2 files changed, 11 insertions(+), 4 deletions(-)
recipes-browser/chromium/chromium/google-chrome +5 -4
@@ -3,8 +3,9 @@ export CHROME_DEVEL_SANDBOX=/usr/sbin/chrome-devel-sandbox export LD_LIBRARY_PATH=/usr/lib/chrome -if [ "${USER}" = "root" ] ; then - /usr/bin/chrome/chrome --user-data-dir=${HOME}/.chromium/ $@ -else - /usr/bin/chrome/chrome $@ +CHROME_EXTRA_ARGS="" +if [ "${USER}" = "root" ] ; then + CHROME_EXTRA_ARGS="${CHROME_EXTRA_ARGS} --user-data-dir=${HOME}/.chromium/" fi + +/usr/bin/chrome/chrome ${CHROME_EXTRA_ARGS} $@
recipes-browser/chromium/chromium_35.0.1883.0.bb +6 -0
@@ -33,6 +33,8 @@ EXTRA_OEGYP = " \ " ARMFPABI_armv7a = "${@bb.utils.contains('TUNE_FEATURES', 'callconvention-hard', 'arm_float_abi=hard', 'arm_float_abi=softfp', d)}" +CHROMIUM_EXTRA_ARGS ?= "" + export GYP_DEFINES="${ARMFPABI} release_extra_cflags='-Wno-error=unused-local-typedefs' sysroot=''" do_configure() { cd ${S}
@@ -54,6 +56,10 @@ do_install() { install -d ${D}${bindir} install -m 0755 ${WORKDIR}/google-chrome ${D}${bindir}/ + # Add extra command line arguments to google-chrome script by modifying + # the dummy "CHROME_EXTRA_ARGS" line + sed -i "s/^CHROME_EXTRA_ARGS=\"\"/CHROME_EXTRA_ARGS=\"${CHROMIUM_EXTRA_ARGS}\"/" ${D}${bindir}/google-chrome + install -d ${D}${datadir}/applications install -m 0644 ${WORKDIR}/google-chrome.desktop ${D}${datadir}/applications/
Signature · 1 line
1.8.3.2
PATCH v3 3/4 chromium: Add use-egl PACKAGECONFIG option
In reply to Carlos Rafael GianiBy default, Chromium will try to use GLX and regular OpenGL. On embedded platforms, these are often not present, or unaccelerated, and using EGL and OpenGL ES instead makes more sense. To produce builds that use EGL and OpenGL ES by default instead, this PACKAGECONFIG option can be used.
An EGL/OpenGLES-enabled build produces a chromium version that renders 2D and WebGL with GPU acceleration (if present).
--- recipes-browser/chromium/chromium_35.0.1883.0.bb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
recipes-browser/chromium/chromium_35.0.1883.0.bb +7 -1
@@ -23,6 +23,10 @@ COMPATIBLE_MACHINE_armv7a = "(.*)" inherit gettext +# this makes sure the dependencies for the EGL mode are present; otherwise, the configure scripts +# automatically and silently fall back to GLX +PACKAGECONFIG[use-egl] = ",,virtual/egl virtual/libgles2" + EXTRA_OEGYP = " \ ${@base_contains('DISTRO_FEATURES', 'ld-is-gold', '', '-Dlinux_use_gold_binary=0', d)} \ ${@base_contains('DISTRO_FEATURES', 'ld-is-gold', '', '-Dlinux_use_gold_flags=0', d)} \
@@ -33,7 +37,9 @@ EXTRA_OEGYP = " \ " ARMFPABI_armv7a = "${@bb.utils.contains('TUNE_FEATURES', 'callconvention-hard', 'arm_float_abi=hard', 'arm_float_abi=softfp', d)}" -CHROMIUM_EXTRA_ARGS ?= "" +CHROMIUM_EXTRA_ARGS ?= " \ + ${@bb.utils.contains('PACKAGECONFIG', 'use-egl', '--use-gl=egl', '', d)} \ +" export GYP_DEFINES="${ARMFPABI} release_extra_cflags='-Wno-error=unused-local-typedefs' sysroot=''" do_configure() {
Signature · 1 line
1.8.3.2
PATCH v3 4/4 chromium: Add ignore-lost-context PACKAGECONFIG option
In reply to Carlos Rafael GianiAccelerating the HTML5 canvas element rendering with OpenGL ES is tricky, because an EGL context can get lost with some drivers. Since pages using canvas assume they can paint into the canvas and the pixels inside will never vanish, this is a problem. Workarounds like periodic snapshots are being considered. The WHATWG discussion about this problem can be found at:
http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2012-September/206450.html
Until then, one has to choose: either no acceleration and full standards compliance, or acceleration and potentially lost pixels.
Using this PACKAGECONFIG chooses the second option.
--- .../remove-linux-accel-canvas-from-blacklist.patch | 32 ++++++++++++++++++++++ recipes-browser/chromium/chromium_35.0.1883.0.bb | 2 ++ 2 files changed, 34 insertions(+) create mode 100644 recipes-browser/chromium/chromium/remove-linux-accel-canvas-from-blacklist.patch
recipes-browser/chromium/chromium/remove-linux-accel-canvas-from-blacklist.patch new file +32 -0
@@ -0,0 +1,32 @@ +Together with the --gpu-no-context-lost command line switch, this patch is +necessary to enable hardware accelerated 2D canvas rendering when using +EGL. + +Note the implications on the behavior of Canvas, in particular with lost +contexts, as discussed here: + +http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2012-September/206450.html + +Upstream-Status: Inappropiate [see link above] + +diff --git a/gpu/config/software_rendering_list_json.cc b/gpu/config/software_rendering_list_json.cc +index 35060a9..4bd6ef5 100644 +--- a/gpu/config/software_rendering_list_json.cc ++++ b/gpu/config/software_rendering_list_json.cc +@@ -232,16 +232,6 @@ const char kSoftwareRenderingListJson[] = LONG_STRING_CONST( + ] + }, + { +- "id": 24, +- "description": "Accelerated 2d canvas is unstable in Linux at the moment", +- "os": { +- "type": "linux" +- }, +- "features": [ +- "accelerated_2d_canvas" +- ] +- }, +- { + "id": 27, + "description": "ATI/AMD cards with older drivers in Linux are crash-prone", + "cr_bugs": [95934, 94973, 136240],
recipes-browser/chromium/chromium_35.0.1883.0.bb +2 -0
@@ -7,6 +7,7 @@ SRC_URI = "\ file://include.gypi \ file://oe-defaults.gypi \ ${@bb.utils.contains('PACKAGECONFIG', 'component-build', 'file://component-build.gypi', '', d)} \ + ${@bb.utils.contains('PACKAGECONFIG', 'ignore-lost-context', 'file://remove-linux-accel-canvas-from-blacklist.patch', '', d)} \ file://unistd-2.patch \ file://google-chrome \ file://google-chrome.desktop \
@@ -39,6 +40,7 @@ ARMFPABI_armv7a = "${@bb.utils.contains('TUNE_FEATURES', 'callconvention-hard', CHROMIUM_EXTRA_ARGS ?= " \ ${@bb.utils.contains('PACKAGECONFIG', 'use-egl', '--use-gl=egl', '', d)} \ + ${@bb.utils.contains('PACKAGECONFIG', 'ignore-lost-context', '--gpu-no-context-lost', '', d)} \ " export GYP_DEFINES="${ARMFPABI} release_extra_cflags='-Wno-error=unused-local-typedefs' sysroot=''"
Signature · 1 line
1.8.3.2
Hello Carlos,
Quoted 17 lines · Carlos Rafael Giani
This set of patches extends the chromium recipe to allow for EGL&GLESv2 based 2D rendering, considerably improving performance. This also adds hardware-accelerated WebGL support.
Three new PACKAGECONFIG for chromium are introduced:
* "component-build" : If set, Chromium is built in component mode. Each subsystem of Chromium ends up in a separate shared object. The alternative is the regular mode, which links everything into one big binary. Component builds are useful for development and testing, and consumes significantly less RAM during building. It is essential when building Chromium on a 32-bit OS.
* "use-egl" : Ordinarily, Chromium will try to use GLX and regular (= Desktop) OpenGL for 2D acceleration. If that fails, software rendering is used. If use-egl is set, it will use EGL instead of GLX and OpenGL ES 2.0 instead of regular OpenGL. This is very useful if the target platform provides hardware acceleration for this API. Chromium will then render all 2D components as well as WebGL contents with hardware acceleration, Canvas being an exception (see below).
Quoted 10 lines
* "ignore-lost-context" : Without this flag, HTML Canvas will not be accelerated, even with the "use-egl" flag set. The reason for this is a conceptual problem: HTML Canvas expects the backing store of the canvas to persist until the web page goes away. But if the backing store is a GLES texture, then in theory the associated EGL context could get lost (for example, during a power management cycle), and the texture along with it. This violates requirements for canvas. So, one has to choose: either remain fully standards compliant, and have no acceleration, or have acceleration, and risk losing the Canvas content. Note that context losses do not happen on all platforms (they haven't been observed with Vivante GPUs for example, and internals of its galcore module do not show anything that could cause a lost context). But since these recipes do not depend on a specific platform, this option must be explicitely enabled.
Thanks for this. I applied them all in master branch.
Signature · 3 lines
Otavio Salvador O.S. Systems http://www.ossystems.com.br http://code.ossystems.com.br Mobile: +55 (53) 9981-7854 Mobile: +1 (347) 903-9750