Bug 1437949 - Make the wake_up WR notification poke the renderer. r?kvark
MozReview-Commit-ID: HxMOW4EF6sn
--- a/gfx/webrender_bindings/RenderThread.cpp
+++ b/gfx/webrender_bindings/RenderThread.cpp
@@ -171,16 +171,43 @@ RenderThread::NewFrameReady(wr::WindowId
return;
}
UpdateAndRender(aWindowId);
DecPendingFrameCount(aWindowId);
}
void
+RenderThread::WakeUp(wr::WindowId aWindowId)
+{
+ if (mHasShutdown) {
+ return;
+ }
+
+ if (!IsInRenderThread()) {
+ Loop()->PostTask(
+ NewRunnableMethod<wr::WindowId>("wr::RenderThread::WakeUp",
+ this,
+ &RenderThread::WakeUp,
+ aWindowId));
+ return;
+ }
+
+ if (IsDestroyed(aWindowId)) {
+ return;
+ }
+
+ auto it = mRenderers.find(aWindowId);
+ MOZ_ASSERT(it != mRenderers.end());
+ if (it != mRenderers.end()) {
+ it->second->Update();
+ }
+}
+
+void
RenderThread::RunEvent(wr::WindowId aWindowId, UniquePtr<RendererEvent> aEvent)
{
if (!IsInRenderThread()) {
Loop()->PostTask(
NewRunnableMethod<wr::WindowId, UniquePtr<RendererEvent>&&>(
"wr::RenderThread::RunEvent",
this,
&RenderThread::RunEvent,
@@ -464,18 +491,17 @@ extern "C" {
static void NewFrameReady(mozilla::wr::WrWindowId aWindowId)
{
mozilla::wr::RenderThread::Get()->IncRenderingFrameCount(aWindowId);
mozilla::wr::RenderThread::Get()->NewFrameReady(mozilla::wr::WindowId(aWindowId));
}
void wr_notifier_wake_up(mozilla::wr::WrWindowId aWindowId)
{
- //TODO?
- mozilla::Unused << aWindowId;
+ mozilla::wr::RenderThread::Get()->WakeUp(mozilla::wr::WindowId(aWindowId));
}
void wr_notifier_new_frame_ready(mozilla::wr::WrWindowId aWindowId)
{
NewFrameReady(aWindowId);
}
void wr_notifier_new_scroll_frame_ready(mozilla::wr::WrWindowId aWindowId, bool aCompositeNeeded)
--- a/gfx/webrender_bindings/RenderThread.h
+++ b/gfx/webrender_bindings/RenderThread.h
@@ -113,16 +113,19 @@ public:
RendererOGL* GetRenderer(wr::WindowId aWindowId);
// RenderNotifier implementation
/// Automatically forwarded to the render thread.
void NewFrameReady(wr::WindowId aWindowId);
/// Automatically forwarded to the render thread.
+ void WakeUp(wr::WindowId aWindowId);
+
+ /// Automatically forwarded to the render thread.
void PipelineSizeChanged(wr::WindowId aWindowId, uint64_t aPipelineId, float aWidth, float aHeight);
/// Automatically forwarded to the render thread.
void RunEvent(wr::WindowId aWindowId, UniquePtr<RendererEvent> aCallBack);
/// Can only be called from the render thread.
void UpdateAndRender(wr::WindowId aWindowId);
--- a/gfx/webrender_bindings/RendererOGL.cpp
+++ b/gfx/webrender_bindings/RendererOGL.cpp
@@ -76,16 +76,22 @@ RendererOGL::GetExternalImageHandler()
{
return wr::WrExternalImageHandler {
this,
LockExternalImage,
UnlockExternalImage,
};
}
+void
+RendererOGL::Update()
+{
+ wr_renderer_update(mRenderer);
+}
+
bool
RendererOGL::UpdateAndRender()
{
uint32_t flags = gfx::gfxVars::WebRenderDebugFlags();
if (mDebugFlags.mBits != flags) {
mDebugFlags.mBits = flags;
wr_renderer_set_debug_flags(mRenderer, mDebugFlags);
--- a/gfx/webrender_bindings/RendererOGL.h
+++ b/gfx/webrender_bindings/RendererOGL.h
@@ -45,16 +45,19 @@ class RendererOGL
{
friend wr::WrExternalImage LockExternalImage(void* aObj, wr::WrExternalImageId aId, uint8_t aChannelIndex);
friend void UnlockExternalImage(void* aObj, wr::WrExternalImageId aId, uint8_t aChannelIndex);
public:
wr::WrExternalImageHandler GetExternalImageHandler();
/// This can be called on the render thread only.
+ void Update();
+
+ /// This can be called on the render thread only.
bool UpdateAndRender();
/// This can be called on the render thread only.
bool RenderToTarget(gfx::DrawTarget& aTarget);
/// This can be called on the render thread only.
void SetProfilerEnabled(bool aEnabled);