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>
|
|
|
|
{
|
2016-10-04 04:33:52 +03:00
|
|
|
friend class AvailableRunnable;
|
|
|
|
friend class WebGLRefCountedObject<WebGLQuery>;
|
2013-08-07 01:23:46 +04:00
|
|
|
|
2016-10-04 04:33:52 +03:00
|
|
|
public:
|
|
|
|
const GLuint mGLName;
|
|
|
|
private:
|
|
|
|
GLenum mTarget;
|
2016-11-08 06:38:48 +03:00
|
|
|
WebGLRefPtr<WebGLQuery>* mActiveSlot;
|
2013-08-07 01:23:46 +04:00
|
|
|
|
2016-10-04 04:33:52 +03:00
|
|
|
bool mCanBeAvailable; // Track whether the event loop has spun
|
2013-08-07 01:23:46 +04:00
|
|
|
|
2016-10-04 04:33:52 +03:00
|
|
|
////
|
|
|
|
public:
|
2016-11-08 06:38:48 +03:00
|
|
|
GLenum Target() const { return mTarget; }
|
|
|
|
bool IsActive() const { return bool(mActiveSlot); }
|
2013-08-07 01:23:46 +04:00
|
|
|
|
2016-10-04 04:33:52 +03:00
|
|
|
////
|
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
|
|
|
|
2016-10-04 04:33:52 +03:00
|
|
|
explicit WebGLQuery(WebGLContext* webgl);
|
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
|
|
|
|
2016-10-04 04:33:52 +03:00
|
|
|
// WebGLRefCountedObject
|
|
|
|
void Delete();
|
|
|
|
|
|
|
|
public:
|
|
|
|
WebGLContext* GetParentObject() const { return mContext; }
|
|
|
|
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override;
|
|
|
|
|
|
|
|
////
|
2013-08-07 01:23:46 +04:00
|
|
|
|
2016-11-08 06:38:48 +03:00
|
|
|
void BeginQuery(GLenum target, WebGLRefPtr<WebGLQuery>& slot);
|
2016-10-04 04:33:52 +03:00
|
|
|
void DeleteQuery();
|
|
|
|
void EndQuery();
|
|
|
|
void GetQueryParameter(GLenum pname, JS::MutableHandleValue retval) const;
|
|
|
|
bool IsQuery() const;
|
|
|
|
void QueryCounter(const char* funcName, GLenum target);
|
2013-08-07 01:23:46 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
#endif // WEBGL_QUERY_H_
|