PDFJS_WebGLCanvas.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. http://www.cgsoso.com/forum-211-1.html
  3. CG搜搜 Unity3d 每日Unity3d插件免费更新 更有VIP资源!
  4. CGSOSO 主打游戏开发,影视设计等CG资源素材。
  5. 插件如若商用,请务必官网购买!
  6. daily assets update for try.
  7. U should buy the asset from home store if u use it in your project!
  8. */
  9. using System;
  10. using System.Runtime.InteropServices;
  11. namespace Paroxe.PdfRenderer.WebGL
  12. {
  13. public class PDFJS_WebGLCanvas : IDisposable
  14. {
  15. private bool m_Disposed;
  16. private IntPtr m_NativePointer;
  17. public PDFJS_WebGLCanvas(IntPtr nativePointer)
  18. {
  19. m_NativePointer = nativePointer;
  20. }
  21. ~PDFJS_WebGLCanvas()
  22. {
  23. Dispose(false);
  24. }
  25. protected virtual void Dispose(bool disposing)
  26. {
  27. if (!m_Disposed)
  28. {
  29. if (m_NativePointer != IntPtr.Zero)
  30. {
  31. #if UNITY_WEBGL && !UNITY_EDITOR
  32. PDFJS_DestroyCanvas(m_NativePointer.ToInt32());
  33. #endif
  34. m_NativePointer = IntPtr.Zero;
  35. }
  36. m_Disposed = true;
  37. }
  38. }
  39. public void Dispose()
  40. {
  41. Dispose(true);
  42. GC.SuppressFinalize(this);
  43. }
  44. #if UNITY_WEBGL && !UNITY_EDITOR
  45. [DllImport(PDFLibrary.PLUGIN_ASSEMBLY)]
  46. private static extern void PDFJS_DestroyCanvas(int canvasHandle);
  47. #endif
  48. }
  49. }