зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1685055 [Wayland] Post SyncBegin() to main thread only and remove thread specific code as it's unused, r=jhorak
Differential Revision: https://phabricator.services.mozilla.com/D101157
This commit is contained in:
Родитель
b18d5b9051
Коммит
e8802ce8e3
|
@ -83,10 +83,6 @@
|
|||
# include "mozilla/WindowsVersion.h"
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WAYLAND
|
||||
# include "mozilla/widget/nsWaylandDisplay.h"
|
||||
#endif
|
||||
|
||||
#include "nsGkAtoms.h"
|
||||
#include "gfxPlatformFontList.h"
|
||||
#include "gfxContext.h"
|
||||
|
@ -1353,10 +1349,6 @@ void gfxPlatform::ShutdownLayersIPC() {
|
|||
}
|
||||
sLayersIPCIsUp = false;
|
||||
|
||||
#ifdef MOZ_WAYLAND
|
||||
widget::WaylandDisplayShutdown();
|
||||
#endif
|
||||
|
||||
if (XRE_IsContentProcess()) {
|
||||
gfx::VRManagerChild::ShutDown();
|
||||
// cf bug 1215265.
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
#include "gfxPlatform.h"
|
||||
#include "MozContainer.h"
|
||||
#include "nsTArray.h"
|
||||
#include "base/message_loop.h" // for MessageLoop
|
||||
#include "base/task.h" // for NewRunnableMethod, etc
|
||||
#include "mozilla/ScopeExit.h"
|
||||
#include "mozilla/StaticPrefs_widget.h"
|
||||
|
||||
|
|
|
@ -25,14 +25,6 @@ namespace widget {
|
|||
static RefPtr<nsWaylandDisplay> gWaylandDisplays[MAX_DISPLAY_CONNECTIONS];
|
||||
static StaticMutex gWaylandDisplayArrayWriteMutex;
|
||||
|
||||
void WaylandDisplayShutdown() {
|
||||
for (auto& display : gWaylandDisplays) {
|
||||
if (display) {
|
||||
display->ShutdownThreadLoop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Dispatch events to Compositor/Render queues
|
||||
void WaylandDispatchDisplays() {
|
||||
MOZ_ASSERT(NS_IsMainThread(),
|
||||
|
@ -238,22 +230,10 @@ void nsWaylandDisplay::SyncBegin() {
|
|||
wl_display_flush(mDisplay);
|
||||
}
|
||||
|
||||
static void WaylandDisplayQueueSyncBegin(RefPtr<nsWaylandDisplay> aDisplay) {
|
||||
for (auto& display : gWaylandDisplays) {
|
||||
if (display == aDisplay) {
|
||||
display->SyncBegin();
|
||||
return;
|
||||
}
|
||||
}
|
||||
NS_WARNING("DispatchDisplay was called for released display!");
|
||||
}
|
||||
|
||||
void nsWaylandDisplay::QueueSyncBegin() {
|
||||
MessageLoop* loop = GetThreadLoop();
|
||||
if (loop) {
|
||||
loop->PostTask(NewRunnableFunction("WaylandSyncBegin",
|
||||
&WaylandDisplayQueueSyncBegin, this));
|
||||
}
|
||||
NS_DispatchToMainThread(
|
||||
NS_NewRunnableFunction("nsWaylandDisplay::QueueSyncBegin",
|
||||
[this]() -> void { this->SyncBegin(); }));
|
||||
}
|
||||
|
||||
void nsWaylandDisplay::WaitForSyncEnd() {
|
||||
|
@ -263,6 +243,8 @@ void nsWaylandDisplay::WaitForSyncEnd() {
|
|||
}
|
||||
|
||||
while (mSyncCallback != nullptr) {
|
||||
// TODO: wl_display_dispatch_queue() should not be called while
|
||||
// glib main loop is iterated at nsAppShell::ProcessNextNativeEvent().
|
||||
if (wl_display_dispatch_queue(mDisplay, mEventQueue) == -1) {
|
||||
NS_WARNING("wl_display_dispatch_queue failed!");
|
||||
SyncEnd();
|
||||
|
@ -275,23 +257,8 @@ bool nsWaylandDisplay::Matches(wl_display* aDisplay) {
|
|||
return mThreadId == PR_GetCurrentThread() && aDisplay == mDisplay;
|
||||
}
|
||||
|
||||
class nsWaylandDisplayLoopObserver : public MessageLoop::DestructionObserver {
|
||||
public:
|
||||
explicit nsWaylandDisplayLoopObserver(nsWaylandDisplay* aWaylandDisplay)
|
||||
: mDisplay(aWaylandDisplay){};
|
||||
virtual void WillDestroyCurrentMessageLoop() override {
|
||||
mDisplay->ShutdownThreadLoop();
|
||||
mDisplay = nullptr;
|
||||
delete this;
|
||||
}
|
||||
|
||||
private:
|
||||
nsWaylandDisplay* mDisplay;
|
||||
};
|
||||
|
||||
nsWaylandDisplay::nsWaylandDisplay(wl_display* aDisplay, bool aLighWrapper)
|
||||
: mThreadLoop(nullptr),
|
||||
mThreadId(PR_GetCurrentThread()),
|
||||
: mThreadId(PR_GetCurrentThread()),
|
||||
mDisplay(aDisplay),
|
||||
mEventQueue(nullptr),
|
||||
mDataDeviceManager(nullptr),
|
||||
|
@ -311,11 +278,6 @@ nsWaylandDisplay::nsWaylandDisplay(wl_display* aDisplay, bool aLighWrapper)
|
|||
}
|
||||
|
||||
if (!NS_IsMainThread()) {
|
||||
mThreadLoop = MessageLoop::current();
|
||||
if (mThreadLoop) {
|
||||
auto observer = new nsWaylandDisplayLoopObserver(this);
|
||||
mThreadLoop->AddDestructionObserver(observer);
|
||||
}
|
||||
mEventQueue = wl_display_create_queue(mDisplay);
|
||||
wl_proxy_set_queue((struct wl_proxy*)mRegistry, mEventQueue);
|
||||
}
|
||||
|
@ -331,8 +293,6 @@ nsWaylandDisplay::nsWaylandDisplay(wl_display* aDisplay, bool aLighWrapper)
|
|||
}
|
||||
}
|
||||
|
||||
void nsWaylandDisplay::ShutdownThreadLoop() { mThreadLoop = nullptr; }
|
||||
|
||||
nsWaylandDisplay::~nsWaylandDisplay() {
|
||||
wl_registry_destroy(mRegistry);
|
||||
mRegistry = nullptr;
|
||||
|
|
|
@ -75,15 +75,11 @@ class nsWaylandDisplay {
|
|||
zwp_primary_selection_device_manager_v1* aPrimarySelectionDeviceManager);
|
||||
void SetIdleInhibitManager(zwp_idle_inhibit_manager_v1* aIdleInhibitManager);
|
||||
|
||||
MessageLoop* GetThreadLoop() { return mThreadLoop; }
|
||||
void ShutdownThreadLoop();
|
||||
|
||||
bool IsExplicitSyncEnabled() { return mExplicitSync; }
|
||||
|
||||
private:
|
||||
~nsWaylandDisplay();
|
||||
|
||||
MessageLoop* mThreadLoop;
|
||||
PRThread* mThreadId;
|
||||
wl_display* mDisplay;
|
||||
wl_event_queue* mEventQueue;
|
||||
|
@ -101,7 +97,6 @@ class nsWaylandDisplay {
|
|||
};
|
||||
|
||||
void WaylandDispatchDisplays();
|
||||
void WaylandDisplayShutdown();
|
||||
void WaylandDisplayRelease();
|
||||
|
||||
RefPtr<nsWaylandDisplay> WaylandDisplayGet(GdkDisplay* aGdkDisplay = nullptr);
|
||||
|
|
Загрузка…
Ссылка в новой задаче