-
-
Notifications
You must be signed in to change notification settings - Fork 450
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sdk): GlContext and GlSyncToken API
- Loading branch information
Showing
10 changed files
with
105 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
|
||
using MpGlContext = System.IntPtr; | ||
|
||
namespace Mediapipe { | ||
public class GlContext : ResourceHandle { | ||
private bool _disposed = false; | ||
|
||
public GlContext(MpGlContext ptr, bool isOwner = true) : base(ptr, isOwner) {} | ||
|
||
protected override void Dispose(bool disposing) { | ||
if (_disposed) return; | ||
|
||
if (OwnsResource()) { | ||
UnsafeNativeMethods.MpGlContextDestroy(ptr); | ||
} | ||
|
||
ptr = IntPtr.Zero; | ||
|
||
_disposed = true; | ||
} | ||
|
||
public IntPtr Get() { | ||
return UnsafeNativeMethods.MpGlContextGet(ptr); | ||
} | ||
|
||
public static GlContext GetCurrent() { | ||
return new GlContext(UnsafeNativeMethods.MpGlContextGetCurrent()); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System; | ||
|
||
using MpGlSyncToken = System.IntPtr; | ||
|
||
namespace Mediapipe { | ||
public class GlSyncToken : ResourceHandle { | ||
private bool _disposed = false; | ||
|
||
public GlSyncToken(MpGlSyncToken ptr, bool isOwner = true) : base(ptr, isOwner) {} | ||
|
||
protected override void Dispose(bool disposing) { | ||
if (_disposed) return; | ||
|
||
if (OwnsResource()) { | ||
UnsafeNativeMethods.MpGlSyncTokenDestroy(ptr); | ||
} | ||
|
||
ptr = IntPtr.Zero; | ||
|
||
_disposed = true; | ||
} | ||
|
||
public void Wait() { | ||
UnsafeNativeMethods.MpGlSyncTokenWait(ptr); | ||
} | ||
|
||
public void WaitOnGpu() { | ||
UnsafeNativeMethods.MpGlSyncTokenWaitOnGpu(ptr); | ||
} | ||
|
||
public bool IsReady() { | ||
return UnsafeNativeMethods.MpGlSyncTokenIsReady(ptr); | ||
} | ||
|
||
public GlContext GetContext() { | ||
return new GlContext(UnsafeNativeMethods.MpGlSyncTokenGetContext(ptr)); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters