Diff
Modified: trunk/Source/WebCore/ChangeLog (292390 => 292391)
--- trunk/Source/WebCore/ChangeLog 2022-04-05 10:55:51 UTC (rev 292390)
+++ trunk/Source/WebCore/ChangeLog 2022-04-05 11:30:09 UTC (rev 292391)
@@ -1,3 +1,40 @@
+2022-04-05 Zan Dobersek <zdober...@igalia.com>
+
+ [GTK][WPE] Use UnixFileDescriptor in DMABufObject, DMABufReleaseFlag
+ https://bugs.webkit.org/show_bug.cgi?id=238733
+
+ Reviewed by Adrian Perez de Castro.
+
+ Replace integer values for file descriptors in the DMABufObject and
+ DMABufReleaseFlag structs with UnixFileDescriptors. This enables
+ simply defaulting the destructors and the move constructors and
+ assignment operatos for the two types since the fd wrapper takes care
+ of these operations.
+
+ Additionally, when constructing the UnixFileDescriptor objects from
+ file descriptors coming from different sources, we can more easily
+ adapt to the need for either adoption or duplication of the passed-in
+ file descriptor right there in the constructor invocation.
+
+ * platform/graphics/gbm/DMABufObject.h:
+ (WebCore::DMABufObject::~DMABufObject): Deleted.
+ (WebCore::DMABufObject::operator=): Deleted.
+ * platform/graphics/gbm/DMABufReleaseFlag.h:
+ (WebCore::DMABufReleaseFlag::DMABufReleaseFlag):
+ (WebCore::DMABufReleaseFlag::dup const):
+ (WebCore::DMABufReleaseFlag::released const):
+ (WebCore::DMABufReleaseFlag::release):
+ (WebCore::DMABufReleaseFlag::~DMABufReleaseFlag): Deleted.
+ (WebCore::DMABufReleaseFlag::operator=): Deleted.
+ * platform/graphics/gbm/GBMBufferSwapchain.cpp:
+ (WebCore::GBMBufferSwapchain::Buffer::createDMABufObject const):
+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+ (WebCore::MediaPlayerPrivateGStreamer::pushDMABufToCompositor):
+ * platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp:
+ (WebCore::GraphicsContextGLANGLE::makeContextCurrent):
+ * platform/graphics/texmap/TextureMapperPlatformLayerProxyDMABuf.cpp:
+ (WebCore::TextureMapperPlatformLayerProxyDMABuf::DMABufLayer::createEGLImageData):
+
2022-04-05 Diego Pino Garcia <dp...@igalia.com>
[GStreamer] gst_video_format_info_component not defined in GStreamer <1.18
Modified: trunk/Source/WebCore/platform/graphics/gbm/DMABufObject.h (292390 => 292391)
--- trunk/Source/WebCore/platform/graphics/gbm/DMABufObject.h 2022-04-05 10:55:51 UTC (rev 292390)
+++ trunk/Source/WebCore/platform/graphics/gbm/DMABufObject.h 2022-04-05 11:30:09 UTC (rev 292391)
@@ -32,58 +32,29 @@
#include <cstddef>
#include <cstdint>
#include <unistd.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/unix/UnixFileDescriptor.h>
namespace WebCore {
struct DMABufObject {
+ WTF_MAKE_NONCOPYABLE(DMABufObject);
+
DMABufObject(uintptr_t handle)
: handle(handle)
{ }
- ~DMABufObject()
- {
- for (unsigned i = 0; i < format.numPlanes; ++i) {
- if (fd[i] != -1)
- close(fd[i]);
- }
- }
+ ~DMABufObject() = default;
- 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<int, DMABufFormat::c_maxPlanes> fd { -1, -1, -1, -1 };
+ std::array<UnixFileDescriptor, DMABufFormat::c_maxPlanes> fd { };
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 (292390 => 292391)
--- trunk/Source/WebCore/platform/graphics/gbm/DMABufReleaseFlag.h 2022-04-05 10:55:51 UTC (rev 292390)
+++ trunk/Source/WebCore/platform/graphics/gbm/DMABufReleaseFlag.h 2022-04-05 11:30:09 UTC (rev 292391)
@@ -27,62 +27,41 @@
#pragma once
#include <sys/eventfd.h>
-#include <wtf/UniStdExtras.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/unix/UnixFileDescriptor.h>
namespace WebCore {
struct DMABufReleaseFlag {
+ WTF_MAKE_NONCOPYABLE(DMABufReleaseFlag);
+
DMABufReleaseFlag() = default;
enum InitializeTag { Initialize };
DMABufReleaseFlag(InitializeTag)
{
- fd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
+ fd = { eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK), UnixFileDescriptor::Adopt };
}
- ~DMABufReleaseFlag()
- {
- if (fd != -1)
- close(fd);
- fd = -1;
- }
+ ~DMABufReleaseFlag() = default;
- 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 = dupCloseOnExec(fd);
+ flag.fd = fd.duplicate();
return flag;
}
bool released() const
{
- if (fd == -1)
+ if (!fd)
return true;
uint64_t value { 0 };
- if (read(fd, &value, sizeof(uint64_t)) == sizeof(uint64_t))
+ if (read(fd.value(), &value, sizeof(uint64_t)) == sizeof(uint64_t))
return !!value;
return false;
}
@@ -89,14 +68,14 @@
void release()
{
- if (fd == -1)
+ if (!fd)
return;
uint64_t value { 1 };
- write(fd, &value, sizeof(uint64_t));
+ write(fd.value(), &value, sizeof(uint64_t));
}
- int fd { -1 };
+ UnixFileDescriptor fd;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/gbm/GBMBufferSwapchain.cpp (292390 => 292391)
--- trunk/Source/WebCore/platform/graphics/gbm/GBMBufferSwapchain.cpp 2022-04-05 10:55:51 UTC (rev 292390)
+++ trunk/Source/WebCore/platform/graphics/gbm/GBMBufferSwapchain.cpp 2022-04-05 11:30:09 UTC (rev 292391)
@@ -155,7 +155,7 @@
object.releaseFlag = m_state.releaseFlag.dup();
for (unsigned i = 0; i < m_description.format.numPlanes; ++i) {
- object.fd[i] = gbm_bo_get_fd(m_planes[i].bo);
+ object.fd[i] = UnixFileDescriptor { gbm_bo_get_fd(m_planes[i].bo), UnixFileDescriptor::Adopt };
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 (292390 => 292391)
--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2022-04-05 10:55:51 UTC (rev 292390)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2022-04-05 11:30:09 UTC (rev 292391)
@@ -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] = dupCloseOnExec(gst_dmabuf_memory_get_fd(mem));
+ object.fd[i] = { gst_dmabuf_memory_get_fd(mem), UnixFileDescriptor::Duplicate };
offset = mem->offset + skip;
} else
- object.fd[i] = -1;
+ object.fd[i] = { };
gint comp[GST_VIDEO_MAX_COMPONENTS];
gst_video_format_info_component(videoInfo.finfo, i, comp);
Modified: trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp (292390 => 292391)
--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp 2022-04-05 10:55:51 UTC (rev 292390)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp 2022-04-05 11:30:09 UTC (rev 292391)
@@ -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],
+ EGL_DMA_BUF_PLANE0_FD_EXT, dmabufObject.fd[0].value(),
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 (292390 => 292391)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerProxyDMABuf.cpp 2022-04-05 10:55:51 UTC (rev 292390)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerProxyDMABuf.cpp 2022-04-05 11:30:09 UTC (rev 292391)
@@ -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],
+ EGL_DMA_BUF_PLANE0_FD_EXT, object.fd[i].value(),
EGL_DMA_BUF_PLANE0_OFFSET_EXT, EGLint(object.offset[i]),
EGL_DMA_BUF_PLANE0_PITCH_EXT, EGLint(object.stride[i]),
EGL_NONE,