Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #ifndef WEBGL_QUERY_H_
7 : #define WEBGL_QUERY_H_
8 :
9 : #include "mozilla/LinkedList.h"
10 : #include "nsWrapperCache.h"
11 :
12 : #include "WebGLObjectModel.h"
13 : #include "nsThreadUtils.h"
14 :
15 : namespace mozilla {
16 :
17 : class WebGLQuery final
18 : : public nsWrapperCache
19 : , public WebGLRefCountedObject<WebGLQuery>
20 : , public LinkedListElement<WebGLQuery>
21 : {
22 : friend class AvailableRunnable;
23 : friend class WebGLRefCountedObject<WebGLQuery>;
24 :
25 : public:
26 : const GLuint mGLName;
27 : private:
28 : GLenum mTarget;
29 : WebGLRefPtr<WebGLQuery>* mActiveSlot;
30 :
31 : bool mCanBeAvailable; // Track whether the event loop has spun
32 :
33 : ////
34 : public:
35 0 : GLenum Target() const { return mTarget; }
36 : bool IsActive() const { return bool(mActiveSlot); }
37 :
38 : ////
39 :
40 0 : NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLQuery)
41 0 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLQuery)
42 :
43 : explicit WebGLQuery(WebGLContext* webgl);
44 :
45 : private:
46 0 : ~WebGLQuery() {
47 0 : DeleteOnce();
48 0 : };
49 :
50 : // WebGLRefCountedObject
51 : void Delete();
52 :
53 : public:
54 0 : WebGLContext* GetParentObject() const { return mContext; }
55 : virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override;
56 :
57 : ////
58 :
59 : void BeginQuery(GLenum target, WebGLRefPtr<WebGLQuery>& slot);
60 : void DeleteQuery();
61 : void EndQuery();
62 : void GetQueryParameter(GLenum pname, JS::MutableHandleValue retval) const;
63 : bool IsQuery() const;
64 : void QueryCounter(const char* funcName, GLenum target);
65 : };
66 :
67 : } // namespace mozilla
68 :
69 : #endif // WEBGL_QUERY_H_
|