diff --git a/gfx/thebes/gfxPrefs.h b/gfx/thebes/gfxPrefs.h index ef77c05f04cf..e0537b35e0a7 100644 --- a/gfx/thebes/gfxPrefs.h +++ b/gfx/thebes/gfxPrefs.h @@ -507,6 +507,7 @@ private: DECL_GFX_PREF(Once, "gfx.vsync.compositor.unobserve-count", CompositorUnobserveCount, int32_t, 10); DECL_GFX_PREF(Once, "gfx.webrender.all", WebRenderAll, bool, false); + DECL_GFX_PREF(Once, "gfx.webrender.async-scene-build", WebRenderAsyncSceneBuild, bool, false); DECL_GFX_PREF(Once, "gfx.webrender.enabled", WebRenderEnabledDoNotUseDirectly, bool, false); DECL_OVERRIDE_PREF(Live, "gfx.webrender.blob-images", WebRenderBlobImages, gfxPrefs::WebRenderAll()); DECL_GFX_PREF(Live, "gfx.webrender.blob.invalidation", WebRenderBlobInvalidation, bool, false); diff --git a/gfx/webrender_bindings/WebRenderAPI.cpp b/gfx/webrender_bindings/WebRenderAPI.cpp index ac2fbd2d5856..63f9730a41b5 100644 --- a/gfx/webrender_bindings/WebRenderAPI.cpp +++ b/gfx/webrender_bindings/WebRenderAPI.cpp @@ -5,7 +5,9 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "WebRenderAPI.h" + #include "DisplayItemClipChain.h" +#include "gfxPrefs.h" #include "LayersLogging.h" #include "mozilla/webrender/RendererOGL.h" #include "mozilla/gfx/gfxVars.h" @@ -134,8 +136,15 @@ private: TransactionBuilder::TransactionBuilder() { - mTxn = wr_transaction_new(); - mResourceUpdates = wr_resource_updates_new(); + // We need the if statement to avoid miscompilation on windows, see + // bug 1449982 comment 22. + if (gfxPrefs::WebRenderAsyncSceneBuild()) { + mTxn = wr_transaction_new(true); + mResourceUpdates = wr_resource_updates_new(); + } else { + mResourceUpdates = wr_resource_updates_new(); + mTxn = wr_transaction_new(false); + } } TransactionBuilder::~TransactionBuilder() diff --git a/gfx/webrender_bindings/src/bindings.rs b/gfx/webrender_bindings/src/bindings.rs index adc63e3847d1..5f921063bf3f 100644 --- a/gfx/webrender_bindings/src/bindings.rs +++ b/gfx/webrender_bindings/src/bindings.rs @@ -863,8 +863,17 @@ pub unsafe extern "C" fn wr_api_shut_down(dh: &mut DocumentHandle) { } #[no_mangle] -pub extern "C" fn wr_transaction_new() -> *mut Transaction { - Box::into_raw(Box::new(Transaction::new())) +pub extern "C" fn wr_transaction_new(do_async: bool) -> *mut Transaction { + let mut transaction = Transaction::new(); + // Ensure that we either use async scene building or not based on the + // gecko pref, regardless of what the default is. We can remove this once + // the scene builder thread is enabled everywhere and working well. + if do_async { + transaction.use_scene_builder_thread(); + } else { + transaction.skip_scene_builder(); + } + Box::into_raw(Box::new(transaction)) } /// cbindgen:postfix=WR_DESTRUCTOR_SAFE_FUNC diff --git a/gfx/webrender_bindings/webrender_ffi_generated.h b/gfx/webrender_bindings/webrender_ffi_generated.h index 03bd5387c0e4..75da8e85c66c 100644 --- a/gfx/webrender_bindings/webrender_ffi_generated.h +++ b/gfx/webrender_bindings/webrender_ffi_generated.h @@ -1580,7 +1580,7 @@ bool wr_transaction_is_empty(const Transaction *aTxn) WR_FUNC; WR_INLINE -Transaction *wr_transaction_new() +Transaction *wr_transaction_new(bool aDoAsync) WR_FUNC; WR_INLINE