wpe: Reduce gpointer usage in ThreadedView

Those gpointers were introduced when we had to support some old WPE API, no need
for them anymore.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8413>
This commit is contained in:
Philippe Normand 2024-12-23 11:47:26 +01:00 committed by GStreamer Marge Bot
parent 9adc7bd9f0
commit 1baa10ed07
2 changed files with 30 additions and 31 deletions

View File

@ -815,37 +815,44 @@ void GstWPEThreadedView::setDrawBackground(gboolean drawsBackground)
webkit_web_view_set_background_color(webkit.view, &color);
}
void GstWPEThreadedView::releaseImage(gpointer imagePointer)
void GstWPEThreadedView::releaseImage(struct wpe_fdo_egl_exported_image * image)
{
s_view->dispatch([&]() {
GST_TRACE("Dispatch release exported image %p", imagePointer);
wpe_view_backend_exportable_fdo_egl_dispatch_release_exported_image(wpe.exportable,
static_cast<struct wpe_fdo_egl_exported_image*>(imagePointer));
GST_TRACE("Dispatch release exported image %p", image);
wpe_view_backend_exportable_fdo_egl_dispatch_release_exported_image(wpe.exportable, image);
});
}
struct ImageContext {
GstWPEThreadedView* view;
gpointer image;
struct wpe_fdo_egl_exported_image *image;
};
void GstWPEThreadedView::handleExportedImage(gpointer image)
void GstWPEThreadedView::s_releaseImage(GstEGLImage *image, gpointer data) {
ImageContext *context = static_cast<ImageContext *>(data);
context->view->releaseImage(context->image);
g_free(context);
}
void GstWPEThreadedView::handleExportedImage(struct wpe_fdo_egl_exported_image * image)
{
ImageContext* imageContext = g_new (ImageContext, 1);
imageContext->view = this;
imageContext->image = static_cast<gpointer>(image);
EGLImageKHR eglImage = wpe_fdo_egl_exported_image_get_egl_image(static_cast<struct wpe_fdo_egl_exported_image*>(image));
ImageContext *imageContext = g_new(ImageContext, 1);
imageContext->view = this;
imageContext->image = image;
EGLImageKHR eglImage = wpe_fdo_egl_exported_image_get_egl_image(image);
auto* gstImage = gst_egl_image_new_wrapped(gst.context, eglImage, GST_GL_RGBA, imageContext, s_releaseImage);
{
GMutexHolder lock(images_mutex);
auto *gstImage = gst_egl_image_new_wrapped(gst.context, eglImage, GST_GL_RGBA, imageContext,
s_releaseImage);
{
GMutexHolder lock(images_mutex);
GST_TRACE("EGLImage %p wrapped in GstEGLImage %" GST_PTR_FORMAT, eglImage, gstImage);
gst_clear_mini_object ((GstMiniObject **) &egl.pending);
egl.pending = gstImage;
GST_TRACE("EGLImage %p wrapped in GstEGLImage %" GST_PTR_FORMAT, eglImage,
gstImage);
gst_clear_mini_object((GstMiniObject **)&egl.pending);
egl.pending = gstImage;
notifyLoadFinished();
}
notifyLoadFinished();
}
}
struct SHMBufferContext {
@ -857,9 +864,8 @@ void GstWPEThreadedView::releaseSHMBuffer(gpointer data)
{
SHMBufferContext* context = static_cast<SHMBufferContext*>(data);
s_view->dispatch([&]() {
auto* buffer = static_cast<struct wpe_fdo_shm_exported_buffer*>(context->buffer);
GST_TRACE("Dispatch release exported buffer %p", buffer);
wpe_view_backend_exportable_fdo_dispatch_release_shm_exported_buffer(wpe.exportable, buffer);
GST_TRACE("Dispatch release exported buffer %p", context->buffer);
wpe_view_backend_exportable_fdo_dispatch_release_shm_exported_buffer(wpe.exportable, context->buffer);
});
}
@ -910,7 +916,7 @@ struct wpe_view_backend_exportable_fdo_egl_client GstWPEThreadedView::s_exportab
nullptr,
[](void* data, struct wpe_fdo_egl_exported_image* image) {
auto& view = *static_cast<GstWPEThreadedView*>(data);
view.handleExportedImage(static_cast<gpointer>(image));
view.handleExportedImage(image);
},
nullptr,
// padding
@ -929,13 +935,6 @@ struct wpe_view_backend_exportable_fdo_client GstWPEThreadedView::s_exportableCl
nullptr,
};
void GstWPEThreadedView::s_releaseImage(GstEGLImage* image, gpointer data)
{
ImageContext* context = static_cast<ImageContext*>(data);
context->view->releaseImage(context->image);
g_free (context);
}
struct wpe_view_backend* GstWPEThreadedView::backend() const
{
return wpe.exportable ? wpe_view_backend_exportable_fdo_get_view_backend(wpe.exportable) : nullptr;

View File

@ -65,7 +65,7 @@ public:
void notifyLoadFinished();
protected:
void handleExportedImage(gpointer);
void handleExportedImage(struct wpe_fdo_egl_exported_image*);
void handleExportedBuffer(struct wpe_fdo_shm_exported_buffer*);
private:
@ -73,7 +73,7 @@ private:
void frameComplete();
void loadUriUnlocked(const gchar*);
void releaseImage(gpointer);
void releaseImage(struct wpe_fdo_egl_exported_image *);
void releaseSHMBuffer(gpointer);
static void s_releaseSHMBuffer(gpointer);