Bug 1457448 - Ensure we flush the async scene builder thread before snapshotting. r?nical
MozReview-Commit-ID: 3XTFWiEmk0p
--- a/gfx/layers/wr/WebRenderBridgeParent.cpp
+++ b/gfx/layers/wr/WebRenderBridgeParent.cpp
@@ -840,16 +840,19 @@ WebRenderBridgeParent::RecvGetSnapshot(P
uint32_t buffer_size = size.width * size.height * 4;
// Assert the stride of the buffer is what webrender expects
MOZ_ASSERT((uint32_t)(size.width * 4) == stride);
mForceRendering = true;
mCompositorScheduler->FlushPendingComposite();
+ if (gfxPrefs::WebRenderAsyncSceneBuild()) {
+ mApi->FlushSceneBuilder();
+ }
mApi->Readback(size, buffer, buffer_size);
mForceRendering = false;
return IPC_OK();
}
void
--- a/gfx/webrender_bindings/WebRenderAPI.cpp
+++ b/gfx/webrender_bindings/WebRenderAPI.cpp
@@ -522,16 +522,22 @@ WebRenderAPI::Resume()
void
WebRenderAPI::WakeSceneBuilder()
{
wr_api_wake_scene_builder(mDocHandle);
}
void
+WebRenderAPI::FlushSceneBuilder()
+{
+ wr_api_flush_scene_builder(mDocHandle);
+}
+
+void
WebRenderAPI::WaitFlushed()
{
class WaitFlushedEvent : public RendererEvent
{
public:
explicit WaitFlushedEvent(layers::SynchronousTask* aTask)
: mTask(aTask)
{
--- a/gfx/webrender_bindings/WebRenderAPI.h
+++ b/gfx/webrender_bindings/WebRenderAPI.h
@@ -193,16 +193,17 @@ public:
void RunOnRenderThread(UniquePtr<RendererEvent> aEvent);
void Readback(gfx::IntSize aSize, uint8_t *aBuffer, uint32_t aBufferSize);
void Pause();
bool Resume();
void WakeSceneBuilder();
+ void FlushSceneBuilder();
wr::WrIdNamespace GetNamespace();
uint32_t GetMaxTextureSize() const { return mMaxTextureSize; }
bool GetUseANGLE() const { return mUseANGLE; }
layers::SyncHandle GetSyncHandle() const { return mSyncHandle; }
void Capture();
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -1477,16 +1477,21 @@ pub unsafe extern "C" fn wr_api_get_name
dh.api.get_namespace_id()
}
#[no_mangle]
pub unsafe extern "C" fn wr_api_wake_scene_builder(dh: &mut DocumentHandle) {
dh.api.wake_scene_builder();
}
+#[no_mangle]
+pub unsafe extern "C" fn wr_api_flush_scene_builder(dh: &mut DocumentHandle) {
+ dh.api.flush_scene_builder();
+}
+
// RenderThread WIP notes:
// In order to separate the compositor thread (or ipc receiver) and the render
// thread, some of the logic below needs to be rewritten. In particular
// the WrWindowState and Notifier implementations aren't designed to work with
// a separate render thread.
// As part of that I am moving the bindings closer to WebRender's API boundary,
// and moving more of the logic in C++ land.
// This work is tracked by bug 1328602.
--- a/gfx/webrender_bindings/webrender_ffi_generated.h
+++ b/gfx/webrender_bindings/webrender_ffi_generated.h
@@ -1015,16 +1015,20 @@ WR_DESTRUCTOR_SAFE_FUNC;
WR_INLINE
void wr_api_finalize_builder(WrState *aState,
LayoutSize *aContentSize,
BuiltDisplayListDescriptor *aDlDescriptor,
WrVecU8 *aDlData)
WR_FUNC;
WR_INLINE
+void wr_api_flush_scene_builder(DocumentHandle *aDh)
+WR_FUNC;
+
+WR_INLINE
WrIdNamespace wr_api_get_namespace(DocumentHandle *aDh)
WR_FUNC;
WR_INLINE
bool wr_api_hit_test(DocumentHandle *aDh,
WorldPoint aPoint,
WrPipelineId *aOutPipelineId,
uint64_t *aOutScrollId,