PDFJS_WebGLCanvas.cs 971 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using Paroxe.PdfRenderer.Internal;
  3. namespace Paroxe.PdfRenderer.WebGL
  4. {
  5. public class PDFJS_WebGLCanvas : IDisposable
  6. {
  7. private bool m_Disposed;
  8. private IntPtr m_NativePointer;
  9. public PDFJS_WebGLCanvas(IntPtr nativePointer)
  10. {
  11. m_NativePointer = nativePointer;
  12. }
  13. ~PDFJS_WebGLCanvas()
  14. {
  15. Dispose(false);
  16. }
  17. protected virtual void Dispose(bool disposing)
  18. {
  19. if (!m_Disposed)
  20. {
  21. if (m_NativePointer != IntPtr.Zero)
  22. {
  23. #if UNITY_WEBGL && !UNITY_EDITOR
  24. NativeMethods.PDFJS_DestroyCanvas(m_NativePointer.ToInt32());
  25. #endif
  26. m_NativePointer = IntPtr.Zero;
  27. }
  28. m_Disposed = true;
  29. }
  30. }
  31. public void Dispose()
  32. {
  33. Dispose(true);
  34. GC.SuppressFinalize(this);
  35. }
  36. }
  37. }