Diff
Modified: trunk/Source/WebCore/ChangeLog (292379 => 292380)
--- trunk/Source/WebCore/ChangeLog 2022-04-05 07:28:33 UTC (rev 292379)
+++ trunk/Source/WebCore/ChangeLog 2022-04-05 07:32:25 UTC (rev 292380)
@@ -1,3 +1,16 @@
+2022-04-05 Zan Dobersek <zdober...@igalia.com>
+
+ Unreviewed, reverting r292377.
+
+ The depended-on patch hasn't landed yet
+
+ Reverted changeset:
+
+ "[GTK][WPE] Use UnixFileDescriptor in DMABufObject,
+ DMABufReleaseFlag"
+ https://bugs.webkit.org/show_bug.cgi?id=238733
+ https://commits.webkit.org/r292377
+
2022-04-04 Zan Dobersek <zdober...@igalia.com>
[GTK][WPE] Use UnixFileDescriptor in DMABufObject, DMABufReleaseFlag
Modified: trunk/Source/WebCore/platform/graphics/gbm/DMABufObject.h (292379 => 292380)
--- trunk/Source/WebCore/platform/graphics/gbm/DMABufObject.h 2022-04-05 07:28:33 UTC (rev 292379)
+++ trunk/Source/WebCore/platform/graphics/gbm/DMABufObject.h 2022-04-05 07:32:25 UTC (rev 292380)
@@ -32,7 +32,6 @@
#include <cstddef>
#include <cstdint>
#include <unistd.h>
-#include <wtf/unix/UnixFileDescriptor.h>
namespace WebCore {
@@ -41,20 +40,50 @@
: handle(handle)
{ }
- ~DMABufObject() = default;
+ ~DMABufObject()
+ {
+ for (unsigned i = 0; i < format.numPlanes; ++i) {
+ if (fd[i] != -1)
+ close(fd[i]);
+ }
+ }
DMABufObject(const DMABufObject&) = delete;
DMABufObject& operator=(const DMABufObject&) = delete;
- DMABufObject(DMABufObject&&) = default;
- DMABufObject& operator=(DMABufObject&&) = default;
+ DMABufObject(DMABufObject&& o)
+ : handle(o.handle)
+ , format(o.format)
+ , width(o.width)
+ , height(o.height)
+ , releaseFlag(WTFMove(o.releaseFlag))
+ {
+ for (unsigned i = 0; i < format.numPlanes; ++i) {
+ fd[i] = o.fd[i];
+ o.fd[i] = -1;
+ offset[i] = o.offset[i];
+ stride[i] = o.stride[i];
+ modifier[i] = o.modifier[i];
+ }
+ }
+
+ DMABufObject& operator=(DMABufObject&& o)
+ {
+ if (this == &o)
+ return *this;
+
+ this->~DMABufObject();
+ new (this) DMABufObject(WTFMove(o));
+ return *this;
+ }
+
uintptr_t handle { 0 };
DMABufFormat format { };
uint32_t width { 0 };
uint32_t height { 0 };
DMABufReleaseFlag releaseFlag { };
- std::array<WTF::UnixFileDescriptor, DMABufFormat::c_maxPlanes> fd { };
+ std::array<int, DMABufFormat::c_maxPlanes> fd { -1, -1, -1, -1 };
std::array<size_t, DMABufFormat::c_maxPlanes> offset { 0, 0, 0, 0 };
std::array<uint32_t, DMABufFormat::c_maxPlanes> stride { 0, 0, 0, 0 };
std::array<uint64_t, DMABufFormat::c_maxPlanes> modifier { 0, 0, 0, 0 };
Modified: trunk/Source/WebCore/platform/graphics/gbm/DMABufReleaseFlag.h (292379 => 292380)
--- trunk/Source/WebCore/platform/graphics/gbm/DMABufReleaseFlag.h 2022-04-05 07:28:33 UTC (rev 292379)
+++ trunk/Source/WebCore/platform/graphics/gbm/DMABufReleaseFlag.h 2022-04-05 07:32:25 UTC (rev 292380)
@@ -27,7 +27,7 @@
#pragma once
#include <sys/eventfd.h>
-#include <wtf/unix/UnixFileDescriptor.h>
+#include <wtf/UniStdExtras.h>
namespace WebCore {
@@ -37,31 +37,52 @@
enum InitializeTag { Initialize };
DMABufReleaseFlag(InitializeTag)
{
- fd = { eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK), WTF::UnixFileDescriptor::Adopt };
+ fd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
}
- ~DMABufReleaseFlag() = default;
+ ~DMABufReleaseFlag()
+ {
+ if (fd != -1)
+ close(fd);
+ fd = -1;
+ }
DMABufReleaseFlag(const DMABufReleaseFlag&) = delete;
DMABufReleaseFlag& operator=(const DMABufReleaseFlag&) = delete;
- DMABufReleaseFlag(DMABufReleaseFlag&&) = default;
- DMABufReleaseFlag& operator=(DMABufReleaseFlag&&) = default;
+ DMABufReleaseFlag(DMABufReleaseFlag&& o)
+ {
+ fd = o.fd;
+ o.fd = -1;
+ }
+ DMABufReleaseFlag& operator=(DMABufReleaseFlag&& o)
+ {
+ if (this == &o)
+ return *this;
+
+ this->~DMABufReleaseFlag();
+ new (this) DMABufReleaseFlag(WTFMove(o));
+ return *this;
+ }
+
DMABufReleaseFlag dup() const
{
+ if (fd == -1)
+ return { };
+
DMABufReleaseFlag flag;
- flag.fd = fd.duplicate();
+ flag.fd = dupCloseOnExec(fd);
return flag;
}
bool released() const
{
- if (fd.value == -1)
+ if (fd == -1)
return true;
uint64_t value { 0 };
- if (read(fd.value, &value, sizeof(uint64_t)) == sizeof(uint64_t))
+ if (read(fd, &value, sizeof(uint64_t)) == sizeof(uint64_t))
return !!value;
return false;
}
@@ -68,14 +89,14 @@
void release()
{
- if (fd.value == -1)
+ if (fd == -1)
return;
uint64_t value { 1 };
- write(fd.value, &value, sizeof(uint64_t));
+ write(fd, &value, sizeof(uint64_t));
}
- WTF::UnixFileDescriptor fd { };
+ int fd { -1 };
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/gbm/GBMBufferSwapchain.cpp (292379 => 292380)
--- trunk/Source/WebCore/platform/graphics/gbm/GBMBufferSwapchain.cpp 2022-04-05 07:28:33 UTC (rev 292379)
+++ trunk/Source/WebCore/platform/graphics/gbm/GBMBufferSwapchain.cpp 2022-04-05 07:32:25 UTC (rev 292380)
@@ -155,7 +155,7 @@
object.releaseFlag = m_state.releaseFlag.dup();
for (unsigned i = 0; i < m_description.format.numPlanes; ++i) {
- object.fd[i] = WTF::UnixFileDescriptor { gbm_bo_get_fd(m_planes[i].bo), WTF::UnixFileDescriptor::Adopt };
+ object.fd[i] = gbm_bo_get_fd(m_planes[i].bo);
object.offset[i] = 0;
object.stride[i] = m_planes[i].stride;
// TODO: these should be the plane-specific modifiers. We don't use them yet.
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (292379 => 292380)
--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2022-04-05 07:28:33 UTC (rev 292379)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2022-04-05 07:32:25 UTC (rev 292380)
@@ -3106,10 +3106,10 @@
gsize skip = 0;
if (gst_buffer_find_memory(buffer, offset, 1, &memid, &length, &skip)) {
auto* mem = gst_buffer_peek_memory(buffer, memid);
- object.fd[i] = { gst_dmabuf_memory_get_fd(mem), WTF::UnixFileDescriptor::Duplicate };
+ object.fd[i] = dupCloseOnExec(gst_dmabuf_memory_get_fd(mem));
offset = mem->offset + skip;
} else
- object.fd[i] = { };
+ object.fd[i] = -1;
gint comp[GST_VIDEO_MAX_COMPONENTS];
gst_video_format_info_component(videoInfo.finfo, i, comp);
Modified: trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp (292379 => 292380)
--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp 2022-04-05 07:28:33 UTC (rev 292379)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp 2022-04-05 07:32:25 UTC (rev 292380)
@@ -126,7 +126,7 @@
EGL_WIDTH, EGLint(dmabufObject.format.planeWidth(0, dmabufObject.width)),
EGL_HEIGHT, EGLint(dmabufObject.format.planeHeight(0, dmabufObject.height)),
EGL_LINUX_DRM_FOURCC_EXT, static_cast<EGLint>(dmabufObject.format.planes[0].fourcc),
- EGL_DMA_BUF_PLANE0_FD_EXT, dmabufObject.fd[0].value,
+ EGL_DMA_BUF_PLANE0_FD_EXT, dmabufObject.fd[0],
EGL_DMA_BUF_PLANE0_PITCH_EXT, static_cast<EGLint>(dmabufObject.stride[0]),
EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
EGL_NONE,
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerProxyDMABuf.cpp (292379 => 292380)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerProxyDMABuf.cpp 2022-04-05 07:28:33 UTC (rev 292379)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerProxyDMABuf.cpp 2022-04-05 07:32:25 UTC (rev 292380)
@@ -255,7 +255,7 @@
EGL_WIDTH, EGLint(object.format.planeWidth(i, object.width)),
EGL_HEIGHT, EGLint(object.format.planeHeight(i, object.height)),
EGL_LINUX_DRM_FOURCC_EXT, EGLint(object.format.planes[i].fourcc),
- EGL_DMA_BUF_PLANE0_FD_EXT, object.fd[i].value,
+ EGL_DMA_BUF_PLANE0_FD_EXT, object.fd[i],
EGL_DMA_BUF_PLANE0_OFFSET_EXT, EGLint(object.offset[i]),
EGL_DMA_BUF_PLANE0_PITCH_EXT, EGLint(object.stride[i]),
EGL_NONE,