mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1218881. Enforce queries' new availability semantics. r=jgilbert
This adds a Runnable that we dispatch to the event loop so that we can make sure queries don't become available before they are supposed to.
This commit is contained in:
parent
3ce0bc1135
commit
668c8b1285
@ -6,6 +6,8 @@
|
||||
#include "WebGL2Context.h"
|
||||
#include "GLContext.h"
|
||||
#include "WebGLQuery.h"
|
||||
#include "gfxPrefs.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -255,6 +257,7 @@ WebGL2Context::EndQuery(GLenum target)
|
||||
}
|
||||
|
||||
UpdateBoundQuery(target, nullptr);
|
||||
NS_DispatchToCurrentThread(new WebGLQuery::AvailableRunnable(activeQuery));
|
||||
}
|
||||
|
||||
already_AddRefed<WebGLQuery>
|
||||
@ -325,6 +328,11 @@ WebGL2Context::GetQueryParameter(JSContext*, WebGLQuery* query, GLenum pname,
|
||||
return;
|
||||
}
|
||||
|
||||
// We must wait for an event loop before the query can be available
|
||||
if (!query->mCanBeAvailable && !gfxPrefs::WebGLImmediateQueries()) {
|
||||
return;
|
||||
}
|
||||
|
||||
MakeContextCurrent();
|
||||
GLuint returned = 0;
|
||||
switch (pname) {
|
||||
|
@ -20,6 +20,7 @@ WebGLQuery::WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto)
|
||||
|
||||
WebGLQuery::WebGLQuery(WebGLContext* webgl)
|
||||
: WebGLContextBoundObject(webgl)
|
||||
, mCanBeAvailable(false)
|
||||
, mGLName(0)
|
||||
, mType(0)
|
||||
{
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
#include "WebGLObjectModel.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -22,6 +23,19 @@ class WebGLQuery final
|
||||
public:
|
||||
explicit WebGLQuery(WebGLContext* webgl);
|
||||
|
||||
class AvailableRunnable final : public nsRunnable
|
||||
{
|
||||
public:
|
||||
AvailableRunnable(WebGLQuery* query) : mQuery(query) { }
|
||||
|
||||
NS_IMETHOD Run() override {
|
||||
mQuery->mCanBeAvailable = true;
|
||||
return NS_OK;
|
||||
}
|
||||
private:
|
||||
const RefPtr<WebGLQuery> mQuery;
|
||||
};
|
||||
|
||||
bool IsActive() const;
|
||||
|
||||
bool HasEverBeenActive() const {
|
||||
@ -42,6 +56,8 @@ public:
|
||||
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLQuery)
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLQuery)
|
||||
|
||||
// Track whether the event loop has spun
|
||||
bool mCanBeAvailable;
|
||||
|
||||
private:
|
||||
~WebGLQuery() {
|
||||
|
@ -437,6 +437,7 @@ private:
|
||||
DECL_GFX_PREF(Live, "webgl.msaa-force", WebGLForceMSAA, bool, false);
|
||||
DECL_GFX_PREF(Live, "webgl.prefer-16bpp", WebGLPrefer16bpp, bool, false);
|
||||
DECL_GFX_PREF(Live, "webgl.restore-context-when-visible", WebGLRestoreWhenVisible, bool, true);
|
||||
DECL_GFX_PREF(Live, "webgl.allow-immediate-queries", WebGLImmediateQueries, bool, false);
|
||||
|
||||
DECL_GFX_PREF(Live, "webgl.webgl2-compat-mode", WebGL2CompatMode, bool, false);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user