mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Bug 1251390. Make timer queries available at the appropriate time. r=jgilbert
This is similar to what we do for other queries.
This commit is contained in:
parent
5acfe256eb
commit
c8d4db8b1a
@ -12,6 +12,7 @@
|
||||
#include "GLContext.h"
|
||||
#include "WebGLContext.h"
|
||||
#include "WebGLTimerQuery.h"
|
||||
#include "gfxPrefs.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -117,6 +118,7 @@ WebGLExtensionDisjointTimerQuery::EndQueryEXT(GLenum target)
|
||||
|
||||
mContext->MakeContextCurrent();
|
||||
mContext->GL()->fEndQuery(target);
|
||||
mActiveQuery->QueueAvailablity();
|
||||
mActiveQuery = nullptr;
|
||||
}
|
||||
|
||||
@ -139,6 +141,7 @@ WebGLExtensionDisjointTimerQuery::QueryCounterEXT(WebGLTimerQuery* query,
|
||||
mContext->MakeContextCurrent();
|
||||
mContext->GL()->fQueryCounter(query->mGLName, target);
|
||||
query->mTarget = LOCAL_GL_TIMESTAMP_EXT;
|
||||
query->QueueAvailablity();
|
||||
}
|
||||
|
||||
void
|
||||
@ -221,7 +224,8 @@ WebGLExtensionDisjointTimerQuery::GetQueryObjectEXT(JSContext* cx,
|
||||
mContext->GL()->fGetQueryObjectuiv(query->mGLName,
|
||||
LOCAL_GL_QUERY_RESULT_AVAILABLE_EXT,
|
||||
&avail);
|
||||
retval.set(JS::BooleanValue(bool(avail)));
|
||||
bool canBeAvailable = query->CanBeAvailable() || gfxPrefs::WebGLImmediateQueries();
|
||||
retval.set(JS::BooleanValue(bool(avail) && canBeAvailable));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "mozilla/dom/WebGLRenderingContextBinding.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "WebGLContext.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -23,6 +24,7 @@ WebGLTimerQuery::WebGLTimerQuery(WebGLContext* webgl, GLuint name)
|
||||
: WebGLContextBoundObject(webgl)
|
||||
, mGLName(name)
|
||||
, mTarget(LOCAL_GL_NONE)
|
||||
, mCanBeAvailable(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -53,6 +55,12 @@ WebGLTimerQuery::GetParentObject() const
|
||||
return mContext;
|
||||
}
|
||||
|
||||
void
|
||||
WebGLTimerQuery::QueueAvailablity()
|
||||
{
|
||||
RefPtr<WebGLTimerQuery> self = this;
|
||||
NS_DispatchToCurrentThread(NS_NewRunnableFunction([self] { self->mCanBeAvailable = true; }));
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WebGLTimerQuery)
|
||||
|
||||
|
@ -24,6 +24,8 @@ public:
|
||||
void Delete();
|
||||
|
||||
bool HasEverBeenBound() const { return mTarget != LOCAL_GL_NONE; }
|
||||
bool CanBeAvailable() const { return mCanBeAvailable; }
|
||||
void QueueAvailablity();
|
||||
GLenum Target() const { return mTarget; }
|
||||
|
||||
WebGLContext* GetParentObject() const;
|
||||
@ -41,6 +43,7 @@ private:
|
||||
~WebGLTimerQuery();
|
||||
|
||||
GLenum mTarget;
|
||||
bool mCanBeAvailable;
|
||||
|
||||
friend class WebGLExtensionDisjointTimerQuery;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user