Skip to content

properly restore GL state after present #136

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

Merged
merged 1 commit into from
Dec 9, 2020
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
20 changes: 17 additions & 3 deletions src/compositor.c
Original file line number Diff line number Diff line change
Expand Up @@ -954,24 +954,38 @@ static bool on_present_layers(
bool use_atomic_modesetting;
int ok;

// TODO: proper error handling

compositor = userdata;
drmdev = compositor->drmdev;
schedule_fake_page_flip_event = compositor->do_blocking_atomic_commits;
use_atomic_modesetting = drmdev->supports_atomic_modesetting;

req = NULL;
if (use_atomic_modesetting) {
drmdev_new_atomic_req(compositor->drmdev, &req);
ok = drmdev_new_atomic_req(compositor->drmdev, &req);
if (ok != 0) {
return false;
}
} else {
planes = PSET_INITIALIZER_STATIC(planes_storage, 32);
for_each_plane_in_drmdev(drmdev, plane) {
if (plane->plane->possible_crtcs & drmdev->selected_crtc->bitmask) {
pset_put(&planes, plane);
ok = pset_put(&planes, plane);
if (ok != 0) {
return false;
}
}
}
}

cpset_lock(&compositor->cbs);

EGLDisplay stored_display = eglGetCurrentDisplay();
EGLSurface stored_read_surface = eglGetCurrentSurface(EGL_READ);
EGLSurface stored_write_surface = eglGetCurrentSurface(EGL_DRAW);
EGLContext stored_context = eglGetCurrentContext();

eglMakeCurrent(flutterpi.egl.display, flutterpi.egl.surface, flutterpi.egl.surface, flutterpi.egl.root_context);
eglSwapBuffers(flutterpi.egl.display, flutterpi.egl.surface);

Expand Down Expand Up @@ -1313,7 +1327,7 @@ static bool on_present_layers(
}
}

eglMakeCurrent(flutterpi.egl.display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglMakeCurrent(stored_display, stored_read_surface, stored_write_surface, stored_context);

if (use_atomic_modesetting) {
do_commit:
Expand Down