Commit 612d357c authored by Alexis Hetu's avatar Alexis Hetu Committed by Commit Bot

Y and UV planes release mechanism fix

The Y and UV planes weren't getting released properly because the local
variables used in base::RetainBlock() are snapshots of their current
values and do not get updated by subsequent code. In this case,
y_surface and uv_surface would always be at their original value of
EGL_NO_SURFACE and eglReleaseTexImage/eglDestroySurface would never get
called. Using pointers to these values solves the issue, since the
pointers do not get modified by subsequent code and the values can be
checked properly by dereferencing the pointers.

Bug: chromium:932986 chromium:929088
Change-Id: Id0b9fcc79af733b645eaf8fed12d905dd40e9fbc
Reviewed-on: https://chromium-review.googlesource.com/c/1483690Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Commit-Queue: Alexis Hétu <sugoi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#634837}
parent 0cce9e79
......@@ -190,21 +190,23 @@ bool GLImageIOSurfaceEGL::CopyTexImage(unsigned target) {
EGLSurface y_surface = EGL_NO_SURFACE;
EGLSurface uv_surface = EGL_NO_SURFACE;
EGLSurface* y_surface_ptr = &y_surface;
EGLSurface* uv_surface_ptr = &uv_surface;
glGetIntegerv(target_getter, &rgb_texture);
base::ScopedClosureRunner destroy_resources_runner(
base::BindOnce(base::RetainBlock(^{
if (y_surface != EGL_NO_SURFACE) {
if (*y_surface_ptr != EGL_NO_SURFACE) {
EGLBoolean result =
eglReleaseTexImage(display_, y_surface, EGL_BACK_BUFFER);
eglReleaseTexImage(display_, *y_surface_ptr, EGL_BACK_BUFFER);
DCHECK(result == EGL_TRUE);
result = eglDestroySurface(display_, y_surface);
result = eglDestroySurface(display_, *y_surface_ptr);
DCHECK(result == EGL_TRUE);
}
if (uv_surface != EGL_NO_SURFACE) {
if (*uv_surface_ptr != EGL_NO_SURFACE) {
EGLBoolean result =
eglReleaseTexImage(display_, uv_surface, EGL_BACK_BUFFER);
eglReleaseTexImage(display_, *uv_surface_ptr, EGL_BACK_BUFFER);
DCHECK(result == EGL_TRUE);
result = eglDestroySurface(display_, uv_surface);
result = eglDestroySurface(display_, *uv_surface_ptr);
DCHECK(result == EGL_TRUE);
}
glBindTexture(target, rgb_texture);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment