Bug 1531417 - enable shared buffer provider for software canvas on all platforms. r=nical
authorLee Salzman <lsalzman@mozilla.com>
Fri, 01 Mar 2019 09:53:43 -0500
changeset 519986 0ce0e1ad2096d014f2a6d58d20ba8f9f143dd96b
parent 519985 5e4f3a3033e9e63528fe4e68685296aaf5deed60
child 519987 2c8674d20ba67335e850efd59ce5a7c1ad4811f7
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1531417
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1531417 - enable shared buffer provider for software canvas on all platforms. r=nical
dom/canvas/CanvasRenderingContext2D.cpp
modules/libpref/init/all.js
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -1350,16 +1350,23 @@ bool CanvasRenderingContext2D::TryShared
       (mBufferProvider->GetType() == LayersBackend::LAYERS_CLIENT ||
        mBufferProvider->GetType() == LayersBackend::LAYERS_WR)) {
     // we are already using a shared buffer provider, we are allocating a new
     // one because the current one failed so let's just fall back to the basic
     // provider.
     return false;
   }
 
+#ifdef XP_WIN
+  // Bug 1285271 - Disable shared buffer provider on Windows with D2D due to instability
+  if (gfxPlatform::GetPlatform()->GetPreferredCanvasBackend() == BackendType::DIRECT2D1_1) {
+    return false;
+  }
+#endif
+
   RefPtr<LayerManager> layerManager =
       LayerManagerFromCanvasElement(mCanvasElement);
 
   if (!layerManager) {
     return false;
   }
 
   aOutProvider = layerManager->CreatePersistentBufferProvider(
@@ -4552,17 +4559,20 @@ void CanvasRenderingContext2D::DrawWindo
   // Flush layout updates
   if (!(aFlags & CanvasRenderingContext2D_Binding::DRAWWINDOW_DO_NOT_FLUSH)) {
     nsContentUtils::FlushLayoutForTree(aWindow.AsInner()->GetOuterWindow());
   }
 
   CompositionOp op = UsedOperation();
   bool discardContent =
       GlobalAlpha() == 1.0f &&
-      (op == CompositionOp::OP_OVER || op == CompositionOp::OP_SOURCE);
+      (op == CompositionOp::OP_OVER || op == CompositionOp::OP_SOURCE) &&
+      (!mBufferProvider ||
+        (mBufferProvider->GetType() != LayersBackend::LAYERS_CLIENT &&
+         mBufferProvider->GetType() != LayersBackend::LAYERS_WR));
   const gfx::Rect drawRect(aX, aY, aW, aH);
   EnsureTarget(discardContent ? &drawRect : nullptr);
   if (!IsTargetValid()) {
     return;
   }
 
   RefPtr<nsPresContext> presContext;
   nsIDocShell* docshell = aWindow.GetDocShell();
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -5077,25 +5077,16 @@ pref("gfx.direct3d11.enable-debug-layer"
 pref("gfx.direct3d11.break-on-error", false);
 
 pref("layers.prefer-opengl", false);
 #endif
 
 // Copy-on-write canvas
 pref("layers.shared-buffer-provider.enabled", true);
 
-#ifdef XP_WIN
-pref("layers.shared-buffer-provider.enabled", false);
-#endif
-
-#ifdef XP_MACOSX
-// cf. Bug 1324908
-pref("layers.shared-buffer-provider.enabled", false);
-#endif
-
 // Force all possible layers to be always active layers
 pref("layers.force-active", false);
 
 // Enable/Disable the geolocation API for content
 pref("geo.enabled", true);
 
 // Timeout for outbound network geolocation provider XHR
 pref("geo.wifi.xhr.timeout", 60000);