зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1365099 - Convert NS_GetCurrentThread uses in gfx (r=dvander)
MozReview-Commit-ID: 9I4eXsBl2s8
This commit is contained in:
Родитель
aefa2aa5da
Коммит
f9aca3eae6
|
@ -86,7 +86,7 @@ OffscreenCanvas::ClearResources()
|
|||
mCanvasClient->Clear();
|
||||
|
||||
if (mCanvasRenderer) {
|
||||
nsCOMPtr<nsISerialEventTarget> activeTarget = mCanvasRenderer->GetActiveThread();
|
||||
nsCOMPtr<nsISerialEventTarget> activeTarget = mCanvasRenderer->GetActiveEventTarget();
|
||||
MOZ_RELEASE_ASSERT(activeTarget, "GFX: failed to get active event target.");
|
||||
bool current;
|
||||
activeTarget->IsOnCurrentThread(¤t);
|
||||
|
@ -94,7 +94,7 @@ OffscreenCanvas::ClearResources()
|
|||
mCanvasRenderer->SetCanvasClient(nullptr);
|
||||
mCanvasRenderer->mContext = nullptr;
|
||||
mCanvasRenderer->mGLContext = nullptr;
|
||||
mCanvasRenderer->ResetActiveThread();
|
||||
mCanvasRenderer->ResetActiveEventTarget();
|
||||
}
|
||||
|
||||
mCanvasClient = nullptr;
|
||||
|
@ -143,7 +143,7 @@ OffscreenCanvas::GetContext(JSContext* aCx,
|
|||
WebGLContext* webGL = static_cast<WebGLContext*>(mCurrentContext.get());
|
||||
gl::GLContext* gl = webGL->GL();
|
||||
mCanvasRenderer->mContext = mCurrentContext;
|
||||
mCanvasRenderer->SetActiveThread();
|
||||
mCanvasRenderer->SetActiveEventTarget();
|
||||
mCanvasRenderer->mGLContext = gl;
|
||||
mCanvasRenderer->SetIsAlphaPremultiplied(webGL->IsPremultAlpha() || !gl->Caps().alpha);
|
||||
|
||||
|
|
|
@ -1375,7 +1375,7 @@ HTMLCanvasElement::OnVisibilityChange()
|
|||
};
|
||||
|
||||
RefPtr<nsIRunnable> runnable = new Runnable(mAsyncCanvasRenderer);
|
||||
nsCOMPtr<nsIEventTarget> activeTarget = mAsyncCanvasRenderer->GetActiveThread();
|
||||
nsCOMPtr<nsIEventTarget> activeTarget = mAsyncCanvasRenderer->GetActiveEventTarget();
|
||||
if (activeTarget) {
|
||||
activeTarget->Dispatch(runnable, nsIThread::DISPATCH_NORMAL);
|
||||
}
|
||||
|
@ -1417,7 +1417,7 @@ HTMLCanvasElement::OnMemoryPressure()
|
|||
};
|
||||
|
||||
RefPtr<nsIRunnable> runnable = new Runnable(mAsyncCanvasRenderer);
|
||||
nsCOMPtr<nsIEventTarget> activeTarget = mAsyncCanvasRenderer->GetActiveThread();
|
||||
nsCOMPtr<nsIEventTarget> activeTarget = mAsyncCanvasRenderer->GetActiveEventTarget();
|
||||
if (activeTarget) {
|
||||
activeTarget->Dispatch(runnable, nsIThread::DISPATCH_NORMAL);
|
||||
}
|
||||
|
|
|
@ -216,9 +216,6 @@ SharedSurface::SharedSurface(SharedSurfaceType type,
|
|||
, mCanRecycle(canRecycle)
|
||||
, mIsLocked(false)
|
||||
, mIsProducerAcquired(false)
|
||||
#ifdef DEBUG
|
||||
, mOwningThread(NS_GetCurrentThread())
|
||||
#endif
|
||||
{ }
|
||||
|
||||
layers::TextureFlags
|
||||
|
|
|
@ -67,9 +67,6 @@ public:
|
|||
protected:
|
||||
bool mIsLocked;
|
||||
bool mIsProducerAcquired;
|
||||
#ifdef DEBUG
|
||||
nsIThread* const mOwningThread;
|
||||
#endif
|
||||
|
||||
SharedSurface(SharedSurfaceType type,
|
||||
AttachmentType attachType,
|
||||
|
|
|
@ -122,24 +122,24 @@ AsyncCanvasRenderer::SetCanvasClient(CanvasClient* aClient)
|
|||
}
|
||||
|
||||
void
|
||||
AsyncCanvasRenderer::SetActiveThread()
|
||||
AsyncCanvasRenderer::SetActiveEventTarget()
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
mActiveThread = NS_GetCurrentThread();
|
||||
mActiveEventTarget = GetCurrentThreadSerialEventTarget();
|
||||
}
|
||||
|
||||
void
|
||||
AsyncCanvasRenderer::ResetActiveThread()
|
||||
AsyncCanvasRenderer::ResetActiveEventTarget()
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
mActiveThread = nullptr;
|
||||
mActiveEventTarget = nullptr;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIThread>
|
||||
AsyncCanvasRenderer::GetActiveThread()
|
||||
already_AddRefed<nsISerialEventTarget>
|
||||
AsyncCanvasRenderer::GetActiveEventTarget()
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
nsCOMPtr<nsIThread> result = mActiveThread;
|
||||
nsCOMPtr<nsISerialEventTarget> result = mActiveEventTarget;
|
||||
return result.forget();
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
class nsICanvasRenderingContextInternal;
|
||||
class nsIInputStream;
|
||||
class nsIThread;
|
||||
class nsISerialEventTarget;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -79,8 +79,8 @@ public:
|
|||
}
|
||||
|
||||
// Active thread means the thread which spawns GLContext.
|
||||
void SetActiveThread();
|
||||
void ResetActiveThread();
|
||||
void SetActiveEventTarget();
|
||||
void ResetActiveEventTarget();
|
||||
|
||||
// This will readback surface and return the surface
|
||||
// in the DataSourceSurface.
|
||||
|
@ -116,7 +116,7 @@ public:
|
|||
return mCanvasClient;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIThread> GetActiveThread();
|
||||
already_AddRefed<nsISerialEventTarget> GetActiveEventTarget();
|
||||
|
||||
// The lifetime is controllered by HTMLCanvasElement.
|
||||
// Only accessed in main thread.
|
||||
|
@ -159,7 +159,7 @@ private:
|
|||
Mutex mMutex;
|
||||
|
||||
// Can be accessed in any thread, need protect by mutex.
|
||||
nsCOMPtr<nsIThread> mActiveThread;
|
||||
nsCOMPtr<nsISerialEventTarget> mActiveEventTarget;
|
||||
};
|
||||
|
||||
} // namespace layers
|
||||
|
|
|
@ -107,25 +107,23 @@ public:
|
|||
static RawRef Void() { return nullptr; }
|
||||
void Release(RawRef aRawRef)
|
||||
{
|
||||
MOZ_ASSERT(mOwningThread);
|
||||
bool current;
|
||||
mOwningThread->IsOnCurrentThread(¤t);
|
||||
if (current) {
|
||||
MOZ_ASSERT(mOwningEventTarget);
|
||||
if (mOwningEventTarget->IsOnCurrentThread()) {
|
||||
aRawRef->Release();
|
||||
return;
|
||||
}
|
||||
nsCOMPtr<nsIRunnable> runnable = new SurfaceReleaser(aRawRef);
|
||||
mOwningThread->Dispatch(runnable, nsIThread::DISPATCH_NORMAL);
|
||||
mOwningEventTarget->Dispatch(runnable, nsIThread::DISPATCH_NORMAL);
|
||||
}
|
||||
void AddRef(RawRef aRawRef)
|
||||
{
|
||||
MOZ_ASSERT(!mOwningThread);
|
||||
NS_GetCurrentThread(getter_AddRefs(mOwningThread));
|
||||
MOZ_ASSERT(!mOwningEventTarget);
|
||||
mOwningEventTarget = mozilla::GetCurrentThreadSerialEventTarget();
|
||||
aRawRef->AddRef();
|
||||
}
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIThread> mOwningThread;
|
||||
nsCOMPtr<nsISerialEventTarget> mOwningEventTarget;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -787,7 +787,7 @@ public:
|
|||
protected:
|
||||
virtual ~DebugDataSender() {}
|
||||
void RemoveData() {
|
||||
MOZ_ASSERT(NS_GetCurrentThread() == mThread);
|
||||
MOZ_ASSERT(mThread->SerialEventTarget()->IsOnCurrentThread());
|
||||
if (mList.isEmpty())
|
||||
return;
|
||||
|
||||
|
@ -1159,7 +1159,7 @@ LayerScopeWebSocketManager::SocketHandler::OpenStream(nsISocketTransport* aTrans
|
|||
0,
|
||||
getter_AddRefs(debugInputStream));
|
||||
mInputStream = do_QueryInterface(debugInputStream);
|
||||
mInputStream->AsyncWait(this, 0, 0, NS_GetCurrentThread());
|
||||
mInputStream->AsyncWait(this, 0, 0, GetCurrentThreadEventTarget());
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1234,7 +1234,7 @@ LayerScopeWebSocketManager::SocketHandler::OnInputStreamReady(nsIAsyncInputStrea
|
|||
if (WebSocketHandshake(protocolString)) {
|
||||
mState = HandshakeSuccess;
|
||||
mConnected = true;
|
||||
mInputStream->AsyncWait(this, 0, 0, NS_GetCurrentThread());
|
||||
mInputStream->AsyncWait(this, 0, 0, GetCurrentThreadEventTarget());
|
||||
} else {
|
||||
mState = HandshakeFailed;
|
||||
}
|
||||
|
@ -1364,7 +1364,7 @@ LayerScopeWebSocketManager::SocketHandler::HandleSocketMessage(nsIAsyncInputStre
|
|||
// TODO: combine packets if we have to read more than once
|
||||
|
||||
if (rv == NS_BASE_STREAM_WOULD_BLOCK) {
|
||||
mInputStream->AsyncWait(this, 0, 0, NS_GetCurrentThread());
|
||||
mInputStream->AsyncWait(this, 0, 0, GetCurrentThreadEventTarget());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ GetUiThread()
|
|||
static bool
|
||||
IsOnUiThread()
|
||||
{
|
||||
return NS_GetCurrentThread() == GetUiThread();
|
||||
return GetUiThread()->SerialEventTarget()->IsOnCurrentThread();
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
|
|
Загрузка…
Ссылка в новой задаче