Bug 1006336 - Change OwningThreadId in GLContext to PlatformThread::CurrentId(). r=bjacob

This commit is contained in:
Peter Chang 2014-05-09 00:18:00 -04:00
parent 409ceee740
commit 254d3e5865
2 changed files with 5 additions and 18 deletions

View File

@ -285,7 +285,7 @@ GLContext::GLContext(const SurfaceCaps& caps,
mNeedsTextureSizeChecks(false),
mWorkAroundDriverBugs(true)
{
mOwningThread = NS_GetCurrentThread();
mOwningThreadId = PlatformThread::CurrentId();
}
GLContext::~GLContext() {
@ -2108,20 +2108,7 @@ GLContext::IsOffscreenSizeAllowed(const IntSize& aSize) const {
bool
GLContext::IsOwningThreadCurrent()
{
return NS_GetCurrentThread() == mOwningThread;
}
void
GLContext::DispatchToOwningThread(nsIRunnable *event)
{
// Before dispatching, we need to ensure we're not in the middle of
// shutting down. Dispatching runnables in the middle of shutdown
// (that is, when the main thread is no longer get-able) can cause them
// to leak. See Bug 741319, and Bug 744115.
nsCOMPtr<nsIThread> mainThread;
if (NS_SUCCEEDED(NS_GetMainThread(getter_AddRefs(mainThread)))) {
mOwningThread->Dispatch(event, NS_DISPATCH_NORMAL);
}
return PlatformThread::CurrentId() == mOwningThreadId;
}
GLBlitHelper*

View File

@ -38,6 +38,7 @@
#include "SurfaceTypes.h"
#include "GLScreenBuffer.h"
#include "GLContextSymbols.h"
#include "base/platform_thread.h" // for PlatformThreadId
#include "mozilla/GenericRefCounted.h"
#include "mozilla/Scoped.h"
#include "gfx2DGlue.h"
@ -2569,7 +2570,6 @@ public:
* executing thread.
*/
bool IsOwningThreadCurrent();
void DispatchToOwningThread(nsIRunnable *event);
static void PlatformStartup();
@ -2733,8 +2733,8 @@ public:
protected:
nsRefPtr<GLContext> mSharedContext;
// The thread on which this context was created.
nsCOMPtr<nsIThread> mOwningThread;
// The thread id which this context was created.
PlatformThreadId mOwningThreadId;
GLContextSymbols mSymbols;