Log Message
Implement canvas remote rendering https://bugs.webkit.org/show_bug.cgi?id=204955
Patch by Said Abou-Hallawa <[email protected]> on 2020-03-02 Reviewed by Jon Lee. Source/WebCore: Prepare ConcreteImageBuffer to be created without immediate backend. RemoteImageBuffer, which is a superclass of ConcreteImageBuffer, will be created initially without a backend. It will be created when its twin RemoteImageBufferProxy in the GPUProcess shares its backend. * platform/graphics/ConcreteImageBuffer.h: (WebCore::ConcreteImageBuffer::ensureBackendCreated const): (WebCore::ConcreteImageBuffer::ensureBackend const): Deleted. Source/WebKit: * WebProcess/GPU/graphics/RemoteImageBuffer.h: * WebProcess/GPU/graphics/RemoteImageBufferMessageHandler.cpp: (WebKit::RemoteImageBufferMessageHandler::waitForCreateImageBufferBackend): (WebKit::RemoteImageBufferMessageHandler::waitForCommitImageBufferFlushContext): Synchronize the RemoteImageBuffer backend such that the context and the DrawingContext are flushed to the backend in the GPUProcess only when its pixels are needed in the WebProcess. * WebProcess/GPU/graphics/RemoteImageBufferMessageHandler.h: (WebKit::RemoteImageBufferMessageHandler::isPendingFlush const): Tells whether the pixels of the backend is ready to use or a flushing is being committed. * WebProcess/GPU/graphics/RemoteRenderingBackend.cpp: (WebKit::RemoteRenderingBackend::waitForCreateImageBufferBackend): (WebKit::RemoteRenderingBackend::waitForCommitImageBufferFlushContext): * WebProcess/GPU/graphics/RemoteRenderingBackend.h: They block execution till certain RemoteRenderingBackendProxy messages are received.
Modified Paths
- trunk/Source/WebCore/ChangeLog
- trunk/Source/WebCore/platform/graphics/ConcreteImageBuffer.h
- trunk/Source/WebKit/ChangeLog
- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBuffer.h
- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferMessageHandler.cpp
- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferMessageHandler.h
- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackend.cpp
- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackend.h
Diff
Modified: trunk/Source/WebCore/ChangeLog (257746 => 257747)
--- trunk/Source/WebCore/ChangeLog 2020-03-03 00:16:02 UTC (rev 257746)
+++ trunk/Source/WebCore/ChangeLog 2020-03-03 00:39:24 UTC (rev 257747)
@@ -1,3 +1,18 @@
+2020-03-02 Said Abou-Hallawa <[email protected]>
+ Implement canvas remote rendering
+ https://bugs.webkit.org/show_bug.cgi?id=204955
+
+ Reviewed by Jon Lee.
+
+ Prepare ConcreteImageBuffer to be created without immediate backend.
+ RemoteImageBuffer, which is a superclass of ConcreteImageBuffer, will be
+ created initially without a backend. It will be created when its twin
+ RemoteImageBufferProxy in the GPUProcess shares its backend.
+
+ * platform/graphics/ConcreteImageBuffer.h:
+ (WebCore::ConcreteImageBuffer::ensureBackendCreated const):
+ (WebCore::ConcreteImageBuffer::ensureBackend const): Deleted.
+
2020-03-02 Mark Lam <[email protected]>
ScriptController::executeIfJavaScriptURL() uses wrong JSGlobalObject.
Modified: trunk/Source/WebCore/platform/graphics/ConcreteImageBuffer.h (257746 => 257747)
--- trunk/Source/WebCore/platform/graphics/ConcreteImageBuffer.h 2020-03-03 00:16:02 UTC (rev 257746)
+++ trunk/Source/WebCore/platform/graphics/ConcreteImageBuffer.h 2020-03-03 00:39:24 UTC (rev 257747)
@@ -59,7 +59,7 @@
ConcreteImageBuffer() = default;
- virtual BackendType* ensureBackend() const { return m_backend.get(); }
+ virtual BackendType* ensureBackendCreated() const { return m_backend.get(); }
GraphicsContext& context() const override
{
@@ -69,110 +69,186 @@
void flushContext() override
{
- flushDrawingContext();
- m_backend->flushContext();
+ if (auto* backend = ensureBackendCreated()) {
+ flushDrawingContext();
+ backend->flushContext();
+ }
}
- AffineTransform baseTransform() const override { return m_backend->baseTransform(); }
- IntSize logicalSize() const override { return m_backend->logicalSize(); }
- IntSize backendSize() const override { return m_backend->backendSize(); }
- float resolutionScale() const override { return m_backend->resolutionScale(); }
+ AffineTransform baseTransform() const override
+ {
+ if (auto* backend = ensureBackendCreated())
+ return backend->baseTransform();
+ return { };
+ }
- size_t memoryCost() const override { return m_backend->memoryCost(); }
- size_t externalMemoryCost() const override { return m_backend->externalMemoryCost(); }
+ IntSize logicalSize() const override
+ {
+ if (auto* backend = ensureBackendCreated())
+ return backend->logicalSize();
+ return { };
+ }
+ IntSize backendSize() const override
+ {
+ if (auto* backend = ensureBackendCreated())
+ return backend->backendSize();
+ return { };
+ }
+
+ float resolutionScale() const override
+ {
+ if (auto* backend = ensureBackendCreated())
+ return backend->resolutionScale();
+ return 1;
+ }
+
+ size_t memoryCost() const override
+ {
+ if (auto* backend = ensureBackendCreated())
+ return backend->memoryCost();
+ return 0;
+ }
+
+ size_t externalMemoryCost() const override
+ {
+ if (auto* backend = ensureBackendCreated())
+ return backend->externalMemoryCost();
+ return 0;
+ }
+
NativeImagePtr copyNativeImage(BackingStoreCopy copyBehavior = CopyBackingStore) const override
{
- const_cast<ConcreteImageBuffer&>(*this).flushDrawingContext();
- return m_backend->copyNativeImage(copyBehavior);
+ if (auto* backend = ensureBackendCreated()) {
+ const_cast<ConcreteImageBuffer&>(*this).flushDrawingContext();
+ return backend->copyNativeImage(copyBehavior);
+ }
+ return nullptr;
}
RefPtr<Image> copyImage(BackingStoreCopy copyBehavior = CopyBackingStore, PreserveResolution preserveResolution = PreserveResolution::No) const override
{
- const_cast<ConcreteImageBuffer&>(*this).flushDrawingContext();
- return m_backend->copyImage(copyBehavior, preserveResolution);
+ if (auto* backend = ensureBackendCreated()) {
+ const_cast<ConcreteImageBuffer&>(*this).flushDrawingContext();
+ return backend->copyImage(copyBehavior, preserveResolution);
+ }
+ return nullptr;
}
void draw(GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) override
{
- flushDrawingContext();
- m_backend->draw(destContext, destRect, srcRect, options);
+ if (auto* backend = ensureBackendCreated()) {
+ flushDrawingContext();
+ backend->draw(destContext, destRect, srcRect, options);
+ }
}
void drawPattern(GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& options) override
{
- flushDrawingContext();
- m_backend->drawPattern(destContext, destRect, srcRect, patternTransform, phase, spacing, options);
+ if (auto* backend = ensureBackendCreated()) {
+ flushDrawingContext();
+ backend->drawPattern(destContext, destRect, srcRect, patternTransform, phase, spacing, options);
+ }
}
NativeImagePtr sinkIntoNativeImage() override
{
- flushDrawingContext();
- return m_backend->sinkIntoNativeImage();
+ if (auto* backend = ensureBackendCreated()) {
+ flushDrawingContext();
+ return backend->sinkIntoNativeImage();
+ }
+ return nullptr;
}
RefPtr<Image> sinkIntoImage(PreserveResolution preserveResolution = PreserveResolution::No) override
{
- flushDrawingContext();
- return m_backend->sinkIntoImage(preserveResolution);
+ if (auto* backend = ensureBackendCreated()) {
+ flushDrawingContext();
+ return backend->sinkIntoImage(preserveResolution);
+ }
+ return nullptr;
}
void drawConsuming(GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) override
{
- flushDrawingContext();
- m_backend->drawConsuming(destContext, destRect, srcRect, options);
+ if (auto* backend = ensureBackendCreated()) {
+ flushDrawingContext();
+ backend->drawConsuming(destContext, destRect, srcRect, options);
+ }
}
void convertToLuminanceMask() override
{
- flushDrawingContext();
- m_backend->convertToLuminanceMask();
+ if (auto* backend = ensureBackendCreated()) {
+ flushDrawingContext();
+ backend->convertToLuminanceMask();
+ }
}
void transformColorSpace(ColorSpace srcColorSpace, ColorSpace destColorSpace) override
{
- flushDrawingContext();
- m_backend->transformColorSpace(srcColorSpace, destColorSpace);
+ if (auto* backend = ensureBackendCreated()) {
+ flushDrawingContext();
+ backend->transformColorSpace(srcColorSpace, destColorSpace);
+ }
}
String toDataURL(const String& mimeType, Optional<double> quality, PreserveResolution preserveResolution) const override
{
- const_cast<ConcreteImageBuffer&>(*this).flushContext();
- return m_backend->toDataURL(mimeType, quality, preserveResolution);
+ if (auto* backend = ensureBackendCreated()) {
+ const_cast<ConcreteImageBuffer&>(*this).flushContext();
+ return backend->toDataURL(mimeType, quality, preserveResolution);
+ }
+ return String();
}
Vector<uint8_t> toData(const String& mimeType, Optional<double> quality = WTF::nullopt) const override
{
- const_cast<ConcreteImageBuffer&>(*this).flushContext();
- return m_backend->toData(mimeType, quality);
+ if (auto* backend = ensureBackendCreated()) {
+ const_cast<ConcreteImageBuffer&>(*this).flushContext();
+ return backend->toData(mimeType, quality);
+ }
+ return { };
}
Vector<uint8_t> toBGRAData() const override
{
- const_cast<ConcreteImageBuffer&>(*this).flushContext();
- return m_backend->toBGRAData();
+ if (auto* backend = ensureBackendCreated()) {
+ const_cast<ConcreteImageBuffer&>(*this).flushContext();
+ return backend->toBGRAData();
+ }
+ return { };
}
RefPtr<ImageData> getImageData(AlphaPremultiplication outputFormat, const IntRect& srcRect) const override
{
- const_cast<ConcreteImageBuffer&>(*this).flushContext();
- return m_backend->getImageData(outputFormat, srcRect);
+ if (auto* backend = ensureBackendCreated()) {
+ const_cast<ConcreteImageBuffer&>(*this).flushContext();
+ return backend->getImageData(outputFormat, srcRect);
+ }
+ return nullptr;
}
void putImageData(AlphaPremultiplication inputFormat, const ImageData& imageData, const IntRect& srcRect, const IntPoint& destPoint = { }) override
{
- flushContext();
- m_backend->putImageData(inputFormat, imageData, srcRect, destPoint);
+ if (auto* backend = ensureBackendCreated()) {
+ flushContext();
+ backend->putImageData(inputFormat, imageData, srcRect, destPoint);
+ }
}
PlatformLayer* platformLayer() const override
{
- return m_backend->platformLayer();
+ if (auto* backend = ensureBackendCreated())
+ return backend->platformLayer();
+ return nullptr;
}
bool copyToPlatformTexture(GraphicsContextGLOpenGL& context, GCGLenum target, PlatformGLObject destinationTexture, GCGLenum internalformat, bool premultiplyAlpha, bool flipY) const override
{
- return m_backend->copyToPlatformTexture(context, target, destinationTexture, internalformat, premultiplyAlpha, flipY);
+ if (auto* backend = ensureBackendCreated())
+ return backend->copyToPlatformTexture(context, target, destinationTexture, internalformat, premultiplyAlpha, flipY);
+ return false;
}
std::unique_ptr<BackendType> m_backend;
Modified: trunk/Source/WebKit/ChangeLog (257746 => 257747)
--- trunk/Source/WebKit/ChangeLog 2020-03-03 00:16:02 UTC (rev 257746)
+++ trunk/Source/WebKit/ChangeLog 2020-03-03 00:39:24 UTC (rev 257747)
@@ -1,3 +1,30 @@
+2020-03-02 Said Abou-Hallawa <[email protected]>
+
+ Implement canvas remote rendering
+ https://bugs.webkit.org/show_bug.cgi?id=204955
+
+ Reviewed by Jon Lee.
+
+ * WebProcess/GPU/graphics/RemoteImageBuffer.h:
+ * WebProcess/GPU/graphics/RemoteImageBufferMessageHandler.cpp:
+ (WebKit::RemoteImageBufferMessageHandler::waitForCreateImageBufferBackend):
+ (WebKit::RemoteImageBufferMessageHandler::waitForCommitImageBufferFlushContext):
+ Synchronize the RemoteImageBuffer backend such that the context and the
+ DrawingContext are flushed to the backend in the GPUProcess only when
+ its pixels are needed in the WebProcess.
+
+ * WebProcess/GPU/graphics/RemoteImageBufferMessageHandler.h:
+ (WebKit::RemoteImageBufferMessageHandler::isPendingFlush const):
+ Tells whether the pixels of the backend is ready to use or a flushing is
+ being committed.
+
+ * WebProcess/GPU/graphics/RemoteRenderingBackend.cpp:
+ (WebKit::RemoteRenderingBackend::waitForCreateImageBufferBackend):
+ (WebKit::RemoteRenderingBackend::waitForCommitImageBufferFlushContext):
+ * WebProcess/GPU/graphics/RemoteRenderingBackend.h:
+ They block execution till certain RemoteRenderingBackendProxy messages
+ are received.
+
2020-03-02 Jacob Uphoff <[email protected]>
Unreviewed, rolling out r257725.
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBuffer.h (257746 => 257747)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBuffer.h 2020-03-03 00:16:02 UTC (rev 257746)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBuffer.h 2020-03-03 00:39:24 UTC (rev 257747)
@@ -63,6 +63,15 @@
m_backend = BackendType::create(logicalSize, backendSize, resolutionScale, colorSpace, WTFMove(handle));
}
+ bool isBackendCreated() const override { return m_backend.get(); }
+
+ BackendType* ensureBackendCreated() const override
+ {
+ if (!m_backend)
+ const_cast<RemoteImageBuffer&>(*this).RemoteImageBufferMessageHandler::waitForCreateImageBufferBackend();
+ return m_backend.get();
+ }
+
void flushContext() override
{
flushDrawingContext();
@@ -74,6 +83,7 @@
auto& displayList = m_drawingContext.displayList();
if (displayList.itemCount()) {
RemoteImageBufferMessageHandler::flushDrawingContext(displayList);
+ RemoteImageBufferMessageHandler::waitForCommitImageBufferFlushContext();
displayList.clear();
}
}
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferMessageHandler.cpp (257746 => 257747)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferMessageHandler.cpp 2020-03-03 00:16:02 UTC (rev 257746)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferMessageHandler.cpp 2020-03-03 00:39:24 UTC (rev 257747)
@@ -49,6 +49,18 @@
m_remoteRenderingBackend->send(Messages::RemoteRenderingBackendProxy::ReleaseImageBuffer(m_imageBufferIdentifier), m_remoteRenderingBackend->renderingBackendIdentifier());
}
+void RemoteImageBufferMessageHandler::waitForCreateImageBufferBackend()
+{
+ if (m_remoteRenderingBackend && !isBackendCreated())
+ m_remoteRenderingBackend->waitForCreateImageBufferBackend();
+}
+
+void RemoteImageBufferMessageHandler::waitForCommitImageBufferFlushContext()
+{
+ if (m_remoteRenderingBackend && isPendingFlush())
+ m_remoteRenderingBackend->waitForCommitImageBufferFlushContext();
+}
+
void RemoteImageBufferMessageHandler::flushDrawingContext(const WebCore::DisplayList::DisplayList& displayList)
{
if (!m_remoteRenderingBackend)
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferMessageHandler.h (257746 => 257747)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferMessageHandler.h 2020-03-03 00:16:02 UTC (rev 257746)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferMessageHandler.h 2020-03-03 00:39:24 UTC (rev 257747)
@@ -52,6 +52,12 @@
protected:
RemoteImageBufferMessageHandler(const WebCore::FloatSize&, WebCore::RenderingMode, float resolutionScale, WebCore::ColorSpace, RemoteRenderingBackend&);
+ virtual bool isBackendCreated() const = 0;
+ bool isPendingFlush() const { return m_sentFlushIdentifier != m_receivedFlushIdentifier; }
+
+ void waitForCreateImageBufferBackend();
+ void waitForCommitImageBufferFlushContext();
+
// Messages to be sent. See RemoteRenderingBackendProxy.messages.in.
void flushDrawingContext(const WebCore::DisplayList::DisplayList&);
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackend.cpp (257746 => 257747)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackend.cpp 2020-03-03 00:16:02 UTC (rev 257746)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackend.cpp 2020-03-03 00:39:24 UTC (rev 257747)
@@ -72,6 +72,18 @@
return m_renderingBackendIdentifier.toUInt64();
}
+bool RemoteRenderingBackend::waitForCreateImageBufferBackend()
+{
+ Ref<IPC::Connection> connection = WebProcess::singleton().ensureGPUProcessConnection().connection();
+ return connection->waitForAndDispatchImmediately<Messages::RemoteRenderingBackend::CreateImageBufferBackend>(m_renderingBackendIdentifier, 1_s, IPC::WaitForOption::InterruptWaitingIfSyncMessageArrives);
+}
+
+bool RemoteRenderingBackend::waitForCommitImageBufferFlushContext()
+{
+ Ref<IPC::Connection> connection = WebProcess::singleton().ensureGPUProcessConnection().connection();
+ return connection->waitForAndDispatchImmediately<Messages::RemoteRenderingBackend::CommitImageBufferFlushContext>(m_renderingBackendIdentifier, 1_s, IPC::WaitForOption::InterruptWaitingIfSyncMessageArrives);
+}
+
std::unique_ptr<ImageBuffer> RemoteRenderingBackend::createImageBuffer(const FloatSize& size, RenderingMode renderingMode, float resolutionScale, ColorSpace colorSpace)
{
if (renderingMode == RenderingMode::RemoteAccelerated) {
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackend.h (257746 => 257747)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackend.h 2020-03-03 00:16:02 UTC (rev 257746)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackend.h 2020-03-03 00:39:24 UTC (rev 257747)
@@ -64,6 +64,9 @@
std::unique_ptr<WebCore::ImageBuffer> createImageBuffer(const WebCore::FloatSize&, WebCore::RenderingMode, float resolutionScale, WebCore::ColorSpace);
void releaseImageBuffer(ImageBufferIdentifier);
+ bool waitForCreateImageBufferBackend();
+ bool waitForCommitImageBufferFlushContext();
+
private:
RemoteRenderingBackend();
_______________________________________________ webkit-changes mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-changes
