Jianhui J Dai uploaded patch set #2 to this change.
[GL] Free the X11 pixmap in the NativePixmapEGLX11Binding destructor.
This CL frees the X11 pixmap in the NativePixmapEGLX11Binding destructor
to prevent a memory leak in the X server.
Bug: 1467689
Change-Id: Id4cba30825417db52176f9165db34d7234a05a05
---
M ui/ozone/platform/x11/native_pixmap_egl_x11_binding.cc
M ui/ozone/platform/x11/native_pixmap_egl_x11_binding.h
2 files changed, 10 insertions(+), 3 deletions(-)
To view, visit change 4886249. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Maksim Sisov, Ted (Chromium) Meyer.
Jianhui J Dai would like Maksim Sisov and Ted (Chromium) Meyer to review this change.
[GL] Free the X11 pixmap in the NativePixmapEGLX11Binding destructor.
This CL frees the X11 pixmap in the NativePixmapEGLX11Binding destructor
to prevent a memory leak in the X server.
Bug: 1467689
Change-Id: Id4cba30825417db52176f9165db34d7234a05a05
---
M ui/ozone/platform/x11/native_pixmap_egl_x11_binding.cc
M ui/ozone/platform/x11/native_pixmap_egl_x11_binding.h
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/ui/ozone/platform/x11/native_pixmap_egl_x11_binding.cc b/ui/ozone/platform/x11/native_pixmap_egl_x11_binding.cc
index 46a2d327..68f31a2 100644
--- a/ui/ozone/platform/x11/native_pixmap_egl_x11_binding.cc
+++ b/ui/ozone/platform/x11/native_pixmap_egl_x11_binding.cc
@@ -147,9 +147,16 @@
if (surface_) {
eglDestroySurface(display_, surface_);
}
+
+ if (pixmap_ != x11::Pixmap::None) {
+ auto* connection = x11::Connection::Get();
+ connection->FreePixmap({pixmap_});
+ }
}
bool NativePixmapEGLX11Binding::Initialize(x11::Pixmap pixmap) {
+ pixmap_ = pixmap;
+
if (eglInitialize(display_, nullptr, nullptr) != EGL_TRUE) {
return false;
}
@@ -223,9 +230,7 @@
return nullptr;
}
- // TODO(https://crbug.com/1411749): if we early out below, should we call
- // FreePixmap()?
-
+ // Transfer the ownership of `pixmap` to `NativePixmapEGLX11Binding`.
if (!binding->Initialize(std::move(pixmap))) {
VLOG(1) << "Unable to initialize binding from pixmap";
return nullptr;
diff --git a/ui/ozone/platform/x11/native_pixmap_egl_x11_binding.h b/ui/ozone/platform/x11/native_pixmap_egl_x11_binding.h
index 013df3f7..99b262b 100644
--- a/ui/ozone/platform/x11/native_pixmap_egl_x11_binding.h
+++ b/ui/ozone/platform/x11/native_pixmap_egl_x11_binding.h
@@ -47,6 +47,8 @@
EGLSurface surface_ = nullptr;
EGLDisplay display_;
gfx::BufferFormat format_;
+
+ x11::Pixmap pixmap_ = x11::Pixmap::None;
};
} // namespace ui
To view, visit change 4886249. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Jianhui J Dai, Maksim Sisov.
Patch set 2:Code-Review +1
1 comment:
File ui/ozone/platform/x11/native_pixmap_egl_x11_binding.cc:
Patch Set #2, Line 158: pixmap_ = pixmap;
add
```
CHECK(pixmap != x11::Pixmap::None);
```
before the assignment.
To view, visit change 4886249. To unsubscribe, or for help writing mail filters, visit settings.