From c38ef911b1f3bb944be7abad2b810214d00dfd3b Mon Sep 17 00:00:00 2001 From: Andrew Osmond Date: Mon, 30 Oct 2017 13:10:29 -0400 Subject: [PATCH] Bug 1331944 - Part 5. Integrate SharedSurfacesParent with the WebRender texture cache. r=jrmuizel --- gfx/layers/ipc/SharedSurfacesParent.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gfx/layers/ipc/SharedSurfacesParent.cpp b/gfx/layers/ipc/SharedSurfacesParent.cpp index facfb9250429..508cd28fa540 100644 --- a/gfx/layers/ipc/SharedSurfacesParent.cpp +++ b/gfx/layers/ipc/SharedSurfacesParent.cpp @@ -7,6 +7,8 @@ #include "SharedSurfacesParent.h" #include "mozilla/layers/SourceSurfaceSharedData.h" #include "mozilla/layers/CompositorThread.h" +#include "mozilla/webrender/RenderSharedSurfaceTextureHost.h" +#include "mozilla/webrender/RenderThread.h" namespace mozilla { namespace layers { @@ -105,6 +107,11 @@ SharedSurfacesParent::AddSameProcess(const wr::ExternalImageId& aId, } MOZ_ASSERT(!sInstance->mSurfaces.Contains(id)); + + RefPtr texture = + new wr::RenderSharedSurfaceTextureHost(surface); + wr::RenderThread::Get()->RegisterExternalImage(id, texture.forget()); + sInstance->mSurfaces.Put(id, surface); }); @@ -138,6 +145,7 @@ SharedSurfacesParent::DestroyProcess(base::ProcessId aPid) // lot of surfaces still bound that require unmapping. for (auto i = sInstance->mSurfaces.Iter(); !i.Done(); i.Next()) { if (i.Data()->GetCreatorPid() == aPid) { + wr::RenderThread::Get()->UnregisterExternalImage(i.Key()); i.Remove(); } } @@ -165,6 +173,11 @@ SharedSurfacesParent::Add(const wr::ExternalImageId& aId, uint64_t id = wr::AsUint64(aId); MOZ_ASSERT(!sInstance->mSurfaces.Contains(id)); + + RefPtr texture = + new wr::RenderSharedSurfaceTextureHost(surface); + wr::RenderThread::Get()->RegisterExternalImage(id, texture.forget()); + sInstance->mSurfaces.Put(id, surface.forget()); }