WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
WIP patch
bug-237328-20220301182529.patch (text/plain), 38.95 KB, created by
Zan Dobersek
on 2022-03-01 09:25:31 PST
(
hide
)
Description:
WIP patch
Filename:
MIME Type:
Creator:
Zan Dobersek
Created:
2022-03-01 09:25:31 PST
Size:
38.95 KB
patch
obsolete
>Subversion Revision: 290641 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 7c87443e96bb9e6db57095e806216857dd445127..ae5b56651a38be51234e9eb80fc8c0c0f682ef29 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,76 @@ >+2022-03-01 Zan Dobersek <zdobersek@igalia.com> >+ >+ [GTK][WPE] Add TextureMapperPlatformLayerProxyDMABuf >+ https://bugs.webkit.org/show_bug.cgi?id=237328 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Introduce TextureMapperPlatformLayerProxyDMABuf, a TextureMapper proxy >+ implementation that handles platform layers backed by dmabuf objects. >+ This will be used to handle display of dmabuf producers like GStreamer >+ pipelines or ANGLE-backed WebGL contexts. The DMABufLayer class is the >+ platform layer object, handling display of the actual dmabuf. The proxy >+ itself is tasked with creating and caching such layers for any dmabuf >+ object that originates from the producer. >+ >+ For each dmabuf object pushed into the proxy, the according DMABufLayer >+ object is spawned and cached for future reuse, expecting the producer >+ to be able to provide dmabufs from a pool or swapchain of these objects. >+ The cache is emptied whenever dmabufs go unused for a certain amount of >+ swaps, or if the size of the provided dmabufs changes. >+ >+ Additionally, certain dmabuf-oriented facilities are added. >+ >+ DMABufFormat provides information for different DRM formats, for >+ instance how different planes for specific formats are formatted and >+ sized. >+ >+ DMABufObject is a class that handles a given grouping of dmabufs >+ according to the specified format. It has an associated handle value, >+ size, and per-plane dmabuf file descriptors, offsets, strides and >+ modifiers, along with a DMABufReleaseFlag instance. >+ >+ DMABufReleaseFlag objects are used as an eventfd-based release mechanism >+ that indicates to the producer that the given DMABufObject has been >+ presented and subsequently released and is thus available for reuse. >+ >+ This is a provisional introduction of these facilities into the tree, >+ with certain behavior (e.g. support for rendering YUV formats in the >+ DMABufLayer class) still pending. Integration with producers (like the >+ DMABufVideoSink in the GStreamer pipeline) follows. >+ >+ * platform/TextureMapper.cmake: >+ * platform/graphics/gbm/DMABufFormat.h: Added. >+ (WebCore::DMABufFormatImpl::createFourCC): >+ (WebCore::DMABufFormat::planeWidth const): >+ (WebCore::DMABufFormat::planeHeight const): >+ (WebCore::DMABufFormat::Plane::Plane): >+ (WebCore::DMABufFormatImpl::createSinglePlaneRGBA): >+ (WebCore::DMABufFormatImpl::definePlane): >+ (WebCore::DMABufFormat::instantiate): >+ (WebCore::DMABufFormat::create): >+ * platform/graphics/gbm/DMABufObject.h: Added. >+ (WebCore::DMABufObject::DMABufObject): >+ (WebCore::DMABufObject::~DMABufObject): >+ (WebCore::DMABufObject::operator=): >+ * platform/graphics/gbm/DMABufReleaseFlag.h: Added. >+ (WebCore::DMABufReleaseFlag::DMABufReleaseFlag): >+ (WebCore::DMABufReleaseFlag::~DMABufReleaseFlag): >+ (WebCore::DMABufReleaseFlag::operator=): >+ (WebCore::DMABufReleaseFlag::dup const): >+ (WebCore::DMABufReleaseFlag::released const): >+ (WebCore::DMABufReleaseFlag::release): >+ * platform/graphics/texmap/TextureMapperPlatformLayerProxyDMABuf.cpp: Added. >+ (WebCore::TextureMapperPlatformLayerProxyDMABuf::activateOnCompositingThread): >+ (WebCore::TextureMapperPlatformLayerProxyDMABuf::invalidate): >+ (WebCore::TextureMapperPlatformLayerProxyDMABuf::swapBuffer): >+ (WebCore::TextureMapperPlatformLayerProxyDMABuf::pushDMABuf): >+ (WebCore::TextureMapperPlatformLayerProxyDMABuf::DMABufLayer::DMABufLayer): >+ (WebCore::TextureMapperPlatformLayerProxyDMABuf::DMABufLayer::~DMABufLayer): >+ (WebCore::TextureMapperPlatformLayerProxyDMABuf::DMABufLayer::paintToTextureMapper): >+ (WebCore::TextureMapperPlatformLayerProxyDMABuf::DMABufLayer::createEGLImageData): >+ * platform/graphics/texmap/TextureMapperPlatformLayerProxyDMABuf.h: Added. >+ > 2022-03-01 Tim Nguyen <ntim@apple.com> > > Explicitly disable style sharing for form controls >diff --git a/Source/WebCore/platform/TextureMapper.cmake b/Source/WebCore/platform/TextureMapper.cmake >index 4e0aebe19747788d640dc995a66c43bba2c91816..73f69c509470ef8ae979ccd97d61a0f788a547f5 100644 >--- a/Source/WebCore/platform/TextureMapper.cmake >+++ b/Source/WebCore/platform/TextureMapper.cmake >@@ -34,6 +34,7 @@ list(APPEND WebCore_PRIVATE_FRAMEWORK_HEADERS > platform/graphics/texmap/TextureMapperLayer.h > platform/graphics/texmap/TextureMapperPlatformLayer.h > platform/graphics/texmap/TextureMapperPlatformLayerProxy.h >+ platform/graphics/texmap/TextureMapperPlatformLayerProxyDMABuf.h > platform/graphics/texmap/TextureMapperPlatformLayerProxyGL.h > platform/graphics/texmap/TextureMapperPlatformLayerProxyProvider.h > platform/graphics/texmap/TextureMapperSolidColorLayer.h >@@ -60,6 +61,7 @@ if (USE_COORDINATED_GRAPHICS) > platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp > platform/graphics/texmap/TextureMapperPlatformLayerDmabuf.cpp > platform/graphics/texmap/TextureMapperPlatformLayerProxy.cpp >+ platform/graphics/texmap/TextureMapperPlatformLayerProxyDMABuf.cpp > platform/graphics/texmap/TextureMapperPlatformLayerProxyGL.cpp > > platform/graphics/texmap/coordinated/CoordinatedBackingStore.cpp >diff --git a/Source/WebCore/platform/graphics/gbm/DMABufFormat.h b/Source/WebCore/platform/graphics/gbm/DMABufFormat.h >new file mode 100644 >index 0000000000000000000000000000000000000000..2c1df9956090ed4657b45c7894daade8cf7f310b >--- /dev/null >+++ b/Source/WebCore/platform/graphics/gbm/DMABufFormat.h >@@ -0,0 +1,370 @@ >+/* >+ * Copyright (C) 2022 Metrological Group B.V. >+ * Copyright (C) 2022 Igalia S.L. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include <cstddef> >+#include <cstdint> >+ >+namespace WebCore { >+ >+namespace DMABufFormatImpl { >+ >+static constexpr uint32_t createFourCC(char a, char b, char c, char d) >+{ >+ return uint32_t(a) | (uint32_t(b) << 8) | (uint32_t(c) << 16) | (uint32_t(d) << 24); >+} >+ >+} >+ >+struct DMABufFormat { >+ enum class FourCC : uint32_t { >+ Invalid = 0, >+ >+ R8 = DMABufFormatImpl::createFourCC('R', '8', ' ', ' '), >+ GR88 = DMABufFormatImpl::createFourCC('G', 'R', '8', '8'), >+ >+ XRGB8888 = DMABufFormatImpl::createFourCC('X', 'R', '2', '4'), >+ XBGR8888 = DMABufFormatImpl::createFourCC('X', 'B', '2', '4'), >+ RGBX8888 = DMABufFormatImpl::createFourCC('R', 'X', '2', '4'), >+ BGRX8888 = DMABufFormatImpl::createFourCC('B', 'X', '2', '4'), >+ ARGB8888 = DMABufFormatImpl::createFourCC('A', 'R', '2', '4'), >+ ABGR8888 = DMABufFormatImpl::createFourCC('A', 'B', '2', '4'), >+ RGBA8888 = DMABufFormatImpl::createFourCC('R', 'A', '2', '4'), >+ BGRA8888 = DMABufFormatImpl::createFourCC('B', 'A', '2', '4'), >+ RGB888 = DMABufFormatImpl::createFourCC('R', 'G', '2', '4'), >+ BGR888 = DMABufFormatImpl::createFourCC('B', 'G', '2', '4'), >+ >+ I420 = DMABufFormatImpl::createFourCC('I', '4', '2', '0'), >+ YV12 = DMABufFormatImpl::createFourCC('Y', 'V', '1', '2'), >+ A420 = DMABufFormatImpl::createFourCC('A', '4', '2', '0'), >+ NV12 = DMABufFormatImpl::createFourCC('N', 'V', '1', '2'), >+ NV21 = DMABufFormatImpl::createFourCC('N', 'V', '2', '1'), >+ >+ YUY2 = DMABufFormatImpl::createFourCC('Y', 'U', 'Y', '2'), >+ YVYU = DMABufFormatImpl::createFourCC('Y', 'V', 'Y', 'U'), >+ UYVY = DMABufFormatImpl::createFourCC('U', 'Y', 'V', 'Y'), >+ VYUY = DMABufFormatImpl::createFourCC('V', 'Y', 'U', 'Y'), >+ VUYA = DMABufFormatImpl::createFourCC('V', 'U', 'Y', 'A'), >+ AYUV = DMABufFormatImpl::createFourCC('A', 'Y', 'U', 'V'), >+ >+ Y444 = DMABufFormatImpl::createFourCC('Y', '4', '4', '4'), >+ Y41B = DMABufFormatImpl::createFourCC('Y', '4', '1', 'B'), >+ Y42B = DMABufFormatImpl::createFourCC('Y', '4', '2', 'B'), >+ }; >+ >+ static constexpr unsigned c_maxPlanes = 4; >+ >+ template<FourCC> static DMABufFormat create() = delete; >+ static DMABufFormat create(uint32_t); >+ >+ template<FourCC fourccValue, typename... PlaneDefinitionTypes> >+ static DMABufFormat instantiate(); >+ >+ FourCC fourcc { FourCC::Invalid }; >+ unsigned numPlanes { 0 }; >+ >+ uint32_t planeWidth(unsigned planeIndex, uint32_t width) const >+ { >+ return (width >> planes[planeIndex].horizontalSubsampling); >+ } >+ >+ uint32_t planeHeight(unsigned planeIndex, uint32_t height) const >+ { >+ return (height >> planes[planeIndex].verticalSubsampling); >+ } >+ >+ template<FourCC fourccValue, unsigned hsValue, unsigned vsValue> >+ struct PlaneDefinition { >+ static constexpr FourCC fourcc = fourccValue; >+ static constexpr unsigned horizontalSubsampling = hsValue; >+ static constexpr unsigned verticalSubsampling = vsValue; >+ }; >+ >+ struct Plane { >+ Plane() = default; >+ >+ template<typename PlaneDefitionType> >+ Plane(const PlaneDefitionType&) >+ : fourcc(PlaneDefitionType::fourcc) >+ , horizontalSubsampling(PlaneDefitionType::horizontalSubsampling) >+ , verticalSubsampling(PlaneDefitionType::verticalSubsampling) >+ { } >+ >+ FourCC fourcc { FourCC::Invalid }; >+ unsigned horizontalSubsampling { 0 }; >+ unsigned verticalSubsampling { 0 }; >+ }; >+ std::array<Plane, c_maxPlanes> planes; >+}; >+ >+namespace DMABufFormatImpl { >+ >+template<DMABufFormat::FourCC fourccValue> >+inline DMABufFormat createSinglePlaneRGBA() >+{ >+ return DMABufFormat::instantiate<fourccValue, >+ DMABufFormat::PlaneDefinition<fourccValue, 0, 0>>(); >+} >+ >+template<size_t Index, size_t Size, typename PlaneDefinitionType, typename... PlaneDefinitionTypes> >+void definePlane(std::array<DMABufFormat::Plane, DMABufFormat::c_maxPlanes>& planes) >+{ >+ new (&planes[Index]) DMABufFormat::Plane(PlaneDefinitionType { }); >+ if constexpr ((Index + 1) < Size) >+ definePlane<Index + 1, Size, PlaneDefinitionTypes...>(planes); >+} >+ >+} >+ >+template<DMABufFormat::FourCC fourccValue, typename... PlaneDefinitionTypes> >+inline DMABufFormat DMABufFormat::instantiate() >+{ >+ static_assert(sizeof...(PlaneDefinitionTypes) <= 4); >+ >+ DMABufFormat format; >+ format.fourcc = fourccValue; >+ format.numPlanes = sizeof...(PlaneDefinitionTypes); >+ DMABufFormatImpl::definePlane<0, sizeof...(PlaneDefinitionTypes), PlaneDefinitionTypes...>(format.planes); >+ return format; >+} >+ >+template<> >+inline DMABufFormat DMABufFormat::create<DMABufFormat::FourCC::XRGB8888>() >+{ >+ return DMABufFormatImpl::createSinglePlaneRGBA<FourCC::XRGB8888>(); >+} >+ >+template<> >+inline DMABufFormat DMABufFormat::create<DMABufFormat::FourCC::XBGR8888>() >+{ >+ return DMABufFormatImpl::createSinglePlaneRGBA<FourCC::XBGR8888>(); >+} >+ >+template<> >+inline DMABufFormat DMABufFormat::create<DMABufFormat::FourCC::RGBX8888>() >+{ >+ return DMABufFormatImpl::createSinglePlaneRGBA<FourCC::RGBX8888>(); >+} >+ >+template<> >+inline DMABufFormat DMABufFormat::create<DMABufFormat::FourCC::BGRX8888>() >+{ >+ return DMABufFormatImpl::createSinglePlaneRGBA<FourCC::BGRX8888>(); >+} >+ >+template<> >+inline DMABufFormat DMABufFormat::create<DMABufFormat::FourCC::ARGB8888>() >+{ >+ return DMABufFormatImpl::createSinglePlaneRGBA<FourCC::ARGB8888>(); >+} >+ >+template<> >+inline DMABufFormat DMABufFormat::create<DMABufFormat::FourCC::ABGR8888>() >+{ >+ return DMABufFormatImpl::createSinglePlaneRGBA<FourCC::ABGR8888>(); >+} >+ >+template<> >+inline DMABufFormat DMABufFormat::create<DMABufFormat::FourCC::RGBA8888>() >+{ >+ return DMABufFormatImpl::createSinglePlaneRGBA<FourCC::RGBA8888>(); >+} >+ >+template<> >+inline DMABufFormat DMABufFormat::create<DMABufFormat::FourCC::BGRA8888>() >+{ >+ return DMABufFormatImpl::createSinglePlaneRGBA<FourCC::BGRA8888>(); >+} >+ >+template<> >+inline DMABufFormat DMABufFormat::create<DMABufFormat::FourCC::I420>() >+{ >+ return DMABufFormat::instantiate<FourCC::I420, >+ PlaneDefinition<FourCC::R8, 0, 0>, >+ PlaneDefinition<FourCC::R8, 1, 1>, >+ PlaneDefinition<FourCC::R8, 1, 1>>(); >+} >+ >+template<> >+inline DMABufFormat DMABufFormat::create<DMABufFormat::FourCC::YV12>() >+{ >+ return DMABufFormat::instantiate<FourCC::YV12, >+ PlaneDefinition<FourCC::R8, 0, 0>, >+ PlaneDefinition<FourCC::R8, 1, 1>, >+ PlaneDefinition<FourCC::R8, 1, 1>>(); >+} >+ >+template<> >+inline DMABufFormat DMABufFormat::create<DMABufFormat::FourCC::A420>() >+{ >+ return DMABufFormat::instantiate<FourCC::A420, >+ PlaneDefinition<FourCC::R8, 0, 0>, >+ PlaneDefinition<FourCC::R8, 1, 1>, >+ PlaneDefinition<FourCC::R8, 1, 1>, >+ PlaneDefinition<FourCC::R8, 0, 0>>(); >+} >+ >+template<> >+inline DMABufFormat DMABufFormat::create<DMABufFormat::FourCC::NV12>() >+{ >+ return DMABufFormat::instantiate<FourCC::NV12, >+ PlaneDefinition<FourCC::R8, 0, 0>, >+ PlaneDefinition<FourCC::GR88, 1, 1>>(); >+} >+ >+template<> >+inline DMABufFormat DMABufFormat::create<DMABufFormat::FourCC::NV21>() >+{ >+ return DMABufFormat::instantiate<FourCC::NV21, >+ PlaneDefinition<FourCC::R8, 0, 0>, >+ PlaneDefinition<FourCC::GR88, 1, 1>>(); >+} >+ >+template<> >+inline DMABufFormat DMABufFormat::create<DMABufFormat::FourCC::YUY2>() >+{ >+ return DMABufFormat::instantiate<FourCC::YUY2, >+ PlaneDefinition<FourCC::GR88, 0, 0>>(); >+} >+ >+template<> >+inline DMABufFormat DMABufFormat::create<DMABufFormat::FourCC::YVYU>() >+{ >+ return DMABufFormat::instantiate<FourCC::YVYU, >+ PlaneDefinition<FourCC::GR88, 0, 0>>(); >+} >+ >+template<> >+inline DMABufFormat DMABufFormat::create<DMABufFormat::FourCC::UYVY>() >+{ >+ return DMABufFormat::instantiate<FourCC::UYVY, >+ PlaneDefinition<FourCC::GR88, 0, 0>>(); >+} >+ >+template<> >+inline DMABufFormat DMABufFormat::create<DMABufFormat::FourCC::VYUY>() >+{ >+ return DMABufFormat::instantiate<FourCC::YVYU, >+ PlaneDefinition<FourCC::GR88, 0, 0>>(); >+} >+ >+template<> >+inline DMABufFormat DMABufFormat::create<DMABufFormat::FourCC::VUYA>() >+{ >+ return DMABufFormat::instantiate<FourCC::VUYA, >+ PlaneDefinition<FourCC::ABGR8888, 0, 0>>(); >+} >+ >+template<> >+inline DMABufFormat DMABufFormat::create<DMABufFormat::FourCC::AYUV>() >+{ >+ return DMABufFormat::instantiate<FourCC::VUYA, >+ PlaneDefinition<FourCC::ABGR8888, 0, 0>>(); >+} >+ >+template<> >+inline DMABufFormat DMABufFormat::create<DMABufFormat::FourCC::Y444>() >+{ >+ return DMABufFormat::instantiate<FourCC::Y444, >+ PlaneDefinition<FourCC::R8, 0, 0>, >+ PlaneDefinition<FourCC::R8, 0, 0>, >+ PlaneDefinition<FourCC::R8, 0, 0>>(); >+} >+ >+template<> >+inline DMABufFormat DMABufFormat::create<DMABufFormat::FourCC::Y41B>() >+{ >+ return DMABufFormat::instantiate<FourCC::Y41B, >+ PlaneDefinition<FourCC::R8, 0, 0>, >+ PlaneDefinition<FourCC::R8, 2, 0>, >+ PlaneDefinition<FourCC::R8, 2, 0>>(); >+} >+ >+template<> >+inline DMABufFormat DMABufFormat::create<DMABufFormat::FourCC::Y42B>() >+{ >+ return DMABufFormat::instantiate<FourCC::Y42B, >+ PlaneDefinition<FourCC::R8, 0, 0>, >+ PlaneDefinition<FourCC::R8, 1, 0>, >+ PlaneDefinition<FourCC::R8, 1, 0>>(); >+} >+ >+inline DMABufFormat DMABufFormat::create(uint32_t fourccValue) >+{ >+ switch (fourccValue) { >+ case uint32_t(FourCC::XRGB8888): >+ return create<FourCC::XRGB8888>(); >+ case uint32_t(FourCC::XBGR8888): >+ return create<FourCC::XBGR8888>(); >+ case uint32_t(FourCC::RGBX8888): >+ return create<FourCC::RGBX8888>(); >+ case uint32_t(FourCC::BGRX8888): >+ return create<FourCC::BGRX8888>(); >+ case uint32_t(FourCC::ARGB8888): >+ return create<FourCC::ARGB8888>(); >+ case uint32_t(FourCC::ABGR8888): >+ return create<FourCC::ABGR8888>(); >+ case uint32_t(FourCC::RGBA8888): >+ return create<FourCC::RGBA8888>(); >+ case uint32_t(FourCC::BGRA8888): >+ return create<FourCC::BGRA8888>(); >+ case uint32_t(FourCC::I420): >+ return create<FourCC::I420>(); >+ case uint32_t(FourCC::YV12): >+ return create<FourCC::YV12>(); >+ case uint32_t(FourCC::A420): >+ return create<FourCC::A420>(); >+ case uint32_t(FourCC::NV12): >+ return create<FourCC::NV12>(); >+ case uint32_t(FourCC::NV21): >+ return create<FourCC::NV21>(); >+ case uint32_t(FourCC::YUY2): >+ return create<FourCC::YUY2>(); >+ case uint32_t(FourCC::YVYU): >+ return create<FourCC::YVYU>(); >+ case uint32_t(FourCC::UYVY): >+ return create<FourCC::UYVY>(); >+ case uint32_t(FourCC::VYUY): >+ return create<FourCC::UYVY>(); >+ case uint32_t(FourCC::VUYA): >+ return create<FourCC::VUYA>(); >+ case uint32_t(FourCC::AYUV): >+ return create<FourCC::AYUV>(); >+ case uint32_t(FourCC::Y444): >+ return create<FourCC::Y444>(); >+ case uint32_t(FourCC::Y41B): >+ return create<FourCC::Y41B>(); >+ case uint32_t(FourCC::Y42B): >+ return create<FourCC::Y42B>(); >+ default: >+ break; >+ } >+ >+ return { }; >+} >+ >+} // namespace WebCore >diff --git a/Source/WebCore/platform/graphics/gbm/DMABufObject.h b/Source/WebCore/platform/graphics/gbm/DMABufObject.h >new file mode 100644 >index 0000000000000000000000000000000000000000..08644444394f7b9d9ff43dcbdc392abaa77cc5a7 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/gbm/DMABufObject.h >@@ -0,0 +1,92 @@ >+/* >+ * Copyright (C) 2022 Metrological Group B.V. >+ * Copyright (C) 2022 Igalia S.L. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include "DMABufFormat.h" >+#include "DMABufReleaseFlag.h" >+#include <array> >+#include <cstddef> >+#include <cstdint> >+#include <unistd.h> >+ >+namespace WebCore { >+ >+struct DMABufObject { >+ DMABufObject(uintptr_t handle) >+ : handle(handle) >+ { } >+ >+ ~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&& 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<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 }; >+}; >+ >+} // namespace WebCore >diff --git a/Source/WebCore/platform/graphics/gbm/DMABufReleaseFlag.h b/Source/WebCore/platform/graphics/gbm/DMABufReleaseFlag.h >new file mode 100644 >index 0000000000000000000000000000000000000000..cf4d7760053f99c5587650a086aab97104875f7e >--- /dev/null >+++ b/Source/WebCore/platform/graphics/gbm/DMABufReleaseFlag.h >@@ -0,0 +1,102 @@ >+/* >+ * Copyright (C) 2022 Metrological Group B.V. >+ * Copyright (C) 2022 Igalia S.L. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include <sys/eventfd.h> >+#include <wtf/UniStdExtras.h> >+ >+namespace WebCore { >+ >+struct DMABufReleaseFlag { >+ DMABufReleaseFlag() = default; >+ >+ enum InitializeTag { Initialize }; >+ DMABufReleaseFlag(InitializeTag) >+ { >+ fd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); >+ } >+ >+ ~DMABufReleaseFlag() >+ { >+ if (fd != -1) >+ close(fd); >+ fd = -1; >+ } >+ >+ DMABufReleaseFlag(const DMABufReleaseFlag&) = delete; >+ DMABufReleaseFlag& operator=(const DMABufReleaseFlag&) = delete; >+ >+ 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); >+ return flag; >+ } >+ >+ bool released() const >+ { >+ if (fd == -1) >+ return true; >+ >+ uint64_t value { 0 }; >+ if (read(fd, &value, sizeof(uint64_t)) == sizeof(uint64_t)) >+ return !!value; >+ return false; >+ } >+ >+ void release() >+ { >+ if (fd == -1) >+ return; >+ >+ uint64_t value { 1 }; >+ write(fd, &value, sizeof(uint64_t)); >+ } >+ >+ int fd { -1 }; >+}; >+ >+} // namespace WebCore >diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerProxyDMABuf.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerProxyDMABuf.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..684dccc563256411c195e5f1d757d1b8ec2d9a76 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerProxyDMABuf.cpp >@@ -0,0 +1,249 @@ >+/* >+ * Copyright (C) 2022 Metrological Group B.V. >+ * Copyright (C) 2022 Igalia S.L. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "TextureMapperPlatformLayerProxyDMABuf.h" >+ >+#if USE(COORDINATED_GRAPHICS) >+ >+#include "EpoxyEGL.h" >+#include "PlatformDisplay.h" >+#include "TextureMapperGL.h" >+#include "TextureMapperLayer.h" >+#include <fcntl.h> >+#include <unistd.h> >+ >+namespace WebCore { >+ >+struct TextureMapperPlatformLayerProxyDMABuf::DMABufLayer::EGLImageData { >+ WTF_MAKE_STRUCT_FAST_ALLOCATED; >+ >+ uint32_t width { 0 }; >+ uint32_t height { 0 }; >+ unsigned numImages { 0 }; >+ std::array<GLuint, DMABufFormat::c_maxPlanes> texture { 0, 0, 0, 0 }; >+ std::array<EGLImageKHR, DMABufFormat::c_maxPlanes> image { EGL_NO_IMAGE_KHR, EGL_NO_IMAGE_KHR, EGL_NO_IMAGE_KHR, EGL_NO_IMAGE_KHR }; >+}; >+ >+TextureMapperPlatformLayerProxyDMABuf::TextureMapperPlatformLayerProxyDMABuf() = default; >+TextureMapperPlatformLayerProxyDMABuf::~TextureMapperPlatformLayerProxyDMABuf() = default; >+ >+void TextureMapperPlatformLayerProxyDMABuf::activateOnCompositingThread(Compositor* compositor, TextureMapperLayer* targetLayer) >+{ >+#ifndef NDEBUG >+ if (!m_compositorThread) >+ m_compositorThread = &Thread::current(); >+#endif >+ ASSERT(m_compositorThread == &Thread::current()); >+ ASSERT(compositor); >+ ASSERT(targetLayer); >+ >+ { >+ Locker locker { m_lock }; >+ m_compositor = compositor; >+ m_targetLayer = targetLayer; >+ } >+} >+ >+void TextureMapperPlatformLayerProxyDMABuf::invalidate() >+{ >+ Locker locker { m_lock }; >+ >+ m_pendingLayer = nullptr; >+ m_committedLayer = nullptr; >+ m_layers = { }; >+ >+ m_compositor = nullptr; >+ m_targetLayer = nullptr; >+} >+ >+void TextureMapperPlatformLayerProxyDMABuf::swapBuffer() >+{ >+ Locker locker { m_lock }; >+ if (!m_targetLayer || !m_pendingLayer) >+ return; >+ >+ auto previousLayer = WTFMove(m_committedLayer); >+ m_committedLayer = WTFMove(m_pendingLayer); >+ m_targetLayer->setContentsLayer(m_committedLayer.get()); >+ >+ // Avoid any funky situation where the two layers are the same. >+ if (previousLayer && previousLayer != m_committedLayer) >+ previousLayer->release(); >+ >+ if (!m_committedLayer->m_imageData) >+ m_committedLayer->m_imageData = DMABufLayer::createEGLImageData(m_committedLayer->m_object); >+ m_committedLayer->m_age = 0; >+ >+ auto& committedObject = m_committedLayer->m_object; >+ auto isStaleLayer = >+ [&](auto& layer) >+ { >+ return layer.m_age > DMABufLayer::c_maximumAge >+ || !(layer.m_object.width == committedObject.width && layer.m_object.height == committedObject.height); >+ }; >+ >+ bool hasStaleLayers = false; >+ for (auto it = m_layers.begin(); it != m_layers.end(); ++it) { >+ auto& layer = it->value; >+ ++layer->m_age; >+ hasStaleLayers |= isStaleLayer(layer.get()); >+ } >+ >+ if (hasStaleLayers) { >+ LayerMap updatedLayers; >+ for (auto it = m_layers.begin(); it != m_layers.end(); ++it) { >+ if (!isStaleLayer(it->value.get())) >+ updatedLayers.add(it->key, it->value.copyRef()); >+ } >+ m_layers = WTFMove(updatedLayers); >+ } >+} >+ >+void TextureMapperPlatformLayerProxyDMABuf::pushDMABuf(Ref<DMABufLayer>&& dmabufLayer) >+{ >+ ASSERT(m_lock.isHeld()); >+ >+ // Avoid any funky situation where the two layers are the same. >+ if (m_pendingLayer && m_pendingLayer != dmabufLayer.ptr()) >+ m_pendingLayer->release(); >+ >+ m_pendingLayer = WTFMove(dmabufLayer); >+ if (m_compositor) >+ m_compositor->onNewBufferAvailable(); >+} >+ >+TextureMapperPlatformLayerProxyDMABuf::DMABufLayer::DMABufLayer(DMABufObject&& object, TextureMapperGL::Flags flags) >+ : m_object(WTFMove(object)) >+ , m_flags(flags) >+{ } >+ >+TextureMapperPlatformLayerProxyDMABuf::DMABufLayer::~DMABufLayer() >+{ >+ m_object = DMABufObject(0); >+ >+ if (m_imageData) { >+ auto& data = *m_imageData; >+ if (!!data.numImages) { >+ glDeleteTextures(data.numImages, data.texture.data()); >+ >+ for (unsigned i = 0; i < data.numImages; ++i) { >+ if (data.image[i] != EGL_NO_IMAGE_KHR) { >+ eglDestroyImageKHR(PlatformDisplay::sharedDisplayForCompositing().eglDisplay(), data.image[i]); >+ data.image[i] = EGL_NO_IMAGE_KHR; >+ } >+ } >+ } >+ } >+ m_imageData = nullptr; >+} >+ >+void TextureMapperPlatformLayerProxyDMABuf::DMABufLayer::paintToTextureMapper(TextureMapper& textureMapper, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity) >+{ >+ if (!m_imageData) >+ return; >+ >+ TextureMapperGL& texmapGL = static_cast<TextureMapperGL&>(textureMapper); >+ auto& data = *m_imageData; >+ >+ switch (m_object.format.fourcc) { >+ case DMABufFormat::FourCC::XRGB8888: >+ case DMABufFormat::FourCC::XBGR8888: >+ case DMABufFormat::FourCC::ARGB8888: >+ case DMABufFormat::FourCC::ABGR8888: >+ texmapGL.drawTexture(data.texture[0], m_flags, IntSize(data.width, data.height), targetRect, modelViewMatrix, opacity); >+ break; >+ case DMABufFormat::FourCC::I420: >+ case DMABufFormat::FourCC::Y444: >+ case DMABufFormat::FourCC::Y41B: >+ case DMABufFormat::FourCC::Y42B: >+ case DMABufFormat::FourCC::YV12: >+ case DMABufFormat::FourCC::A420: >+ case DMABufFormat::FourCC::NV12: >+ case DMABufFormat::FourCC::NV21: >+ case DMABufFormat::FourCC::YUY2: >+ case DMABufFormat::FourCC::UYVY: >+ case DMABufFormat::FourCC::VUYA: >+ case DMABufFormat::FourCC::YVYU: >+ // TODO: YUV support, possible when different colorspaces are supported. >+ break; >+ default: >+ break; >+ } >+} >+ >+std::unique_ptr<TextureMapperPlatformLayerProxyDMABuf::DMABufLayer::EGLImageData> TextureMapperPlatformLayerProxyDMABuf::DMABufLayer::createEGLImageData(DMABufObject& object) >+{ >+ using EGLImageData = TextureMapperPlatformLayerProxyDMABuf::DMABufLayer::EGLImageData; >+ >+ EGLDisplay eglDisplay = PlatformDisplay::sharedDisplayForCompositing().eglDisplay(); >+ >+ EGLImageKHR image[DMABufFormat::c_maxPlanes]; >+ for (unsigned i = 0; i < object.format.numPlanes; ++i) { >+ unsigned attrIndex = 0; >+ EGLint attributes[64]; >+ >+ attributes[attrIndex++] = EGL_WIDTH; >+ attributes[attrIndex++] = object.format.planeWidth(i, object.width); >+ attributes[attrIndex++] = EGL_HEIGHT; >+ attributes[attrIndex++] = object.format.planeHeight(i, object.height); >+ attributes[attrIndex++] = EGL_LINUX_DRM_FOURCC_EXT; >+ attributes[attrIndex++] = EGLint(object.format.planes[i].fourcc); >+ attributes[attrIndex++] = EGL_DMA_BUF_PLANE0_FD_EXT; >+ attributes[attrIndex++] = object.fd[i]; >+ attributes[attrIndex++] = EGL_DMA_BUF_PLANE0_OFFSET_EXT; >+ attributes[attrIndex++] = object.offset[i]; >+ attributes[attrIndex++] = EGL_DMA_BUF_PLANE0_PITCH_EXT; >+ attributes[attrIndex++] = object.stride[i]; >+ attributes[attrIndex++] = EGL_NONE; >+ >+ image[i] = eglCreateImageKHR(eglDisplay, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, nullptr, attributes); >+ } >+ >+ auto imageData = makeUnique<EGLImageData>(); >+ auto& data = *imageData; >+ data.width = object.width; >+ data.height = object.height; >+ data.numImages = object.format.numPlanes; >+ glGenTextures(data.numImages, data.texture.data()); >+ for (unsigned i = 0; i < data.numImages; ++i) { >+ data.image[i] = image[i]; >+ >+ glBindTexture(GL_TEXTURE_2D, data.texture[i]); >+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); >+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); >+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); >+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); >+ glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, data.image[i]); >+ glBindTexture(GL_TEXTURE_2D, 0); >+ } >+ >+ return imageData; >+} >+ >+} // namespace WebCore >+ >+#endif // USE(COORDINATED_GRAPHICS) >diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerProxyDMABuf.h b/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerProxyDMABuf.h >new file mode 100644 >index 0000000000000000000000000000000000000000..08c0bdaca6d2dbe10951ece83de765c0a732a9f0 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerProxyDMABuf.h >@@ -0,0 +1,111 @@ >+/* >+ * Copyright (C) 2022 Metrological Group B.V. >+ * Copyright (C) 2022 Igalia S.L. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include "TextureMapperPlatformLayer.h" >+#include "TextureMapperPlatformLayerProxy.h" >+ >+#if USE(COORDINATED_GRAPHICS) >+ >+#include "DMABufFormat.h" >+#include "DMABufObject.h" >+#include "TextureMapperGL.h" >+#include <cstdint> >+#include <memory> >+ >+namespace WebCore { >+ >+class TextureMapperPlatformLayerProxyDMABuf final : public TextureMapperPlatformLayerProxy { >+ WTF_MAKE_FAST_ALLOCATED; >+public: >+ TextureMapperPlatformLayerProxyDMABuf(); >+ virtual ~TextureMapperPlatformLayerProxyDMABuf(); >+ >+ bool isDMABufBased() const override { return true; } >+ >+ WEBCORE_EXPORT void activateOnCompositingThread(Compositor*, TextureMapperLayer*) override; >+ WEBCORE_EXPORT void invalidate() override; >+ WEBCORE_EXPORT void swapBuffer() override; >+ >+ class DMABufLayer : public ThreadSafeRefCounted<DMABufLayer>, public TextureMapperPlatformLayer { >+ WTF_MAKE_FAST_ALLOCATED; >+ public: >+ DMABufLayer(DMABufObject&&, TextureMapperGL::Flags = 0); >+ virtual ~DMABufLayer(); >+ >+ void paintToTextureMapper(TextureMapper&, const FloatRect&, const TransformationMatrix& modelViewMatrix = { }, float opacity = 1.0) final; >+ >+ void release() >+ { >+ m_object.releaseFlag.release(); >+ } >+ >+ private: >+ friend class TextureMapperPlatformLayerProxyDMABuf; >+ >+ struct EGLImageData; >+ static std::unique_ptr<EGLImageData> createEGLImageData(DMABufObject&); >+ >+ DMABufObject m_object; >+ std::unique_ptr<EGLImageData> m_imageData; >+ TextureMapperGL::Flags m_flags; >+ >+ static constexpr unsigned c_maximumAge { 16 }; >+ unsigned m_age { 0 }; >+ }; >+ >+ template<typename F> >+ void pushDMABuf(DMABufObject&& dmabufObject, const F& constructor, TextureMapperGL::Flags flags = 0) >+ { >+ ASSERT(m_lock.isHeld()); >+ >+ auto result = m_layers.ensure(dmabufObject.handle, >+ [&] { >+ return adoptRef(*new DMABufLayer(constructor(WTFMove(dmabufObject)), flags)); >+ }); >+ pushDMABuf(result.iterator->value.copyRef()); >+ } >+ >+private: >+ void pushDMABuf(Ref<DMABufLayer>&&); >+ >+#ifndef NDEBUG >+ RefPtr<Thread> m_compositorThread; >+#endif >+ >+ using LayerMap = HashMap<uintptr_t, Ref<DMABufLayer>, WTF::DefaultHash<uintptr_t>, WTF::UnsignedWithZeroKeyHashTraits<uintptr_t>>; >+ LayerMap m_layers; >+ >+ RefPtr<DMABufLayer> m_pendingLayer; >+ RefPtr<DMABufLayer> m_committedLayer; >+}; >+ >+} // namespace WebCore >+ >+SPECIALIZE_TYPE_TRAITS_TEXTUREMAPPER_PLATFORMLAYERPROXY(TextureMapperPlatformLayerProxyDMABuf, isDMABufBased()); >+ >+#endif // USE(COORDINATED_GRAPHICS)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 237328
:
453504
|
453709
|
453729
|
453839
|
454329
|
454674
|
454821