diff --git a/mediapipe/gpu/gl_context.cc b/mediapipe/gpu/gl_context.cc index 7f7ba0e23..91d2837c5 100644 --- a/mediapipe/gpu/gl_context.cc +++ b/mediapipe/gpu/gl_context.cc @@ -826,10 +826,14 @@ std::shared_ptr GlContext::CreateSyncToken() { return token; } -bool GlContext::IsAnyContextCurrent() { +PlatformGlContext GlContext::GetCurrentNativeContext() { ContextBinding ctx; GetCurrentContextBinding(&ctx); - return ctx.context != kPlatformGlContextNone; + return ctx.context; +} + +bool GlContext::IsAnyContextCurrent() { + return GetCurrentNativeContext() != kPlatformGlContextNone; } std::shared_ptr diff --git a/mediapipe/gpu/gl_context.h b/mediapipe/gpu/gl_context.h index 957cb510f..7f5168d8b 100644 --- a/mediapipe/gpu/gl_context.h +++ b/mediapipe/gpu/gl_context.h @@ -307,6 +307,10 @@ class GlContext : public std::enable_shared_from_this { // the GlContext class, is current. static bool IsAnyContextCurrent(); + // Returns the current native context, whether managed by this class or not. + // Useful as a cross-platform way to get the current PlatformGlContext. + static PlatformGlContext GetCurrentNativeContext(); + // Creates a synchronization token for the current, non-GlContext-owned // context. This can be passed to MediaPipe so it can synchronize with the // commands issued in the external context up to this point.