Bug 1634253 - P6. Remove MessageLoop use from gfx. r=kats,mattwoodrow

Differential Revision: https://phabricator.services.mozilla.com/D73825
This commit is contained in:
Jean-Yves Avenard 2020-05-07 08:04:53 +00:00
Родитель 444a610296
Коммит f304da03ac
45 изменённых файлов: 273 добавлений и 355 удалений

Просмотреть файл

@ -17,6 +17,7 @@ Cameras IPC
ChainedPipePump ChainedPipePump
ChainedPipeRecv ChainedPipeRecv
Checker Test Checker Test
Compositor
Cookie Cookie
CrashRep Inject CrashRep Inject
DDMediaLogs DDMediaLogs
@ -41,6 +42,7 @@ IMAP
IPC Launch IPC Launch
IPDL Background IPDL Background
IdentityCrypto IdentityCrypto
ImageBridgeChld
LS Thread LS Thread
LayerScope LayerScope
MDCDMThread MDCDMThread

Просмотреть файл

@ -71,7 +71,7 @@ void MediaSystemResourceManager::Init() {
barrier.NotifyAll(); barrier.NotifyAll();
}); });
imageBridge->GetMessageLoop()->PostTask(runnable.forget()); imageBridge->GetThread()->Dispatch(runnable.forget());
// should stop the thread until done. // should stop the thread until done.
while (!done) { while (!done) {
@ -178,7 +178,7 @@ void MediaSystemResourceManager::Acquire(MediaSystemResourceClient* aClient) {
return; return;
} }
aClient->mResourceState = MediaSystemResourceClient::RESOURCE_STATE_WAITING; aClient->mResourceState = MediaSystemResourceClient::RESOURCE_STATE_WAITING;
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask( ImageBridgeChild::GetSingleton()->GetThread()->Dispatch(
NewRunnableMethod<uint32_t>("MediaSystemResourceManager::DoAcquire", this, NewRunnableMethod<uint32_t>("MediaSystemResourceManager::DoAcquire", this,
&MediaSystemResourceManager::DoAcquire, &MediaSystemResourceManager::DoAcquire,
aClient->mId)); aClient->mId));
@ -220,7 +220,7 @@ bool MediaSystemResourceManager::AcquireSyncNoWait(
aClient->mResourceState = MediaSystemResourceClient::RESOURCE_STATE_WAITING; aClient->mResourceState = MediaSystemResourceClient::RESOURCE_STATE_WAITING;
} }
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask( ImageBridgeChild::GetSingleton()->GetThread()->Dispatch(
NewRunnableMethod<uint32_t>("MediaSystemResourceManager::DoAcquire", this, NewRunnableMethod<uint32_t>("MediaSystemResourceManager::DoAcquire", this,
&MediaSystemResourceManager::DoAcquire, &MediaSystemResourceManager::DoAcquire,
aClient->mId)); aClient->mId));
@ -282,7 +282,7 @@ void MediaSystemResourceManager::ReleaseResource(
aClient->mResourceState = MediaSystemResourceClient::RESOURCE_STATE_END; aClient->mResourceState = MediaSystemResourceClient::RESOURCE_STATE_END;
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask( ImageBridgeChild::GetSingleton()->GetThread()->Dispatch(
NewRunnableMethod<uint32_t>( NewRunnableMethod<uint32_t>(
"MediaSystemResourceManager::DoRelease", this, "MediaSystemResourceManager::DoRelease", this,
&MediaSystemResourceManager::DoRelease, aClient->mId)); &MediaSystemResourceManager::DoRelease, aClient->mId));
@ -304,7 +304,7 @@ void MediaSystemResourceManager::RecvResponse(uint32_t aId, bool aSuccess) {
void MediaSystemResourceManager::HandleAcquireResult(uint32_t aId, void MediaSystemResourceManager::HandleAcquireResult(uint32_t aId,
bool aSuccess) { bool aSuccess) {
if (!InImageBridgeChildThread()) { if (!InImageBridgeChildThread()) {
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask( ImageBridgeChild::GetSingleton()->GetThread()->Dispatch(
NewRunnableMethod<uint32_t, bool>( NewRunnableMethod<uint32_t, bool>(
"MediaSystemResourceManager::HandleAcquireResult", this, "MediaSystemResourceManager::HandleAcquireResult", this,
&MediaSystemResourceManager::HandleAcquireResult, aId, aSuccess)); &MediaSystemResourceManager::HandleAcquireResult, aId, aSuccess));

Просмотреть файл

@ -551,7 +551,7 @@ class AsyncPluginSurfaceManager : public IGPUVideoSurfaceManager {
if (!InImageBridgeChildThread()) { if (!InImageBridgeChildThread()) {
SynchronousTask task("AsyncPluginSurfaceManager readback sync"); SynchronousTask task("AsyncPluginSurfaceManager readback sync");
RefPtr<gfx::SourceSurface> result; RefPtr<gfx::SourceSurface> result;
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask( ImageBridgeChild::GetSingleton()->GetThread()->Dispatch(
NewRunnableFunction("AsyncPluginSurfaceManager readback", NewRunnableFunction("AsyncPluginSurfaceManager readback",
&DoSyncReadback, &pluginSD, &result, &task)); &DoSyncReadback, &pluginSD, &result, &task));
task.Wait(); task.Wait();
@ -565,7 +565,7 @@ class AsyncPluginSurfaceManager : public IGPUVideoSurfaceManager {
const SurfaceDescriptorGPUVideo& aSD) override { const SurfaceDescriptorGPUVideo& aSD) override {
SurfaceDescriptorPlugin pluginSD = aSD; SurfaceDescriptorPlugin pluginSD = aSD;
if (!InImageBridgeChildThread()) { if (!InImageBridgeChildThread()) {
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask( ImageBridgeChild::GetSingleton()->GetThread()->Dispatch(
NewRunnableFunction("AsyncPluginSurfaceManager dealloc", &DoDealloc, NewRunnableFunction("AsyncPluginSurfaceManager dealloc", &DoDealloc,
&pluginSD)); &pluginSD));
return; return;
@ -739,7 +739,7 @@ mozilla::ipc::IPCResult PluginInstanceParent::RecvInitDXGISurface(
// render to. // render to.
SurfaceDescriptorPlugin sd; SurfaceDescriptorPlugin sd;
SynchronousTask task("SendMakeAsyncPluginSurfaces sync"); SynchronousTask task("SendMakeAsyncPluginSurfaces sync");
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask( ImageBridgeChild::GetSingleton()->GetThread()->Dispatch(
NewRunnableFunction("SendingMakeAsyncPluginSurfaces", &InitDXGISurface, NewRunnableFunction("SendingMakeAsyncPluginSurfaces", &InitDXGISurface,
format, size, &sd, &task)); format, size, &sd, &task));
task.Wait(); task.Wait();
@ -781,9 +781,8 @@ mozilla::ipc::IPCResult PluginInstanceParent::RecvFinalizeDXGISurface(
// Release the plugin surface but keep the display surface since it may // Release the plugin surface but keep the display surface since it may
// still be displayed. Also let the display surface know that it should // still be displayed. Also let the display surface know that it should
// not receive further requests to copy from the plugin surface. // not receive further requests to copy from the plugin surface.
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask( ImageBridgeChild::GetSingleton()->GetThread()->Dispatch(NewRunnableFunction(
NewRunnableFunction("SendingRemoveAsyncPluginSurface", "SendingRemoveAsyncPluginSurface", &FinalizeDXGISurface, asi.mSD));
&FinalizeDXGISurface, asi.mSD));
mAsyncSurfaceMap.remove(asiIt); mAsyncSurfaceMap.remove(asiIt);
#endif #endif
@ -897,9 +896,8 @@ mozilla::ipc::IPCResult PluginInstanceParent::RecvShowDirectDXGISurface(
// Tell the ImageBridge to copy from the plugin surface to the display surface // Tell the ImageBridge to copy from the plugin surface to the display surface
SynchronousTask task("SendUpdateAsyncPluginSurface sync"); SynchronousTask task("SendUpdateAsyncPluginSurface sync");
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask( ImageBridgeChild::GetSingleton()->GetThread()->Dispatch(NewRunnableFunction(
NewRunnableFunction("SendingUpdateAsyncPluginSurface", &CopyDXGISurface, "SendingUpdateAsyncPluginSurface", &CopyDXGISurface, asi.mSD, &task));
asi.mSD, &task));
task.Wait(); task.Wait();
// Make sure we have an ImageContainer for SetCurrentImage. // Make sure we have an ImageContainer for SetCurrentImage.

Просмотреть файл

@ -20,7 +20,7 @@ RefPtr<VsyncBridgeParent> VsyncBridgeParent::Start(
RefPtr<Runnable> task = NewRunnableMethod<Endpoint<PVsyncBridgeParent>&&>( RefPtr<Runnable> task = NewRunnableMethod<Endpoint<PVsyncBridgeParent>&&>(
"gfx::VsyncBridgeParent::Open", parent, &VsyncBridgeParent::Open, "gfx::VsyncBridgeParent::Open", parent, &VsyncBridgeParent::Open,
std::move(aEndpoint)); std::move(aEndpoint));
CompositorThreadHolder::Loop()->PostTask(task.forget()); CompositorThread()->Dispatch(task.forget());
return parent; return parent;
} }
@ -48,10 +48,10 @@ mozilla::ipc::IPCResult VsyncBridgeParent::RecvNotifyVsync(
} }
void VsyncBridgeParent::Shutdown() { void VsyncBridgeParent::Shutdown() {
MessageLoop* ccloop = CompositorThreadHolder::Loop(); if (!CompositorThreadHolder::IsInCompositorThread()) {
if (MessageLoop::current() != ccloop) { CompositorThread()->Dispatch(
ccloop->PostTask(NewRunnableMethod("gfx::VsyncBridgeParent::ShutdownImpl", NewRunnableMethod("gfx::VsyncBridgeParent::ShutdownImpl", this,
this, &VsyncBridgeParent::ShutdownImpl)); &VsyncBridgeParent::ShutdownImpl));
return; return;
} }

Просмотреть файл

@ -111,7 +111,7 @@ static void CheckTexturesForUnlock() {
void TextureSync::DispatchCheckTexturesForUnlock() { void TextureSync::DispatchCheckTexturesForUnlock() {
RefPtr<Runnable> task = RefPtr<Runnable> task =
NS_NewRunnableFunction("CheckTexturesForUnlock", &CheckTexturesForUnlock); NS_NewRunnableFunction("CheckTexturesForUnlock", &CheckTexturesForUnlock);
CompositorThreadHolder::Loop()->PostTask(task.forget()); CompositorThread()->Dispatch(task.forget());
} }
void TextureSync::HandleWaitForTexturesMessage(MachReceiveMessage* rmsg, void TextureSync::HandleWaitForTexturesMessage(MachReceiveMessage* rmsg,

Просмотреть файл

@ -373,8 +373,8 @@ void APZUpdater::RunOnUpdaterThread(LayersId aLayersId,
return; return;
} }
if (MessageLoop* loop = CompositorThreadHolder::Loop()) { if (CompositorThread()) {
loop->PostTask(task.forget()); CompositorThread()->Dispatch(task.forget());
} else { } else {
// Could happen during startup // Could happen during startup
NS_WARNING("Dropping task posted to updater thread"); NS_WARNING("Dropping task posted to updater thread");

Просмотреть файл

@ -169,8 +169,7 @@ TextureClientRecycleAllocator* CompositableClient::GetTextureClientRecycler() {
barrier.NotifyAll(); barrier.NotifyAll();
}); });
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask( ImageBridgeChild::GetSingleton()->GetThread()->Dispatch(runnable.forget());
runnable.forget());
// should stop the thread until done. // should stop the thread until done.
while (!done) { while (!done) {

Просмотреть файл

@ -5,57 +5,61 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/layers/TextureClient.h" #include "mozilla/layers/TextureClient.h"
#include <stdint.h> // for uint8_t, uint32_t, etc #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 "gfx2DGlue.h"
#include "gfxPlatform.h" // for gfxPlatform #include "gfxPlatform.h" // for gfxPlatform
#include "MainThreadUtils.h" #include "gfxUtils.h" // for gfxUtils::GetAsLZ4Base64Str
#include "mozilla/Atomics.h" #include "mozilla/Atomics.h"
#include "mozilla/Mutex.h"
#include "mozilla/SchedulerGroup.h" #include "mozilla/SchedulerGroup.h"
#include "mozilla/StaticPrefs_gfx.h" #include "mozilla/StaticPrefs_gfx.h"
#include "mozilla/StaticPrefs_layers.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/gfx/gfxVars.h"
#include "mozilla/ipc/CrossProcessSemaphore.h"
#include "mozilla/ipc/SharedMemory.h" // for SharedMemory, etc #include "mozilla/ipc/SharedMemory.h" // for SharedMemory, etc
#include "mozilla/layers/CompositableForwarder.h" #include "mozilla/layers/CompositableForwarder.h"
#include "mozilla/layers/ISurfaceAllocator.h" #include "mozilla/layers/ISurfaceAllocator.h"
#include "mozilla/layers/ImageBridgeChild.h" #include "mozilla/layers/ImageBridgeChild.h"
#include "mozilla/layers/ImageDataSerializer.h" #include "mozilla/layers/ImageDataSerializer.h"
#include "mozilla/layers/PTextureChild.h"
#include "mozilla/layers/PaintThread.h" #include "mozilla/layers/PaintThread.h"
#include "mozilla/layers/ShadowLayers.h"
#include "mozilla/layers/TextureClientOGL.h"
#include "mozilla/layers/TextureClientRecycleAllocator.h" #include "mozilla/layers/TextureClientRecycleAllocator.h"
#include "mozilla/layers/TextureRecorded.h" #include "mozilla/layers/TextureRecorded.h"
#include "mozilla/Mutex.h"
#include "nsDebug.h" // for NS_ASSERTION, NS_WARNING, etc #include "nsDebug.h" // for NS_ASSERTION, NS_WARNING, etc
#include "nsISerialEventTarget.h"
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc
#include "ImageContainer.h" // for PlanarYCbCrData, etc #include "nsPrintfCString.h" // for nsPrintfCString
#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"
#ifdef XP_WIN #ifdef XP_WIN
# include "gfx2DGlue.h"
# include "gfxWindowsPlatform.h"
# include "mozilla/gfx/DeviceManagerDx.h" # include "mozilla/gfx/DeviceManagerDx.h"
# include "mozilla/layers/TextureD3D11.h" # include "mozilla/layers/TextureD3D11.h"
# include "mozilla/layers/TextureDIB.h" # include "mozilla/layers/TextureDIB.h"
# include "gfxWindowsPlatform.h"
# include "gfx2DGlue.h"
#endif #endif
#ifdef MOZ_X11 #ifdef MOZ_X11
# include "mozilla/layers/TextureClientX11.h"
# include "GLXLibrary.h" # include "GLXLibrary.h"
# include "mozilla/layers/TextureClientX11.h"
#endif #endif
#ifdef MOZ_WAYLAND #ifdef MOZ_WAYLAND
# include <gtk/gtkx.h> # include <gtk/gtkx.h>
# include "mozilla/widget/nsWaylandDisplay.h"
# include "mozilla/layers/WaylandDMABUFTextureClientOGL.h"
# include "gfxPlatformGtk.h" # include "gfxPlatformGtk.h"
# include "mozilla/layers/WaylandDMABUFTextureClientOGL.h"
# include "mozilla/widget/nsWaylandDisplay.h"
#endif #endif
#ifdef XP_MACOSX #ifdef XP_MACOSX
@ -490,12 +494,12 @@ void DeallocateTextureClient(TextureDeallocParams params) {
} }
TextureChild* actor = params.actor; TextureChild* actor = params.actor;
MessageLoop* ipdlMsgLoop = nullptr; nsCOMPtr<nsISerialEventTarget> ipdlThread;
if (params.allocator) { if (params.allocator) {
ipdlMsgLoop = params.allocator->GetMessageLoop(); ipdlThread = params.allocator->GetThread();
if (!ipdlMsgLoop) { if (!ipdlThread) {
// An allocator with no message loop means we are too late in the shutdown // An allocator with no thread means we are too late in the shutdown
// sequence. // sequence.
gfxCriticalError() << "Texture deallocated too late during shutdown"; gfxCriticalError() << "Texture deallocated too late during shutdown";
return; return;
@ -503,19 +507,19 @@ void DeallocateTextureClient(TextureDeallocParams params) {
} }
// First make sure that the work is happening on the IPDL thread. // First make sure that the work is happening on the IPDL thread.
if (ipdlMsgLoop && MessageLoop::current() != ipdlMsgLoop) { if (ipdlThread && !ipdlThread->IsOnCurrentThread()) {
if (params.syncDeallocation) { if (params.syncDeallocation) {
bool done = false; bool done = false;
ReentrantMonitor barrier("DeallocateTextureClient"); ReentrantMonitor barrier("DeallocateTextureClient");
ReentrantMonitorAutoEnter autoMon(barrier); ReentrantMonitorAutoEnter autoMon(barrier);
ipdlMsgLoop->PostTask(NewRunnableFunction( ipdlThread->Dispatch(NewRunnableFunction(
"DeallocateTextureClientSyncProxyRunnable", "DeallocateTextureClientSyncProxyRunnable",
DeallocateTextureClientSyncProxy, params, &barrier, &done)); DeallocateTextureClientSyncProxy, params, &barrier, &done));
while (!done) { while (!done) {
barrier.Wait(); barrier.Wait();
} }
} else { } else {
ipdlMsgLoop->PostTask(NewRunnableFunction( ipdlThread->Dispatch(NewRunnableFunction(
"DeallocateTextureClientRunnable", DeallocateTextureClient, params)); "DeallocateTextureClientRunnable", DeallocateTextureClient, params));
} }
// The work has been forwarded to the IPDL thread, we are done. // 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 // Below this line, we are either in the IPDL thread or ther is no IPDL
// thread anymore. // thread anymore.
if (!ipdlMsgLoop) { if (!ipdlThread) {
// If we don't have a message loop we can't know for sure that we are in // If we don't have a thread we can't know for sure that we are in
// the IPDL thread and use the LayersIPCChannel. // the IPDL thread and use the LayersIPCChannel.
// This should ideally not happen outside of gtest, but some shutdown // This should ideally not happen outside of gtest, but some shutdown
// raciness could put us in this situation. // raciness could put us in this situation.
@ -978,15 +982,14 @@ static void CancelTextureClientNotifyNotUsed(uint64_t aTextureId,
if (!aAllocator) { if (!aAllocator) {
return; return;
} }
MessageLoop* msgLoop = nullptr; nsCOMPtr<nsISerialEventTarget> thread = aAllocator->GetThread();
msgLoop = aAllocator->GetMessageLoop(); if (!thread) {
if (!msgLoop) {
return; return;
} }
if (MessageLoop::current() == msgLoop) { if (thread->IsOnCurrentThread()) {
aAllocator->CancelWaitForNotifyNotUsed(aTextureId); aAllocator->CancelWaitForNotifyNotUsed(aTextureId);
} else { } else {
msgLoop->PostTask(NewRunnableFunction( thread->Dispatch(NewRunnableFunction(
"CancelTextureClientNotifyNotUsedRunnable", "CancelTextureClientNotifyNotUsedRunnable",
CancelTextureClientNotifyNotUsed, aTextureId, aAllocator)); CancelTextureClientNotifyNotUsed, aTextureId, aAllocator));
} }
@ -1017,9 +1020,8 @@ void TextureClient::SetRecycleAllocator(
} }
bool TextureClient::InitIPDLActor(CompositableForwarder* aForwarder) { bool TextureClient::InitIPDLActor(CompositableForwarder* aForwarder) {
MOZ_ASSERT(aForwarder && MOZ_ASSERT(aForwarder && aForwarder->GetTextureForwarder()->GetThread() ==
aForwarder->GetTextureForwarder()->GetMessageLoop() == mAllocator->GetThread());
mAllocator->GetMessageLoop());
if (mActor && !mActor->IPCOpen()) { if (mActor && !mActor->IPCOpen()) {
return false; return false;
@ -1112,8 +1114,8 @@ bool TextureClient::InitIPDLActor(CompositableForwarder* aForwarder) {
bool TextureClient::InitIPDLActor(KnowsCompositor* aKnowsCompositor) { bool TextureClient::InitIPDLActor(KnowsCompositor* aKnowsCompositor) {
MOZ_ASSERT(aKnowsCompositor && MOZ_ASSERT(aKnowsCompositor &&
aKnowsCompositor->GetTextureForwarder()->GetMessageLoop() == aKnowsCompositor->GetTextureForwarder()->GetThread() ==
mAllocator->GetMessageLoop()); mAllocator->GetThread());
TextureForwarder* fwd = aKnowsCompositor->GetTextureForwarder(); TextureForwarder* fwd = aKnowsCompositor->GetTextureForwarder();
if (mActor && !mActor->mDestroyed) { if (mActor && !mActor->mDestroyed) {
CompositableForwarder* currentFwd = mActor->mCompositableForwarder; CompositableForwarder* currentFwd = mActor->mCompositableForwarder;

Просмотреть файл

@ -153,7 +153,7 @@ already_AddRefed<TextureClient> TextureClientRecycleAllocator::CreateOrRecycle(
new TextureClientReleaseTask(textureHolder->GetTextureClient()); new TextureClientReleaseTask(textureHolder->GetTextureClient());
textureHolder->ClearTextureClient(); textureHolder->ClearTextureClient();
textureHolder = nullptr; textureHolder = nullptr;
mKnowsCompositor->GetTextureForwarder()->GetMessageLoop()->PostTask( mKnowsCompositor->GetTextureForwarder()->GetThread()->Dispatch(
task.forget()); task.forget());
} else { } else {
textureHolder->GetTextureClient()->RecycleTexture( textureHolder->GetTextureClient()->RecycleTexture(

Просмотреть файл

@ -34,8 +34,8 @@ CanvasThreadHolder::CanvasThreadHolder(
CanvasThreadHolder::~CanvasThreadHolder() { CanvasThreadHolder::~CanvasThreadHolder() {
// Note we can't just use NS_IsInCompositorThread() here because // Note we can't just use NS_IsInCompositorThread() here because
// sCompositorThreadHolder might have already gone. // sCompositorThreadHolder might have already gone.
MOZ_ASSERT(mCompositorThreadKeepAlive->GetCompositorThread()->thread_id() == MOZ_ASSERT(
PlatformThread::CurrentId()); mCompositorThreadKeepAlive->GetCompositorThread()->IsOnCurrentThread());
} }
/* static */ /* static */
@ -75,8 +75,7 @@ void CanvasThreadHolder::StaticRelease(
RefPtr<CanvasThreadHolder> threadHolder = aCanvasThreadHolder; RefPtr<CanvasThreadHolder> threadHolder = aCanvasThreadHolder;
// Note we can't just use NS_IsInCompositorThread() here because // Note we can't just use NS_IsInCompositorThread() here because
// sCompositorThreadHolder might have already gone. // sCompositorThreadHolder might have already gone.
MOZ_ASSERT(threadHolder->mCompositorThreadKeepAlive->GetCompositorThread() MOZ_ASSERT(threadHolder->mCompositorThreadKeepAlive->IsInCompositorThread());
->thread_id() == PlatformThread::CurrentId());
threadHolder = nullptr; threadHolder = nullptr;
auto lockedCanvasThreadHolder = sCanvasThreadHolder.Lock(); auto lockedCanvasThreadHolder = sCanvasThreadHolder.Lock();
@ -89,12 +88,11 @@ void CanvasThreadHolder::StaticRelease(
void CanvasThreadHolder::ReleaseOnCompositorThread( void CanvasThreadHolder::ReleaseOnCompositorThread(
already_AddRefed<CanvasThreadHolder> aCanvasThreadHolder) { already_AddRefed<CanvasThreadHolder> aCanvasThreadHolder) {
auto lockedCanvasThreadHolder = sCanvasThreadHolder.Lock(); auto lockedCanvasThreadHolder = sCanvasThreadHolder.Lock();
base::Thread* compositorThread = lockedCanvasThreadHolder.ref()
lockedCanvasThreadHolder.ref() ->mCompositorThreadKeepAlive->GetCompositorThread()
->mCompositorThreadKeepAlive->GetCompositorThread(); ->Dispatch(NewRunnableFunction("CanvasThreadHolder::StaticRelease",
compositorThread->message_loop()->PostTask(NewRunnableFunction( CanvasThreadHolder::StaticRelease,
"CanvasThreadHolder::StaticRelease", CanvasThreadHolder::StaticRelease, std::move(aCanvasThreadHolder)));
std::move(aCanvasThreadHolder)));
} }
/* static */ /* static */

Просмотреть файл

@ -9,7 +9,6 @@
#include "mozilla/layers/CompositorThread.h" #include "mozilla/layers/CompositorThread.h"
#include <stddef.h> // for size_t #include <stddef.h> // for size_t
#include "ClientLayerManager.h" // for ClientLayerManager #include "ClientLayerManager.h" // for ClientLayerManager
#include "base/message_loop.h" // for MessageLoop
#include "base/task.h" // for NewRunnableMethod, etc #include "base/task.h" // for NewRunnableMethod, etc
#include "mozilla/StaticPrefs_layers.h" #include "mozilla/StaticPrefs_layers.h"
#include "mozilla/layers/CompositorManagerChild.h" #include "mozilla/layers/CompositorManagerChild.h"
@ -36,7 +35,6 @@
#include "nsDebug.h" // for NS_WARNING #include "nsDebug.h" // for NS_WARNING
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc
#include "nsTArray.h" // for nsTArray, nsTArray_Impl #include "nsTArray.h" // for nsTArray, nsTArray_Impl
#include "nsXULAppAPI.h" // for XRE_GetIOMessageLoop, etc
#include "FrameLayerBuilder.h" #include "FrameLayerBuilder.h"
#include "mozilla/dom/BrowserChild.h" #include "mozilla/dom/BrowserChild.h"
#include "mozilla/dom/BrowserParent.h" #include "mozilla/dom/BrowserParent.h"
@ -85,7 +83,7 @@ CompositorBridgeChild::CompositorBridgeChild(CompositorManagerChild* aManager)
mCanSend(false), mCanSend(false),
mActorDestroyed(false), mActorDestroyed(false),
mFwdTransactionId(0), mFwdTransactionId(0),
mMessageLoop(MessageLoop::current()), mThread(NS_GetCurrentThread()),
mProcessToken(0), mProcessToken(0),
mSectionAllocator(nullptr), mSectionAllocator(nullptr),
mPaintLock("CompositorBridgeChild.mPaintLock"), mPaintLock("CompositorBridgeChild.mPaintLock"),
@ -168,7 +166,7 @@ void CompositorBridgeChild::Destroy() {
// We may have already called destroy but still have lingering references // We may have already called destroy but still have lingering references
// or CompositorBridgeChild::ActorDestroy was called. Ensure that we do our // or CompositorBridgeChild::ActorDestroy was called. Ensure that we do our
// post destroy clean up no matter what. It is safe to call multiple times. // post destroy clean up no matter what. It is safe to call multiple times.
MessageLoop::current()->PostTask( NS_GetCurrentThread()->Dispatch(
NewRunnableMethod("CompositorBridgeChild::PrepareFinalDestroy", selfRef, NewRunnableMethod("CompositorBridgeChild::PrepareFinalDestroy", selfRef,
&CompositorBridgeChild::PrepareFinalDestroy)); &CompositorBridgeChild::PrepareFinalDestroy));
return; return;
@ -225,12 +223,12 @@ void CompositorBridgeChild::Destroy() {
// CompositorBridgeParent to the CompositorBridgeChild (e.g. caused by the // CompositorBridgeParent to the CompositorBridgeChild (e.g. caused by the
// destruction of shared memory). We need to ensure this gets processed 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 // CompositorBridgeChild before it gets destroyed. It suffices to ensure that
// events already in the MessageLoop get processed before the // events already in the thread get processed before the
// CompositorBridgeChild is destroyed, so we add a task to the MessageLoop to // CompositorBridgeChild is destroyed, so we add a task to the thread to
// handle compositor destruction. // handle compositor destruction.
// From now on we can't send any message message. // From now on we can't send any message message.
MessageLoop::current()->PostTask( NS_GetCurrentThread()->Dispatch(
NewRunnableMethod("CompositorBridgeChild::PrepareFinalDestroy", selfRef, NewRunnableMethod("CompositorBridgeChild::PrepareFinalDestroy", selfRef,
&CompositorBridgeChild::PrepareFinalDestroy)); &CompositorBridgeChild::PrepareFinalDestroy));
} }
@ -470,8 +468,8 @@ mozilla::ipc::IPCResult CompositorBridgeChild::RecvUpdatePluginConfigurations(
#if defined(XP_WIN) #if defined(XP_WIN)
static void ScheduleSendAllPluginsCaptured(CompositorBridgeChild* aThis, static void ScheduleSendAllPluginsCaptured(CompositorBridgeChild* aThis,
MessageLoop* aLoop) { nsISerialEventTarget* aThread) {
aLoop->PostTask(NewNonOwningRunnableMethod( aThread->Dispatch(NewNonOwningRunnableMethod(
"CompositorBridgeChild::SendAllPluginsCaptured", aThis, "CompositorBridgeChild::SendAllPluginsCaptured", aThis,
&CompositorBridgeChild::SendAllPluginsCaptured)); &CompositorBridgeChild::SendAllPluginsCaptured));
} }
@ -483,12 +481,11 @@ mozilla::ipc::IPCResult CompositorBridgeChild::RecvCaptureAllPlugins(
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
nsIWidget::CaptureRegisteredPlugins(aParentWidget); 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. // to make sure that the image updates on that thread have been processed.
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask( ImageBridgeChild::GetSingleton()->GetThread()->Dispatch(NewRunnableFunction(
NewRunnableFunction("ScheduleSendAllPluginsCapturedRunnable", "ScheduleSendAllPluginsCapturedRunnable", &ScheduleSendAllPluginsCaptured,
&ScheduleSendAllPluginsCaptured, this, this, NS_GetCurrentThread()));
MessageLoop::current()));
return IPC_OK(); return IPC_OK();
#else #else
MOZ_ASSERT_UNREACHABLE( MOZ_ASSERT_UNREACHABLE(

Просмотреть файл

@ -200,7 +200,7 @@ class CompositorBridgeChild final : public PCompositorBridgeChild,
void HandleMemoryPressure(); void HandleMemoryPressure();
MessageLoop* GetMessageLoop() const override { return mMessageLoop; } nsISerialEventTarget* GetThread() const override { return mThread; }
base::ProcessId GetParentPid() const override { return OtherPid(); } base::ProcessId GetParentPid() const override { return OtherPid(); }
@ -373,7 +373,7 @@ class CompositorBridgeChild final : public PCompositorBridgeChild,
std::unordered_map<uint64_t, RefPtr<TextureClient>> std::unordered_map<uint64_t, RefPtr<TextureClient>>
mTexturesWaitingNotifyNotUsed; mTexturesWaitingNotifyNotUsed;
MessageLoop* mMessageLoop; nsCOMPtr<nsISerialEventTarget> mThread;
AutoTArray<RefPtr<TextureClientPool>, 2> mTexturePools; AutoTArray<RefPtr<TextureClientPool>, 2> mTexturePools;

Просмотреть файл

@ -14,10 +14,7 @@
#include "apz/src/APZCTreeManager.h" // for APZCTreeManager #include "apz/src/APZCTreeManager.h" // for APZCTreeManager
#include "LayerTransactionParent.h" // for LayerTransactionParent #include "LayerTransactionParent.h" // for LayerTransactionParent
#include "RenderTrace.h" // for RenderTraceLayers #include "RenderTrace.h" // for RenderTraceLayers
#include "base/message_loop.h" // for MessageLoop
#include "base/process.h" // for ProcessId #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 "gfxContext.h" // for gfxContext
#include "gfxPlatform.h" // for gfxPlatform #include "gfxPlatform.h" // for gfxPlatform
#include "TreeTraversal.h" // for ForEachNode #include "TreeTraversal.h" // for ForEachNode
@ -80,7 +77,6 @@
#include "nsIWidget.h" // for nsIWidget #include "nsIWidget.h" // for nsIWidget
#include "nsTArray.h" // for nsTArray #include "nsTArray.h" // for nsTArray
#include "nsThreadUtils.h" // for NS_IsMainThread #include "nsThreadUtils.h" // for NS_IsMainThread
#include "nsXULAppAPI.h" // for XRE_GetIOMessageLoop
#ifdef XP_WIN #ifdef XP_WIN
# include "mozilla/layers/CompositorD3D11.h" # include "mozilla/layers/CompositorD3D11.h"
# include "mozilla/widget/WinCompositorWidget.h" # include "mozilla/widget/WinCompositorWidget.h"
@ -174,10 +170,6 @@ bool CompositorBridgeParentBase::DeallocShmem(ipc::Shmem& aShmem) {
return PCompositorBridgeParent::DeallocShmem(aShmem); return PCompositorBridgeParent::DeallocShmem(aShmem);
} }
static inline MessageLoop* CompositorLoop() {
return CompositorThreadHolder::Loop();
}
base::ProcessId CompositorBridgeParentBase::RemotePid() { return OtherPid(); } base::ProcessId CompositorBridgeParentBase::RemotePid() { return OtherPid(); }
bool CompositorBridgeParentBase::StartSharingMetrics( bool CompositorBridgeParentBase::StartSharingMetrics(
@ -185,8 +177,8 @@ bool CompositorBridgeParentBase::StartSharingMetrics(
CrossProcessMutexHandle aMutexHandle, LayersId aLayersId, CrossProcessMutexHandle aMutexHandle, LayersId aLayersId,
uint32_t aApzcId) { uint32_t aApzcId) {
if (!CompositorThreadHolder::IsInCompositorThread()) { if (!CompositorThreadHolder::IsInCompositorThread()) {
MOZ_ASSERT(CompositorLoop()); MOZ_ASSERT(CompositorThread());
CompositorLoop()->PostTask( CompositorThread()->Dispatch(
NewRunnableMethod<ipc::SharedMemoryBasic::Handle, NewRunnableMethod<ipc::SharedMemoryBasic::Handle,
CrossProcessMutexHandle, LayersId, uint32_t>( CrossProcessMutexHandle, LayersId, uint32_t>(
"layers::CompositorBridgeParent::StartSharingMetrics", this, "layers::CompositorBridgeParent::StartSharingMetrics", this,
@ -206,8 +198,8 @@ bool CompositorBridgeParentBase::StartSharingMetrics(
bool CompositorBridgeParentBase::StopSharingMetrics( bool CompositorBridgeParentBase::StopSharingMetrics(
ScrollableLayerGuid::ViewID aScrollId, uint32_t aApzcId) { ScrollableLayerGuid::ViewID aScrollId, uint32_t aApzcId) {
if (!CompositorThreadHolder::IsInCompositorThread()) { if (!CompositorThreadHolder::IsInCompositorThread()) {
MOZ_ASSERT(CompositorLoop()); MOZ_ASSERT(CompositorThread());
CompositorLoop()->PostTask( CompositorThread()->Dispatch(
NewRunnableMethod<ScrollableLayerGuid::ViewID, uint32_t>( NewRunnableMethod<ScrollableLayerGuid::ViewID, uint32_t>(
"layers::CompositorBridgeParent::StopSharingMetrics", this, "layers::CompositorBridgeParent::StopSharingMetrics", this,
&CompositorBridgeParentBase::StopSharingMetrics, aScrollId, &CompositorBridgeParentBase::StopSharingMetrics, aScrollId,
@ -404,8 +396,8 @@ void CompositorBridgeParent::Initialize() {
// FIXME: This holds on the the fact that right now the only thing that // 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 // can destroy this instance is initialized on the compositor thread after
// this task has been processed. // this task has been processed.
MOZ_ASSERT(CompositorLoop()); MOZ_ASSERT(CompositorThread());
CompositorLoop()->PostTask(NewRunnableFunction( CompositorThread()->Dispatch(NewRunnableFunction(
"AddCompositorRunnable", &AddCompositor, this, &mCompositorBridgeID)); "AddCompositorRunnable", &AddCompositor, this, &mCompositorBridgeID));
{ // scope lock { // scope lock
@ -680,22 +672,22 @@ void CompositorBridgeParent::ActorDestroy(ActorDestroyReason why) {
// on this thread. We must keep the compositor parent alive untill the code // on this thread. We must keep the compositor parent alive untill the code
// handling message reception is finished on this thread. // handling message reception is finished on this thread.
mSelfRef = this; mSelfRef = this;
MessageLoop::current()->PostTask( NS_GetCurrentThread()->Dispatch(
NewRunnableMethod("layers::CompositorBridgeParent::DeferredDestroy", this, NewRunnableMethod("layers::CompositorBridgeParent::DeferredDestroy", this,
&CompositorBridgeParent::DeferredDestroy)); &CompositorBridgeParent::DeferredDestroy));
} }
void CompositorBridgeParent::ScheduleRenderOnCompositorThread( void CompositorBridgeParent::ScheduleRenderOnCompositorThread(
const wr::RenderRootSet& aRenderRoots) { const wr::RenderRootSet& aRenderRoots) {
MOZ_ASSERT(CompositorLoop()); MOZ_ASSERT(CompositorThread());
CompositorLoop()->PostTask(NewRunnableMethod<wr::RenderRootSet>( CompositorThread()->Dispatch(NewRunnableMethod<wr::RenderRootSet>(
"layers::CompositorBridgeParent::ScheduleComposition", this, "layers::CompositorBridgeParent::ScheduleComposition", this,
&CompositorBridgeParent::ScheduleComposition, aRenderRoots)); &CompositorBridgeParent::ScheduleComposition, aRenderRoots));
} }
void CompositorBridgeParent::InvalidateOnCompositorThread() { void CompositorBridgeParent::InvalidateOnCompositorThread() {
MOZ_ASSERT(CompositorLoop()); MOZ_ASSERT(CompositorThread());
CompositorLoop()->PostTask( CompositorThread()->Dispatch(
NewRunnableMethod("layers::CompositorBridgeParent::Invalidate", this, NewRunnableMethod("layers::CompositorBridgeParent::Invalidate", this,
&CompositorBridgeParent::Invalidate)); &CompositorBridgeParent::Invalidate));
} }
@ -793,8 +785,8 @@ void CompositorBridgeParent::ResumeCompositionAndResize(int x, int y, int width,
void CompositorBridgeParent::SchedulePauseOnCompositorThread() { void CompositorBridgeParent::SchedulePauseOnCompositorThread() {
MonitorAutoLock lock(mPauseCompositionMonitor); MonitorAutoLock lock(mPauseCompositionMonitor);
MOZ_ASSERT(CompositorLoop()); MOZ_ASSERT(CompositorThread());
CompositorLoop()->PostTask( CompositorThread()->Dispatch(
NewRunnableMethod("layers::CompositorBridgeParent::PauseComposition", NewRunnableMethod("layers::CompositorBridgeParent::PauseComposition",
this, &CompositorBridgeParent::PauseComposition)); this, &CompositorBridgeParent::PauseComposition));
@ -805,8 +797,8 @@ void CompositorBridgeParent::SchedulePauseOnCompositorThread() {
bool CompositorBridgeParent::ScheduleResumeOnCompositorThread() { bool CompositorBridgeParent::ScheduleResumeOnCompositorThread() {
MonitorAutoLock lock(mResumeCompositionMonitor); MonitorAutoLock lock(mResumeCompositionMonitor);
MOZ_ASSERT(CompositorLoop()); MOZ_ASSERT(CompositorThread());
CompositorLoop()->PostTask( CompositorThread()->Dispatch(
NewRunnableMethod("layers::CompositorBridgeParent::ResumeComposition", NewRunnableMethod("layers::CompositorBridgeParent::ResumeComposition",
this, &CompositorBridgeParent::ResumeComposition)); this, &CompositorBridgeParent::ResumeComposition));
@ -821,8 +813,8 @@ bool CompositorBridgeParent::ScheduleResumeOnCompositorThread(int x, int y,
int height) { int height) {
MonitorAutoLock lock(mResumeCompositionMonitor); MonitorAutoLock lock(mResumeCompositionMonitor);
MOZ_ASSERT(CompositorLoop()); MOZ_ASSERT(CompositorThread());
CompositorLoop()->PostTask(NewRunnableMethod<int, int, int, int>( CompositorThread()->Dispatch(NewRunnableMethod<int, int, int, int>(
"layers::CompositorBridgeParent::ResumeCompositionAndResize", this, "layers::CompositorBridgeParent::ResumeCompositionAndResize", this,
&CompositorBridgeParent::ResumeCompositionAndResize, x, y, width, &CompositorBridgeParent::ResumeCompositionAndResize, x, y, width,
height)); height));
@ -1226,9 +1218,9 @@ void CompositorBridgeParent::ScheduleRotationOnCompositorThread(
&CompositorBridgeParent::ForceComposition); &CompositorBridgeParent::ForceComposition);
mForceCompositionTask = task; mForceCompositionTask = task;
if (StaticPrefs::layers_orientation_sync_timeout() == 0) { if (StaticPrefs::layers_orientation_sync_timeout() == 0) {
CompositorThreadHolder::Loop()->PostTask(task.forget()); CompositorThread()->Dispatch(task.forget());
} else { } else {
CompositorThreadHolder::Loop()->PostDelayedTask( CompositorThread()->DelayedDispatch(
task.forget(), StaticPrefs::layers_orientation_sync_timeout()); task.forget(), StaticPrefs::layers_orientation_sync_timeout());
} }
} }
@ -1987,13 +1979,13 @@ void CompositorBridgeParent::InitializeStatics() {
/*static*/ /*static*/
void CompositorBridgeParent::UpdateQualitySettings() { void CompositorBridgeParent::UpdateQualitySettings() {
if (!CompositorThreadHolder::IsInCompositorThread()) { if (!CompositorThreadHolder::IsInCompositorThread()) {
if (CompositorLoop()) { if (CompositorThread()) {
CompositorLoop()->PostTask( CompositorThread()->Dispatch(
NewRunnableFunction("CompositorBridgeParent::UpdateQualitySettings", NewRunnableFunction("CompositorBridgeParent::UpdateQualitySettings",
&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. // safefully just ignore this request.
return; return;
} }
@ -2007,13 +1999,13 @@ void CompositorBridgeParent::UpdateQualitySettings() {
/*static*/ /*static*/
void CompositorBridgeParent::UpdateDebugFlags() { void CompositorBridgeParent::UpdateDebugFlags() {
if (!CompositorThreadHolder::IsInCompositorThread()) { if (!CompositorThreadHolder::IsInCompositorThread()) {
if (CompositorLoop()) { if (CompositorThread()) {
CompositorLoop()->PostTask( CompositorThread()->Dispatch(
NewRunnableFunction("CompositorBridgeParent::UpdateDebugFlags", NewRunnableFunction("CompositorBridgeParent::UpdateDebugFlags",
&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. // safefully just ignore this request.
return; return;
} }
@ -2027,8 +2019,8 @@ void CompositorBridgeParent::UpdateDebugFlags() {
/*static*/ /*static*/
void CompositorBridgeParent::UpdateWebRenderMultithreading() { void CompositorBridgeParent::UpdateWebRenderMultithreading() {
if (!CompositorThreadHolder::IsInCompositorThread()) { if (!CompositorThreadHolder::IsInCompositorThread()) {
if (CompositorLoop()) { if (CompositorThread()) {
CompositorLoop()->PostTask(NewRunnableFunction( CompositorThread()->Dispatch(NewRunnableFunction(
"CompositorBridgeParent::UpdateWebRenderMultithreading", "CompositorBridgeParent::UpdateWebRenderMultithreading",
&CompositorBridgeParent::UpdateWebRenderMultithreading)); &CompositorBridgeParent::UpdateWebRenderMultithreading));
} }
@ -2045,8 +2037,8 @@ void CompositorBridgeParent::UpdateWebRenderMultithreading() {
/*static*/ /*static*/
void CompositorBridgeParent::UpdateWebRenderBatchingParameters() { void CompositorBridgeParent::UpdateWebRenderBatchingParameters() {
if (!CompositorThreadHolder::IsInCompositorThread()) { if (!CompositorThreadHolder::IsInCompositorThread()) {
if (CompositorLoop()) { if (CompositorThread()) {
CompositorLoop()->PostTask(NewRunnableFunction( CompositorThread()->Dispatch(NewRunnableFunction(
"CompositorBridgeParent::UpdateWebRenderBatchingParameters", "CompositorBridgeParent::UpdateWebRenderBatchingParameters",
&CompositorBridgeParent::UpdateWebRenderBatchingParameters)); &CompositorBridgeParent::UpdateWebRenderBatchingParameters));
} }
@ -2095,11 +2087,11 @@ void CompositorBridgeParent::DeallocateLayerTreeId(LayersId aId) {
// Here main thread notifies compositor to remove an element from // Here main thread notifies compositor to remove an element from
// sIndirectLayerTrees. This removed element might be queried soon. // sIndirectLayerTrees. This removed element might be queried soon.
// Checking the elements of sIndirectLayerTrees exist or not before using. // Checking the elements of sIndirectLayerTrees exist or not before using.
if (!CompositorLoop()) { if (!CompositorThread()) {
gfxCriticalError() << "Attempting to post to a invalid Compositor Loop"; gfxCriticalError() << "Attempting to post to an invalid Compositor Thread";
return; return;
} }
CompositorLoop()->PostTask( CompositorThread()->Dispatch(
NewRunnableFunction("EraseLayerStateRunnable", &EraseLayerState, aId)); NewRunnableFunction("EraseLayerStateRunnable", &EraseLayerState, aId));
} }
@ -2131,7 +2123,7 @@ void CompositorBridgeParent::SetControllerForLayerTree(
LayersId aLayersId, GeckoContentController* aController) { LayersId aLayersId, GeckoContentController* aController) {
// This ref is adopted by UpdateControllerForLayersId(). // This ref is adopted by UpdateControllerForLayersId().
aController->AddRef(); aController->AddRef();
CompositorLoop()->PostTask(NewRunnableFunction( CompositorThread()->Dispatch(NewRunnableFunction(
"UpdateControllerForLayersIdRunnable", &UpdateControllerForLayersId, "UpdateControllerForLayersIdRunnable", &UpdateControllerForLayersId,
aLayersId, aController)); aLayersId, aController));
} }
@ -2168,7 +2160,7 @@ void CompositorBridgeParent::PostInsertVsyncProfilerMarker(
#if defined(MOZ_GECKO_PROFILER) #if defined(MOZ_GECKO_PROFILER)
// Called in the vsync thread // Called in the vsync thread
if (profiler_is_active() && CompositorThreadHolder::IsActive()) { if (profiler_is_active() && CompositorThreadHolder::IsActive()) {
CompositorLoop()->PostTask( CompositorThread()->Dispatch(
NewRunnableFunction("InsertVsyncProfilerMarkerRunnable", NewRunnableFunction("InsertVsyncProfilerMarkerRunnable",
InsertVsyncProfilerMarker, aVsyncTimestamp)); InsertVsyncProfilerMarker, aVsyncTimestamp));
} }
@ -2391,7 +2383,7 @@ void CompositorBridgeParent::NotifyDidComposite(TransactionId aTransactionId,
} }
void CompositorBridgeParent::InvalidateRemoteLayers() { void CompositorBridgeParent::InvalidateRemoteLayers() {
MOZ_ASSERT(CompositorLoop() == MessageLoop::current()); MOZ_ASSERT(CompositorThread()->IsOnCurrentThread());
Unused << PCompositorBridgeParent::SendInvalidateLayers(LayersId{0}); Unused << PCompositorBridgeParent::SendInvalidateLayers(LayersId{0});
@ -2513,13 +2505,12 @@ bool CompositorBridgeParent::IsSameProcess() const {
} }
void CompositorBridgeParent::NotifyWebRenderContextPurge() { void CompositorBridgeParent::NotifyWebRenderContextPurge() {
MOZ_ASSERT(CompositorLoop() == MessageLoop::current()); MOZ_ASSERT(CompositorThread()->IsOnCurrentThread());
RefPtr<wr::WebRenderAPI> api = mWrBridge->GetWebRenderAPI(); RefPtr<wr::WebRenderAPI> api = mWrBridge->GetWebRenderAPI();
api->ClearAllCaches();
} }
void CompositorBridgeParent::NotifyWebRenderDisableNativeCompositor() { void CompositorBridgeParent::NotifyWebRenderDisableNativeCompositor() {
MOZ_ASSERT(CompositorLoop() == MessageLoop::current()); MOZ_ASSERT(CompositorThread()->IsOnCurrentThread());
if (mWrBridge) { if (mWrBridge) {
mWrBridge->DisableNativeCompositor(); mWrBridge->DisableNativeCompositor();
} }
@ -2651,8 +2642,8 @@ bool CompositorBridgeParent::UpdatePluginWindowState(LayersId aId) {
} }
void CompositorBridgeParent::ScheduleShowAllPluginWindows() { void CompositorBridgeParent::ScheduleShowAllPluginWindows() {
MOZ_ASSERT(CompositorLoop()); MOZ_ASSERT(CompositorThread());
CompositorLoop()->PostTask( CompositorThread()->Dispatch(
NewRunnableMethod("layers::CompositorBridgeParent::ShowAllPluginWindows", NewRunnableMethod("layers::CompositorBridgeParent::ShowAllPluginWindows",
this, &CompositorBridgeParent::ShowAllPluginWindows)); this, &CompositorBridgeParent::ShowAllPluginWindows));
} }
@ -2664,8 +2655,8 @@ void CompositorBridgeParent::ShowAllPluginWindows() {
} }
void CompositorBridgeParent::ScheduleHideAllPluginWindows() { void CompositorBridgeParent::ScheduleHideAllPluginWindows() {
MOZ_ASSERT(CompositorLoop()); MOZ_ASSERT(CompositorThread());
CompositorLoop()->PostTask( CompositorThread()->Dispatch(
NewRunnableMethod("layers::CompositorBridgeParent::HideAllPluginWindows", NewRunnableMethod("layers::CompositorBridgeParent::HideAllPluginWindows",
this, &CompositorBridgeParent::HideAllPluginWindows)); this, &CompositorBridgeParent::HideAllPluginWindows));
} }
@ -2892,7 +2883,7 @@ mozilla::ipc::IPCResult CompositorBridgeParent::RecvEndRecordingToDisk(
aResolve(true); aResolve(true);
} else if (mWrBridge) { } else if (mWrBridge) {
mWrBridge->WriteCollectedFrames()->Then( mWrBridge->WriteCollectedFrames()->Then(
MessageLoop::current()->SerialEventTarget(), __func__, NS_GetCurrentThread(), __func__,
[resolve{aResolve}](const bool success) { resolve(success); }, [resolve{aResolve}](const bool success) { resolve(success); },
[resolve{aResolve}]() { resolve(false); }); [resolve{aResolve}]() { resolve(false); });
} else { } else {
@ -2921,7 +2912,7 @@ mozilla::ipc::IPCResult CompositorBridgeParent::RecvEndRecordingToMemory(
} else if (mWrBridge) { } else if (mWrBridge) {
RefPtr<CompositorBridgeParent> self = this; RefPtr<CompositorBridgeParent> self = this;
mWrBridge->GetCollectedFrames()->Then( mWrBridge->GetCollectedFrames()->Then(
MessageLoop::current()->SerialEventTarget(), __func__, NS_GetCurrentThread(), __func__,
[self, resolve{aResolve}](CollectedFrames&& frames) { [self, resolve{aResolve}](CollectedFrames&& frames) {
resolve(self->WrapCollectedFrames(std::move(frames))); resolve(self->WrapCollectedFrames(std::move(frames)));
}, },

Просмотреть файл

@ -47,7 +47,6 @@
#include "mozilla/layers/UiCompositorControllerParent.h" #include "mozilla/layers/UiCompositorControllerParent.h"
#include "mozilla/VsyncDispatcher.h" #include "mozilla/VsyncDispatcher.h"
class MessageLoop;
class nsIWidget; class nsIWidget;
namespace mozilla { namespace mozilla {

Просмотреть файл

@ -173,9 +173,8 @@ CompositorManagerChild::CompositorManagerChild(CompositorManagerParent* aParent,
MOZ_ASSERT(aParent); MOZ_ASSERT(aParent);
SetOtherProcessId(base::GetCurrentProcId()); SetOtherProcessId(base::GetCurrentProcId());
MessageLoop* loop = CompositorThreadHolder::Loop();
ipc::MessageChannel* channel = aParent->GetIPCChannel(); ipc::MessageChannel* channel = aParent->GetIPCChannel();
if (NS_WARN_IF(!Open(channel, loop, ipc::ChildSide))) { if (NS_WARN_IF(!Open(channel, CompositorThread(), ipc::ChildSide))) {
return; return;
} }

Просмотреть файл

@ -68,7 +68,7 @@ bool CompositorManagerParent::Create(
NewRunnableMethod<Endpoint<PCompositorManagerParent>&&, bool>( NewRunnableMethod<Endpoint<PCompositorManagerParent>&&, bool>(
"CompositorManagerParent::Bind", bridge, "CompositorManagerParent::Bind", bridge,
&CompositorManagerParent::Bind, std::move(aEndpoint), aIsRoot); &CompositorManagerParent::Bind, std::move(aEndpoint), aIsRoot);
CompositorThreadHolder::Loop()->PostTask(runnable.forget()); CompositorThread()->Dispatch(runnable.forget());
return true; return true;
} }
@ -201,7 +201,7 @@ void CompositorManagerParent::Shutdown() {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
#ifdef COMPOSITOR_MANAGER_PARENT_EXPLICIT_SHUTDOWN #ifdef COMPOSITOR_MANAGER_PARENT_EXPLICIT_SHUTDOWN
CompositorThreadHolder::Loop()->PostTask(NS_NewRunnableFunction( CompositorThread()->Dispatch(NS_NewRunnableFunction(
"layers::CompositorManagerParent::Shutdown", "layers::CompositorManagerParent::Shutdown",
[]() -> void { CompositorManagerParent::ShutdownInternal(); })); []() -> void { CompositorManagerParent::ShutdownInternal(); }));
#endif #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 // thread, so we can't just pass it over to the renderer thread. We use
// an intermediate MozPromise instead. // an intermediate MozPromise instead.
wr::RenderThread::AccumulateMemoryReport(aggregate)->Then( wr::RenderThread::AccumulateMemoryReport(aggregate)->Then(
CompositorThreadHolder::Loop()->SerialEventTarget(), __func__, CompositorThread(), __func__,
[resolver = std::move(aResolver)](MemoryReport aReport) { [resolver = std::move(aResolver)](MemoryReport aReport) {
resolver(aReport); resolver(aReport);
}, },

Просмотреть файл

@ -19,17 +19,12 @@ namespace layers {
static StaticRefPtr<CompositorThreadHolder> sCompositorThreadHolder; static StaticRefPtr<CompositorThreadHolder> sCompositorThreadHolder;
static bool sFinishedCompositorShutDown = false; static bool sFinishedCompositorShutDown = false;
base::Thread* CompositorThread() { nsISerialEventTarget* CompositorThread() {
return sCompositorThreadHolder return sCompositorThreadHolder
? sCompositorThreadHolder->GetCompositorThread() ? sCompositorThreadHolder->GetCompositorThread()
: nullptr; : nullptr;
} }
/* static */
MessageLoop* CompositorThreadHolder::Loop() {
return CompositorThread() ? CompositorThread()->message_loop() : nullptr;
}
CompositorThreadHolder* CompositorThreadHolder::GetSingleton() { CompositorThreadHolder* CompositorThreadHolder::GetSingleton() {
return sCompositorThreadHolder; return sCompositorThreadHolder;
} }
@ -41,57 +36,40 @@ CompositorThreadHolder::CompositorThreadHolder()
CompositorThreadHolder::~CompositorThreadHolder() { CompositorThreadHolder::~CompositorThreadHolder() {
MOZ_ASSERT(NS_IsMainThread()); 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; sFinishedCompositorShutDown = true;
} }
/* static */ base::Thread* CompositorThreadHolder::CreateCompositorThread() { /* static */ already_AddRefed<nsIThread>
CompositorThreadHolder::CreateCompositorThread() {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!sCompositorThreadHolder, MOZ_ASSERT(!sCompositorThreadHolder,
"The compositor thread has already been started!"); "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; // TODO re-enable hangout monitor. Will be done in a follow-up thread
/* Timeout values are powers-of-two to enable us get better data. // base::Thread::Options options;
128ms is chosen for transient hangs because 8Hz should be the minimally // /* Timeout values are powers-of-two to enable us get better data.
acceptable goal for Compositor responsiveness (normal goal is 60Hz). */ // 128ms is chosen for transient hangs because 8Hz should be the minimally
options.transient_hang_timeout = 128; // milliseconds // acceptable goal for Compositor responsiveness (normal goal is 60Hz). */
/* 2048ms is chosen for permanent hangs because it's longer than most // options.transient_hang_timeout = 128; // milliseconds
* Compositor hangs seen in the wild, but is short enough to not miss getting // /* 2048ms is chosen for permanent hangs because it's longer than most
* native hang stacks. */ // * Compositor hangs seen in the wild, but is short enough to not miss
options.permanent_hang_timeout = 2048; // milliseconds // getting
#if defined(_WIN32) // * native hang stacks. */
/* With d3d9 the compositor thread creates native ui, see DeviceManagerD3D9. // options.permanent_hang_timeout = 2048; // milliseconds
* 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
if (!compositorThread->StartWithOptions(options)) { if (NS_FAILED(rv)) {
delete compositorThread;
return nullptr; return nullptr;
} }
CompositorBridgeParent::Setup(); CompositorBridgeParent::Setup();
ImageBridgeParent::Setup(); ImageBridgeParent::Setup();
return compositorThread; return compositorThread.forget();
} }
void CompositorThreadHolder::Start() { void CompositorThreadHolder::Start() {
@ -136,8 +114,12 @@ void CompositorThreadHolder::Shutdown() {
/* static */ /* static */
bool CompositorThreadHolder::IsInCompositorThread() { bool CompositorThreadHolder::IsInCompositorThread() {
return CompositorThread() && if (!CompositorThread()) {
CompositorThread()->thread_id() == PlatformThread::CurrentId(); return false;
}
bool in = false;
MOZ_ALWAYS_SUCCEEDS(CompositorThread()->IsOnCurrentThread(&in));
return in;
} }
} // namespace layers } // namespace layers

Просмотреть файл

@ -6,13 +6,12 @@
#ifndef mozilla_layers_CompositorThread_h #ifndef mozilla_layers_CompositorThread_h
#define 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 "nsISupportsImpl.h"
#include "ThreadSafeRefcountingWithMainThreadDestruction.h" #include "ThreadSafeRefcountingWithMainThreadDestruction.h"
class nsISerialEventTarget;
class nsIThread;
namespace mozilla { namespace mozilla {
namespace layers { namespace layers {
@ -23,7 +22,9 @@ class CompositorThreadHolder final {
public: public:
CompositorThreadHolder(); CompositorThreadHolder();
base::Thread* GetCompositorThread() const { return mCompositorThread; } nsISerialEventTarget* GetCompositorThread() const {
return mCompositorThread;
}
static CompositorThreadHolder* GetSingleton(); static CompositorThreadHolder* GetSingleton();
@ -40,23 +41,20 @@ class CompositorThreadHolder final {
*/ */
static void Shutdown(); static void Shutdown();
static MessageLoop* Loop();
// Returns true if the calling thread is the compositor thread. // Returns true if the calling thread is the compositor thread.
static bool IsInCompositorThread(); static bool IsInCompositorThread();
private: private:
~CompositorThreadHolder(); ~CompositorThreadHolder();
base::Thread* const mCompositorThread; nsCOMPtr<nsIThread> mCompositorThread;
static base::Thread* CreateCompositorThread(); static already_AddRefed<nsIThread> CreateCompositorThread();
static void DestroyCompositorThread(base::Thread* aCompositorThread);
friend class CompositorBridgeParent; friend class CompositorBridgeParent;
}; };
base::Thread* CompositorThread(); nsISerialEventTarget* CompositorThread();
} // namespace layers } // namespace layers
} // namespace mozilla } // namespace mozilla

Просмотреть файл

@ -110,24 +110,24 @@ void CompositorVsyncScheduler::Destroy() {
void CompositorVsyncScheduler::PostCompositeTask( void CompositorVsyncScheduler::PostCompositeTask(
VsyncId aId, TimeStamp aCompositeTimestamp) { VsyncId aId, TimeStamp aCompositeTimestamp) {
MonitorAutoLock lock(mCurrentCompositeTaskMonitor); MonitorAutoLock lock(mCurrentCompositeTaskMonitor);
if (mCurrentCompositeTask == nullptr && CompositorThreadHolder::Loop()) { if (mCurrentCompositeTask == nullptr && CompositorThread()) {
RefPtr<CancelableRunnable> task = RefPtr<CancelableRunnable> task =
NewCancelableRunnableMethod<VsyncId, TimeStamp>( NewCancelableRunnableMethod<VsyncId, TimeStamp>(
"layers::CompositorVsyncScheduler::Composite", this, "layers::CompositorVsyncScheduler::Composite", this,
&CompositorVsyncScheduler::Composite, aId, aCompositeTimestamp); &CompositorVsyncScheduler::Composite, aId, aCompositeTimestamp);
mCurrentCompositeTask = task; mCurrentCompositeTask = task;
ScheduleTask(task.forget()); CompositorThread()->Dispatch(task.forget());
} }
} }
void CompositorVsyncScheduler::PostVRTask(TimeStamp aTimestamp) { void CompositorVsyncScheduler::PostVRTask(TimeStamp aTimestamp) {
MonitorAutoLock lockVR(mCurrentVRTaskMonitor); MonitorAutoLock lockVR(mCurrentVRTaskMonitor);
if (mCurrentVRTask == nullptr && CompositorThreadHolder::Loop()) { if (mCurrentVRTask == nullptr && CompositorThread()) {
RefPtr<CancelableRunnable> task = NewCancelableRunnableMethod<TimeStamp>( RefPtr<CancelableRunnable> task = NewCancelableRunnableMethod<TimeStamp>(
"layers::CompositorVsyncScheduler::DispatchVREvents", this, "layers::CompositorVsyncScheduler::DispatchVREvents", this,
&CompositorVsyncScheduler::DispatchVREvents, aTimestamp); &CompositorVsyncScheduler::DispatchVREvents, aTimestamp);
mCurrentVRTask = task; mCurrentVRTask = task;
CompositorThreadHolder::Loop()->PostDelayedTask(task.forget(), 0); CompositorThread()->Dispatch(task.forget());
} }
} }
@ -329,12 +329,6 @@ void CompositorVsyncScheduler::DispatchVREvents(TimeStamp aVsyncTimestamp) {
vm->NotifyVsync(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 { const TimeStamp& CompositorVsyncScheduler::GetLastComposeTime() const {
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread()); MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
return mLastCompose; return mLastCompose;

Просмотреть файл

@ -109,9 +109,6 @@ class CompositorVsyncScheduler {
private: private:
virtual ~CompositorVsyncScheduler(); 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 // 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. // such a task already queued. Can be called from any thread.
void PostCompositeTask(VsyncId aId, TimeStamp aCompositeTimestamp); void PostCompositeTask(VsyncId aId, TimeStamp aCompositeTimestamp);

Просмотреть файл

@ -10,7 +10,6 @@
#include "ImageContainer.h" // for ImageContainer #include "ImageContainer.h" // for ImageContainer
#include "Layers.h" // for Layer, etc #include "Layers.h" // for Layer, etc
#include "ShadowLayers.h" // for ShadowLayerForwarder #include "ShadowLayers.h" // for ShadowLayerForwarder
#include "base/message_loop.h" // for MessageLoop
#include "base/platform_thread.h" // for PlatformThread #include "base/platform_thread.h" // for PlatformThread
#include "base/process.h" // for ProcessId #include "base/process.h" // for ProcessId
#include "base/task.h" // for NewRunnableFunction, etc #include "base/task.h" // for NewRunnableFunction, etc
@ -38,8 +37,8 @@
#include "nsISupportsImpl.h" // for ImageContainer::AddRef, etc #include "nsISupportsImpl.h" // for ImageContainer::AddRef, etc
#include "nsTArray.h" // for AutoTArray, nsTArray, etc #include "nsTArray.h" // for AutoTArray, nsTArray, etc
#include "nsTArrayForwardDeclare.h" // for AutoTArray #include "nsTArrayForwardDeclare.h" // for AutoTArray
#include "nsThread.h"
#include "nsThreadUtils.h" // for NS_IsMainThread #include "nsThreadUtils.h" // for NS_IsMainThread
#include "nsXULAppAPI.h" // for XRE_GetIOMessageLoop
#include "mozilla/StaticMutex.h" #include "mozilla/StaticMutex.h"
#include "mozilla/StaticPtr.h" // for StaticRefPtr #include "mozilla/StaticPtr.h" // for StaticRefPtr
#include "mozilla/layers/TextureClient.h" #include "mozilla/layers/TextureClient.h"
@ -172,7 +171,10 @@ void ImageBridgeChild::CancelWaitForNotifyNotUsed(uint64_t aTextureId) {
// Singleton // Singleton
static StaticMutex sImageBridgeSingletonLock; static StaticMutex sImageBridgeSingletonLock;
static StaticRefPtr<ImageBridgeChild> sImageBridgeChildSingleton; 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 // dispatched function
void ImageBridgeChild::ShutdownStep1(SynchronousTask* aTask) { void ImageBridgeChild::ShutdownStep1(SynchronousTask* aTask) {
@ -293,8 +295,6 @@ void ImageBridgeChild::ForgetImageContainer(const CompositableHandle& aHandle) {
mImageContainerListeners.erase(aHandle.Value()); mImageContainerListeners.erase(aHandle.Value());
} }
Thread* ImageBridgeChild::GetThread() const { return sImageBridgeChildThread; }
/* static */ /* static */
RefPtr<ImageBridgeChild> ImageBridgeChild::GetSingleton() { RefPtr<ImageBridgeChild> ImageBridgeChild::GetSingleton() {
StaticMutexAutoLock lock(sImageBridgeSingletonLock); StaticMutexAutoLock lock(sImageBridgeSingletonLock);
@ -310,7 +310,7 @@ void ImageBridgeChild::UpdateImageClient(RefPtr<ImageContainer> aContainer) {
RefPtr<Runnable> runnable = RefPtr<Runnable> runnable =
WrapRunnable(RefPtr<ImageBridgeChild>(this), WrapRunnable(RefPtr<ImageBridgeChild>(this),
&ImageBridgeChild::UpdateImageClient, aContainer); &ImageBridgeChild::UpdateImageClient, aContainer);
GetMessageLoop()->PostTask(runnable.forget()); GetThread()->Dispatch(runnable.forget());
return; return;
} }
@ -355,7 +355,7 @@ void ImageBridgeChild::UpdateAsyncCanvasRenderer(
RefPtr<Runnable> runnable = WrapRunnable( RefPtr<Runnable> runnable = WrapRunnable(
RefPtr<ImageBridgeChild>(this), RefPtr<ImageBridgeChild>(this),
&ImageBridgeChild::UpdateAsyncCanvasRendererSync, &task, aWrapper); &ImageBridgeChild::UpdateAsyncCanvasRendererSync, &task, aWrapper);
GetMessageLoop()->PostTask(runnable.forget()); GetThread()->Dispatch(runnable.forget());
task.Wait(); task.Wait();
} }
@ -409,7 +409,7 @@ void ImageBridgeChild::FlushAllImages(ImageClient* aClient,
RefPtr<Runnable> runnable = WrapRunnable( RefPtr<Runnable> runnable = WrapRunnable(
RefPtr<ImageBridgeChild>(this), &ImageBridgeChild::FlushAllImagesSync, RefPtr<ImageBridgeChild>(this), &ImageBridgeChild::FlushAllImagesSync,
&task, aClient, aContainer); &task, aClient, aContainer);
GetMessageLoop()->PostTask(runnable.forget()); GetThread()->Dispatch(runnable.forget());
task.Wait(); task.Wait();
} }
@ -454,9 +454,11 @@ bool ImageBridgeChild::InitForContent(Endpoint<PImageBridgeChild>&& aEndpoint,
gfxPlatform::GetPlatform(); gfxPlatform::GetPlatform();
if (!sImageBridgeChildThread) { if (!sImageBridgeChildThread) {
sImageBridgeChildThread = new Thread("ImageBridgeChild"); nsCOMPtr<nsIThread> thread;
bool success = sImageBridgeChildThread->Start(); nsresult rv = NS_NewNamedThread("ImageBridgeChld", getter_AddRefs(thread));
MOZ_RELEASE_ASSERT(success, "Failed to start ImageBridgeChild thread!"); MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv),
"Failed to start ImageBridgeChild thread!");
sImageBridgeChildThread = thread.forget();
} }
RefPtr<ImageBridgeChild> child = new ImageBridgeChild(aNamespace); RefPtr<ImageBridgeChild> child = new ImageBridgeChild(aNamespace);
@ -464,7 +466,7 @@ bool ImageBridgeChild::InitForContent(Endpoint<PImageBridgeChild>&& aEndpoint,
RefPtr<Runnable> runnable = NewRunnableMethod<Endpoint<PImageBridgeChild>&&>( RefPtr<Runnable> runnable = NewRunnableMethod<Endpoint<PImageBridgeChild>&&>(
"layers::ImageBridgeChild::Bind", child, &ImageBridgeChild::Bind, "layers::ImageBridgeChild::Bind", child, &ImageBridgeChild::Bind,
std::move(aEndpoint)); 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 // Assign this after so other threads can't post messages before we connect to
// IPDL. // IPDL.
@ -501,9 +503,8 @@ void ImageBridgeChild::Bind(Endpoint<PImageBridgeChild>&& aEndpoint) {
} }
void ImageBridgeChild::BindSameProcess(RefPtr<ImageBridgeParent> aParent) { void ImageBridgeChild::BindSameProcess(RefPtr<ImageBridgeParent> aParent) {
MessageLoop* parentMsgLoop = aParent->GetMessageLoop();
ipc::MessageChannel* parentChannel = aParent->GetIPCChannel(); 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 reference is dropped in DeallocPImageBridgeChild.
this->AddRef(); this->AddRef();
@ -517,7 +518,6 @@ void ImageBridgeChild::ShutDown() {
ShutdownSingleton(); ShutdownSingleton();
delete sImageBridgeChildThread;
sImageBridgeChildThread = nullptr; sImageBridgeChildThread = nullptr;
} }
@ -540,7 +540,7 @@ void ImageBridgeChild::WillShutdown() {
RefPtr<Runnable> runnable = RefPtr<Runnable> runnable =
WrapRunnable(RefPtr<ImageBridgeChild>(this), WrapRunnable(RefPtr<ImageBridgeChild>(this),
&ImageBridgeChild::ShutdownStep1, &task); &ImageBridgeChild::ShutdownStep1, &task);
GetMessageLoop()->PostTask(runnable.forget()); GetThread()->Dispatch(runnable.forget());
task.Wait(); task.Wait();
} }
@ -551,7 +551,7 @@ void ImageBridgeChild::WillShutdown() {
RefPtr<Runnable> runnable = RefPtr<Runnable> runnable =
WrapRunnable(RefPtr<ImageBridgeChild>(this), WrapRunnable(RefPtr<ImageBridgeChild>(this),
&ImageBridgeChild::ShutdownStep2, &task); &ImageBridgeChild::ShutdownStep2, &task);
GetMessageLoop()->PostTask(runnable.forget()); GetThread()->Dispatch(runnable.forget());
task.Wait(); task.Wait();
} }
@ -563,17 +563,18 @@ void ImageBridgeChild::InitSameProcess(uint32_t aNamespace) {
MOZ_ASSERT(!sImageBridgeChildSingleton); MOZ_ASSERT(!sImageBridgeChildSingleton);
MOZ_ASSERT(!sImageBridgeChildThread); MOZ_ASSERT(!sImageBridgeChildThread);
sImageBridgeChildThread = new Thread("ImageBridgeChild"); nsCOMPtr<nsIThread> thread;
if (!sImageBridgeChildThread->IsRunning()) { nsresult rv = NS_NewNamedThread("ImageBridgeChld", getter_AddRefs(thread));
sImageBridgeChildThread->Start(); MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv),
} "Failed to start ImageBridgeChild thread!");
sImageBridgeChildThread = thread.forget();
RefPtr<ImageBridgeChild> child = new ImageBridgeChild(aNamespace); RefPtr<ImageBridgeChild> child = new ImageBridgeChild(aNamespace);
RefPtr<ImageBridgeParent> parent = ImageBridgeParent::CreateSameProcess(); RefPtr<ImageBridgeParent> parent = ImageBridgeParent::CreateSameProcess();
RefPtr<Runnable> runnable = RefPtr<Runnable> runnable =
WrapRunnable(child, &ImageBridgeChild::BindSameProcess, parent); 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 // Assign this after so other threads can't post messages before we connect to
// IPDL. // IPDL.
@ -590,15 +591,15 @@ void ImageBridgeChild::InitWithGPUProcess(
MOZ_ASSERT(!sImageBridgeChildSingleton); MOZ_ASSERT(!sImageBridgeChildSingleton);
MOZ_ASSERT(!sImageBridgeChildThread); MOZ_ASSERT(!sImageBridgeChildThread);
sImageBridgeChildThread = new Thread("ImageBridgeChild"); nsCOMPtr<nsIThread> thread;
if (!sImageBridgeChildThread->IsRunning()) { nsresult rv = NS_NewNamedThread("ImageBridgeChld", getter_AddRefs(thread));
sImageBridgeChildThread->Start(); MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv),
} "Failed to start ImageBridgeChild thread!");
sImageBridgeChildThread = thread.forget();
RefPtr<ImageBridgeChild> child = new ImageBridgeChild(aNamespace); RefPtr<ImageBridgeChild> child = new ImageBridgeChild(aNamespace);
MessageLoop* loop = child->GetMessageLoop(); child->GetThread()->Dispatch(NewRunnableMethod<Endpoint<PImageBridgeChild>&&>(
loop->PostTask(NewRunnableMethod<Endpoint<PImageBridgeChild>&&>(
"layers::ImageBridgeChild::Bind", child, &ImageBridgeChild::Bind, "layers::ImageBridgeChild::Bind", child, &ImageBridgeChild::Bind,
std::move(aEndpoint))); std::move(aEndpoint)));
@ -612,12 +613,11 @@ void ImageBridgeChild::InitWithGPUProcess(
bool InImageBridgeChildThread() { bool InImageBridgeChildThread() {
return sImageBridgeChildThread && return sImageBridgeChildThread &&
sImageBridgeChildThread->thread_id() == PlatformThread::CurrentId(); sImageBridgeChildThread->IsOnCurrentThread();
} }
MessageLoop* ImageBridgeChild::GetMessageLoop() const { nsISerialEventTarget* ImageBridgeChild::GetThread() const {
return sImageBridgeChildThread ? sImageBridgeChildThread->message_loop() return sImageBridgeChildThread;
: nullptr;
} }
/* static */ /* static */
@ -697,7 +697,7 @@ RefPtr<ImageClient> ImageBridgeChild::CreateImageClient(
RefPtr<Runnable> runnable = WrapRunnable( RefPtr<Runnable> runnable = WrapRunnable(
RefPtr<ImageBridgeChild>(this), &ImageBridgeChild::CreateImageClientSync, RefPtr<ImageBridgeChild>(this), &ImageBridgeChild::CreateImageClientSync,
&task, &result, aType, aImageContainer); &task, &result, aType, aImageContainer);
GetMessageLoop()->PostTask(runnable.forget()); GetThread()->Dispatch(runnable.forget());
task.Wait(); task.Wait();
@ -733,7 +733,7 @@ already_AddRefed<CanvasClient> ImageBridgeChild::CreateCanvasClient(
RefPtr<Runnable> runnable = WrapRunnable( RefPtr<Runnable> runnable = WrapRunnable(
RefPtr<ImageBridgeChild>(this), &ImageBridgeChild::CreateCanvasClientSync, RefPtr<ImageBridgeChild>(this), &ImageBridgeChild::CreateCanvasClientSync,
&task, aType, aFlag, &result); &task, aType, aFlag, &result);
GetMessageLoop()->PostTask(runnable.forget()); GetThread()->Dispatch(runnable.forget());
task.Wait(); task.Wait();
@ -807,7 +807,7 @@ bool ImageBridgeChild::DispatchAllocShmemInternal(
RefPtr<Runnable> runnable = WrapRunnable( RefPtr<Runnable> runnable = WrapRunnable(
RefPtr<ImageBridgeChild>(this), &ImageBridgeChild::ProxyAllocShmemNow, RefPtr<ImageBridgeChild>(this), &ImageBridgeChild::ProxyAllocShmemNow,
&task, aSize, aType, aShmem, aUnsafe, &success); &task, aSize, aType, aShmem, aUnsafe, &success);
GetMessageLoop()->PostTask(runnable.forget()); GetThread()->Dispatch(runnable.forget());
task.Wait(); task.Wait();
@ -844,7 +844,7 @@ bool ImageBridgeChild::DeallocShmem(ipc::Shmem& aShmem) {
RefPtr<Runnable> runnable = WrapRunnable( RefPtr<Runnable> runnable = WrapRunnable(
RefPtr<ImageBridgeChild>(this), &ImageBridgeChild::ProxyDeallocShmemNow, RefPtr<ImageBridgeChild>(this), &ImageBridgeChild::ProxyDeallocShmemNow,
&task, &aShmem, &result); &task, &aShmem, &result);
GetMessageLoop()->PostTask(runnable.forget()); GetThread()->Dispatch(runnable.forget());
task.Wait(); task.Wait();
return result; return result;
@ -999,7 +999,7 @@ void ImageBridgeChild::ReleaseCompositable(const CompositableHandle& aHandle) {
RefPtr<Runnable> runnable = RefPtr<Runnable> runnable =
WrapRunnable(RefPtr<ImageBridgeChild>(this), WrapRunnable(RefPtr<ImageBridgeChild>(this),
&ImageBridgeChild::ReleaseCompositable, aHandle); &ImageBridgeChild::ReleaseCompositable, aHandle);
GetMessageLoop()->PostTask(runnable.forget()); GetThread()->Dispatch(runnable.forget());
return; return;
} }

Просмотреть файл

@ -25,12 +25,6 @@
#include "mozilla/gfx/Rect.h" #include "mozilla/gfx/Rect.h"
#include "mozilla/ReentrantMonitor.h" // for ReentrantMonitor, etc #include "mozilla/ReentrantMonitor.h" // for ReentrantMonitor, etc
class MessageLoop;
namespace base {
class Thread;
} // namespace base
namespace mozilla { namespace mozilla {
namespace ipc { namespace ipc {
class Shmem; class Shmem;
@ -166,14 +160,7 @@ class ImageBridgeChild final : public PImageBridgeChild,
* *
* Can be called from any thread. * Can be called from any thread.
*/ */
base::Thread* GetThread() const; nsISerialEventTarget* GetThread() const override;
/**
* Returns the ImageBridgeChild's message loop.
*
* Can be called from any thread.
*/
MessageLoop* GetMessageLoop() const override;
base::ProcessId GetParentPid() const override { return OtherPid(); } base::ProcessId GetParentPid() const override { return OtherPid(); }

Просмотреть файл

@ -7,7 +7,6 @@
#include "ImageBridgeParent.h" #include "ImageBridgeParent.h"
#include <stdint.h> // for uint64_t, uint32_t #include <stdint.h> // for uint64_t, uint32_t
#include "CompositableHost.h" // for CompositableParent, Create #include "CompositableHost.h" // for CompositableParent, Create
#include "base/message_loop.h" // for MessageLoop
#include "base/process.h" // for ProcessId #include "base/process.h" // for ProcessId
#include "base/task.h" // for CancelableTask, DeleteTask, etc #include "base/task.h" // for CancelableTask, DeleteTask, etc
#include "mozilla/ClearOnShutdown.h" #include "mozilla/ClearOnShutdown.h"
@ -62,9 +61,9 @@ void ImageBridgeParent::Setup() {
} }
} }
ImageBridgeParent::ImageBridgeParent(MessageLoop* aLoop, ImageBridgeParent::ImageBridgeParent(nsISerialEventTarget* aThread,
ProcessId aChildProcessId) ProcessId aChildProcessId)
: mMessageLoop(aLoop), : mThread(aThread),
mClosed(false), mClosed(false),
mCompositorThreadHolder(CompositorThreadHolder::GetSingleton()) { mCompositorThreadHolder(CompositorThreadHolder::GetSingleton()) {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
@ -77,7 +76,7 @@ ImageBridgeParent::~ImageBridgeParent() = default;
ImageBridgeParent* ImageBridgeParent::CreateSameProcess() { ImageBridgeParent* ImageBridgeParent::CreateSameProcess() {
base::ProcessId pid = base::GetCurrentProcId(); base::ProcessId pid = base::GetCurrentProcId();
RefPtr<ImageBridgeParent> parent = RefPtr<ImageBridgeParent> parent =
new ImageBridgeParent(CompositorThreadHolder::Loop(), pid); new ImageBridgeParent(CompositorThread(), pid);
parent->mSelfRef = parent; parent->mSelfRef = parent;
{ {
@ -95,15 +94,15 @@ bool ImageBridgeParent::CreateForGPUProcess(
Endpoint<PImageBridgeParent>&& aEndpoint) { Endpoint<PImageBridgeParent>&& aEndpoint) {
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_GPU); MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_GPU);
MessageLoop* loop = CompositorThreadHolder::Loop(); nsCOMPtr<nsISerialEventTarget> compositorThread = CompositorThread();
if (!loop) { if (!compositorThread) {
return false; return false;
} }
RefPtr<ImageBridgeParent> parent = 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, "layers::ImageBridgeParent::Bind", parent, &ImageBridgeParent::Bind,
std::move(aEndpoint))); std::move(aEndpoint)));
@ -133,7 +132,7 @@ void ImageBridgeParent::ShutdownInternal() {
/* static */ /* static */
void ImageBridgeParent::Shutdown() { void ImageBridgeParent::Shutdown() {
CompositorThreadHolder::Loop()->PostTask(NS_NewRunnableFunction( CompositorThread()->Dispatch(NS_NewRunnableFunction(
"ImageBridgeParent::Shutdown", "ImageBridgeParent::Shutdown",
[]() -> void { ImageBridgeParent::ShutdownInternal(); })); []() -> void { ImageBridgeParent::ShutdownInternal(); }));
} }
@ -146,7 +145,7 @@ void ImageBridgeParent::ActorDestroy(ActorDestroyReason aWhy) {
MonitorAutoLock lock(*sImageBridgesLock); MonitorAutoLock lock(*sImageBridgesLock);
sImageBridges.erase(OtherPid()); sImageBridges.erase(OtherPid());
} }
MessageLoop::current()->PostTask( GetThread()->Dispatch(
NewRunnableMethod("layers::ImageBridgeParent::DeferredDestroy", this, NewRunnableMethod("layers::ImageBridgeParent::DeferredDestroy", this,
&ImageBridgeParent::DeferredDestroy)); &ImageBridgeParent::DeferredDestroy));
@ -219,14 +218,14 @@ mozilla::ipc::IPCResult ImageBridgeParent::RecvUpdate(
/* static */ /* static */
bool ImageBridgeParent::CreateForContent( bool ImageBridgeParent::CreateForContent(
Endpoint<PImageBridgeParent>&& aEndpoint) { Endpoint<PImageBridgeParent>&& aEndpoint) {
MessageLoop* loop = CompositorThreadHolder::Loop(); nsCOMPtr<nsISerialEventTarget> compositorThread = CompositorThread();
if (!loop) { if (!compositorThread) {
return false; return false;
} }
RefPtr<ImageBridgeParent> bridge = RefPtr<ImageBridgeParent> bridge =
new ImageBridgeParent(loop, aEndpoint.OtherPid()); new ImageBridgeParent(compositorThread, aEndpoint.OtherPid());
loop->PostTask(NewRunnableMethod<Endpoint<PImageBridgeParent>&&>( compositorThread->Dispatch(NewRunnableMethod<Endpoint<PImageBridgeParent>&&>(
"layers::ImageBridgeParent::Bind", bridge, &ImageBridgeParent::Bind, "layers::ImageBridgeParent::Bind", bridge, &ImageBridgeParent::Bind,
std::move(aEndpoint))); std::move(aEndpoint)));

Просмотреть файл

@ -19,12 +19,6 @@
#include "nsISupportsImpl.h" #include "nsISupportsImpl.h"
#include "nsTArrayForwardDeclare.h" // for nsTArray #include "nsTArrayForwardDeclare.h" // for nsTArray
class MessageLoop;
namespace base {
class Thread;
} // namespace base
namespace mozilla { namespace mozilla {
namespace ipc { namespace ipc {
class Shmem; class Shmem;
@ -45,7 +39,7 @@ class ImageBridgeParent final : public PImageBridgeParent,
typedef nsTArray<OpDestroy> OpDestroyArray; typedef nsTArray<OpDestroy> OpDestroyArray;
protected: protected:
ImageBridgeParent(MessageLoop* aLoop, ProcessId aChildProcessId); ImageBridgeParent(nsISerialEventTarget* aThread, ProcessId aChildProcessId);
public: public:
virtual ~ImageBridgeParent(); virtual ~ImageBridgeParent();
@ -98,7 +92,7 @@ class ImageBridgeParent final : public PImageBridgeParent,
// Shutdown step 1 // Shutdown step 1
mozilla::ipc::IPCResult RecvWillClose(); mozilla::ipc::IPCResult RecvWillClose();
MessageLoop* GetMessageLoop() const { return mMessageLoop; } nsISerialEventTarget* GetThread() const { return mThread; }
// IShmemAllocator // IShmemAllocator
@ -142,7 +136,7 @@ class ImageBridgeParent final : public PImageBridgeParent,
static void ShutdownInternal(); static void ShutdownInternal();
void DeferredDestroy(); void DeferredDestroy();
MessageLoop* mMessageLoop; nsCOMPtr<nsISerialEventTarget> mThread;
// This keeps us alive until ActorDestroy(), at which point we do a // This keeps us alive until ActorDestroy(), at which point we do a
// deferred destruction of ourselves. // deferred destruction of ourselves.
RefPtr<ImageBridgeParent> mSelfRef; RefPtr<ImageBridgeParent> mSelfRef;

Просмотреть файл

@ -189,7 +189,7 @@ RefPtr<KnowsCompositor> ShadowLayerForwarder::GetForMedia() {
ShadowLayerForwarder::ShadowLayerForwarder( ShadowLayerForwarder::ShadowLayerForwarder(
ClientLayerManager* aClientLayerManager) ClientLayerManager* aClientLayerManager)
: mClientLayerManager(aClientLayerManager), : mClientLayerManager(aClientLayerManager),
mMessageLoop(MessageLoop::current()), mThread(NS_GetCurrentThread()),
mDiagnosticTypes(DiagnosticTypes::NO_DIAGNOSTIC), mDiagnosticTypes(DiagnosticTypes::NO_DIAGNOSTIC),
mIsFirstPaint(false), mIsFirstPaint(false),
mNextLayerHandle(1) { mNextLayerHandle(1) {
@ -500,9 +500,7 @@ void ShadowLayerForwarder::RemoveTextureFromCompositable(
} }
bool ShadowLayerForwarder::InWorkerThread() { bool ShadowLayerForwarder::InWorkerThread() {
return MessageLoop::current() && return GetTextureForwarder()->GetThread()->IsOnCurrentThread();
(GetTextureForwarder()->GetMessageLoop()->id() ==
MessageLoop::current()->id());
} }
void ShadowLayerForwarder::StorePluginWidgetConfigurations( void ShadowLayerForwarder::StorePluginWidgetConfigurations(

Просмотреть файл

@ -418,7 +418,7 @@ class ShadowLayerForwarder final : public LayersIPCActor,
private: private:
ClientLayerManager* mClientLayerManager; ClientLayerManager* mClientLayerManager;
Transaction* mTxn; Transaction* mTxn;
MessageLoop* mMessageLoop; nsCOMPtr<nsISerialEventTarget> mThread;
DiagnosticTypes mDiagnosticTypes; DiagnosticTypes mDiagnosticTypes;
bool mIsFirstPaint; bool mIsFirstPaint;
FocusTarget mFocusTarget; FocusTarget mFocusTarget;

Просмотреть файл

@ -13,6 +13,7 @@
#include "mozilla/layers/LayersTypes.h" // for LayersBackend #include "mozilla/layers/LayersTypes.h" // for LayersBackend
#include "mozilla/layers/TextureClient.h" // for TextureClient #include "mozilla/layers/TextureClient.h" // for TextureClient
#include "mozilla/layers/KnowsCompositor.h" #include "mozilla/layers/KnowsCompositor.h"
#include "nsISerialEventTarget.h"
namespace mozilla { namespace mozilla {
namespace ipc { namespace ipc {
@ -47,7 +48,7 @@ class LayersIPCChannel : public LayersIPCActor,
virtual base::ProcessId GetParentPid() const = 0; virtual base::ProcessId GetParentPid() const = 0;
virtual MessageLoop* GetMessageLoop() const = 0; virtual nsISerialEventTarget* GetThread() const = 0;
virtual FixedSizeSmallShmemSectionAllocator* GetTileLockAllocator() { virtual FixedSizeSmallShmemSectionAllocator* GetTileLockAllocator() {
return nullptr; return nullptr;

Просмотреть файл

@ -27,9 +27,7 @@ static RefPtr<nsThread> GetUiThread() {
} }
#endif // defined(MOZ_WIDGET_ANDROID) #endif // defined(MOZ_WIDGET_ANDROID)
static bool IsOnUiThread() { static bool IsOnUiThread() { return GetUiThread()->IsOnCurrentThread(); }
return GetUiThread()->SerialEventTarget()->IsOnCurrentThread();
}
namespace mozilla { namespace mozilla {
namespace layers { namespace layers {
@ -262,8 +260,7 @@ UiCompositorControllerChild::~UiCompositorControllerChild() = default;
void UiCompositorControllerChild::OpenForSameProcess() { void UiCompositorControllerChild::OpenForSameProcess() {
MOZ_ASSERT(IsOnUiThread()); MOZ_ASSERT(IsOnUiThread());
mIsOpen = Open(mParent->GetIPCChannel(), mIsOpen = Open(mParent->GetIPCChannel(), mozilla::layers::CompositorThread(),
mozilla::layers::CompositorThreadHolder::Loop(),
mozilla::ipc::ChildSide); mozilla::ipc::ChildSide);
if (!mIsOpen) { if (!mIsOpen) {

Просмотреть файл

@ -50,7 +50,7 @@ RefPtr<UiCompositorControllerParent> UiCompositorControllerParent::Start(
NewRunnableMethod<Endpoint<PUiCompositorControllerParent>&&>( NewRunnableMethod<Endpoint<PUiCompositorControllerParent>&&>(
"layers::UiCompositorControllerParent::Open", parent, "layers::UiCompositorControllerParent::Open", parent,
&UiCompositorControllerParent::Open, std::move(aEndpoint)); &UiCompositorControllerParent::Open, std::move(aEndpoint));
CompositorThreadHolder::Loop()->PostTask(task.forget()); CompositorThread()->Dispatch(task.forget());
return parent; return parent;
} }
@ -181,7 +181,7 @@ void UiCompositorControllerParent::ToolbarAnimatorMessageFromCompositor(
int32_t aMessage) { int32_t aMessage) {
// This function can be call from ether compositor or controller thread. // This function can be call from ether compositor or controller thread.
if (!CompositorThreadHolder::IsInCompositorThread()) { if (!CompositorThreadHolder::IsInCompositorThread()) {
CompositorThreadHolder::Loop()->PostTask(NewRunnableMethod<int32_t>( CompositorThread()->Dispatch(NewRunnableMethod<int32_t>(
"layers::UiCompositorControllerParent::" "layers::UiCompositorControllerParent::"
"ToolbarAnimatorMessageFromCompositor", "ToolbarAnimatorMessageFromCompositor",
this, this,
@ -218,11 +218,10 @@ void UiCompositorControllerParent::NotifyUpdateScreenMetrics(
aMetrics.GetZoom().ToScaleFactor(), aMetrics.GetZoom().ToScaleFactor(),
PixelCastJustification::ScreenIsParentLayerForRoot); PixelCastJustification::ScreenIsParentLayerForRoot);
ScreenPoint scrollOffset = aMetrics.GetScrollOffset() * scale; ScreenPoint scrollOffset = aMetrics.GetScrollOffset() * scale;
CompositorThreadHolder::Loop()->PostTask( CompositorThread()->Dispatch(NewRunnableMethod<ScreenPoint, CSSToScreenScale>(
NewRunnableMethod<ScreenPoint, CSSToScreenScale>( "UiCompositorControllerParent::SendRootFrameMetrics", this,
"UiCompositorControllerParent::SendRootFrameMetrics", this, &UiCompositorControllerParent::SendRootFrameMetrics, scrollOffset,
&UiCompositorControllerParent::SendRootFrameMetrics, scrollOffset, scale));
scale));
#endif #endif
} }
@ -249,7 +248,7 @@ void UiCompositorControllerParent::InitializeForSameProcess() {
SynchronousTask task( SynchronousTask task(
"UiCompositorControllerParent::InitializeForSameProcess"); "UiCompositorControllerParent::InitializeForSameProcess");
CompositorThreadHolder::Loop()->PostTask(NS_NewRunnableFunction( CompositorThread()->Dispatch(NS_NewRunnableFunction(
"UiCompositorControllerParent::InitializeForSameProcess", [&]() { "UiCompositorControllerParent::InitializeForSameProcess", [&]() {
AutoCompleteTask complete(&task); AutoCompleteTask complete(&task);
InitializeForSameProcess(); InitializeForSameProcess();

Просмотреть файл

@ -48,9 +48,7 @@ void VideoBridgeChild::Shutdown() {
} }
VideoBridgeChild::VideoBridgeChild() VideoBridgeChild::VideoBridgeChild()
: mIPDLSelfRef(this), : mIPDLSelfRef(this), mThread(NS_GetCurrentThread()), mCanSend(true) {}
mMessageLoop(MessageLoop::current()),
mCanSend(true) {}
VideoBridgeChild::~VideoBridgeChild() = default; VideoBridgeChild::~VideoBridgeChild() = default;
@ -59,7 +57,7 @@ VideoBridgeChild* VideoBridgeChild::GetSingleton() { return sVideoBridge; }
bool VideoBridgeChild::AllocUnsafeShmem( bool VideoBridgeChild::AllocUnsafeShmem(
size_t aSize, ipc::SharedMemory::SharedMemoryType aType, size_t aSize, ipc::SharedMemory::SharedMemoryType aType,
ipc::Shmem* aShmem) { ipc::Shmem* aShmem) {
if (MessageLoop::current() != mMessageLoop) { if (!mThread->IsOnCurrentThread()) {
return DispatchAllocShmemInternal(aSize, aType, aShmem, return DispatchAllocShmemInternal(aSize, aType, aShmem,
true); // true: unsafe true); // true: unsafe
} }
@ -106,7 +104,7 @@ bool VideoBridgeChild::DispatchAllocShmemInternal(
RefPtr<Runnable> runnable = WrapRunnable( RefPtr<Runnable> runnable = WrapRunnable(
RefPtr<VideoBridgeChild>(this), &VideoBridgeChild::ProxyAllocShmemNow, RefPtr<VideoBridgeChild>(this), &VideoBridgeChild::ProxyAllocShmemNow,
&task, aSize, aType, aShmem, aUnsafe, &success); &task, aSize, aType, aShmem, aUnsafe, &success);
GetMessageLoop()->PostTask(runnable.forget()); GetThread()->Dispatch(runnable.forget());
task.Wait(); task.Wait();
@ -124,7 +122,7 @@ void VideoBridgeChild::ProxyDeallocShmemNow(SynchronousTask* aTask,
} }
bool VideoBridgeChild::DeallocShmem(ipc::Shmem& aShmem) { bool VideoBridgeChild::DeallocShmem(ipc::Shmem& aShmem) {
if (MessageLoop::current() == mMessageLoop) { if (GetThread()->IsOnCurrentThread()) {
if (!CanSend()) { if (!CanSend()) {
return false; return false;
} }
@ -137,7 +135,7 @@ bool VideoBridgeChild::DeallocShmem(ipc::Shmem& aShmem) {
RefPtr<Runnable> runnable = WrapRunnable( RefPtr<Runnable> runnable = WrapRunnable(
RefPtr<VideoBridgeChild>(this), &VideoBridgeChild::ProxyDeallocShmemNow, RefPtr<VideoBridgeChild>(this), &VideoBridgeChild::ProxyDeallocShmemNow,
&task, &aShmem, &result); &task, &aShmem, &result);
GetMessageLoop()->PostTask(runnable.forget()); GetThread()->Dispatch(runnable.forget());
task.Wait(); task.Wait();
return result; return result;

Просмотреть файл

@ -57,7 +57,7 @@ class VideoBridgeChild final : public PVideoBridgeChild,
// ClientIPCAllocator // ClientIPCAllocator
base::ProcessId GetParentPid() const override { return OtherPid(); } 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 { void CancelWaitForNotifyNotUsed(uint64_t aTextureId) override {
MOZ_ASSERT(false, "NO RECYCLING HERE"); MOZ_ASSERT(false, "NO RECYCLING HERE");
} }
@ -86,7 +86,7 @@ class VideoBridgeChild final : public PVideoBridgeChild,
virtual ~VideoBridgeChild(); virtual ~VideoBridgeChild();
RefPtr<VideoBridgeChild> mIPDLSelfRef; RefPtr<VideoBridgeChild> mIPDLSelfRef;
MessageLoop* mMessageLoop; nsCOMPtr<nsISerialEventTarget> mThread;
bool mCanSend; bool mCanSend;
}; };

Просмотреть файл

@ -48,7 +48,7 @@ void VideoBridgeParent::Open(Endpoint<PVideoBridgeParent>&& aEndpoint,
VideoBridgeSource aSource) { VideoBridgeSource aSource) {
RefPtr<VideoBridgeParent> parent = new VideoBridgeParent(aSource); RefPtr<VideoBridgeParent> parent = new VideoBridgeParent(aSource);
CompositorThreadHolder::Loop()->PostTask( CompositorThread()->Dispatch(
NewRunnableMethod<Endpoint<PVideoBridgeParent>&&>( NewRunnableMethod<Endpoint<PVideoBridgeParent>&&>(
"gfx::layers::VideoBridgeParent::Bind", parent, "gfx::layers::VideoBridgeParent::Bind", parent,
&VideoBridgeParent::Bind, std::move(aEndpoint))); &VideoBridgeParent::Bind, std::move(aEndpoint)));

Просмотреть файл

@ -551,7 +551,7 @@ void AsyncImagePipelineManager::NotifyPipelinesUpdated(
// Queue a runnable on the compositor thread to process the updates. // Queue a runnable on the compositor thread to process the updates.
// This will also call CheckForTextureHostsNotUsedByGPU. // This will also call CheckForTextureHostsNotUsedByGPU.
layers::CompositorThreadHolder::Loop()->PostTask( layers::CompositorThread()->Dispatch(
NewRunnableMethod("ProcessPipelineUpdates", this, NewRunnableMethod("ProcessPipelineUpdates", this,
&AsyncImagePipelineManager::ProcessPipelineUpdates)); &AsyncImagePipelineManager::ProcessPipelineUpdates));
} }

Просмотреть файл

@ -193,7 +193,7 @@ class ScheduleObserveLayersUpdate : public wr::NotificationHandler {
mIsActive(aIsActive) {} mIsActive(aIsActive) {}
void Notify(wr::Checkpoint) override { void Notify(wr::Checkpoint) override {
CompositorThreadHolder::Loop()->PostTask( CompositorThread()->Dispatch(
NewRunnableMethod<LayersId, LayersObserverEpoch, int>( NewRunnableMethod<LayersId, LayersObserverEpoch, int>(
"ObserveLayersUpdate", mBridge, "ObserveLayersUpdate", mBridge,
&CompositorBridgeParentBase::ObserveLayersUpdate, mLayersId, &CompositorBridgeParentBase::ObserveLayersUpdate, mLayersId,
@ -217,7 +217,7 @@ class SceneBuiltNotification : public wr::NotificationHandler {
auto startTime = this->mTxnStartTime; auto startTime = this->mTxnStartTime;
RefPtr<WebRenderBridgeParent> parent = mParent; RefPtr<WebRenderBridgeParent> parent = mParent;
wr::Epoch epoch = mEpoch; wr::Epoch epoch = mEpoch;
CompositorThreadHolder::Loop()->PostTask(NS_NewRunnableFunction( CompositorThread()->Dispatch(NS_NewRunnableFunction(
"SceneBuiltNotificationRunnable", [parent, epoch, startTime]() { "SceneBuiltNotificationRunnable", [parent, epoch, startTime]() {
auto endTime = TimeStamp::Now(); auto endTime = TimeStamp::Now();
#ifdef MOZ_GECKO_PROFILER #ifdef MOZ_GECKO_PROFILER
@ -287,7 +287,7 @@ class WebRenderBridgeParent::ScheduleSharedSurfaceRelease final
} }
void Notify(wr::Checkpoint) override { void Notify(wr::Checkpoint) override {
CompositorThreadHolder::Loop()->PostTask( CompositorThread()->Dispatch(
NewRunnableMethod<nsTArray<wr::ExternalImageKeyPair>>( NewRunnableMethod<nsTArray<wr::ExternalImageKeyPair>>(
"ObserveSharedSurfaceRelease", mWrBridge, "ObserveSharedSurfaceRelease", mWrBridge,
&WebRenderBridgeParent::ObserveSharedSurfaceRelease, &WebRenderBridgeParent::ObserveSharedSurfaceRelease,

Просмотреть файл

@ -1384,8 +1384,7 @@ void DeviceManagerDx::GetCompositorDevices(
/* static */ /* static */
void DeviceManagerDx::PreloadAttachmentsOnCompositorThread() { void DeviceManagerDx::PreloadAttachmentsOnCompositorThread() {
MessageLoop* loop = layers::CompositorThreadHolder::Loop(); if (!CompositorThread()) {
if (!loop) {
return; return;
} }
@ -1404,7 +1403,7 @@ void DeviceManagerDx::PreloadAttachmentsOnCompositorThread() {
} }
} }
}); });
loop->PostTask(task.forget()); CompositorThread()->Dispatch(task.forget());
} }
} // namespace gfx } // namespace gfx

Просмотреть файл

@ -309,7 +309,7 @@ void VRManager::StartTasks() {
if (!mTaskTimer) { if (!mTaskTimer) {
mTaskInterval = GetOptimalTaskInterval(); mTaskInterval = GetOptimalTaskInterval();
mTaskTimer = NS_NewTimer(); mTaskTimer = NS_NewTimer();
mTaskTimer->SetTarget(CompositorThreadHolder::Loop()->SerialEventTarget()); mTaskTimer->SetTarget(CompositorThread());
mTaskTimer->InitWithNamedFuncCallback( mTaskTimer->InitWithNamedFuncCallback(
TaskTimerCallback, this, mTaskInterval, TaskTimerCallback, this, mTaskInterval,
nsITimer::TYPE_REPEATING_PRECISE_CAN_SKIP, nsITimer::TYPE_REPEATING_PRECISE_CAN_SKIP,
@ -1380,7 +1380,7 @@ void VRManager::SubmitFrame(VRLayerParent* aLayer,
mSubmitThread->Start(); mSubmitThread->Start();
mSubmitThread->PostTask(task.forget()); mSubmitThread->PostTask(task.forget());
#else #else
CompositorThreadHolder::Loop()->PostTask(task.forget()); CompositorThread()->Dispatch(task.forget());
#endif // defined(MOZ_WIDGET_ANDROID) #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 * frames to continue at a lower refresh rate until frame submission
* succeeds again. * succeeds again.
*/ */
MessageLoop* loop = CompositorThreadHolder::Loop(); CompositorThread()->Dispatch(NewRunnableMethod("gfx::VRManager::StartFrame",
this, &VRManager::StartFrame));
loop->PostTask(NewRunnableMethod("gfx::VRManager::StartFrame", this,
&VRManager::StartFrame));
#elif defined(MOZ_WIDGET_ANDROID) #elif defined(MOZ_WIDGET_ANDROID)
// We are already in the CompositorThreadHolder event loop on Android. // We are already in the CompositorThreadHolder event loop on Android.
StartFrame(); StartFrame();

Просмотреть файл

@ -7,6 +7,7 @@
#include "VRThread.h" #include "VRThread.h"
#include "nsDebug.h" #include "nsDebug.h"
#include "nsThreadManager.h" #include "nsThreadManager.h"
#include "nsThread.h"
#include "nsThreadUtils.h" #include "nsThreadUtils.h"
#include "VRManager.h" #include "VRManager.h"

Просмотреть файл

@ -56,7 +56,7 @@ void VRGPUChild::Shutdown() {
void VRGPUChild::ActorDestroy(ActorDestroyReason aWhy) { void VRGPUChild::ActorDestroy(ActorDestroyReason aWhy) {
VRManager* vm = VRManager::Get(); VRManager* vm = VRManager::Get();
mozilla::layers::CompositorThreadHolder::Loop()->PostTask( mozilla::layers::CompositorThread()->Dispatch(
NewRunnableMethod("VRGPUChild::ActorDestroy", vm, &VRManager::Shutdown)); NewRunnableMethod("VRGPUChild::ActorDestroy", vm, &VRManager::Shutdown));
mClosed = true; mClosed = true;

Просмотреть файл

@ -40,7 +40,6 @@ void ReleaseVRManagerParentSingleton() { sVRManagerParentSingleton = nullptr; }
VRManagerChild::VRManagerChild() VRManagerChild::VRManagerChild()
: mRuntimeCapabilities(VRDisplayCapabilityFlags::Cap_None), : mRuntimeCapabilities(VRDisplayCapabilityFlags::Cap_None),
mMessageLoop(MessageLoop::current()),
mFrameRequestCallbackCounter(0), mFrameRequestCallbackCounter(0),
mWaitingForEnumeration(false), mWaitingForEnumeration(false),
mBackend(layers::LayersBackend::LAYERS_NONE) { mBackend(layers::LayersBackend::LAYERS_NONE) {
@ -112,8 +111,7 @@ void VRManagerChild::InitSameProcess() {
sVRManagerChildSingleton = new VRManagerChild(); sVRManagerChildSingleton = new VRManagerChild();
sVRManagerParentSingleton = VRManagerParent::CreateSameProcess(); sVRManagerParentSingleton = VRManagerParent::CreateSameProcess();
sVRManagerChildSingleton->Open(sVRManagerParentSingleton->GetIPCChannel(), sVRManagerChildSingleton->Open(sVRManagerParentSingleton->GetIPCChannel(),
CompositorThreadHolder::Loop(), CompositorThread(), mozilla::ipc::ChildSide);
mozilla::ipc::ChildSide);
} }
/* static */ /* static */

Просмотреть файл

@ -158,8 +158,6 @@ class VRManagerChild : public PVRManagerChild {
bool mDisplaysInitialized; bool mDisplaysInitialized;
nsTArray<uint64_t> mNavigatorCallbacks; nsTArray<uint64_t> mNavigatorCallbacks;
MessageLoop* mMessageLoop;
struct XRFrameRequest { struct XRFrameRequest {
XRFrameRequest(mozilla::dom::FrameRequestCallback& aCallback, XRFrameRequest(mozilla::dom::FrameRequestCallback& aCallback,
int32_t aHandle) int32_t aHandle)

Просмотреть файл

@ -72,13 +72,12 @@ void VRManagerParent::UnregisterFromManager() {
/* static */ /* static */
bool VRManagerParent::CreateForContent(Endpoint<PVRManagerParent>&& aEndpoint) { bool VRManagerParent::CreateForContent(Endpoint<PVRManagerParent>&& aEndpoint) {
MessageLoop* loop = CompositorThreadHolder::Loop(); if (!CompositorThread()) {
if (!loop) {
return false; return false;
} }
RefPtr<VRManagerParent> vmp = new VRManagerParent(aEndpoint.OtherPid(), true); RefPtr<VRManagerParent> vmp = new VRManagerParent(aEndpoint.OtherPid(), true);
loop->PostTask(NewRunnableMethod<Endpoint<PVRManagerParent>&&>( CompositorThread()->Dispatch(NewRunnableMethod<Endpoint<PVRManagerParent>&&>(
"gfx::VRManagerParent::Bind", vmp, &VRManagerParent::Bind, "gfx::VRManagerParent::Bind", vmp, &VRManagerParent::Bind,
std::move(aEndpoint))); std::move(aEndpoint)));
@ -102,12 +101,11 @@ void VRManagerParent::RegisterVRManagerInCompositorThread(
/*static*/ /*static*/
VRManagerParent* VRManagerParent::CreateSameProcess() { VRManagerParent* VRManagerParent::CreateSameProcess() {
MessageLoop* loop = CompositorThreadHolder::Loop();
RefPtr<VRManagerParent> vmp = RefPtr<VRManagerParent> vmp =
new VRManagerParent(base::GetCurrentProcId(), false); new VRManagerParent(base::GetCurrentProcId(), false);
vmp->mCompositorThreadHolder = CompositorThreadHolder::GetSingleton(); vmp->mCompositorThreadHolder = CompositorThreadHolder::GetSingleton();
vmp->mSelfRef = vmp; vmp->mSelfRef = vmp;
loop->PostTask( CompositorThread()->Dispatch(
NewRunnableFunction("RegisterVRManagerIncompositorThreadRunnable", NewRunnableFunction("RegisterVRManagerIncompositorThreadRunnable",
RegisterVRManagerInCompositorThread, vmp.get())); RegisterVRManagerInCompositorThread, vmp.get()));
return vmp.get(); return vmp.get();
@ -115,13 +113,11 @@ VRManagerParent* VRManagerParent::CreateSameProcess() {
bool VRManagerParent::CreateForGPUProcess( bool VRManagerParent::CreateForGPUProcess(
Endpoint<PVRManagerParent>&& aEndpoint) { Endpoint<PVRManagerParent>&& aEndpoint) {
MessageLoop* loop = CompositorThreadHolder::Loop();
RefPtr<VRManagerParent> vmp = RefPtr<VRManagerParent> vmp =
new VRManagerParent(aEndpoint.OtherPid(), false); new VRManagerParent(aEndpoint.OtherPid(), false);
vmp->mCompositorThreadHolder = CompositorThreadHolder::GetSingleton(); vmp->mCompositorThreadHolder = CompositorThreadHolder::GetSingleton();
vmp->mSelfRef = vmp; vmp->mSelfRef = vmp;
loop->PostTask(NewRunnableMethod<Endpoint<PVRManagerParent>&&>( CompositorThread()->Dispatch(NewRunnableMethod<Endpoint<PVRManagerParent>&&>(
"gfx::VRManagerParent::Bind", vmp, &VRManagerParent::Bind, "gfx::VRManagerParent::Bind", vmp, &VRManagerParent::Bind,
std::move(aEndpoint))); std::move(aEndpoint)));
return true; return true;
@ -130,7 +126,7 @@ bool VRManagerParent::CreateForGPUProcess(
/*static*/ /*static*/
void VRManagerParent::Shutdown() { void VRManagerParent::Shutdown() {
ReleaseVRManagerParentSingleton(); ReleaseVRManagerParentSingleton();
CompositorThreadHolder::Loop()->PostTask(NS_NewRunnableFunction( CompositorThread()->Dispatch(NS_NewRunnableFunction(
"VRManagerParent::Shutdown", "VRManagerParent::Shutdown",
[]() -> void { VRManagerParent::ShutdownInternal(); })); []() -> void { VRManagerParent::ShutdownInternal(); }));
} }

Просмотреть файл

@ -469,7 +469,7 @@ void RenderThread::UpdateAndRender(
auto& renderer = it->second; auto& renderer = it->second;
layers::CompositorThreadHolder::Loop()->PostTask( layers::CompositorThread()->Dispatch(
NewRunnableFunction("NotifyDidStartRenderRunnable", &NotifyDidStartRender, NewRunnableFunction("NotifyDidStartRenderRunnable", &NotifyDidStartRender,
renderer->GetCompositorBridge())); renderer->GetCompositorBridge()));
@ -487,7 +487,7 @@ void RenderThread::UpdateAndRender(
TimeStamp end = TimeStamp::Now(); TimeStamp end = TimeStamp::Now();
RefPtr<const WebRenderPipelineInfo> info = renderer->FlushPipelineInfo(); RefPtr<const WebRenderPipelineInfo> info = renderer->FlushPipelineInfo();
layers::CompositorThreadHolder::Loop()->PostTask( layers::CompositorThread()->Dispatch(
NewRunnableFunction("NotifyDidRenderRunnable", &NotifyDidRender, NewRunnableFunction("NotifyDidRenderRunnable", &NotifyDidRender,
renderer->GetCompositorBridge(), info, aStartId, renderer->GetCompositorBridge(), info, aStartId,
aStartTime, start, end, aRender, stats)); aStartTime, start, end, aRender, stats));
@ -821,7 +821,7 @@ void RenderThread::HandleWebRenderError(WebRenderError aError) {
return; return;
} }
layers::CompositorThreadHolder::Loop()->PostTask(NewRunnableFunction( layers::CompositorThread()->Dispatch(NewRunnableFunction(
"DoNotifyWebRenderErrorRunnable", &DoNotifyWebRenderError, aError)); "DoNotifyWebRenderErrorRunnable", &DoNotifyWebRenderError, aError));
{ {
MutexAutoLock lock(mRenderTextureMapLock); MutexAutoLock lock(mRenderTextureMapLock);
@ -1114,7 +1114,7 @@ void wr_finished_scene_build(mozilla::wr::WrWindowId aWindowId,
for (size_t i = 0; i < aDocumentIdsCount; ++i) { for (size_t i = 0; i < aDocumentIdsCount; ++i) {
renderRoots[i] = wr::RenderRootFromId(aDocumentIds[i]); renderRoots[i] = wr::RenderRootFromId(aDocumentIds[i]);
} }
layers::CompositorThreadHolder::Loop()->PostTask( layers::CompositorThread()->Dispatch(
NewRunnableFunction("NotifyDidSceneBuild", &NotifyDidSceneBuild, cbp, NewRunnableFunction("NotifyDidSceneBuild", &NotifyDidSceneBuild, cbp,
std::move(renderRoots), info)); std::move(renderRoots), info));
} }

Просмотреть файл

@ -200,7 +200,7 @@ bool RendererOGL::EnsureAsyncScreenshot() {
return true; return true;
} }
if (!mDisableNativeCompositor) { if (!mDisableNativeCompositor) {
layers::CompositorThreadHolder::Loop()->PostTask( layers::CompositorThread()->Dispatch(
NewRunnableFunction("DoWebRenderDisableNativeCompositorRunnable", NewRunnableFunction("DoWebRenderDisableNativeCompositorRunnable",
&DoWebRenderDisableNativeCompositor, mBridge)); &DoWebRenderDisableNativeCompositor, mBridge));
@ -219,7 +219,7 @@ void RendererOGL::CheckGraphicsResetStatus() {
if (gl->IsSupported(gl::GLFeature::robustness)) { if (gl->IsSupported(gl::GLFeature::robustness)) {
GLenum resetStatus = gl->fGetGraphicsResetStatus(); GLenum resetStatus = gl->fGetGraphicsResetStatus();
if (resetStatus == LOCAL_GL_PURGED_CONTEXT_RESET_NV) { if (resetStatus == LOCAL_GL_PURGED_CONTEXT_RESET_NV) {
layers::CompositorThreadHolder::Loop()->PostTask( layers::CompositorThread()->Dispatch(
NewRunnableFunction("DoNotifyWebRenderContextPurgeRunnable", NewRunnableFunction("DoNotifyWebRenderContextPurgeRunnable",
&DoNotifyWebRenderContextPurge, mBridge)); &DoNotifyWebRenderContextPurge, mBridge));
} }

Просмотреть файл

@ -54,7 +54,6 @@ T MinIgnoreZero(const T& a, const T& b);
class VideoStreamFactory; class VideoStreamFactory;
class WebrtcAudioConduit; class WebrtcAudioConduit;
class nsThread;
// Interface of external video encoder for WebRTC. // Interface of external video encoder for WebRTC.
class WebrtcVideoEncoder : public VideoEncoder, public webrtc::VideoEncoder {}; class WebrtcVideoEncoder : public VideoEncoder, public webrtc::VideoEncoder {};

Просмотреть файл

@ -216,7 +216,7 @@ void CompositorWidgetParent::UpdateCompositorWnd(const HWND aCompositorWnd,
SendUpdateCompositorWnd(reinterpret_cast<WindowsHandle>(aCompositorWnd), SendUpdateCompositorWnd(reinterpret_cast<WindowsHandle>(aCompositorWnd),
reinterpret_cast<WindowsHandle>(aParentWnd)) reinterpret_cast<WindowsHandle>(aParentWnd))
->Then( ->Then(
layers::CompositorThreadHolder::Loop()->SerialEventTarget(), __func__, layers::CompositorThread(), __func__,
[self](const bool& aSuccess) { [self](const bool& aSuccess) {
if (aSuccess && self->mRootLayerTreeID.isSome()) { if (aSuccess && self->mRootLayerTreeID.isSome()) {
self->mSetParentCompleted = true; self->mSetParentCompleted = true;