Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[android] clear gl context after rendering op #1472

Merged
merged 1 commit into from
Dec 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions android/src/main/cpp/iris_rtc_rendering_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class GLContext {
return is_setup_surface_;
}

bool CreateContextAndMakeCurrent(const void *share_context) {
bool GLContextMakeCurrent(const void *share_context) {
// Need recreate context
if (context_ != EGL_NO_CONTEXT && share_context_ != share_context) {
eglMakeCurrent(display_, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
Expand Down Expand Up @@ -120,6 +120,12 @@ class GLContext {
return result;
}

void GLContextClearCurrent() {
if (context_ != EGL_NO_CONTEXT) {
eglMakeCurrent(display_, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
}
}

EGLint Swap() {
eglSwapBuffers(display_, surface_);
CHECK_GL_ERROR()
Expand Down Expand Up @@ -522,8 +528,6 @@ class YUVRendering final : public RenderingOp {
CHECK_GL_ERROR()
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
CHECK_GL_ERROR()
glViewport(0, 0, width, height);
CHECK_GL_ERROR()

glEnableVertexAttribArray(aPositionLoc_);
CHECK_GL_ERROR()
Expand Down Expand Up @@ -730,7 +734,7 @@ class NativeTextureRenderer final
return;
}

if (!gl_context_->CreateContextAndMakeCurrent(video_frame->sharedContext)) {
if (!gl_context_->GLContextMakeCurrent(video_frame->sharedContext)) {
LOGCATE("GLContext#CreateContextAndMakeCurrent failed ");
return;
}
Expand All @@ -756,6 +760,8 @@ class NativeTextureRenderer final
}

rendering_op_->Rendering(video_frame);

gl_context_->GLContextClearCurrent();
}

void Dispose() {
Expand Down