Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* -*- Mode: C++; tab-width: 20; 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/. */
6 #include "WebGLContext.h"
7 #include "GLContext.h"
8 #include "WebGLQuery.h"
9 #include "mozilla/dom/WebGL2RenderingContextBinding.h"
10 #include "nsContentUtils.h"
12 using namespace mozilla;
14 JSObject*
15 WebGLQuery::WrapObject(JSContext *cx) {
16 return dom::WebGLQueryBinding::Wrap(cx, this);
17 }
19 WebGLQuery::WebGLQuery(WebGLContext* context)
20 : WebGLContextBoundObject(context)
21 , mGLName(0)
22 , mType(0)
23 {
24 SetIsDOMBinding();
25 mContext->mQueries.insertBack(this);
27 mContext->MakeContextCurrent();
28 mContext->gl->fGenQueries(1, &mGLName);
29 }
31 void WebGLQuery::Delete() {
32 mContext->MakeContextCurrent();
33 mContext->gl->fDeleteQueries(1, &mGLName);
34 LinkedListElement<WebGLQuery>::removeFrom(mContext->mQueries);
35 }
37 bool WebGLQuery::IsActive() const
38 {
39 WebGLRefPtr<WebGLQuery>* targetSlot = mContext->GetQueryTargetSlot(mType, "WebGLQuery::IsActive()");
41 MOZ_ASSERT(targetSlot, "unknown query object's type");
43 return targetSlot && *targetSlot == this;
44 }
47 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WebGLQuery)
49 NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WebGLQuery, AddRef)
50 NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WebGLQuery, Release)