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 : #include "WebGLSync.h"
7 :
8 : #include "GLContext.h"
9 : #include "mozilla/dom/WebGL2RenderingContextBinding.h"
10 : #include "WebGLContext.h"
11 :
12 : namespace mozilla {
13 :
14 0 : WebGLSync::WebGLSync(WebGLContext* webgl, GLenum condition, GLbitfield flags)
15 0 : : WebGLRefCountedObject(webgl)
16 : {
17 0 : mContext->mSyncs.insertBack(this);
18 0 : mGLName = mContext->gl->fFenceSync(condition, flags);
19 0 : }
20 :
21 0 : WebGLSync::~WebGLSync()
22 : {
23 0 : DeleteOnce();
24 0 : }
25 :
26 : void
27 0 : WebGLSync::Delete()
28 : {
29 0 : mContext->MakeContextCurrent();
30 0 : mContext->gl->fDeleteSync(mGLName);
31 0 : mGLName = 0;
32 0 : LinkedListElement<WebGLSync>::removeFrom(mContext->mSyncs);
33 0 : }
34 :
35 : WebGLContext*
36 0 : WebGLSync::GetParentObject() const
37 : {
38 0 : return mContext;
39 : }
40 :
41 : // -------------------------------------------------------------------------
42 : // IMPLEMENT NS
43 : JSObject*
44 0 : WebGLSync::WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto)
45 : {
46 0 : return dom::WebGLSyncBinding::Wrap(cx, this, givenProto);
47 : }
48 :
49 0 : NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WebGLSync)
50 0 : NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WebGLSync, AddRef)
51 0 : NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WebGLSync, Release);
52 :
53 : } // namespace mozilla
|