2013-08-07 01:23:46 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
#ifndef WEBGL_QUERY_H_
|
|
|
|
#define WEBGL_QUERY_H_
|
2013-08-07 01:23:46 +04:00
|
|
|
|
|
|
|
#include "mozilla/LinkedList.h"
|
2014-11-14 07:03:50 +03:00
|
|
|
#include "nsWrapperCache.h"
|
2015-07-15 03:37:28 +03:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
#include "WebGLObjectModel.h"
|
2015-12-19 01:05:42 +03:00
|
|
|
#include "nsThreadUtils.h"
|
2013-08-07 01:23:46 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class WebGLQuery final
|
2013-09-04 16:14:48 +04:00
|
|
|
: public nsWrapperCache
|
2013-08-07 01:23:46 +04:00
|
|
|
, public WebGLRefCountedObject<WebGLQuery>
|
|
|
|
, public LinkedListElement<WebGLQuery>
|
|
|
|
, public WebGLContextBoundObject
|
|
|
|
{
|
|
|
|
public:
|
2014-11-14 07:03:50 +03:00
|
|
|
explicit WebGLQuery(WebGLContext* webgl);
|
2013-08-07 01:23:46 +04:00
|
|
|
|
2015-12-19 01:05:42 +03:00
|
|
|
class AvailableRunnable final : public nsRunnable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit AvailableRunnable(WebGLQuery* query) : mQuery(query) { }
|
|
|
|
|
|
|
|
NS_IMETHOD Run() override {
|
|
|
|
mQuery->mCanBeAvailable = true;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
const RefPtr<WebGLQuery> mQuery;
|
|
|
|
};
|
|
|
|
|
2013-09-04 16:14:52 +04:00
|
|
|
bool IsActive() const;
|
2013-08-07 01:23:46 +04:00
|
|
|
|
2015-12-11 18:12:18 +03:00
|
|
|
bool HasEverBeenActive() const {
|
2013-08-07 01:23:46 +04:00
|
|
|
return mType != 0;
|
|
|
|
}
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
// WebGLRefCountedObject
|
2013-08-07 01:23:46 +04:00
|
|
|
void Delete();
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
// nsWrapperCache
|
|
|
|
WebGLContext* GetParentObject() const {
|
2015-11-25 07:15:29 +03:00
|
|
|
return mContext;
|
2013-08-07 01:23:46 +04:00
|
|
|
}
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
// NS
|
2015-07-15 03:37:28 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override;
|
2013-08-07 01:23:46 +04:00
|
|
|
|
2013-09-04 16:14:48 +04:00
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLQuery)
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLQuery)
|
2013-08-07 01:23:46 +04:00
|
|
|
|
2015-12-19 01:05:42 +03:00
|
|
|
// Track whether the event loop has spun
|
|
|
|
bool mCanBeAvailable;
|
2013-08-07 01:23:46 +04:00
|
|
|
|
|
|
|
private:
|
2014-06-26 17:30:49 +04:00
|
|
|
~WebGLQuery() {
|
|
|
|
DeleteOnce();
|
|
|
|
};
|
2013-08-07 01:23:46 +04:00
|
|
|
|
2013-09-04 16:14:43 +04:00
|
|
|
GLuint mGLName;
|
|
|
|
GLenum mType;
|
2013-08-07 01:23:46 +04:00
|
|
|
|
2014-11-03 08:35:04 +03:00
|
|
|
friend class WebGL2Context;
|
2013-08-07 01:23:46 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
#endif // WEBGL_QUERY_H_
|