WebGLSync.cpp 1.4 KB

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