зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1469496 - Handle video memory purge with WebRender. r=sotaro
This commit is contained in:
Родитель
085c930700
Коммит
3cea37c9c2
|
@ -2354,6 +2354,14 @@ CompositorBridgeParent::NotifyWebRenderError(wr::WebRenderError aError)
|
|||
Unused << SendNotifyWebRenderError(aError);
|
||||
}
|
||||
|
||||
void
|
||||
CompositorBridgeParent::NotifyWebRenderContextPurge()
|
||||
{
|
||||
MOZ_ASSERT(CompositorLoop() == MessageLoop::current());
|
||||
RefPtr<wr::WebRenderAPI> api = mWrBridge->GetWebRenderAPI();
|
||||
api->ClearAllCaches();
|
||||
}
|
||||
|
||||
#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
|
||||
//#define PLUGINS_LOG(...) printf_stderr("CP [%s]: ", __FUNCTION__);
|
||||
// printf_stderr(__VA_ARGS__);
|
||||
|
|
|
@ -274,6 +274,7 @@ public:
|
|||
bool IsSameProcess() const override;
|
||||
|
||||
void NotifyWebRenderError(wr::WebRenderError aError);
|
||||
void NotifyWebRenderContextPurge();
|
||||
void NotifyPipelineRendered(const wr::PipelineId& aPipelineId,
|
||||
const wr::Epoch& aEpoch,
|
||||
TimeStamp& aCompositeStart,
|
||||
|
|
|
@ -95,6 +95,12 @@ RendererOGL::Update()
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
DoNotifyWebRenderContextPurge(layers::CompositorBridgeParent* aBridge)
|
||||
{
|
||||
aBridge->NotifyWebRenderContextPurge();
|
||||
}
|
||||
|
||||
bool
|
||||
RendererOGL::UpdateAndRender(bool aReadback)
|
||||
{
|
||||
|
@ -150,6 +156,18 @@ RendererOGL::UpdateAndRender(bool aReadback)
|
|||
mFrameStartTime = TimeStamp();
|
||||
#endif
|
||||
|
||||
gl::GLContext* gl = mCompositor->gl();
|
||||
if (gl->IsSupported(gl::GLFeature::robustness)) {
|
||||
GLenum resetStatus = gl->fGetGraphicsResetStatus();
|
||||
if (resetStatus == LOCAL_GL_PURGED_CONTEXT_RESET_NV) {
|
||||
layers::CompositorThreadHolder::Loop()->PostTask(NewRunnableFunction(
|
||||
"DoNotifyWebRenderContextPurgeRunnable",
|
||||
&DoNotifyWebRenderContextPurge,
|
||||
mBridge
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Flush pending actions such as texture deletions/unlocks and
|
||||
// textureHosts recycling.
|
||||
|
||||
|
|
|
@ -422,6 +422,12 @@ WebRenderAPI::Readback(const TimeStamp& aStartTime,
|
|||
task.Wait();
|
||||
}
|
||||
|
||||
void
|
||||
WebRenderAPI::ClearAllCaches()
|
||||
{
|
||||
wr_api_clear_all_caches(mDocHandle);
|
||||
}
|
||||
|
||||
void
|
||||
WebRenderAPI::Pause()
|
||||
{
|
||||
|
|
|
@ -198,6 +198,8 @@ public:
|
|||
|
||||
void Readback(const TimeStamp& aStartTime, gfx::IntSize aSize, uint8_t *aBuffer, uint32_t aBufferSize);
|
||||
|
||||
void ClearAllCaches();
|
||||
|
||||
void Pause();
|
||||
bool Resume();
|
||||
|
||||
|
|
|
@ -1029,6 +1029,12 @@ pub unsafe extern "C" fn wr_api_shut_down(dh: &mut DocumentHandle) {
|
|||
dh.api.shut_down();
|
||||
}
|
||||
|
||||
/// cbindgen:postfix=WR_DESTRUCTOR_SAFE_FUNC
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn wr_api_clear_all_caches(dh: &mut DocumentHandle) {
|
||||
dh.api.send_debug_cmd(DebugCommand::ClearCaches(ClearCache::all()));
|
||||
}
|
||||
|
||||
fn make_transaction(do_async: bool) -> Transaction {
|
||||
let mut transaction = Transaction::new();
|
||||
// Ensure that we either use async scene building or not based on the
|
||||
|
|
|
@ -1050,6 +1050,10 @@ void wr_api_capture(DocumentHandle *aDh,
|
|||
uint32_t aBitsRaw)
|
||||
WR_FUNC;
|
||||
|
||||
WR_INLINE
|
||||
void wr_api_clear_all_caches(DocumentHandle *aDh)
|
||||
WR_DESTRUCTOR_SAFE_FUNC;
|
||||
|
||||
WR_INLINE
|
||||
void wr_api_clone(DocumentHandle *aDh,
|
||||
DocumentHandle **aOutHandle)
|
||||
|
|
Загрузка…
Ссылка в новой задаче