Bug 947504 - Only enable HwcComposer2D by default if hardware supports it. r=gal, a=1.3+
authorDiego Wilson <dwilson@codeaurora.org>
Tue, 14 Jan 2014 10:15:57 -0800
changeset 174849 f4bc0d1cae6ffd2290bbb8638d4b6943fb8c0e88
parent 174848 075d1f1d8e3fd07b76035a515f4b22d1544ac4da
child 174850 ac12618cf462b8ed36fc354c72e0742c2a6488e0
push idunknown
push userunknown
push dateunknown
reviewersgal, 1
bugs947504
milestone28.0a2
Bug 947504 - Only enable HwcComposer2D by default if hardware supports it. r=gal, a=1.3+ This feature will only be enabled by default on hardware that supports it which sets the gonk prop "ro.display.colorfill" to true. The feature can still be force enabled (or force disabled) via the "layers.composer2d.enabled" setting.
b2g/app/b2g.js
b2g/chrome/content/settings.js
--- a/b2g/app/b2g.js
+++ b/b2g/app/b2g.js
@@ -263,17 +263,16 @@ pref("layers.offmainthreadcomposition.as
 pref("layers.async-video.enabled", false);
 #else
 pref("dom.ipc.tabs.disabled", false);
 pref("layers.acceleration.disabled", false);
 pref("layers.offmainthreadcomposition.async-animations", true);
 pref("layers.async-video.enabled", true);
 pref("layers.async-pan-zoom.enabled", true);
 pref("gfx.content.azure.backends", "cairo");
-pref("layers.composer2d.enabled", true);
 #endif
 
 // Web Notifications
 pref("notification.feature.enabled", true);
 
 // IndexedDB
 pref("dom.indexedDB.warningQuota", 5);
 
--- a/b2g/chrome/content/settings.js
+++ b/b2g/chrome/content/settings.js
@@ -522,11 +522,46 @@ SettingsListener.observe("debug.fps.enab
   Services.prefs.setBoolPref("layers.acceleration.draw-fps", value);
 });
 SettingsListener.observe("debug.paint-flashing.enabled", false, function(value) {
   Services.prefs.setBoolPref("nglayout.debug.paint_flashing", value);
 });
 SettingsListener.observe("layers.draw-borders", false, function(value) {
   Services.prefs.setBoolPref("layers.draw-borders", value);
 });
-SettingsListener.observe("layers.composer2d.enabled", true, function(value) {
-  Services.prefs.setBoolPref("layers.composer2d.enabled", value);
-});
+
+(function Composer2DSettingToPref() {
+  //layers.composer.enabled can be toggled in three ways
+  //In order of precedence they are:
+  //First: layers.composer.enabled mozSetting
+  //Second: layers.composer.enabled gecko pref
+  //Third: ro.display.colorfill gonk prop
+
+  var req = navigator.mozSettings.createLock().get('layers.composer2d.enabled');
+  req.onsuccess = function() {
+    if(typeof(req.result['layers.composer2d.enabled']) == 'undefined') {
+      var enabled = false;
+      if (Services.prefs.getPrefType('layers.composer2d.enabled') == Ci.nsIPrefBranch.PREF_BOOL) {
+        enabled = Services.prefs.getBoolPref('layers.composer2d.enabled');
+      }
+      else {
+#ifdef MOZ_WIDGET_GONK
+        if (libcutils.property_get('ro.display.colorfill') == 1) {
+          enabled = true;
+        }
+        else {
+          enabled = false;
+        }
+#endif
+      }
+      navigator.mozSettings.createLock().set(
+        {'layers.composer2d.enabled': enabled});
+    }
+
+    SettingsListener.observe("layers.composer2d.enabled", true, function(value) {
+      Services.prefs.setBoolPref("layers.composer2d.enabled", value);
+    });
+  };
+  req.onerror = function() {
+    dump("Error configuring layers.composer2d.enabled setting");
+  };
+
+})();