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

Fix image delete on window.location.replace() #185

Open
wants to merge 1 commit into
base: wpebackend-fdo-1.14
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/view-backend-exportable-fdo-egl-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct wpe_fdo_egl_exported_image {
EGLImageKHR eglImage { nullptr };
uint32_t width { 0 };
uint32_t height { 0 };
bool exported { false };
bool released { false };
struct wl_resource* bufferResource { nullptr };
struct wl_listener bufferDestroyListener;
};
27 changes: 4 additions & 23 deletions src/view-backend-exportable-fdo-egl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,6 @@ class ClientBundleEGL final : public ClientBundle {

void exportBuffer(struct wl_resource* bufferResource) override
{
if (auto* image = findImage(bufferResource)) {
exportImage(image);
return;
}

EGLImageKHR eglImage = WS::instanceImpl<WS::ImplEGL>().createImage(bufferResource);
if (!eglImage)
return;
Expand All @@ -200,11 +195,6 @@ class ClientBundleEGL final : public ClientBundle {

void exportBuffer(const struct linux_dmabuf_buffer* dmabufBuffer) override
{
if (auto* image = findImage(dmabufBuffer->buffer_resource)) {
exportImage(image);
return;
}

EGLImageKHR eglImage = WS::instanceImpl<WS::ImplEGL>().createImage(dmabufBuffer);
if (!eglImage)
return;
Expand Down Expand Up @@ -247,6 +237,7 @@ class ClientBundleEGL final : public ClientBundle {

void releaseImage(struct wpe_fdo_egl_exported_image* image)
{
image->released = true;
if (image->bufferResource)
viewBackend->releaseBuffer(image->bufferResource);
else
Expand All @@ -263,21 +254,8 @@ class ClientBundleEGL final : public ClientBundle {
const struct wpe_view_backend_exportable_fdo_egl_client* client;

private:
struct wpe_fdo_egl_exported_image* findImage(struct wl_resource* bufferResource)
{
if (bufferResource) {
if (auto* listener = wl_resource_get_destroy_listener(bufferResource, bufferDestroyListenerCallback)) {
struct wpe_fdo_egl_exported_image* image;
return wl_container_of(listener, image, bufferDestroyListener);
}
}

return nullptr;
}

void exportImage(struct wpe_fdo_egl_exported_image* image)
{
image->exported = true;
client->export_fdo_egl_image(data, image);
}

Expand All @@ -295,6 +273,9 @@ class ClientBundleEGL final : public ClientBundle {
image = wl_container_of(listener, image, bufferDestroyListener);

image->bufferResource = nullptr;

if (image->released)
deleteImage(image);
}
};

Expand Down