- Revision
- 234643
- Author
- [email protected]
- Date
- 2018-08-07 02:03:57 -0700 (Tue, 07 Aug 2018)
Log Message
[Nicosia] Add the TextureMapper-specific ContentLayer::Impl derivative
https://bugs.webkit.org/show_bug.cgi?id=188344
Reviewed by Carlos Garcia Campos.
Add Nicosia::ContentLayerTextureMapperImpl class, providing the
TextureMapper-specific implementation that derives from the
ContentLayer::Impl class and which can be used by the
Nicosia::ContentLayer instances.
Internally a TextureMapperPlatformLayerProxy is created, and is
accessible to others through a getter. This way the content producers
can push new buffers into this proxy object, and the scene compositor
can take these buffers for display purposes.
Nicosia::ContentLayerTextureMapperImpl::swapBuffersIfNeeded() will be
called during layer flushes, and the call will cause the content layer
clients to take their texture, wrap it into a buffer, and push it into
the TextureMapperPlatformLayerProxy object. At the moment this operation
is required by the ImageBuffer and GraphicsContext3D producers.
The Client object is managed under its own lock. While the producers
will only live on the main thread, the thread-safe check in the
destructor is necessary in case the ContentLayerTextureMapperImpl object
ends up being destroyed on some other thread.
The patch only adds the class implementation. It will be integrated into
the layer tree later, once all the other pieces of the puzzle land.
* platform/TextureMapper.cmake:
* platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp: Added.
(Nicosia::ContentLayerTextureMapperImpl::createFactory):
(Nicosia::ContentLayerTextureMapperImpl::ContentLayerTextureMapperImpl):
(Nicosia::ContentLayerTextureMapperImpl::~ContentLayerTextureMapperImpl):
(Nicosia::ContentLayerTextureMapperImpl::invalidateClient):
(Nicosia::ContentLayerTextureMapperImpl::swapBuffersIfNeeded):
* platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.h: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (234642 => 234643)
--- trunk/Source/WebCore/ChangeLog 2018-08-07 08:30:39 UTC (rev 234642)
+++ trunk/Source/WebCore/ChangeLog 2018-08-07 09:03:57 UTC (rev 234643)
@@ -1,3 +1,43 @@
+2018-08-07 Zan Dobersek <[email protected]>
+
+ [Nicosia] Add the TextureMapper-specific ContentLayer::Impl derivative
+ https://bugs.webkit.org/show_bug.cgi?id=188344
+
+ Reviewed by Carlos Garcia Campos.
+
+ Add Nicosia::ContentLayerTextureMapperImpl class, providing the
+ TextureMapper-specific implementation that derives from the
+ ContentLayer::Impl class and which can be used by the
+ Nicosia::ContentLayer instances.
+
+ Internally a TextureMapperPlatformLayerProxy is created, and is
+ accessible to others through a getter. This way the content producers
+ can push new buffers into this proxy object, and the scene compositor
+ can take these buffers for display purposes.
+
+ Nicosia::ContentLayerTextureMapperImpl::swapBuffersIfNeeded() will be
+ called during layer flushes, and the call will cause the content layer
+ clients to take their texture, wrap it into a buffer, and push it into
+ the TextureMapperPlatformLayerProxy object. At the moment this operation
+ is required by the ImageBuffer and GraphicsContext3D producers.
+
+ The Client object is managed under its own lock. While the producers
+ will only live on the main thread, the thread-safe check in the
+ destructor is necessary in case the ContentLayerTextureMapperImpl object
+ ends up being destroyed on some other thread.
+
+ The patch only adds the class implementation. It will be integrated into
+ the layer tree later, once all the other pieces of the puzzle land.
+
+ * platform/TextureMapper.cmake:
+ * platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp: Added.
+ (Nicosia::ContentLayerTextureMapperImpl::createFactory):
+ (Nicosia::ContentLayerTextureMapperImpl::ContentLayerTextureMapperImpl):
+ (Nicosia::ContentLayerTextureMapperImpl::~ContentLayerTextureMapperImpl):
+ (Nicosia::ContentLayerTextureMapperImpl::invalidateClient):
+ (Nicosia::ContentLayerTextureMapperImpl::swapBuffersIfNeeded):
+ * platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.h: Added.
+
2018-08-07 Frederic Wang <[email protected]>
Make DOMWindow::scrollBy rely on DOMWindow::scrollTo
Modified: trunk/Source/WebCore/platform/TextureMapper.cmake (234642 => 234643)
--- trunk/Source/WebCore/platform/TextureMapper.cmake 2018-08-07 08:30:39 UTC (rev 234642)
+++ trunk/Source/WebCore/platform/TextureMapper.cmake 2018-08-07 09:03:57 UTC (rev 234643)
@@ -56,6 +56,8 @@
platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp
platform/graphics/nicosia/cairo/NicosiaPaintingContextCairo.cpp
+
+ platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp
)
else ()
list(APPEND WebCore_SOURCES
Added: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp (0 => 234643)
--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp (rev 0)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp 2018-08-07 09:03:57 UTC (rev 234643)
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2018 Metrological Group B.V.
+ * Copyright (C) 2018 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * HOLDER OR 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 "NicosiaContentLayerTextureMapperImpl.h"
+
+#if USE(TEXTURE_MAPPER)
+
+#include "TextureMapperPlatformLayerProxy.h"
+
+namespace Nicosia {
+
+auto ContentLayerTextureMapperImpl::createFactory(Client& client) -> Factory
+{
+ return Factory(
+ [&client](ContentLayer&) {
+ return std::make_unique<ContentLayerTextureMapperImpl>(client);
+ });
+}
+
+ContentLayerTextureMapperImpl::ContentLayerTextureMapperImpl(Client& client)
+ : m_proxy(adoptRef(*new WebCore::TextureMapperPlatformLayerProxy))
+ , m_client { { }, &client }
+{
+}
+
+ContentLayerTextureMapperImpl::~ContentLayerTextureMapperImpl()
+{
+#if !ASSERT_DISABLED
+ LockHolder locker(m_client.lock);
+ ASSERT(!m_client.client);
+#endif
+}
+
+void ContentLayerTextureMapperImpl::invalidateClient()
+{
+ LockHolder locker(m_client.lock);
+ m_client.client = nullptr;
+}
+
+void ContentLayerTextureMapperImpl::swapBuffersIfNeeded()
+{
+ LockHolder locker(m_client.lock);
+ if (m_client.client)
+ m_client.client->swapBuffersIfNeeded();
+}
+
+ContentLayerTextureMapperImpl::Client::~Client() = default;
+
+} // namespace Nicosia
+
+#endif // USE(TEXTURE_MAPPER)
Added: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.h (0 => 234643)
--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.h 2018-08-07 09:03:57 UTC (rev 234643)
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2018 Metrological Group B.V.
+ * Copyright (C) 2018 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * HOLDER OR 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
+
+#if USE(TEXTURE_MAPPER)
+
+#include "NicosiaPlatformLayer.h"
+#include <wtf/Lock.h>
+#include <wtf/Ref.h>
+
+namespace WebCore {
+class TextureMapperPlatformLayerProxy;
+}
+
+namespace Nicosia {
+
+class ContentLayerTextureMapperImpl final : public ContentLayer::Impl {
+public:
+ class Client {
+ public:
+ virtual ~Client();
+ virtual void swapBuffersIfNeeded() = 0;
+ };
+
+ static Factory createFactory(Client&);
+
+ explicit ContentLayerTextureMapperImpl(Client&);
+ virtual ~ContentLayerTextureMapperImpl();
+ bool isTextureMapperImpl() const override { return true; }
+
+ void invalidateClient();
+
+ WebCore::TextureMapperPlatformLayerProxy& proxy() const { return m_proxy; }
+ void swapBuffersIfNeeded();
+
+private:
+ Ref<WebCore::TextureMapperPlatformLayerProxy> m_proxy;
+ struct {
+ Lock lock;
+ Client* client { nullptr };
+ } m_client;
+};
+
+} // namespace Nicosia
+
+SPECIALIZE_TYPE_TRAITS_NICOSIA_CONTENTLAYER_IMPL(ContentLayerTextureMapperImpl, isTextureMapperImpl());
+
+#endif // USE(TEXTURE_MAPPER)