зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1634253 - P6. Remove MessageLoop use from gfx. r=kats,mattwoodrow
Differential Revision: https://phabricator.services.mozilla.com/D73825
This commit is contained in:
Родитель
147c8cf3ef
Коммит
96d7622823
|
@ -17,6 +17,7 @@ Cameras IPC
|
|||
ChainedPipePump
|
||||
ChainedPipeRecv
|
||||
Checker Test
|
||||
Compositor
|
||||
Cookie
|
||||
CrashRep Inject
|
||||
DDMediaLogs
|
||||
|
@ -41,6 +42,7 @@ IMAP
|
|||
IPC Launch
|
||||
IPDL Background
|
||||
IdentityCrypto
|
||||
ImageBridgeChld
|
||||
LS Thread
|
||||
LayerScope
|
||||
MDCDMThread
|
||||
|
|
|
@ -71,7 +71,7 @@ void MediaSystemResourceManager::Init() {
|
|||
barrier.NotifyAll();
|
||||
});
|
||||
|
||||
imageBridge->GetMessageLoop()->PostTask(runnable.forget());
|
||||
imageBridge->GetThread()->Dispatch(runnable.forget());
|
||||
|
||||
// should stop the thread until done.
|
||||
while (!done) {
|
||||
|
@ -178,7 +178,7 @@ void MediaSystemResourceManager::Acquire(MediaSystemResourceClient* aClient) {
|
|||
return;
|
||||
}
|
||||
aClient->mResourceState = MediaSystemResourceClient::RESOURCE_STATE_WAITING;
|
||||
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(
|
||||
ImageBridgeChild::GetSingleton()->GetThread()->Dispatch(
|
||||
NewRunnableMethod<uint32_t>("MediaSystemResourceManager::DoAcquire", this,
|
||||
&MediaSystemResourceManager::DoAcquire,
|
||||
aClient->mId));
|
||||
|
@ -220,7 +220,7 @@ bool MediaSystemResourceManager::AcquireSyncNoWait(
|
|||
aClient->mResourceState = MediaSystemResourceClient::RESOURCE_STATE_WAITING;
|
||||
}
|
||||
|
||||
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(
|
||||
ImageBridgeChild::GetSingleton()->GetThread()->Dispatch(
|
||||
NewRunnableMethod<uint32_t>("MediaSystemResourceManager::DoAcquire", this,
|
||||
&MediaSystemResourceManager::DoAcquire,
|
||||
aClient->mId));
|
||||
|
@ -282,7 +282,7 @@ void MediaSystemResourceManager::ReleaseResource(
|
|||
|
||||
aClient->mResourceState = MediaSystemResourceClient::RESOURCE_STATE_END;
|
||||
|
||||
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(
|
||||
ImageBridgeChild::GetSingleton()->GetThread()->Dispatch(
|
||||
NewRunnableMethod<uint32_t>(
|
||||
"MediaSystemResourceManager::DoRelease", this,
|
||||
&MediaSystemResourceManager::DoRelease, aClient->mId));
|
||||
|
@ -304,7 +304,7 @@ void MediaSystemResourceManager::RecvResponse(uint32_t aId, bool aSuccess) {
|
|||
void MediaSystemResourceManager::HandleAcquireResult(uint32_t aId,
|
||||
bool aSuccess) {
|
||||
if (!InImageBridgeChildThread()) {
|
||||
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(
|
||||
ImageBridgeChild::GetSingleton()->GetThread()->Dispatch(
|
||||
NewRunnableMethod<uint32_t, bool>(
|
||||
"MediaSystemResourceManager::HandleAcquireResult", this,
|
||||
&MediaSystemResourceManager::HandleAcquireResult, aId, aSuccess));
|
||||
|
|
|
@ -551,7 +551,7 @@ class AsyncPluginSurfaceManager : public IGPUVideoSurfaceManager {
|
|||
if (!InImageBridgeChildThread()) {
|
||||
SynchronousTask task("AsyncPluginSurfaceManager readback sync");
|
||||
RefPtr<gfx::SourceSurface> result;
|
||||
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(
|
||||
ImageBridgeChild::GetSingleton()->GetThread()->Dispatch(
|
||||
NewRunnableFunction("AsyncPluginSurfaceManager readback",
|
||||
&DoSyncReadback, &pluginSD, &result, &task));
|
||||
task.Wait();
|
||||
|
@ -565,7 +565,7 @@ class AsyncPluginSurfaceManager : public IGPUVideoSurfaceManager {
|
|||
const SurfaceDescriptorGPUVideo& aSD) override {
|
||||
SurfaceDescriptorPlugin pluginSD = aSD;
|
||||
if (!InImageBridgeChildThread()) {
|
||||
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(
|
||||
ImageBridgeChild::GetSingleton()->GetThread()->Dispatch(
|
||||
NewRunnableFunction("AsyncPluginSurfaceManager dealloc", &DoDealloc,
|
||||
&pluginSD));
|
||||
return;
|
||||
|
@ -739,7 +739,7 @@ mozilla::ipc::IPCResult PluginInstanceParent::RecvInitDXGISurface(
|
|||
// render to.
|
||||
SurfaceDescriptorPlugin sd;
|
||||
SynchronousTask task("SendMakeAsyncPluginSurfaces sync");
|
||||
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(
|
||||
ImageBridgeChild::GetSingleton()->GetThread()->Dispatch(
|
||||
NewRunnableFunction("SendingMakeAsyncPluginSurfaces", &InitDXGISurface,
|
||||
format, size, &sd, &task));
|
||||
task.Wait();
|
||||
|
@ -781,9 +781,8 @@ mozilla::ipc::IPCResult PluginInstanceParent::RecvFinalizeDXGISurface(
|
|||
// Release the plugin surface but keep the display surface since it may
|
||||
// still be displayed. Also let the display surface know that it should
|
||||
// not receive further requests to copy from the plugin surface.
|
||||
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(
|
||||
NewRunnableFunction("SendingRemoveAsyncPluginSurface",
|
||||
&FinalizeDXGISurface, asi.mSD));
|
||||
ImageBridgeChild::GetSingleton()->GetThread()->Dispatch(NewRunnableFunction(
|
||||
"SendingRemoveAsyncPluginSurface", &FinalizeDXGISurface, asi.mSD));
|
||||
|
||||
mAsyncSurfaceMap.remove(asiIt);
|
||||
#endif
|
||||
|
@ -897,9 +896,8 @@ mozilla::ipc::IPCResult PluginInstanceParent::RecvShowDirectDXGISurface(
|
|||
|
||||
// Tell the ImageBridge to copy from the plugin surface to the display surface
|
||||
SynchronousTask task("SendUpdateAsyncPluginSurface sync");
|
||||
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(
|
||||
NewRunnableFunction("SendingUpdateAsyncPluginSurface", &CopyDXGISurface,
|
||||
asi.mSD, &task));
|
||||
ImageBridgeChild::GetSingleton()->GetThread()->Dispatch(NewRunnableFunction(
|
||||
"SendingUpdateAsyncPluginSurface", &CopyDXGISurface, asi.mSD, &task));
|
||||
task.Wait();
|
||||
|
||||
// Make sure we have an ImageContainer for SetCurrentImage.
|
||||
|
|
|
@ -20,7 +20,7 @@ RefPtr<VsyncBridgeParent> VsyncBridgeParent::Start(
|
|||
RefPtr<Runnable> task = NewRunnableMethod<Endpoint<PVsyncBridgeParent>&&>(
|
||||
"gfx::VsyncBridgeParent::Open", parent, &VsyncBridgeParent::Open,
|
||||
std::move(aEndpoint));
|
||||
CompositorThreadHolder::Loop()->PostTask(task.forget());
|
||||
CompositorThread()->Dispatch(task.forget());
|
||||
|
||||
return parent;
|
||||
}
|
||||
|
@ -48,10 +48,10 @@ mozilla::ipc::IPCResult VsyncBridgeParent::RecvNotifyVsync(
|
|||
}
|
||||
|
||||
void VsyncBridgeParent::Shutdown() {
|
||||
MessageLoop* ccloop = CompositorThreadHolder::Loop();
|
||||
if (MessageLoop::current() != ccloop) {
|
||||
ccloop->PostTask(NewRunnableMethod("gfx::VsyncBridgeParent::ShutdownImpl",
|
||||
this, &VsyncBridgeParent::ShutdownImpl));
|
||||
if (!CompositorThreadHolder::IsInCompositorThread()) {
|
||||
CompositorThread()->Dispatch(
|
||||
NewRunnableMethod("gfx::VsyncBridgeParent::ShutdownImpl", this,
|
||||
&VsyncBridgeParent::ShutdownImpl));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ static void CheckTexturesForUnlock() {
|
|||
void TextureSync::DispatchCheckTexturesForUnlock() {
|
||||
RefPtr<Runnable> task =
|
||||
NS_NewRunnableFunction("CheckTexturesForUnlock", &CheckTexturesForUnlock);
|
||||
CompositorThreadHolder::Loop()->PostTask(task.forget());
|
||||
CompositorThread()->Dispatch(task.forget());
|
||||
}
|
||||
|
||||
void TextureSync::HandleWaitForTexturesMessage(MachReceiveMessage* rmsg,
|
||||
|
|
|
@ -373,8 +373,8 @@ void APZUpdater::RunOnUpdaterThread(LayersId aLayersId,
|
|||
return;
|
||||
}
|
||||
|
||||
if (MessageLoop* loop = CompositorThreadHolder::Loop()) {
|
||||
loop->PostTask(task.forget());
|
||||
if (CompositorThread()) {
|
||||
CompositorThread()->Dispatch(task.forget());
|
||||
} else {
|
||||
// Could happen during startup
|
||||
NS_WARNING("Dropping task posted to updater thread");
|
||||
|
|
|
@ -169,8 +169,7 @@ TextureClientRecycleAllocator* CompositableClient::GetTextureClientRecycler() {
|
|||
barrier.NotifyAll();
|
||||
});
|
||||
|
||||
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(
|
||||
runnable.forget());
|
||||
ImageBridgeChild::GetSingleton()->GetThread()->Dispatch(runnable.forget());
|
||||
|
||||
// should stop the thread until done.
|
||||
while (!done) {
|
||||
|
|
|
@ -5,57 +5,61 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/layers/TextureClient.h"
|
||||
|
||||
#include <stdint.h> // for uint8_t, uint32_t, etc
|
||||
#include "Layers.h" // for Layer, etc
|
||||
|
||||
#include "BufferTexture.h"
|
||||
#include "IPDLActor.h"
|
||||
#include "ImageContainer.h" // for PlanarYCbCrData, etc
|
||||
#include "Layers.h" // for Layer, etc
|
||||
#include "LayersLogging.h" // for AppendToString
|
||||
#include "MainThreadUtils.h"
|
||||
#include "gfx2DGlue.h"
|
||||
#include "gfxPlatform.h" // for gfxPlatform
|
||||
#include "MainThreadUtils.h"
|
||||
#include "gfxUtils.h" // for gfxUtils::GetAsLZ4Base64Str
|
||||
#include "mozilla/Atomics.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "mozilla/SchedulerGroup.h"
|
||||
#include "mozilla/StaticPrefs_gfx.h"
|
||||
#include "mozilla/StaticPrefs_layers.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/gfx/DataSurfaceHelpers.h" // for CreateDataSourceSurfaceByCloning
|
||||
#include "mozilla/gfx/Logging.h" // for gfxDebug
|
||||
#include "mozilla/gfx/gfxVars.h"
|
||||
#include "mozilla/ipc/CrossProcessSemaphore.h"
|
||||
#include "mozilla/ipc/SharedMemory.h" // for SharedMemory, etc
|
||||
#include "mozilla/layers/CompositableForwarder.h"
|
||||
#include "mozilla/layers/ISurfaceAllocator.h"
|
||||
#include "mozilla/layers/ImageBridgeChild.h"
|
||||
#include "mozilla/layers/ImageDataSerializer.h"
|
||||
#include "mozilla/layers/PTextureChild.h"
|
||||
#include "mozilla/layers/PaintThread.h"
|
||||
#include "mozilla/layers/ShadowLayers.h"
|
||||
#include "mozilla/layers/TextureClientOGL.h"
|
||||
#include "mozilla/layers/TextureClientRecycleAllocator.h"
|
||||
#include "mozilla/layers/TextureRecorded.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "nsDebug.h" // for NS_ASSERTION, NS_WARNING, etc
|
||||
#include "nsISerialEventTarget.h"
|
||||
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc
|
||||
#include "ImageContainer.h" // for PlanarYCbCrData, etc
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/gfx/Logging.h" // for gfxDebug
|
||||
#include "mozilla/layers/TextureClientOGL.h"
|
||||
#include "mozilla/layers/PTextureChild.h"
|
||||
#include "mozilla/gfx/DataSurfaceHelpers.h" // for CreateDataSourceSurfaceByCloning
|
||||
#include "nsPrintfCString.h" // for nsPrintfCString
|
||||
#include "LayersLogging.h" // for AppendToString
|
||||
#include "gfxUtils.h" // for gfxUtils::GetAsLZ4Base64Str
|
||||
#include "IPDLActor.h"
|
||||
#include "BufferTexture.h"
|
||||
#include "mozilla/layers/ShadowLayers.h"
|
||||
#include "mozilla/ipc/CrossProcessSemaphore.h"
|
||||
#include "nsPrintfCString.h" // for nsPrintfCString
|
||||
|
||||
#ifdef XP_WIN
|
||||
# include "gfx2DGlue.h"
|
||||
# include "gfxWindowsPlatform.h"
|
||||
# include "mozilla/gfx/DeviceManagerDx.h"
|
||||
# include "mozilla/layers/TextureD3D11.h"
|
||||
# include "mozilla/layers/TextureDIB.h"
|
||||
# include "gfxWindowsPlatform.h"
|
||||
# include "gfx2DGlue.h"
|
||||
#endif
|
||||
#ifdef MOZ_X11
|
||||
# include "mozilla/layers/TextureClientX11.h"
|
||||
# include "GLXLibrary.h"
|
||||
# include "mozilla/layers/TextureClientX11.h"
|
||||
#endif
|
||||
#ifdef MOZ_WAYLAND
|
||||
# include <gtk/gtkx.h>
|
||||
# include "mozilla/widget/nsWaylandDisplay.h"
|
||||
# include "mozilla/layers/WaylandDMABUFTextureClientOGL.h"
|
||||
|
||||
# include "gfxPlatformGtk.h"
|
||||
# include "mozilla/layers/WaylandDMABUFTextureClientOGL.h"
|
||||
# include "mozilla/widget/nsWaylandDisplay.h"
|
||||
#endif
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
|
@ -490,12 +494,12 @@ void DeallocateTextureClient(TextureDeallocParams params) {
|
|||
}
|
||||
|
||||
TextureChild* actor = params.actor;
|
||||
MessageLoop* ipdlMsgLoop = nullptr;
|
||||
nsCOMPtr<nsISerialEventTarget> ipdlThread;
|
||||
|
||||
if (params.allocator) {
|
||||
ipdlMsgLoop = params.allocator->GetMessageLoop();
|
||||
if (!ipdlMsgLoop) {
|
||||
// An allocator with no message loop means we are too late in the shutdown
|
||||
ipdlThread = params.allocator->GetThread();
|
||||
if (!ipdlThread) {
|
||||
// An allocator with no thread means we are too late in the shutdown
|
||||
// sequence.
|
||||
gfxCriticalError() << "Texture deallocated too late during shutdown";
|
||||
return;
|
||||
|
@ -503,19 +507,19 @@ void DeallocateTextureClient(TextureDeallocParams params) {
|
|||
}
|
||||
|
||||
// First make sure that the work is happening on the IPDL thread.
|
||||
if (ipdlMsgLoop && MessageLoop::current() != ipdlMsgLoop) {
|
||||
if (ipdlThread && !ipdlThread->IsOnCurrentThread()) {
|
||||
if (params.syncDeallocation) {
|
||||
bool done = false;
|
||||
ReentrantMonitor barrier("DeallocateTextureClient");
|
||||
ReentrantMonitorAutoEnter autoMon(barrier);
|
||||
ipdlMsgLoop->PostTask(NewRunnableFunction(
|
||||
ipdlThread->Dispatch(NewRunnableFunction(
|
||||
"DeallocateTextureClientSyncProxyRunnable",
|
||||
DeallocateTextureClientSyncProxy, params, &barrier, &done));
|
||||
while (!done) {
|
||||
barrier.Wait();
|
||||
}
|
||||
} else {
|
||||
ipdlMsgLoop->PostTask(NewRunnableFunction(
|
||||
ipdlThread->Dispatch(NewRunnableFunction(
|
||||
"DeallocateTextureClientRunnable", DeallocateTextureClient, params));
|
||||
}
|
||||
// The work has been forwarded to the IPDL thread, we are done.
|
||||
|
@ -525,8 +529,8 @@ void DeallocateTextureClient(TextureDeallocParams params) {
|
|||
// Below this line, we are either in the IPDL thread or ther is no IPDL
|
||||
// thread anymore.
|
||||
|
||||
if (!ipdlMsgLoop) {
|
||||
// If we don't have a message loop we can't know for sure that we are in
|
||||
if (!ipdlThread) {
|
||||
// If we don't have a thread we can't know for sure that we are in
|
||||
// the IPDL thread and use the LayersIPCChannel.
|
||||
// This should ideally not happen outside of gtest, but some shutdown
|
||||
// raciness could put us in this situation.
|
||||
|
@ -978,15 +982,14 @@ static void CancelTextureClientNotifyNotUsed(uint64_t aTextureId,
|
|||
if (!aAllocator) {
|
||||
return;
|
||||
}
|
||||
MessageLoop* msgLoop = nullptr;
|
||||
msgLoop = aAllocator->GetMessageLoop();
|
||||
if (!msgLoop) {
|
||||
nsCOMPtr<nsISerialEventTarget> thread = aAllocator->GetThread();
|
||||
if (!thread) {
|
||||
return;
|
||||
}
|
||||
if (MessageLoop::current() == msgLoop) {
|
||||
if (thread->IsOnCurrentThread()) {
|
||||
aAllocator->CancelWaitForNotifyNotUsed(aTextureId);
|
||||
} else {
|
||||
msgLoop->PostTask(NewRunnableFunction(
|
||||
thread->Dispatch(NewRunnableFunction(
|
||||
"CancelTextureClientNotifyNotUsedRunnable",
|
||||
CancelTextureClientNotifyNotUsed, aTextureId, aAllocator));
|
||||
}
|
||||
|
@ -1017,9 +1020,8 @@ void TextureClient::SetRecycleAllocator(
|
|||
}
|
||||
|
||||
bool TextureClient::InitIPDLActor(CompositableForwarder* aForwarder) {
|
||||
MOZ_ASSERT(aForwarder &&
|
||||
aForwarder->GetTextureForwarder()->GetMessageLoop() ==
|
||||
mAllocator->GetMessageLoop());
|
||||
MOZ_ASSERT(aForwarder && aForwarder->GetTextureForwarder()->GetThread() ==
|
||||
mAllocator->GetThread());
|
||||
|
||||
if (mActor && !mActor->IPCOpen()) {
|
||||
return false;
|
||||
|
@ -1112,8 +1114,8 @@ bool TextureClient::InitIPDLActor(CompositableForwarder* aForwarder) {
|
|||
|
||||
bool TextureClient::InitIPDLActor(KnowsCompositor* aKnowsCompositor) {
|
||||
MOZ_ASSERT(aKnowsCompositor &&
|
||||
aKnowsCompositor->GetTextureForwarder()->GetMessageLoop() ==
|
||||
mAllocator->GetMessageLoop());
|
||||
aKnowsCompositor->GetTextureForwarder()->GetThread() ==
|
||||
mAllocator->GetThread());
|
||||
TextureForwarder* fwd = aKnowsCompositor->GetTextureForwarder();
|
||||
if (mActor && !mActor->mDestroyed) {
|
||||
CompositableForwarder* currentFwd = mActor->mCompositableForwarder;
|
||||
|
|
|
@ -153,7 +153,7 @@ already_AddRefed<TextureClient> TextureClientRecycleAllocator::CreateOrRecycle(
|
|||
new TextureClientReleaseTask(textureHolder->GetTextureClient());
|
||||
textureHolder->ClearTextureClient();
|
||||
textureHolder = nullptr;
|
||||
mKnowsCompositor->GetTextureForwarder()->GetMessageLoop()->PostTask(
|
||||
mKnowsCompositor->GetTextureForwarder()->GetThread()->Dispatch(
|
||||
task.forget());
|
||||
} else {
|
||||
textureHolder->GetTextureClient()->RecycleTexture(
|
||||
|
|
|
@ -34,8 +34,8 @@ CanvasThreadHolder::CanvasThreadHolder(
|
|||
CanvasThreadHolder::~CanvasThreadHolder() {
|
||||
// Note we can't just use NS_IsInCompositorThread() here because
|
||||
// sCompositorThreadHolder might have already gone.
|
||||
MOZ_ASSERT(mCompositorThreadKeepAlive->GetCompositorThread()->thread_id() ==
|
||||
PlatformThread::CurrentId());
|
||||
MOZ_ASSERT(
|
||||
mCompositorThreadKeepAlive->GetCompositorThread()->IsOnCurrentThread());
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
@ -75,8 +75,7 @@ void CanvasThreadHolder::StaticRelease(
|
|||
RefPtr<CanvasThreadHolder> threadHolder = aCanvasThreadHolder;
|
||||
// Note we can't just use NS_IsInCompositorThread() here because
|
||||
// sCompositorThreadHolder might have already gone.
|
||||
MOZ_ASSERT(threadHolder->mCompositorThreadKeepAlive->GetCompositorThread()
|
||||
->thread_id() == PlatformThread::CurrentId());
|
||||
MOZ_ASSERT(threadHolder->mCompositorThreadKeepAlive->IsInCompositorThread());
|
||||
threadHolder = nullptr;
|
||||
|
||||
auto lockedCanvasThreadHolder = sCanvasThreadHolder.Lock();
|
||||
|
@ -89,12 +88,11 @@ void CanvasThreadHolder::StaticRelease(
|
|||
void CanvasThreadHolder::ReleaseOnCompositorThread(
|
||||
already_AddRefed<CanvasThreadHolder> aCanvasThreadHolder) {
|
||||
auto lockedCanvasThreadHolder = sCanvasThreadHolder.Lock();
|
||||
base::Thread* compositorThread =
|
||||
lockedCanvasThreadHolder.ref()
|
||||
->mCompositorThreadKeepAlive->GetCompositorThread();
|
||||
compositorThread->message_loop()->PostTask(NewRunnableFunction(
|
||||
"CanvasThreadHolder::StaticRelease", CanvasThreadHolder::StaticRelease,
|
||||
std::move(aCanvasThreadHolder)));
|
||||
lockedCanvasThreadHolder.ref()
|
||||
->mCompositorThreadKeepAlive->GetCompositorThread()
|
||||
->Dispatch(NewRunnableFunction("CanvasThreadHolder::StaticRelease",
|
||||
CanvasThreadHolder::StaticRelease,
|
||||
std::move(aCanvasThreadHolder)));
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include "mozilla/layers/CompositorThread.h"
|
||||
#include <stddef.h> // for size_t
|
||||
#include "ClientLayerManager.h" // for ClientLayerManager
|
||||
#include "base/message_loop.h" // for MessageLoop
|
||||
#include "base/task.h" // for NewRunnableMethod, etc
|
||||
#include "mozilla/StaticPrefs_layers.h"
|
||||
#include "mozilla/layers/CompositorManagerChild.h"
|
||||
|
@ -36,7 +35,6 @@
|
|||
#include "nsDebug.h" // for NS_WARNING
|
||||
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc
|
||||
#include "nsTArray.h" // for nsTArray, nsTArray_Impl
|
||||
#include "nsXULAppAPI.h" // for XRE_GetIOMessageLoop, etc
|
||||
#include "FrameLayerBuilder.h"
|
||||
#include "mozilla/dom/BrowserChild.h"
|
||||
#include "mozilla/dom/BrowserParent.h"
|
||||
|
@ -85,7 +83,7 @@ CompositorBridgeChild::CompositorBridgeChild(CompositorManagerChild* aManager)
|
|||
mCanSend(false),
|
||||
mActorDestroyed(false),
|
||||
mFwdTransactionId(0),
|
||||
mMessageLoop(MessageLoop::current()),
|
||||
mThread(NS_GetCurrentThread()),
|
||||
mProcessToken(0),
|
||||
mSectionAllocator(nullptr),
|
||||
mPaintLock("CompositorBridgeChild.mPaintLock"),
|
||||
|
@ -168,7 +166,7 @@ void CompositorBridgeChild::Destroy() {
|
|||
// We may have already called destroy but still have lingering references
|
||||
// or CompositorBridgeChild::ActorDestroy was called. Ensure that we do our
|
||||
// post destroy clean up no matter what. It is safe to call multiple times.
|
||||
MessageLoop::current()->PostTask(
|
||||
NS_GetCurrentThread()->Dispatch(
|
||||
NewRunnableMethod("CompositorBridgeChild::PrepareFinalDestroy", selfRef,
|
||||
&CompositorBridgeChild::PrepareFinalDestroy));
|
||||
return;
|
||||
|
@ -225,12 +223,12 @@ void CompositorBridgeChild::Destroy() {
|
|||
// CompositorBridgeParent to the CompositorBridgeChild (e.g. caused by the
|
||||
// destruction of shared memory). We need to ensure this gets processed by the
|
||||
// CompositorBridgeChild before it gets destroyed. It suffices to ensure that
|
||||
// events already in the MessageLoop get processed before the
|
||||
// CompositorBridgeChild is destroyed, so we add a task to the MessageLoop to
|
||||
// events already in the thread get processed before the
|
||||
// CompositorBridgeChild is destroyed, so we add a task to the thread to
|
||||
// handle compositor destruction.
|
||||
|
||||
// From now on we can't send any message message.
|
||||
MessageLoop::current()->PostTask(
|
||||
NS_GetCurrentThread()->Dispatch(
|
||||
NewRunnableMethod("CompositorBridgeChild::PrepareFinalDestroy", selfRef,
|
||||
&CompositorBridgeChild::PrepareFinalDestroy));
|
||||
}
|
||||
|
@ -470,8 +468,8 @@ mozilla::ipc::IPCResult CompositorBridgeChild::RecvUpdatePluginConfigurations(
|
|||
|
||||
#if defined(XP_WIN)
|
||||
static void ScheduleSendAllPluginsCaptured(CompositorBridgeChild* aThis,
|
||||
MessageLoop* aLoop) {
|
||||
aLoop->PostTask(NewNonOwningRunnableMethod(
|
||||
nsISerialEventTarget* aThread) {
|
||||
aThread->Dispatch(NewNonOwningRunnableMethod(
|
||||
"CompositorBridgeChild::SendAllPluginsCaptured", aThis,
|
||||
&CompositorBridgeChild::SendAllPluginsCaptured));
|
||||
}
|
||||
|
@ -483,12 +481,11 @@ mozilla::ipc::IPCResult CompositorBridgeChild::RecvCaptureAllPlugins(
|
|||
MOZ_ASSERT(NS_IsMainThread());
|
||||
nsIWidget::CaptureRegisteredPlugins(aParentWidget);
|
||||
|
||||
// Bounce the call to SendAllPluginsCaptured off the ImageBridgeChild loop,
|
||||
// Bounce the call to SendAllPluginsCaptured off the ImageBridgeChild thread,
|
||||
// to make sure that the image updates on that thread have been processed.
|
||||
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(
|
||||
NewRunnableFunction("ScheduleSendAllPluginsCapturedRunnable",
|
||||
&ScheduleSendAllPluginsCaptured, this,
|
||||
MessageLoop::current()));
|
||||
ImageBridgeChild::GetSingleton()->GetThread()->Dispatch(NewRunnableFunction(
|
||||
"ScheduleSendAllPluginsCapturedRunnable", &ScheduleSendAllPluginsCaptured,
|
||||
this, NS_GetCurrentThread()));
|
||||
return IPC_OK();
|
||||
#else
|
||||
MOZ_ASSERT_UNREACHABLE(
|
||||
|
|
|
@ -200,7 +200,7 @@ class CompositorBridgeChild final : public PCompositorBridgeChild,
|
|||
|
||||
void HandleMemoryPressure();
|
||||
|
||||
MessageLoop* GetMessageLoop() const override { return mMessageLoop; }
|
||||
nsISerialEventTarget* GetThread() const override { return mThread; }
|
||||
|
||||
base::ProcessId GetParentPid() const override { return OtherPid(); }
|
||||
|
||||
|
@ -373,7 +373,7 @@ class CompositorBridgeChild final : public PCompositorBridgeChild,
|
|||
std::unordered_map<uint64_t, RefPtr<TextureClient>>
|
||||
mTexturesWaitingNotifyNotUsed;
|
||||
|
||||
MessageLoop* mMessageLoop;
|
||||
nsCOMPtr<nsISerialEventTarget> mThread;
|
||||
|
||||
AutoTArray<RefPtr<TextureClientPool>, 2> mTexturePools;
|
||||
|
||||
|
|
|
@ -14,10 +14,7 @@
|
|||
#include "apz/src/APZCTreeManager.h" // for APZCTreeManager
|
||||
#include "LayerTransactionParent.h" // for LayerTransactionParent
|
||||
#include "RenderTrace.h" // for RenderTraceLayers
|
||||
#include "base/message_loop.h" // for MessageLoop
|
||||
#include "base/process.h" // for ProcessId
|
||||
#include "base/task.h" // for CancelableTask, etc
|
||||
#include "base/thread.h" // for Thread
|
||||
#include "gfxContext.h" // for gfxContext
|
||||
#include "gfxPlatform.h" // for gfxPlatform
|
||||
#include "TreeTraversal.h" // for ForEachNode
|
||||
|
@ -80,7 +77,6 @@
|
|||
#include "nsIWidget.h" // for nsIWidget
|
||||
#include "nsTArray.h" // for nsTArray
|
||||
#include "nsThreadUtils.h" // for NS_IsMainThread
|
||||
#include "nsXULAppAPI.h" // for XRE_GetIOMessageLoop
|
||||
#ifdef XP_WIN
|
||||
# include "mozilla/layers/CompositorD3D11.h"
|
||||
# include "mozilla/widget/WinCompositorWidget.h"
|
||||
|
@ -174,10 +170,6 @@ bool CompositorBridgeParentBase::DeallocShmem(ipc::Shmem& aShmem) {
|
|||
return PCompositorBridgeParent::DeallocShmem(aShmem);
|
||||
}
|
||||
|
||||
static inline MessageLoop* CompositorLoop() {
|
||||
return CompositorThreadHolder::Loop();
|
||||
}
|
||||
|
||||
base::ProcessId CompositorBridgeParentBase::RemotePid() { return OtherPid(); }
|
||||
|
||||
bool CompositorBridgeParentBase::StartSharingMetrics(
|
||||
|
@ -185,8 +177,8 @@ bool CompositorBridgeParentBase::StartSharingMetrics(
|
|||
CrossProcessMutexHandle aMutexHandle, LayersId aLayersId,
|
||||
uint32_t aApzcId) {
|
||||
if (!CompositorThreadHolder::IsInCompositorThread()) {
|
||||
MOZ_ASSERT(CompositorLoop());
|
||||
CompositorLoop()->PostTask(
|
||||
MOZ_ASSERT(CompositorThread());
|
||||
CompositorThread()->Dispatch(
|
||||
NewRunnableMethod<ipc::SharedMemoryBasic::Handle,
|
||||
CrossProcessMutexHandle, LayersId, uint32_t>(
|
||||
"layers::CompositorBridgeParent::StartSharingMetrics", this,
|
||||
|
@ -206,8 +198,8 @@ bool CompositorBridgeParentBase::StartSharingMetrics(
|
|||
bool CompositorBridgeParentBase::StopSharingMetrics(
|
||||
ScrollableLayerGuid::ViewID aScrollId, uint32_t aApzcId) {
|
||||
if (!CompositorThreadHolder::IsInCompositorThread()) {
|
||||
MOZ_ASSERT(CompositorLoop());
|
||||
CompositorLoop()->PostTask(
|
||||
MOZ_ASSERT(CompositorThread());
|
||||
CompositorThread()->Dispatch(
|
||||
NewRunnableMethod<ScrollableLayerGuid::ViewID, uint32_t>(
|
||||
"layers::CompositorBridgeParent::StopSharingMetrics", this,
|
||||
&CompositorBridgeParentBase::StopSharingMetrics, aScrollId,
|
||||
|
@ -404,8 +396,8 @@ void CompositorBridgeParent::Initialize() {
|
|||
// FIXME: This holds on the the fact that right now the only thing that
|
||||
// can destroy this instance is initialized on the compositor thread after
|
||||
// this task has been processed.
|
||||
MOZ_ASSERT(CompositorLoop());
|
||||
CompositorLoop()->PostTask(NewRunnableFunction(
|
||||
MOZ_ASSERT(CompositorThread());
|
||||
CompositorThread()->Dispatch(NewRunnableFunction(
|
||||
"AddCompositorRunnable", &AddCompositor, this, &mCompositorBridgeID));
|
||||
|
||||
{ // scope lock
|
||||
|
@ -680,22 +672,22 @@ void CompositorBridgeParent::ActorDestroy(ActorDestroyReason why) {
|
|||
// on this thread. We must keep the compositor parent alive untill the code
|
||||
// handling message reception is finished on this thread.
|
||||
mSelfRef = this;
|
||||
MessageLoop::current()->PostTask(
|
||||
NS_GetCurrentThread()->Dispatch(
|
||||
NewRunnableMethod("layers::CompositorBridgeParent::DeferredDestroy", this,
|
||||
&CompositorBridgeParent::DeferredDestroy));
|
||||
}
|
||||
|
||||
void CompositorBridgeParent::ScheduleRenderOnCompositorThread(
|
||||
const wr::RenderRootSet& aRenderRoots) {
|
||||
MOZ_ASSERT(CompositorLoop());
|
||||
CompositorLoop()->PostTask(NewRunnableMethod<wr::RenderRootSet>(
|
||||
MOZ_ASSERT(CompositorThread());
|
||||
CompositorThread()->Dispatch(NewRunnableMethod<wr::RenderRootSet>(
|
||||
"layers::CompositorBridgeParent::ScheduleComposition", this,
|
||||
&CompositorBridgeParent::ScheduleComposition, aRenderRoots));
|
||||
}
|
||||
|
||||
void CompositorBridgeParent::InvalidateOnCompositorThread() {
|
||||
MOZ_ASSERT(CompositorLoop());
|
||||
CompositorLoop()->PostTask(
|
||||
MOZ_ASSERT(CompositorThread());
|
||||
CompositorThread()->Dispatch(
|
||||
NewRunnableMethod("layers::CompositorBridgeParent::Invalidate", this,
|
||||
&CompositorBridgeParent::Invalidate));
|
||||
}
|
||||
|
@ -793,8 +785,8 @@ void CompositorBridgeParent::ResumeCompositionAndResize(int x, int y, int width,
|
|||
void CompositorBridgeParent::SchedulePauseOnCompositorThread() {
|
||||
MonitorAutoLock lock(mPauseCompositionMonitor);
|
||||
|
||||
MOZ_ASSERT(CompositorLoop());
|
||||
CompositorLoop()->PostTask(
|
||||
MOZ_ASSERT(CompositorThread());
|
||||
CompositorThread()->Dispatch(
|
||||
NewRunnableMethod("layers::CompositorBridgeParent::PauseComposition",
|
||||
this, &CompositorBridgeParent::PauseComposition));
|
||||
|
||||
|
@ -805,8 +797,8 @@ void CompositorBridgeParent::SchedulePauseOnCompositorThread() {
|
|||
bool CompositorBridgeParent::ScheduleResumeOnCompositorThread() {
|
||||
MonitorAutoLock lock(mResumeCompositionMonitor);
|
||||
|
||||
MOZ_ASSERT(CompositorLoop());
|
||||
CompositorLoop()->PostTask(
|
||||
MOZ_ASSERT(CompositorThread());
|
||||
CompositorThread()->Dispatch(
|
||||
NewRunnableMethod("layers::CompositorBridgeParent::ResumeComposition",
|
||||
this, &CompositorBridgeParent::ResumeComposition));
|
||||
|
||||
|
@ -821,8 +813,8 @@ bool CompositorBridgeParent::ScheduleResumeOnCompositorThread(int x, int y,
|
|||
int height) {
|
||||
MonitorAutoLock lock(mResumeCompositionMonitor);
|
||||
|
||||
MOZ_ASSERT(CompositorLoop());
|
||||
CompositorLoop()->PostTask(NewRunnableMethod<int, int, int, int>(
|
||||
MOZ_ASSERT(CompositorThread());
|
||||
CompositorThread()->Dispatch(NewRunnableMethod<int, int, int, int>(
|
||||
"layers::CompositorBridgeParent::ResumeCompositionAndResize", this,
|
||||
&CompositorBridgeParent::ResumeCompositionAndResize, x, y, width,
|
||||
height));
|
||||
|
@ -1226,9 +1218,9 @@ void CompositorBridgeParent::ScheduleRotationOnCompositorThread(
|
|||
&CompositorBridgeParent::ForceComposition);
|
||||
mForceCompositionTask = task;
|
||||
if (StaticPrefs::layers_orientation_sync_timeout() == 0) {
|
||||
CompositorThreadHolder::Loop()->PostTask(task.forget());
|
||||
CompositorThread()->Dispatch(task.forget());
|
||||
} else {
|
||||
CompositorThreadHolder::Loop()->PostDelayedTask(
|
||||
CompositorThread()->DelayedDispatch(
|
||||
task.forget(), StaticPrefs::layers_orientation_sync_timeout());
|
||||
}
|
||||
}
|
||||
|
@ -1987,13 +1979,13 @@ void CompositorBridgeParent::InitializeStatics() {
|
|||
/*static*/
|
||||
void CompositorBridgeParent::UpdateQualitySettings() {
|
||||
if (!CompositorThreadHolder::IsInCompositorThread()) {
|
||||
if (CompositorLoop()) {
|
||||
CompositorLoop()->PostTask(
|
||||
if (CompositorThread()) {
|
||||
CompositorThread()->Dispatch(
|
||||
NewRunnableFunction("CompositorBridgeParent::UpdateQualitySettings",
|
||||
&CompositorBridgeParent::UpdateQualitySettings));
|
||||
}
|
||||
|
||||
// If there is no compositor loop, e.g. due to shutdown, then we can
|
||||
// If there is no compositor thread, e.g. due to shutdown, then we can
|
||||
// safefully just ignore this request.
|
||||
return;
|
||||
}
|
||||
|
@ -2007,13 +1999,13 @@ void CompositorBridgeParent::UpdateQualitySettings() {
|
|||
/*static*/
|
||||
void CompositorBridgeParent::UpdateDebugFlags() {
|
||||
if (!CompositorThreadHolder::IsInCompositorThread()) {
|
||||
if (CompositorLoop()) {
|
||||
CompositorLoop()->PostTask(
|
||||
if (CompositorThread()) {
|
||||
CompositorThread()->Dispatch(
|
||||
NewRunnableFunction("CompositorBridgeParent::UpdateDebugFlags",
|
||||
&CompositorBridgeParent::UpdateDebugFlags));
|
||||
}
|
||||
|
||||
// If there is no compositor loop, e.g. due to shutdown, then we can
|
||||
// If there is no compositor thread, e.g. due to shutdown, then we can
|
||||
// safefully just ignore this request.
|
||||
return;
|
||||
}
|
||||
|
@ -2027,8 +2019,8 @@ void CompositorBridgeParent::UpdateDebugFlags() {
|
|||
/*static*/
|
||||
void CompositorBridgeParent::UpdateWebRenderMultithreading() {
|
||||
if (!CompositorThreadHolder::IsInCompositorThread()) {
|
||||
if (CompositorLoop()) {
|
||||
CompositorLoop()->PostTask(NewRunnableFunction(
|
||||
if (CompositorThread()) {
|
||||
CompositorThread()->Dispatch(NewRunnableFunction(
|
||||
"CompositorBridgeParent::UpdateWebRenderMultithreading",
|
||||
&CompositorBridgeParent::UpdateWebRenderMultithreading));
|
||||
}
|
||||
|
@ -2045,8 +2037,8 @@ void CompositorBridgeParent::UpdateWebRenderMultithreading() {
|
|||
/*static*/
|
||||
void CompositorBridgeParent::UpdateWebRenderBatchingParameters() {
|
||||
if (!CompositorThreadHolder::IsInCompositorThread()) {
|
||||
if (CompositorLoop()) {
|
||||
CompositorLoop()->PostTask(NewRunnableFunction(
|
||||
if (CompositorThread()) {
|
||||
CompositorThread()->Dispatch(NewRunnableFunction(
|
||||
"CompositorBridgeParent::UpdateWebRenderBatchingParameters",
|
||||
&CompositorBridgeParent::UpdateWebRenderBatchingParameters));
|
||||
}
|
||||
|
@ -2095,11 +2087,11 @@ void CompositorBridgeParent::DeallocateLayerTreeId(LayersId aId) {
|
|||
// Here main thread notifies compositor to remove an element from
|
||||
// sIndirectLayerTrees. This removed element might be queried soon.
|
||||
// Checking the elements of sIndirectLayerTrees exist or not before using.
|
||||
if (!CompositorLoop()) {
|
||||
gfxCriticalError() << "Attempting to post to a invalid Compositor Loop";
|
||||
if (!CompositorThread()) {
|
||||
gfxCriticalError() << "Attempting to post to an invalid Compositor Thread";
|
||||
return;
|
||||
}
|
||||
CompositorLoop()->PostTask(
|
||||
CompositorThread()->Dispatch(
|
||||
NewRunnableFunction("EraseLayerStateRunnable", &EraseLayerState, aId));
|
||||
}
|
||||
|
||||
|
@ -2131,7 +2123,7 @@ void CompositorBridgeParent::SetControllerForLayerTree(
|
|||
LayersId aLayersId, GeckoContentController* aController) {
|
||||
// This ref is adopted by UpdateControllerForLayersId().
|
||||
aController->AddRef();
|
||||
CompositorLoop()->PostTask(NewRunnableFunction(
|
||||
CompositorThread()->Dispatch(NewRunnableFunction(
|
||||
"UpdateControllerForLayersIdRunnable", &UpdateControllerForLayersId,
|
||||
aLayersId, aController));
|
||||
}
|
||||
|
@ -2168,7 +2160,7 @@ void CompositorBridgeParent::PostInsertVsyncProfilerMarker(
|
|||
#if defined(MOZ_GECKO_PROFILER)
|
||||
// Called in the vsync thread
|
||||
if (profiler_is_active() && CompositorThreadHolder::IsActive()) {
|
||||
CompositorLoop()->PostTask(
|
||||
CompositorThread()->Dispatch(
|
||||
NewRunnableFunction("InsertVsyncProfilerMarkerRunnable",
|
||||
InsertVsyncProfilerMarker, aVsyncTimestamp));
|
||||
}
|
||||
|
@ -2391,7 +2383,7 @@ void CompositorBridgeParent::NotifyDidComposite(TransactionId aTransactionId,
|
|||
}
|
||||
|
||||
void CompositorBridgeParent::InvalidateRemoteLayers() {
|
||||
MOZ_ASSERT(CompositorLoop() == MessageLoop::current());
|
||||
MOZ_ASSERT(CompositorThread()->IsOnCurrentThread());
|
||||
|
||||
Unused << PCompositorBridgeParent::SendInvalidateLayers(LayersId{0});
|
||||
|
||||
|
@ -2513,13 +2505,12 @@ bool CompositorBridgeParent::IsSameProcess() const {
|
|||
}
|
||||
|
||||
void CompositorBridgeParent::NotifyWebRenderContextPurge() {
|
||||
MOZ_ASSERT(CompositorLoop() == MessageLoop::current());
|
||||
MOZ_ASSERT(CompositorThread()->IsOnCurrentThread());
|
||||
RefPtr<wr::WebRenderAPI> api = mWrBridge->GetWebRenderAPI();
|
||||
api->ClearAllCaches();
|
||||
}
|
||||
|
||||
void CompositorBridgeParent::NotifyWebRenderDisableNativeCompositor() {
|
||||
MOZ_ASSERT(CompositorLoop() == MessageLoop::current());
|
||||
MOZ_ASSERT(CompositorThread()->IsOnCurrentThread());
|
||||
if (mWrBridge) {
|
||||
mWrBridge->DisableNativeCompositor();
|
||||
}
|
||||
|
@ -2651,8 +2642,8 @@ bool CompositorBridgeParent::UpdatePluginWindowState(LayersId aId) {
|
|||
}
|
||||
|
||||
void CompositorBridgeParent::ScheduleShowAllPluginWindows() {
|
||||
MOZ_ASSERT(CompositorLoop());
|
||||
CompositorLoop()->PostTask(
|
||||
MOZ_ASSERT(CompositorThread());
|
||||
CompositorThread()->Dispatch(
|
||||
NewRunnableMethod("layers::CompositorBridgeParent::ShowAllPluginWindows",
|
||||
this, &CompositorBridgeParent::ShowAllPluginWindows));
|
||||
}
|
||||
|
@ -2664,8 +2655,8 @@ void CompositorBridgeParent::ShowAllPluginWindows() {
|
|||
}
|
||||
|
||||
void CompositorBridgeParent::ScheduleHideAllPluginWindows() {
|
||||
MOZ_ASSERT(CompositorLoop());
|
||||
CompositorLoop()->PostTask(
|
||||
MOZ_ASSERT(CompositorThread());
|
||||
CompositorThread()->Dispatch(
|
||||
NewRunnableMethod("layers::CompositorBridgeParent::HideAllPluginWindows",
|
||||
this, &CompositorBridgeParent::HideAllPluginWindows));
|
||||
}
|
||||
|
@ -2892,7 +2883,7 @@ mozilla::ipc::IPCResult CompositorBridgeParent::RecvEndRecordingToDisk(
|
|||
aResolve(true);
|
||||
} else if (mWrBridge) {
|
||||
mWrBridge->WriteCollectedFrames()->Then(
|
||||
MessageLoop::current()->SerialEventTarget(), __func__,
|
||||
NS_GetCurrentThread(), __func__,
|
||||
[resolve{aResolve}](const bool success) { resolve(success); },
|
||||
[resolve{aResolve}]() { resolve(false); });
|
||||
} else {
|
||||
|
@ -2921,7 +2912,7 @@ mozilla::ipc::IPCResult CompositorBridgeParent::RecvEndRecordingToMemory(
|
|||
} else if (mWrBridge) {
|
||||
RefPtr<CompositorBridgeParent> self = this;
|
||||
mWrBridge->GetCollectedFrames()->Then(
|
||||
MessageLoop::current()->SerialEventTarget(), __func__,
|
||||
NS_GetCurrentThread(), __func__,
|
||||
[self, resolve{aResolve}](CollectedFrames&& frames) {
|
||||
resolve(self->WrapCollectedFrames(std::move(frames)));
|
||||
},
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
#include "mozilla/layers/UiCompositorControllerParent.h"
|
||||
#include "mozilla/VsyncDispatcher.h"
|
||||
|
||||
class MessageLoop;
|
||||
class nsIWidget;
|
||||
|
||||
namespace mozilla {
|
||||
|
|
|
@ -173,9 +173,8 @@ CompositorManagerChild::CompositorManagerChild(CompositorManagerParent* aParent,
|
|||
MOZ_ASSERT(aParent);
|
||||
|
||||
SetOtherProcessId(base::GetCurrentProcId());
|
||||
MessageLoop* loop = CompositorThreadHolder::Loop();
|
||||
ipc::MessageChannel* channel = aParent->GetIPCChannel();
|
||||
if (NS_WARN_IF(!Open(channel, loop, ipc::ChildSide))) {
|
||||
if (NS_WARN_IF(!Open(channel, CompositorThread(), ipc::ChildSide))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ bool CompositorManagerParent::Create(
|
|||
NewRunnableMethod<Endpoint<PCompositorManagerParent>&&, bool>(
|
||||
"CompositorManagerParent::Bind", bridge,
|
||||
&CompositorManagerParent::Bind, std::move(aEndpoint), aIsRoot);
|
||||
CompositorThreadHolder::Loop()->PostTask(runnable.forget());
|
||||
CompositorThread()->Dispatch(runnable.forget());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ void CompositorManagerParent::Shutdown() {
|
|||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
#ifdef COMPOSITOR_MANAGER_PARENT_EXPLICIT_SHUTDOWN
|
||||
CompositorThreadHolder::Loop()->PostTask(NS_NewRunnableFunction(
|
||||
CompositorThread()->Dispatch(NS_NewRunnableFunction(
|
||||
"layers::CompositorManagerParent::Shutdown",
|
||||
[]() -> void { CompositorManagerParent::ShutdownInternal(); }));
|
||||
#endif
|
||||
|
@ -307,7 +307,7 @@ mozilla::ipc::IPCResult CompositorManagerParent::RecvReportMemory(
|
|||
// thread, so we can't just pass it over to the renderer thread. We use
|
||||
// an intermediate MozPromise instead.
|
||||
wr::RenderThread::AccumulateMemoryReport(aggregate)->Then(
|
||||
CompositorThreadHolder::Loop()->SerialEventTarget(), __func__,
|
||||
CompositorThread(), __func__,
|
||||
[resolver = std::move(aResolver)](MemoryReport aReport) {
|
||||
resolver(aReport);
|
||||
},
|
||||
|
|
|
@ -19,17 +19,12 @@ namespace layers {
|
|||
static StaticRefPtr<CompositorThreadHolder> sCompositorThreadHolder;
|
||||
static bool sFinishedCompositorShutDown = false;
|
||||
|
||||
base::Thread* CompositorThread() {
|
||||
nsISerialEventTarget* CompositorThread() {
|
||||
return sCompositorThreadHolder
|
||||
? sCompositorThreadHolder->GetCompositorThread()
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
/* static */
|
||||
MessageLoop* CompositorThreadHolder::Loop() {
|
||||
return CompositorThread() ? CompositorThread()->message_loop() : nullptr;
|
||||
}
|
||||
|
||||
CompositorThreadHolder* CompositorThreadHolder::GetSingleton() {
|
||||
return sCompositorThreadHolder;
|
||||
}
|
||||
|
@ -41,57 +36,40 @@ CompositorThreadHolder::CompositorThreadHolder()
|
|||
|
||||
CompositorThreadHolder::~CompositorThreadHolder() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (mCompositorThread) {
|
||||
DestroyCompositorThread(mCompositorThread);
|
||||
}
|
||||
}
|
||||
|
||||
/* static */
|
||||
void CompositorThreadHolder::DestroyCompositorThread(
|
||||
base::Thread* aCompositorThread) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
MOZ_ASSERT(!sCompositorThreadHolder,
|
||||
"We shouldn't be destroying the compositor thread yet.");
|
||||
|
||||
delete aCompositorThread;
|
||||
sFinishedCompositorShutDown = true;
|
||||
}
|
||||
|
||||
/* static */ base::Thread* CompositorThreadHolder::CreateCompositorThread() {
|
||||
/* static */ already_AddRefed<nsIThread>
|
||||
CompositorThreadHolder::CreateCompositorThread() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
MOZ_ASSERT(!sCompositorThreadHolder,
|
||||
"The compositor thread has already been started!");
|
||||
|
||||
base::Thread* compositorThread = new base::Thread("Compositor");
|
||||
nsCOMPtr<nsIThread> compositorThread;
|
||||
nsresult rv =
|
||||
NS_NewNamedThread("Compositor", getter_AddRefs(compositorThread));
|
||||
|
||||
base::Thread::Options options;
|
||||
/* Timeout values are powers-of-two to enable us get better data.
|
||||
128ms is chosen for transient hangs because 8Hz should be the minimally
|
||||
acceptable goal for Compositor responsiveness (normal goal is 60Hz). */
|
||||
options.transient_hang_timeout = 128; // milliseconds
|
||||
/* 2048ms is chosen for permanent hangs because it's longer than most
|
||||
* Compositor hangs seen in the wild, but is short enough to not miss getting
|
||||
* native hang stacks. */
|
||||
options.permanent_hang_timeout = 2048; // milliseconds
|
||||
#if defined(_WIN32)
|
||||
/* With d3d9 the compositor thread creates native ui, see DeviceManagerD3D9.
|
||||
* As such the thread is a gui thread, and must process a windows message
|
||||
* queue or
|
||||
* risk deadlocks. Chromium message loop TYPE_UI does exactly what we need. */
|
||||
options.message_loop_type = MessageLoop::TYPE_UI;
|
||||
#endif
|
||||
// TODO re-enable hangout monitor. Will be done in a follow-up thread
|
||||
// base::Thread::Options options;
|
||||
// /* Timeout values are powers-of-two to enable us get better data.
|
||||
// 128ms is chosen for transient hangs because 8Hz should be the minimally
|
||||
// acceptable goal for Compositor responsiveness (normal goal is 60Hz). */
|
||||
// options.transient_hang_timeout = 128; // milliseconds
|
||||
// /* 2048ms is chosen for permanent hangs because it's longer than most
|
||||
// * Compositor hangs seen in the wild, but is short enough to not miss
|
||||
// getting
|
||||
// * native hang stacks. */
|
||||
// options.permanent_hang_timeout = 2048; // milliseconds
|
||||
|
||||
if (!compositorThread->StartWithOptions(options)) {
|
||||
delete compositorThread;
|
||||
if (NS_FAILED(rv)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CompositorBridgeParent::Setup();
|
||||
ImageBridgeParent::Setup();
|
||||
|
||||
return compositorThread;
|
||||
return compositorThread.forget();
|
||||
}
|
||||
|
||||
void CompositorThreadHolder::Start() {
|
||||
|
@ -136,8 +114,12 @@ void CompositorThreadHolder::Shutdown() {
|
|||
|
||||
/* static */
|
||||
bool CompositorThreadHolder::IsInCompositorThread() {
|
||||
return CompositorThread() &&
|
||||
CompositorThread()->thread_id() == PlatformThread::CurrentId();
|
||||
if (!CompositorThread()) {
|
||||
return false;
|
||||
}
|
||||
bool in = false;
|
||||
MOZ_ALWAYS_SUCCEEDS(CompositorThread()->IsOnCurrentThread(&in));
|
||||
return in;
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
|
|
|
@ -6,13 +6,12 @@
|
|||
#ifndef mozilla_layers_CompositorThread_h
|
||||
#define mozilla_layers_CompositorThread_h
|
||||
|
||||
#include "base/basictypes.h" // for DISALLOW_EVIL_CONSTRUCTORS
|
||||
#include "base/platform_thread.h" // for PlatformThreadId
|
||||
#include "base/thread.h" // for Thread
|
||||
#include "base/message_loop.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "ThreadSafeRefcountingWithMainThreadDestruction.h"
|
||||
|
||||
class nsISerialEventTarget;
|
||||
class nsIThread;
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
|
@ -23,7 +22,9 @@ class CompositorThreadHolder final {
|
|||
public:
|
||||
CompositorThreadHolder();
|
||||
|
||||
base::Thread* GetCompositorThread() const { return mCompositorThread; }
|
||||
nsISerialEventTarget* GetCompositorThread() const {
|
||||
return mCompositorThread;
|
||||
}
|
||||
|
||||
static CompositorThreadHolder* GetSingleton();
|
||||
|
||||
|
@ -40,23 +41,20 @@ class CompositorThreadHolder final {
|
|||
*/
|
||||
static void Shutdown();
|
||||
|
||||
static MessageLoop* Loop();
|
||||
|
||||
// Returns true if the calling thread is the compositor thread.
|
||||
static bool IsInCompositorThread();
|
||||
|
||||
private:
|
||||
~CompositorThreadHolder();
|
||||
|
||||
base::Thread* const mCompositorThread;
|
||||
nsCOMPtr<nsIThread> mCompositorThread;
|
||||
|
||||
static base::Thread* CreateCompositorThread();
|
||||
static void DestroyCompositorThread(base::Thread* aCompositorThread);
|
||||
static already_AddRefed<nsIThread> CreateCompositorThread();
|
||||
|
||||
friend class CompositorBridgeParent;
|
||||
};
|
||||
|
||||
base::Thread* CompositorThread();
|
||||
nsISerialEventTarget* CompositorThread();
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -110,24 +110,24 @@ void CompositorVsyncScheduler::Destroy() {
|
|||
void CompositorVsyncScheduler::PostCompositeTask(
|
||||
VsyncId aId, TimeStamp aCompositeTimestamp) {
|
||||
MonitorAutoLock lock(mCurrentCompositeTaskMonitor);
|
||||
if (mCurrentCompositeTask == nullptr && CompositorThreadHolder::Loop()) {
|
||||
if (mCurrentCompositeTask == nullptr && CompositorThread()) {
|
||||
RefPtr<CancelableRunnable> task =
|
||||
NewCancelableRunnableMethod<VsyncId, TimeStamp>(
|
||||
"layers::CompositorVsyncScheduler::Composite", this,
|
||||
&CompositorVsyncScheduler::Composite, aId, aCompositeTimestamp);
|
||||
mCurrentCompositeTask = task;
|
||||
ScheduleTask(task.forget());
|
||||
CompositorThread()->Dispatch(task.forget());
|
||||
}
|
||||
}
|
||||
|
||||
void CompositorVsyncScheduler::PostVRTask(TimeStamp aTimestamp) {
|
||||
MonitorAutoLock lockVR(mCurrentVRTaskMonitor);
|
||||
if (mCurrentVRTask == nullptr && CompositorThreadHolder::Loop()) {
|
||||
if (mCurrentVRTask == nullptr && CompositorThread()) {
|
||||
RefPtr<CancelableRunnable> task = NewCancelableRunnableMethod<TimeStamp>(
|
||||
"layers::CompositorVsyncScheduler::DispatchVREvents", this,
|
||||
&CompositorVsyncScheduler::DispatchVREvents, aTimestamp);
|
||||
mCurrentVRTask = task;
|
||||
CompositorThreadHolder::Loop()->PostDelayedTask(task.forget(), 0);
|
||||
CompositorThread()->Dispatch(task.forget());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -329,12 +329,6 @@ void CompositorVsyncScheduler::DispatchVREvents(TimeStamp aVsyncTimestamp) {
|
|||
vm->NotifyVsync(aVsyncTimestamp);
|
||||
}
|
||||
|
||||
void CompositorVsyncScheduler::ScheduleTask(
|
||||
already_AddRefed<CancelableRunnable> aTask) {
|
||||
MOZ_ASSERT(CompositorThreadHolder::Loop());
|
||||
CompositorThreadHolder::Loop()->PostDelayedTask(std::move(aTask), 0);
|
||||
}
|
||||
|
||||
const TimeStamp& CompositorVsyncScheduler::GetLastComposeTime() const {
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
return mLastCompose;
|
||||
|
|
|
@ -109,9 +109,6 @@ class CompositorVsyncScheduler {
|
|||
private:
|
||||
virtual ~CompositorVsyncScheduler();
|
||||
|
||||
// Schedule a task to run on the compositor thread.
|
||||
void ScheduleTask(already_AddRefed<CancelableRunnable>);
|
||||
|
||||
// Post a task to run Composite() on the compositor thread, if there isn't
|
||||
// such a task already queued. Can be called from any thread.
|
||||
void PostCompositeTask(VsyncId aId, TimeStamp aCompositeTimestamp);
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include "ImageContainer.h" // for ImageContainer
|
||||
#include "Layers.h" // for Layer, etc
|
||||
#include "ShadowLayers.h" // for ShadowLayerForwarder
|
||||
#include "base/message_loop.h" // for MessageLoop
|
||||
#include "base/platform_thread.h" // for PlatformThread
|
||||
#include "base/process.h" // for ProcessId
|
||||
#include "base/task.h" // for NewRunnableFunction, etc
|
||||
|
@ -38,8 +37,8 @@
|
|||
#include "nsISupportsImpl.h" // for ImageContainer::AddRef, etc
|
||||
#include "nsTArray.h" // for AutoTArray, nsTArray, etc
|
||||
#include "nsTArrayForwardDeclare.h" // for AutoTArray
|
||||
#include "nsThread.h"
|
||||
#include "nsThreadUtils.h" // for NS_IsMainThread
|
||||
#include "nsXULAppAPI.h" // for XRE_GetIOMessageLoop
|
||||
#include "mozilla/StaticMutex.h"
|
||||
#include "mozilla/StaticPtr.h" // for StaticRefPtr
|
||||
#include "mozilla/layers/TextureClient.h"
|
||||
|
@ -172,7 +171,10 @@ void ImageBridgeChild::CancelWaitForNotifyNotUsed(uint64_t aTextureId) {
|
|||
// Singleton
|
||||
static StaticMutex sImageBridgeSingletonLock;
|
||||
static StaticRefPtr<ImageBridgeChild> sImageBridgeChildSingleton;
|
||||
static Thread* sImageBridgeChildThread = nullptr;
|
||||
// sImageBridgeChildThread cannot be converted to use a generic
|
||||
// nsISerialEventTarget (which may be backed by a threadpool) until bug 1634846
|
||||
// is addressed. Therefore we keep it as an nsIThread here.
|
||||
static StaticRefPtr<nsIThread> sImageBridgeChildThread;
|
||||
|
||||
// dispatched function
|
||||
void ImageBridgeChild::ShutdownStep1(SynchronousTask* aTask) {
|
||||
|
@ -293,8 +295,6 @@ void ImageBridgeChild::ForgetImageContainer(const CompositableHandle& aHandle) {
|
|||
mImageContainerListeners.erase(aHandle.Value());
|
||||
}
|
||||
|
||||
Thread* ImageBridgeChild::GetThread() const { return sImageBridgeChildThread; }
|
||||
|
||||
/* static */
|
||||
RefPtr<ImageBridgeChild> ImageBridgeChild::GetSingleton() {
|
||||
StaticMutexAutoLock lock(sImageBridgeSingletonLock);
|
||||
|
@ -310,7 +310,7 @@ void ImageBridgeChild::UpdateImageClient(RefPtr<ImageContainer> aContainer) {
|
|||
RefPtr<Runnable> runnable =
|
||||
WrapRunnable(RefPtr<ImageBridgeChild>(this),
|
||||
&ImageBridgeChild::UpdateImageClient, aContainer);
|
||||
GetMessageLoop()->PostTask(runnable.forget());
|
||||
GetThread()->Dispatch(runnable.forget());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -355,7 +355,7 @@ void ImageBridgeChild::UpdateAsyncCanvasRenderer(
|
|||
RefPtr<Runnable> runnable = WrapRunnable(
|
||||
RefPtr<ImageBridgeChild>(this),
|
||||
&ImageBridgeChild::UpdateAsyncCanvasRendererSync, &task, aWrapper);
|
||||
GetMessageLoop()->PostTask(runnable.forget());
|
||||
GetThread()->Dispatch(runnable.forget());
|
||||
|
||||
task.Wait();
|
||||
}
|
||||
|
@ -409,7 +409,7 @@ void ImageBridgeChild::FlushAllImages(ImageClient* aClient,
|
|||
RefPtr<Runnable> runnable = WrapRunnable(
|
||||
RefPtr<ImageBridgeChild>(this), &ImageBridgeChild::FlushAllImagesSync,
|
||||
&task, aClient, aContainer);
|
||||
GetMessageLoop()->PostTask(runnable.forget());
|
||||
GetThread()->Dispatch(runnable.forget());
|
||||
|
||||
task.Wait();
|
||||
}
|
||||
|
@ -454,9 +454,11 @@ bool ImageBridgeChild::InitForContent(Endpoint<PImageBridgeChild>&& aEndpoint,
|
|||
gfxPlatform::GetPlatform();
|
||||
|
||||
if (!sImageBridgeChildThread) {
|
||||
sImageBridgeChildThread = new Thread("ImageBridgeChild");
|
||||
bool success = sImageBridgeChildThread->Start();
|
||||
MOZ_RELEASE_ASSERT(success, "Failed to start ImageBridgeChild thread!");
|
||||
nsCOMPtr<nsIThread> thread;
|
||||
nsresult rv = NS_NewNamedThread("ImageBridgeChld", getter_AddRefs(thread));
|
||||
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv),
|
||||
"Failed to start ImageBridgeChild thread!");
|
||||
sImageBridgeChildThread = thread.forget();
|
||||
}
|
||||
|
||||
RefPtr<ImageBridgeChild> child = new ImageBridgeChild(aNamespace);
|
||||
|
@ -464,7 +466,7 @@ bool ImageBridgeChild::InitForContent(Endpoint<PImageBridgeChild>&& aEndpoint,
|
|||
RefPtr<Runnable> runnable = NewRunnableMethod<Endpoint<PImageBridgeChild>&&>(
|
||||
"layers::ImageBridgeChild::Bind", child, &ImageBridgeChild::Bind,
|
||||
std::move(aEndpoint));
|
||||
child->GetMessageLoop()->PostTask(runnable.forget());
|
||||
child->GetThread()->Dispatch(runnable.forget());
|
||||
|
||||
// Assign this after so other threads can't post messages before we connect to
|
||||
// IPDL.
|
||||
|
@ -501,9 +503,8 @@ void ImageBridgeChild::Bind(Endpoint<PImageBridgeChild>&& aEndpoint) {
|
|||
}
|
||||
|
||||
void ImageBridgeChild::BindSameProcess(RefPtr<ImageBridgeParent> aParent) {
|
||||
MessageLoop* parentMsgLoop = aParent->GetMessageLoop();
|
||||
ipc::MessageChannel* parentChannel = aParent->GetIPCChannel();
|
||||
Open(parentChannel, parentMsgLoop, mozilla::ipc::ChildSide);
|
||||
Open(parentChannel, aParent->GetThread(), mozilla::ipc::ChildSide);
|
||||
|
||||
// This reference is dropped in DeallocPImageBridgeChild.
|
||||
this->AddRef();
|
||||
|
@ -517,7 +518,6 @@ void ImageBridgeChild::ShutDown() {
|
|||
|
||||
ShutdownSingleton();
|
||||
|
||||
delete sImageBridgeChildThread;
|
||||
sImageBridgeChildThread = nullptr;
|
||||
}
|
||||
|
||||
|
@ -540,7 +540,7 @@ void ImageBridgeChild::WillShutdown() {
|
|||
RefPtr<Runnable> runnable =
|
||||
WrapRunnable(RefPtr<ImageBridgeChild>(this),
|
||||
&ImageBridgeChild::ShutdownStep1, &task);
|
||||
GetMessageLoop()->PostTask(runnable.forget());
|
||||
GetThread()->Dispatch(runnable.forget());
|
||||
|
||||
task.Wait();
|
||||
}
|
||||
|
@ -551,7 +551,7 @@ void ImageBridgeChild::WillShutdown() {
|
|||
RefPtr<Runnable> runnable =
|
||||
WrapRunnable(RefPtr<ImageBridgeChild>(this),
|
||||
&ImageBridgeChild::ShutdownStep2, &task);
|
||||
GetMessageLoop()->PostTask(runnable.forget());
|
||||
GetThread()->Dispatch(runnable.forget());
|
||||
|
||||
task.Wait();
|
||||
}
|
||||
|
@ -563,17 +563,18 @@ void ImageBridgeChild::InitSameProcess(uint32_t aNamespace) {
|
|||
MOZ_ASSERT(!sImageBridgeChildSingleton);
|
||||
MOZ_ASSERT(!sImageBridgeChildThread);
|
||||
|
||||
sImageBridgeChildThread = new Thread("ImageBridgeChild");
|
||||
if (!sImageBridgeChildThread->IsRunning()) {
|
||||
sImageBridgeChildThread->Start();
|
||||
}
|
||||
nsCOMPtr<nsIThread> thread;
|
||||
nsresult rv = NS_NewNamedThread("ImageBridgeChld", getter_AddRefs(thread));
|
||||
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv),
|
||||
"Failed to start ImageBridgeChild thread!");
|
||||
sImageBridgeChildThread = thread.forget();
|
||||
|
||||
RefPtr<ImageBridgeChild> child = new ImageBridgeChild(aNamespace);
|
||||
RefPtr<ImageBridgeParent> parent = ImageBridgeParent::CreateSameProcess();
|
||||
|
||||
RefPtr<Runnable> runnable =
|
||||
WrapRunnable(child, &ImageBridgeChild::BindSameProcess, parent);
|
||||
child->GetMessageLoop()->PostTask(runnable.forget());
|
||||
child->GetThread()->Dispatch(runnable.forget());
|
||||
|
||||
// Assign this after so other threads can't post messages before we connect to
|
||||
// IPDL.
|
||||
|
@ -590,15 +591,15 @@ void ImageBridgeChild::InitWithGPUProcess(
|
|||
MOZ_ASSERT(!sImageBridgeChildSingleton);
|
||||
MOZ_ASSERT(!sImageBridgeChildThread);
|
||||
|
||||
sImageBridgeChildThread = new Thread("ImageBridgeChild");
|
||||
if (!sImageBridgeChildThread->IsRunning()) {
|
||||
sImageBridgeChildThread->Start();
|
||||
}
|
||||
nsCOMPtr<nsIThread> thread;
|
||||
nsresult rv = NS_NewNamedThread("ImageBridgeChld", getter_AddRefs(thread));
|
||||
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv),
|
||||
"Failed to start ImageBridgeChild thread!");
|
||||
sImageBridgeChildThread = thread.forget();
|
||||
|
||||
RefPtr<ImageBridgeChild> child = new ImageBridgeChild(aNamespace);
|
||||
|
||||
MessageLoop* loop = child->GetMessageLoop();
|
||||
loop->PostTask(NewRunnableMethod<Endpoint<PImageBridgeChild>&&>(
|
||||
child->GetThread()->Dispatch(NewRunnableMethod<Endpoint<PImageBridgeChild>&&>(
|
||||
"layers::ImageBridgeChild::Bind", child, &ImageBridgeChild::Bind,
|
||||
std::move(aEndpoint)));
|
||||
|
||||
|
@ -612,12 +613,11 @@ void ImageBridgeChild::InitWithGPUProcess(
|
|||
|
||||
bool InImageBridgeChildThread() {
|
||||
return sImageBridgeChildThread &&
|
||||
sImageBridgeChildThread->thread_id() == PlatformThread::CurrentId();
|
||||
sImageBridgeChildThread->IsOnCurrentThread();
|
||||
}
|
||||
|
||||
MessageLoop* ImageBridgeChild::GetMessageLoop() const {
|
||||
return sImageBridgeChildThread ? sImageBridgeChildThread->message_loop()
|
||||
: nullptr;
|
||||
nsISerialEventTarget* ImageBridgeChild::GetThread() const {
|
||||
return sImageBridgeChildThread;
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
@ -697,7 +697,7 @@ RefPtr<ImageClient> ImageBridgeChild::CreateImageClient(
|
|||
RefPtr<Runnable> runnable = WrapRunnable(
|
||||
RefPtr<ImageBridgeChild>(this), &ImageBridgeChild::CreateImageClientSync,
|
||||
&task, &result, aType, aImageContainer);
|
||||
GetMessageLoop()->PostTask(runnable.forget());
|
||||
GetThread()->Dispatch(runnable.forget());
|
||||
|
||||
task.Wait();
|
||||
|
||||
|
@ -733,7 +733,7 @@ already_AddRefed<CanvasClient> ImageBridgeChild::CreateCanvasClient(
|
|||
RefPtr<Runnable> runnable = WrapRunnable(
|
||||
RefPtr<ImageBridgeChild>(this), &ImageBridgeChild::CreateCanvasClientSync,
|
||||
&task, aType, aFlag, &result);
|
||||
GetMessageLoop()->PostTask(runnable.forget());
|
||||
GetThread()->Dispatch(runnable.forget());
|
||||
|
||||
task.Wait();
|
||||
|
||||
|
@ -807,7 +807,7 @@ bool ImageBridgeChild::DispatchAllocShmemInternal(
|
|||
RefPtr<Runnable> runnable = WrapRunnable(
|
||||
RefPtr<ImageBridgeChild>(this), &ImageBridgeChild::ProxyAllocShmemNow,
|
||||
&task, aSize, aType, aShmem, aUnsafe, &success);
|
||||
GetMessageLoop()->PostTask(runnable.forget());
|
||||
GetThread()->Dispatch(runnable.forget());
|
||||
|
||||
task.Wait();
|
||||
|
||||
|
@ -844,7 +844,7 @@ bool ImageBridgeChild::DeallocShmem(ipc::Shmem& aShmem) {
|
|||
RefPtr<Runnable> runnable = WrapRunnable(
|
||||
RefPtr<ImageBridgeChild>(this), &ImageBridgeChild::ProxyDeallocShmemNow,
|
||||
&task, &aShmem, &result);
|
||||
GetMessageLoop()->PostTask(runnable.forget());
|
||||
GetThread()->Dispatch(runnable.forget());
|
||||
|
||||
task.Wait();
|
||||
return result;
|
||||
|
@ -999,7 +999,7 @@ void ImageBridgeChild::ReleaseCompositable(const CompositableHandle& aHandle) {
|
|||
RefPtr<Runnable> runnable =
|
||||
WrapRunnable(RefPtr<ImageBridgeChild>(this),
|
||||
&ImageBridgeChild::ReleaseCompositable, aHandle);
|
||||
GetMessageLoop()->PostTask(runnable.forget());
|
||||
GetThread()->Dispatch(runnable.forget());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,12 +25,6 @@
|
|||
#include "mozilla/gfx/Rect.h"
|
||||
#include "mozilla/ReentrantMonitor.h" // for ReentrantMonitor, etc
|
||||
|
||||
class MessageLoop;
|
||||
|
||||
namespace base {
|
||||
class Thread;
|
||||
} // namespace base
|
||||
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
class Shmem;
|
||||
|
@ -166,14 +160,7 @@ class ImageBridgeChild final : public PImageBridgeChild,
|
|||
*
|
||||
* Can be called from any thread.
|
||||
*/
|
||||
base::Thread* GetThread() const;
|
||||
|
||||
/**
|
||||
* Returns the ImageBridgeChild's message loop.
|
||||
*
|
||||
* Can be called from any thread.
|
||||
*/
|
||||
MessageLoop* GetMessageLoop() const override;
|
||||
nsISerialEventTarget* GetThread() const override;
|
||||
|
||||
base::ProcessId GetParentPid() const override { return OtherPid(); }
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include "ImageBridgeParent.h"
|
||||
#include <stdint.h> // for uint64_t, uint32_t
|
||||
#include "CompositableHost.h" // for CompositableParent, Create
|
||||
#include "base/message_loop.h" // for MessageLoop
|
||||
#include "base/process.h" // for ProcessId
|
||||
#include "base/task.h" // for CancelableTask, DeleteTask, etc
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
|
@ -62,9 +61,9 @@ void ImageBridgeParent::Setup() {
|
|||
}
|
||||
}
|
||||
|
||||
ImageBridgeParent::ImageBridgeParent(MessageLoop* aLoop,
|
||||
ImageBridgeParent::ImageBridgeParent(nsISerialEventTarget* aThread,
|
||||
ProcessId aChildProcessId)
|
||||
: mMessageLoop(aLoop),
|
||||
: mThread(aThread),
|
||||
mClosed(false),
|
||||
mCompositorThreadHolder(CompositorThreadHolder::GetSingleton()) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
@ -77,7 +76,7 @@ ImageBridgeParent::~ImageBridgeParent() = default;
|
|||
ImageBridgeParent* ImageBridgeParent::CreateSameProcess() {
|
||||
base::ProcessId pid = base::GetCurrentProcId();
|
||||
RefPtr<ImageBridgeParent> parent =
|
||||
new ImageBridgeParent(CompositorThreadHolder::Loop(), pid);
|
||||
new ImageBridgeParent(CompositorThread(), pid);
|
||||
parent->mSelfRef = parent;
|
||||
|
||||
{
|
||||
|
@ -95,15 +94,15 @@ bool ImageBridgeParent::CreateForGPUProcess(
|
|||
Endpoint<PImageBridgeParent>&& aEndpoint) {
|
||||
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_GPU);
|
||||
|
||||
MessageLoop* loop = CompositorThreadHolder::Loop();
|
||||
if (!loop) {
|
||||
nsCOMPtr<nsISerialEventTarget> compositorThread = CompositorThread();
|
||||
if (!compositorThread) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RefPtr<ImageBridgeParent> parent =
|
||||
new ImageBridgeParent(loop, aEndpoint.OtherPid());
|
||||
new ImageBridgeParent(compositorThread, aEndpoint.OtherPid());
|
||||
|
||||
loop->PostTask(NewRunnableMethod<Endpoint<PImageBridgeParent>&&>(
|
||||
compositorThread->Dispatch(NewRunnableMethod<Endpoint<PImageBridgeParent>&&>(
|
||||
"layers::ImageBridgeParent::Bind", parent, &ImageBridgeParent::Bind,
|
||||
std::move(aEndpoint)));
|
||||
|
||||
|
@ -133,7 +132,7 @@ void ImageBridgeParent::ShutdownInternal() {
|
|||
|
||||
/* static */
|
||||
void ImageBridgeParent::Shutdown() {
|
||||
CompositorThreadHolder::Loop()->PostTask(NS_NewRunnableFunction(
|
||||
CompositorThread()->Dispatch(NS_NewRunnableFunction(
|
||||
"ImageBridgeParent::Shutdown",
|
||||
[]() -> void { ImageBridgeParent::ShutdownInternal(); }));
|
||||
}
|
||||
|
@ -146,7 +145,7 @@ void ImageBridgeParent::ActorDestroy(ActorDestroyReason aWhy) {
|
|||
MonitorAutoLock lock(*sImageBridgesLock);
|
||||
sImageBridges.erase(OtherPid());
|
||||
}
|
||||
MessageLoop::current()->PostTask(
|
||||
GetThread()->Dispatch(
|
||||
NewRunnableMethod("layers::ImageBridgeParent::DeferredDestroy", this,
|
||||
&ImageBridgeParent::DeferredDestroy));
|
||||
|
||||
|
@ -219,14 +218,14 @@ mozilla::ipc::IPCResult ImageBridgeParent::RecvUpdate(
|
|||
/* static */
|
||||
bool ImageBridgeParent::CreateForContent(
|
||||
Endpoint<PImageBridgeParent>&& aEndpoint) {
|
||||
MessageLoop* loop = CompositorThreadHolder::Loop();
|
||||
if (!loop) {
|
||||
nsCOMPtr<nsISerialEventTarget> compositorThread = CompositorThread();
|
||||
if (!compositorThread) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RefPtr<ImageBridgeParent> bridge =
|
||||
new ImageBridgeParent(loop, aEndpoint.OtherPid());
|
||||
loop->PostTask(NewRunnableMethod<Endpoint<PImageBridgeParent>&&>(
|
||||
new ImageBridgeParent(compositorThread, aEndpoint.OtherPid());
|
||||
compositorThread->Dispatch(NewRunnableMethod<Endpoint<PImageBridgeParent>&&>(
|
||||
"layers::ImageBridgeParent::Bind", bridge, &ImageBridgeParent::Bind,
|
||||
std::move(aEndpoint)));
|
||||
|
||||
|
|
|
@ -19,12 +19,6 @@
|
|||
#include "nsISupportsImpl.h"
|
||||
#include "nsTArrayForwardDeclare.h" // for nsTArray
|
||||
|
||||
class MessageLoop;
|
||||
|
||||
namespace base {
|
||||
class Thread;
|
||||
} // namespace base
|
||||
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
class Shmem;
|
||||
|
@ -45,7 +39,7 @@ class ImageBridgeParent final : public PImageBridgeParent,
|
|||
typedef nsTArray<OpDestroy> OpDestroyArray;
|
||||
|
||||
protected:
|
||||
ImageBridgeParent(MessageLoop* aLoop, ProcessId aChildProcessId);
|
||||
ImageBridgeParent(nsISerialEventTarget* aThread, ProcessId aChildProcessId);
|
||||
|
||||
public:
|
||||
virtual ~ImageBridgeParent();
|
||||
|
@ -98,7 +92,7 @@ class ImageBridgeParent final : public PImageBridgeParent,
|
|||
// Shutdown step 1
|
||||
mozilla::ipc::IPCResult RecvWillClose();
|
||||
|
||||
MessageLoop* GetMessageLoop() const { return mMessageLoop; }
|
||||
nsISerialEventTarget* GetThread() const { return mThread; }
|
||||
|
||||
// IShmemAllocator
|
||||
|
||||
|
@ -142,7 +136,7 @@ class ImageBridgeParent final : public PImageBridgeParent,
|
|||
static void ShutdownInternal();
|
||||
|
||||
void DeferredDestroy();
|
||||
MessageLoop* mMessageLoop;
|
||||
nsCOMPtr<nsISerialEventTarget> mThread;
|
||||
// This keeps us alive until ActorDestroy(), at which point we do a
|
||||
// deferred destruction of ourselves.
|
||||
RefPtr<ImageBridgeParent> mSelfRef;
|
||||
|
|
|
@ -189,7 +189,7 @@ RefPtr<KnowsCompositor> ShadowLayerForwarder::GetForMedia() {
|
|||
ShadowLayerForwarder::ShadowLayerForwarder(
|
||||
ClientLayerManager* aClientLayerManager)
|
||||
: mClientLayerManager(aClientLayerManager),
|
||||
mMessageLoop(MessageLoop::current()),
|
||||
mThread(NS_GetCurrentThread()),
|
||||
mDiagnosticTypes(DiagnosticTypes::NO_DIAGNOSTIC),
|
||||
mIsFirstPaint(false),
|
||||
mNextLayerHandle(1) {
|
||||
|
@ -500,9 +500,7 @@ void ShadowLayerForwarder::RemoveTextureFromCompositable(
|
|||
}
|
||||
|
||||
bool ShadowLayerForwarder::InWorkerThread() {
|
||||
return MessageLoop::current() &&
|
||||
(GetTextureForwarder()->GetMessageLoop()->id() ==
|
||||
MessageLoop::current()->id());
|
||||
return GetTextureForwarder()->GetThread()->IsOnCurrentThread();
|
||||
}
|
||||
|
||||
void ShadowLayerForwarder::StorePluginWidgetConfigurations(
|
||||
|
|
|
@ -418,7 +418,7 @@ class ShadowLayerForwarder final : public LayersIPCActor,
|
|||
private:
|
||||
ClientLayerManager* mClientLayerManager;
|
||||
Transaction* mTxn;
|
||||
MessageLoop* mMessageLoop;
|
||||
nsCOMPtr<nsISerialEventTarget> mThread;
|
||||
DiagnosticTypes mDiagnosticTypes;
|
||||
bool mIsFirstPaint;
|
||||
FocusTarget mFocusTarget;
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "mozilla/layers/LayersTypes.h" // for LayersBackend
|
||||
#include "mozilla/layers/TextureClient.h" // for TextureClient
|
||||
#include "mozilla/layers/KnowsCompositor.h"
|
||||
#include "nsISerialEventTarget.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
|
@ -47,7 +48,7 @@ class LayersIPCChannel : public LayersIPCActor,
|
|||
|
||||
virtual base::ProcessId GetParentPid() const = 0;
|
||||
|
||||
virtual MessageLoop* GetMessageLoop() const = 0;
|
||||
virtual nsISerialEventTarget* GetThread() const = 0;
|
||||
|
||||
virtual FixedSizeSmallShmemSectionAllocator* GetTileLockAllocator() {
|
||||
return nullptr;
|
||||
|
|
|
@ -27,9 +27,7 @@ static RefPtr<nsThread> GetUiThread() {
|
|||
}
|
||||
#endif // defined(MOZ_WIDGET_ANDROID)
|
||||
|
||||
static bool IsOnUiThread() {
|
||||
return GetUiThread()->SerialEventTarget()->IsOnCurrentThread();
|
||||
}
|
||||
static bool IsOnUiThread() { return GetUiThread()->IsOnCurrentThread(); }
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
@ -262,8 +260,7 @@ UiCompositorControllerChild::~UiCompositorControllerChild() = default;
|
|||
void UiCompositorControllerChild::OpenForSameProcess() {
|
||||
MOZ_ASSERT(IsOnUiThread());
|
||||
|
||||
mIsOpen = Open(mParent->GetIPCChannel(),
|
||||
mozilla::layers::CompositorThreadHolder::Loop(),
|
||||
mIsOpen = Open(mParent->GetIPCChannel(), mozilla::layers::CompositorThread(),
|
||||
mozilla::ipc::ChildSide);
|
||||
|
||||
if (!mIsOpen) {
|
||||
|
|
|
@ -50,7 +50,7 @@ RefPtr<UiCompositorControllerParent> UiCompositorControllerParent::Start(
|
|||
NewRunnableMethod<Endpoint<PUiCompositorControllerParent>&&>(
|
||||
"layers::UiCompositorControllerParent::Open", parent,
|
||||
&UiCompositorControllerParent::Open, std::move(aEndpoint));
|
||||
CompositorThreadHolder::Loop()->PostTask(task.forget());
|
||||
CompositorThread()->Dispatch(task.forget());
|
||||
|
||||
return parent;
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ void UiCompositorControllerParent::ToolbarAnimatorMessageFromCompositor(
|
|||
int32_t aMessage) {
|
||||
// This function can be call from ether compositor or controller thread.
|
||||
if (!CompositorThreadHolder::IsInCompositorThread()) {
|
||||
CompositorThreadHolder::Loop()->PostTask(NewRunnableMethod<int32_t>(
|
||||
CompositorThread()->Dispatch(NewRunnableMethod<int32_t>(
|
||||
"layers::UiCompositorControllerParent::"
|
||||
"ToolbarAnimatorMessageFromCompositor",
|
||||
this,
|
||||
|
@ -218,11 +218,10 @@ void UiCompositorControllerParent::NotifyUpdateScreenMetrics(
|
|||
aMetrics.GetZoom().ToScaleFactor(),
|
||||
PixelCastJustification::ScreenIsParentLayerForRoot);
|
||||
ScreenPoint scrollOffset = aMetrics.GetScrollOffset() * scale;
|
||||
CompositorThreadHolder::Loop()->PostTask(
|
||||
NewRunnableMethod<ScreenPoint, CSSToScreenScale>(
|
||||
"UiCompositorControllerParent::SendRootFrameMetrics", this,
|
||||
&UiCompositorControllerParent::SendRootFrameMetrics, scrollOffset,
|
||||
scale));
|
||||
CompositorThread()->Dispatch(NewRunnableMethod<ScreenPoint, CSSToScreenScale>(
|
||||
"UiCompositorControllerParent::SendRootFrameMetrics", this,
|
||||
&UiCompositorControllerParent::SendRootFrameMetrics, scrollOffset,
|
||||
scale));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -249,7 +248,7 @@ void UiCompositorControllerParent::InitializeForSameProcess() {
|
|||
SynchronousTask task(
|
||||
"UiCompositorControllerParent::InitializeForSameProcess");
|
||||
|
||||
CompositorThreadHolder::Loop()->PostTask(NS_NewRunnableFunction(
|
||||
CompositorThread()->Dispatch(NS_NewRunnableFunction(
|
||||
"UiCompositorControllerParent::InitializeForSameProcess", [&]() {
|
||||
AutoCompleteTask complete(&task);
|
||||
InitializeForSameProcess();
|
||||
|
|
|
@ -48,9 +48,7 @@ void VideoBridgeChild::Shutdown() {
|
|||
}
|
||||
|
||||
VideoBridgeChild::VideoBridgeChild()
|
||||
: mIPDLSelfRef(this),
|
||||
mMessageLoop(MessageLoop::current()),
|
||||
mCanSend(true) {}
|
||||
: mIPDLSelfRef(this), mThread(NS_GetCurrentThread()), mCanSend(true) {}
|
||||
|
||||
VideoBridgeChild::~VideoBridgeChild() = default;
|
||||
|
||||
|
@ -59,7 +57,7 @@ VideoBridgeChild* VideoBridgeChild::GetSingleton() { return sVideoBridge; }
|
|||
bool VideoBridgeChild::AllocUnsafeShmem(
|
||||
size_t aSize, ipc::SharedMemory::SharedMemoryType aType,
|
||||
ipc::Shmem* aShmem) {
|
||||
if (MessageLoop::current() != mMessageLoop) {
|
||||
if (!mThread->IsOnCurrentThread()) {
|
||||
return DispatchAllocShmemInternal(aSize, aType, aShmem,
|
||||
true); // true: unsafe
|
||||
}
|
||||
|
@ -106,7 +104,7 @@ bool VideoBridgeChild::DispatchAllocShmemInternal(
|
|||
RefPtr<Runnable> runnable = WrapRunnable(
|
||||
RefPtr<VideoBridgeChild>(this), &VideoBridgeChild::ProxyAllocShmemNow,
|
||||
&task, aSize, aType, aShmem, aUnsafe, &success);
|
||||
GetMessageLoop()->PostTask(runnable.forget());
|
||||
GetThread()->Dispatch(runnable.forget());
|
||||
|
||||
task.Wait();
|
||||
|
||||
|
@ -124,7 +122,7 @@ void VideoBridgeChild::ProxyDeallocShmemNow(SynchronousTask* aTask,
|
|||
}
|
||||
|
||||
bool VideoBridgeChild::DeallocShmem(ipc::Shmem& aShmem) {
|
||||
if (MessageLoop::current() == mMessageLoop) {
|
||||
if (GetThread()->IsOnCurrentThread()) {
|
||||
if (!CanSend()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -137,7 +135,7 @@ bool VideoBridgeChild::DeallocShmem(ipc::Shmem& aShmem) {
|
|||
RefPtr<Runnable> runnable = WrapRunnable(
|
||||
RefPtr<VideoBridgeChild>(this), &VideoBridgeChild::ProxyDeallocShmemNow,
|
||||
&task, &aShmem, &result);
|
||||
GetMessageLoop()->PostTask(runnable.forget());
|
||||
GetThread()->Dispatch(runnable.forget());
|
||||
|
||||
task.Wait();
|
||||
return result;
|
||||
|
|
|
@ -57,7 +57,7 @@ class VideoBridgeChild final : public PVideoBridgeChild,
|
|||
|
||||
// ClientIPCAllocator
|
||||
base::ProcessId GetParentPid() const override { return OtherPid(); }
|
||||
MessageLoop* GetMessageLoop() const override { return mMessageLoop; }
|
||||
nsISerialEventTarget* GetThread() const override { return mThread; }
|
||||
void CancelWaitForNotifyNotUsed(uint64_t aTextureId) override {
|
||||
MOZ_ASSERT(false, "NO RECYCLING HERE");
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ class VideoBridgeChild final : public PVideoBridgeChild,
|
|||
virtual ~VideoBridgeChild();
|
||||
|
||||
RefPtr<VideoBridgeChild> mIPDLSelfRef;
|
||||
MessageLoop* mMessageLoop;
|
||||
nsCOMPtr<nsISerialEventTarget> mThread;
|
||||
bool mCanSend;
|
||||
};
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ void VideoBridgeParent::Open(Endpoint<PVideoBridgeParent>&& aEndpoint,
|
|||
VideoBridgeSource aSource) {
|
||||
RefPtr<VideoBridgeParent> parent = new VideoBridgeParent(aSource);
|
||||
|
||||
CompositorThreadHolder::Loop()->PostTask(
|
||||
CompositorThread()->Dispatch(
|
||||
NewRunnableMethod<Endpoint<PVideoBridgeParent>&&>(
|
||||
"gfx::layers::VideoBridgeParent::Bind", parent,
|
||||
&VideoBridgeParent::Bind, std::move(aEndpoint)));
|
||||
|
|
|
@ -551,7 +551,7 @@ void AsyncImagePipelineManager::NotifyPipelinesUpdated(
|
|||
|
||||
// Queue a runnable on the compositor thread to process the updates.
|
||||
// This will also call CheckForTextureHostsNotUsedByGPU.
|
||||
layers::CompositorThreadHolder::Loop()->PostTask(
|
||||
layers::CompositorThread()->Dispatch(
|
||||
NewRunnableMethod("ProcessPipelineUpdates", this,
|
||||
&AsyncImagePipelineManager::ProcessPipelineUpdates));
|
||||
}
|
||||
|
|
|
@ -193,7 +193,7 @@ class ScheduleObserveLayersUpdate : public wr::NotificationHandler {
|
|||
mIsActive(aIsActive) {}
|
||||
|
||||
void Notify(wr::Checkpoint) override {
|
||||
CompositorThreadHolder::Loop()->PostTask(
|
||||
CompositorThread()->Dispatch(
|
||||
NewRunnableMethod<LayersId, LayersObserverEpoch, int>(
|
||||
"ObserveLayersUpdate", mBridge,
|
||||
&CompositorBridgeParentBase::ObserveLayersUpdate, mLayersId,
|
||||
|
@ -217,7 +217,7 @@ class SceneBuiltNotification : public wr::NotificationHandler {
|
|||
auto startTime = this->mTxnStartTime;
|
||||
RefPtr<WebRenderBridgeParent> parent = mParent;
|
||||
wr::Epoch epoch = mEpoch;
|
||||
CompositorThreadHolder::Loop()->PostTask(NS_NewRunnableFunction(
|
||||
CompositorThread()->Dispatch(NS_NewRunnableFunction(
|
||||
"SceneBuiltNotificationRunnable", [parent, epoch, startTime]() {
|
||||
auto endTime = TimeStamp::Now();
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
|
@ -287,7 +287,7 @@ class WebRenderBridgeParent::ScheduleSharedSurfaceRelease final
|
|||
}
|
||||
|
||||
void Notify(wr::Checkpoint) override {
|
||||
CompositorThreadHolder::Loop()->PostTask(
|
||||
CompositorThread()->Dispatch(
|
||||
NewRunnableMethod<nsTArray<wr::ExternalImageKeyPair>>(
|
||||
"ObserveSharedSurfaceRelease", mWrBridge,
|
||||
&WebRenderBridgeParent::ObserveSharedSurfaceRelease,
|
||||
|
|
|
@ -1384,8 +1384,7 @@ void DeviceManagerDx::GetCompositorDevices(
|
|||
|
||||
/* static */
|
||||
void DeviceManagerDx::PreloadAttachmentsOnCompositorThread() {
|
||||
MessageLoop* loop = layers::CompositorThreadHolder::Loop();
|
||||
if (!loop) {
|
||||
if (!CompositorThread()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1404,7 +1403,7 @@ void DeviceManagerDx::PreloadAttachmentsOnCompositorThread() {
|
|||
}
|
||||
}
|
||||
});
|
||||
loop->PostTask(task.forget());
|
||||
CompositorThread()->Dispatch(task.forget());
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
|
|
|
@ -309,7 +309,7 @@ void VRManager::StartTasks() {
|
|||
if (!mTaskTimer) {
|
||||
mTaskInterval = GetOptimalTaskInterval();
|
||||
mTaskTimer = NS_NewTimer();
|
||||
mTaskTimer->SetTarget(CompositorThreadHolder::Loop()->SerialEventTarget());
|
||||
mTaskTimer->SetTarget(CompositorThread());
|
||||
mTaskTimer->InitWithNamedFuncCallback(
|
||||
TaskTimerCallback, this, mTaskInterval,
|
||||
nsITimer::TYPE_REPEATING_PRECISE_CAN_SKIP,
|
||||
|
@ -1380,7 +1380,7 @@ void VRManager::SubmitFrame(VRLayerParent* aLayer,
|
|||
mSubmitThread->Start();
|
||||
mSubmitThread->PostTask(task.forget());
|
||||
#else
|
||||
CompositorThreadHolder::Loop()->PostTask(task.forget());
|
||||
CompositorThread()->Dispatch(task.forget());
|
||||
#endif // defined(MOZ_WIDGET_ANDROID)
|
||||
}
|
||||
}
|
||||
|
@ -1514,10 +1514,8 @@ void VRManager::SubmitFrameInternal(const layers::SurfaceDescriptor& aTexture,
|
|||
* frames to continue at a lower refresh rate until frame submission
|
||||
* succeeds again.
|
||||
*/
|
||||
MessageLoop* loop = CompositorThreadHolder::Loop();
|
||||
|
||||
loop->PostTask(NewRunnableMethod("gfx::VRManager::StartFrame", this,
|
||||
&VRManager::StartFrame));
|
||||
CompositorThread()->Dispatch(NewRunnableMethod("gfx::VRManager::StartFrame",
|
||||
this, &VRManager::StartFrame));
|
||||
#elif defined(MOZ_WIDGET_ANDROID)
|
||||
// We are already in the CompositorThreadHolder event loop on Android.
|
||||
StartFrame();
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "VRThread.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsThreadManager.h"
|
||||
#include "nsThread.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "VRManager.h"
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ void VRGPUChild::Shutdown() {
|
|||
|
||||
void VRGPUChild::ActorDestroy(ActorDestroyReason aWhy) {
|
||||
VRManager* vm = VRManager::Get();
|
||||
mozilla::layers::CompositorThreadHolder::Loop()->PostTask(
|
||||
mozilla::layers::CompositorThread()->Dispatch(
|
||||
NewRunnableMethod("VRGPUChild::ActorDestroy", vm, &VRManager::Shutdown));
|
||||
|
||||
mClosed = true;
|
||||
|
|
|
@ -40,7 +40,6 @@ void ReleaseVRManagerParentSingleton() { sVRManagerParentSingleton = nullptr; }
|
|||
|
||||
VRManagerChild::VRManagerChild()
|
||||
: mRuntimeCapabilities(VRDisplayCapabilityFlags::Cap_None),
|
||||
mMessageLoop(MessageLoop::current()),
|
||||
mFrameRequestCallbackCounter(0),
|
||||
mWaitingForEnumeration(false),
|
||||
mBackend(layers::LayersBackend::LAYERS_NONE) {
|
||||
|
@ -112,8 +111,7 @@ void VRManagerChild::InitSameProcess() {
|
|||
sVRManagerChildSingleton = new VRManagerChild();
|
||||
sVRManagerParentSingleton = VRManagerParent::CreateSameProcess();
|
||||
sVRManagerChildSingleton->Open(sVRManagerParentSingleton->GetIPCChannel(),
|
||||
CompositorThreadHolder::Loop(),
|
||||
mozilla::ipc::ChildSide);
|
||||
CompositorThread(), mozilla::ipc::ChildSide);
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
|
|
@ -158,8 +158,6 @@ class VRManagerChild : public PVRManagerChild {
|
|||
bool mDisplaysInitialized;
|
||||
nsTArray<uint64_t> mNavigatorCallbacks;
|
||||
|
||||
MessageLoop* mMessageLoop;
|
||||
|
||||
struct XRFrameRequest {
|
||||
XRFrameRequest(mozilla::dom::FrameRequestCallback& aCallback,
|
||||
int32_t aHandle)
|
||||
|
|
|
@ -72,13 +72,12 @@ void VRManagerParent::UnregisterFromManager() {
|
|||
|
||||
/* static */
|
||||
bool VRManagerParent::CreateForContent(Endpoint<PVRManagerParent>&& aEndpoint) {
|
||||
MessageLoop* loop = CompositorThreadHolder::Loop();
|
||||
if (!loop) {
|
||||
if (!CompositorThread()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RefPtr<VRManagerParent> vmp = new VRManagerParent(aEndpoint.OtherPid(), true);
|
||||
loop->PostTask(NewRunnableMethod<Endpoint<PVRManagerParent>&&>(
|
||||
CompositorThread()->Dispatch(NewRunnableMethod<Endpoint<PVRManagerParent>&&>(
|
||||
"gfx::VRManagerParent::Bind", vmp, &VRManagerParent::Bind,
|
||||
std::move(aEndpoint)));
|
||||
|
||||
|
@ -102,12 +101,11 @@ void VRManagerParent::RegisterVRManagerInCompositorThread(
|
|||
|
||||
/*static*/
|
||||
VRManagerParent* VRManagerParent::CreateSameProcess() {
|
||||
MessageLoop* loop = CompositorThreadHolder::Loop();
|
||||
RefPtr<VRManagerParent> vmp =
|
||||
new VRManagerParent(base::GetCurrentProcId(), false);
|
||||
vmp->mCompositorThreadHolder = CompositorThreadHolder::GetSingleton();
|
||||
vmp->mSelfRef = vmp;
|
||||
loop->PostTask(
|
||||
CompositorThread()->Dispatch(
|
||||
NewRunnableFunction("RegisterVRManagerIncompositorThreadRunnable",
|
||||
RegisterVRManagerInCompositorThread, vmp.get()));
|
||||
return vmp.get();
|
||||
|
@ -115,13 +113,11 @@ VRManagerParent* VRManagerParent::CreateSameProcess() {
|
|||
|
||||
bool VRManagerParent::CreateForGPUProcess(
|
||||
Endpoint<PVRManagerParent>&& aEndpoint) {
|
||||
MessageLoop* loop = CompositorThreadHolder::Loop();
|
||||
|
||||
RefPtr<VRManagerParent> vmp =
|
||||
new VRManagerParent(aEndpoint.OtherPid(), false);
|
||||
vmp->mCompositorThreadHolder = CompositorThreadHolder::GetSingleton();
|
||||
vmp->mSelfRef = vmp;
|
||||
loop->PostTask(NewRunnableMethod<Endpoint<PVRManagerParent>&&>(
|
||||
CompositorThread()->Dispatch(NewRunnableMethod<Endpoint<PVRManagerParent>&&>(
|
||||
"gfx::VRManagerParent::Bind", vmp, &VRManagerParent::Bind,
|
||||
std::move(aEndpoint)));
|
||||
return true;
|
||||
|
@ -130,7 +126,7 @@ bool VRManagerParent::CreateForGPUProcess(
|
|||
/*static*/
|
||||
void VRManagerParent::Shutdown() {
|
||||
ReleaseVRManagerParentSingleton();
|
||||
CompositorThreadHolder::Loop()->PostTask(NS_NewRunnableFunction(
|
||||
CompositorThread()->Dispatch(NS_NewRunnableFunction(
|
||||
"VRManagerParent::Shutdown",
|
||||
[]() -> void { VRManagerParent::ShutdownInternal(); }));
|
||||
}
|
||||
|
|
|
@ -469,7 +469,7 @@ void RenderThread::UpdateAndRender(
|
|||
|
||||
auto& renderer = it->second;
|
||||
|
||||
layers::CompositorThreadHolder::Loop()->PostTask(
|
||||
layers::CompositorThread()->Dispatch(
|
||||
NewRunnableFunction("NotifyDidStartRenderRunnable", &NotifyDidStartRender,
|
||||
renderer->GetCompositorBridge()));
|
||||
|
||||
|
@ -487,7 +487,7 @@ void RenderThread::UpdateAndRender(
|
|||
TimeStamp end = TimeStamp::Now();
|
||||
RefPtr<const WebRenderPipelineInfo> info = renderer->FlushPipelineInfo();
|
||||
|
||||
layers::CompositorThreadHolder::Loop()->PostTask(
|
||||
layers::CompositorThread()->Dispatch(
|
||||
NewRunnableFunction("NotifyDidRenderRunnable", &NotifyDidRender,
|
||||
renderer->GetCompositorBridge(), info, aStartId,
|
||||
aStartTime, start, end, aRender, stats));
|
||||
|
@ -821,7 +821,7 @@ void RenderThread::HandleWebRenderError(WebRenderError aError) {
|
|||
return;
|
||||
}
|
||||
|
||||
layers::CompositorThreadHolder::Loop()->PostTask(NewRunnableFunction(
|
||||
layers::CompositorThread()->Dispatch(NewRunnableFunction(
|
||||
"DoNotifyWebRenderErrorRunnable", &DoNotifyWebRenderError, aError));
|
||||
{
|
||||
MutexAutoLock lock(mRenderTextureMapLock);
|
||||
|
@ -1114,7 +1114,7 @@ void wr_finished_scene_build(mozilla::wr::WrWindowId aWindowId,
|
|||
for (size_t i = 0; i < aDocumentIdsCount; ++i) {
|
||||
renderRoots[i] = wr::RenderRootFromId(aDocumentIds[i]);
|
||||
}
|
||||
layers::CompositorThreadHolder::Loop()->PostTask(
|
||||
layers::CompositorThread()->Dispatch(
|
||||
NewRunnableFunction("NotifyDidSceneBuild", &NotifyDidSceneBuild, cbp,
|
||||
std::move(renderRoots), info));
|
||||
}
|
||||
|
|
|
@ -200,7 +200,7 @@ bool RendererOGL::EnsureAsyncScreenshot() {
|
|||
return true;
|
||||
}
|
||||
if (!mDisableNativeCompositor) {
|
||||
layers::CompositorThreadHolder::Loop()->PostTask(
|
||||
layers::CompositorThread()->Dispatch(
|
||||
NewRunnableFunction("DoWebRenderDisableNativeCompositorRunnable",
|
||||
&DoWebRenderDisableNativeCompositor, mBridge));
|
||||
|
||||
|
@ -219,7 +219,7 @@ void RendererOGL::CheckGraphicsResetStatus() {
|
|||
if (gl->IsSupported(gl::GLFeature::robustness)) {
|
||||
GLenum resetStatus = gl->fGetGraphicsResetStatus();
|
||||
if (resetStatus == LOCAL_GL_PURGED_CONTEXT_RESET_NV) {
|
||||
layers::CompositorThreadHolder::Loop()->PostTask(
|
||||
layers::CompositorThread()->Dispatch(
|
||||
NewRunnableFunction("DoNotifyWebRenderContextPurgeRunnable",
|
||||
&DoNotifyWebRenderContextPurge, mBridge));
|
||||
}
|
||||
|
|
|
@ -54,7 +54,6 @@ T MinIgnoreZero(const T& a, const T& b);
|
|||
|
||||
class VideoStreamFactory;
|
||||
class WebrtcAudioConduit;
|
||||
class nsThread;
|
||||
|
||||
// Interface of external video encoder for WebRTC.
|
||||
class WebrtcVideoEncoder : public VideoEncoder, public webrtc::VideoEncoder {};
|
||||
|
|
|
@ -216,7 +216,7 @@ void CompositorWidgetParent::UpdateCompositorWnd(const HWND aCompositorWnd,
|
|||
SendUpdateCompositorWnd(reinterpret_cast<WindowsHandle>(aCompositorWnd),
|
||||
reinterpret_cast<WindowsHandle>(aParentWnd))
|
||||
->Then(
|
||||
layers::CompositorThreadHolder::Loop()->SerialEventTarget(), __func__,
|
||||
layers::CompositorThread(), __func__,
|
||||
[self](const bool& aSuccess) {
|
||||
if (aSuccess && self->mRootLayerTreeID.isSome()) {
|
||||
self->mSetParentCompleted = true;
|
||||
|
|
Загрузка…
Ссылка в новой задаче