# HG changeset patch # User Alexis Beingessner # Date 1517452483 18000 # Node ID c7dffbc2563adc58c9d484461bcef2f455268513 # Parent d14a6cfbd066730791c8b28a78159ed1f2df207e Bug 1432309 - ensure the GL context is current when updating wr. r=sotaro To avoid future issues, this is done by combining the Render and Update methods into a single call. As a minor side-effect, timing in the parent method now includes the time to run update. MozReview-Commit-ID: GJ0l049eFRj diff --git a/gfx/webrender_bindings/RenderThread.cpp b/gfx/webrender_bindings/RenderThread.cpp --- a/gfx/webrender_bindings/RenderThread.cpp +++ b/gfx/webrender_bindings/RenderThread.cpp @@ -215,21 +215,19 @@ RenderThread::UpdateAndRender(wr::Window auto it = mRenderers.find(aWindowId); MOZ_ASSERT(it != mRenderers.end()); if (it == mRenderers.end()) { return; } auto& renderer = it->second; - renderer->Update(); - TimeStamp start = TimeStamp::Now(); - bool ret = renderer->Render(); + bool ret = renderer->UpdateAndRender(); if (!ret) { // Render did not happen, do not call NotifyDidRender. return; } TimeStamp end = TimeStamp::Now(); auto epochs = renderer->FlushRenderedEpochs(); diff --git a/gfx/webrender_bindings/RendererOGL.cpp b/gfx/webrender_bindings/RendererOGL.cpp --- a/gfx/webrender_bindings/RendererOGL.cpp +++ b/gfx/webrender_bindings/RendererOGL.cpp @@ -76,24 +76,18 @@ RendererOGL::GetExternalImageHandler() { return wr::WrExternalImageHandler { this, LockExternalImage, UnlockExternalImage, }; } -void -RendererOGL::Update() -{ - wr_renderer_update(mRenderer); -} - bool -RendererOGL::Render() +RendererOGL::UpdateAndRender() { uint32_t flags = gfx::gfxVars::WebRenderDebugFlags(); if (mDebugFlags.mBits != flags) { mDebugFlags.mBits = flags; wr_renderer_set_debug_flags(mRenderer, mDebugFlags); } @@ -112,16 +106,18 @@ RendererOGL::Render() return false; } // XXX set clear color if MOZ_WIDGET_ANDROID is defined. if (!mCompositor->BeginFrame()) { return false; } + wr_renderer_update(mRenderer); + auto size = mCompositor->GetClientSize(); if (!wr_renderer_render(mRenderer, size.width, size.height)) { NotifyWebRenderError(WebRenderError::RENDER); } mCompositor->EndFrame(); diff --git a/gfx/webrender_bindings/RendererOGL.h b/gfx/webrender_bindings/RendererOGL.h --- a/gfx/webrender_bindings/RendererOGL.h +++ b/gfx/webrender_bindings/RendererOGL.h @@ -45,20 +45,17 @@ 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 Render(); + 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); /// This can be called on the render thread only.