Skip to content

Commit

Permalink
Cherry-pick b46e324. rdar://122577452
Browse files Browse the repository at this point in the history
    Apply 274319@main to GPU-process rendered layers
    https://bugs.webkit.org/show_bug.cgi?id=270680
    rdar://122577452

    Reviewed by Megan Gardner and Richard Robinson.

    * Source/WebKit/GPUProcess/graphics/RemoteImageBufferSet.cpp:
    (WebKit::RemoteImageBufferSet::ensureBufferForDisplay):
    (WebKit::RemoteImageBufferSet::ensureDynamicContentScalingResourceCache):
    * Source/WebKit/GPUProcess/graphics/RemoteImageBufferSet.h:
    * Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp:
    (WebKit::RemoteRenderingBackend::allocateImageBuffer):
    (WebKit::RemoteRenderingBackend::createImageBuffer):
    * Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h:
    Copy the fix from 274319@main into RemoteImageBufferSet, to fix the bug for
    the GPU-process-enabled case.

    Canonical link: https://commits.webkit.org/275825@main

Identifier: 273664.1388@safari-7619.1.5-branch
  • Loading branch information
hortont424 authored and MyahCobbs committed Mar 11, 2024
1 parent bd79e7e commit f8f66d2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
14 changes: 13 additions & 1 deletion Source/WebKit/GPUProcess/graphics/RemoteImageBufferSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,12 @@ void RemoteImageBufferSet::ensureBufferForDisplay(ImageBufferSetPrepareBufferFor
}

if (!m_frontBuffer) {
m_frontBuffer = m_backend->allocateImageBuffer(m_logicalSize, m_renderingMode, WebCore::RenderingPurpose::LayerBacking, m_resolutionScale, m_colorSpace, m_pixelFormat, WebCore::RenderingResourceIdentifier::generate());
ImageBufferCreationContext creationContext;
#if ENABLE(RE_DYNAMIC_CONTENT_SCALING)
creationContext.dynamicContentScalingResourceCache = ensureDynamicContentScalingResourceCache();
#endif

m_frontBuffer = m_backend->allocateImageBuffer(m_logicalSize, m_renderingMode, WebCore::RenderingPurpose::LayerBacking, m_resolutionScale, m_colorSpace, m_pixelFormat, creationContext, WebCore::RenderingResourceIdentifier::generate());
m_frontBufferIsCleared = true;
}

Expand Down Expand Up @@ -297,6 +302,13 @@ void RemoteImageBufferSet::dynamicContentScalingDisplayList(CompletionHandler<vo
displayList = m_frontBuffer->dynamicContentScalingDisplayList();
completionHandler({ WTFMove(displayList) });
}

DynamicContentScalingResourceCache RemoteImageBufferSet::ensureDynamicContentScalingResourceCache()
{
if (!m_dynamicContentScalingResourceCache)
m_dynamicContentScalingResourceCache = DynamicContentScalingResourceCache::create();
return m_dynamicContentScalingResourceCache;
}
#endif

} // namespace WebKit
Expand Down
5 changes: 5 additions & 0 deletions Source/WebKit/GPUProcess/graphics/RemoteImageBufferSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class RemoteImageBufferSet : public IPC::StreamMessageReceiver {

#if ENABLE(RE_DYNAMIC_CONTENT_SCALING)
void dynamicContentScalingDisplayList(CompletionHandler<void(std::optional<WebCore::DynamicContentScalingDisplayList>&&)>&&);
WebCore::DynamicContentScalingResourceCache ensureDynamicContentScalingResourceCache();
#endif

bool isOpaque() const
Expand Down Expand Up @@ -103,6 +104,10 @@ class RemoteImageBufferSet : public IPC::StreamMessageReceiver {
std::optional<WebCore::IntRect> m_previouslyPaintedRect;

std::optional<IPC::Signal> m_flushSignal;

#if ENABLE(RE_DYNAMIC_CONTENT_SCALING)
WebCore::DynamicContentScalingResourceCache m_dynamicContentScalingResourceCache;
#endif
};


Expand Down
16 changes: 9 additions & 7 deletions Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,25 +264,27 @@ static RefPtr<ImageBuffer> allocateImageBufferInternal(const FloatSize& logicalS
return imageBuffer;
}

RefPtr<ImageBuffer> RemoteRenderingBackend::allocateImageBuffer(const FloatSize& logicalSize, RenderingMode renderingMode, RenderingPurpose purpose, float resolutionScale, const DestinationColorSpace& colorSpace, PixelFormat pixelFormat, RenderingResourceIdentifier imageBufferIdentifier)
RefPtr<ImageBuffer> RemoteRenderingBackend::allocateImageBuffer(const FloatSize& logicalSize, RenderingMode renderingMode, RenderingPurpose purpose, float resolutionScale, const DestinationColorSpace& colorSpace, PixelFormat pixelFormat, const ImageBufferCreationContext& creationContext, RenderingResourceIdentifier imageBufferIdentifier)
{
assertIsCurrent(workQueue());

ImageBufferCreationContext creationContext;
creationContext.resourceOwner = m_resourceOwner;
ASSERT(!creationContext.resourceOwner);
ASSERT(!creationContext.surfacePool);
ImageBufferCreationContext adjustedCreationContext = creationContext;
adjustedCreationContext.resourceOwner = m_resourceOwner;
#if HAVE(IOSURFACE)
creationContext.surfacePool = &ioSurfacePool();
adjustedCreationContext.surfacePool = &ioSurfacePool();
#endif

RefPtr<ImageBuffer> imageBuffer;

#if ENABLE(RE_DYNAMIC_CONTENT_SCALING)
if (m_gpuConnectionToWebProcess->isDynamicContentScalingEnabled() && (purpose == RenderingPurpose::LayerBacking || purpose == RenderingPurpose::DOM))
imageBuffer = allocateImageBufferInternal<DynamicContentScalingBifurcatedImageBuffer>(logicalSize, renderingMode, purpose, resolutionScale, colorSpace, pixelFormat, creationContext, imageBufferIdentifier);
imageBuffer = allocateImageBufferInternal<DynamicContentScalingBifurcatedImageBuffer>(logicalSize, renderingMode, purpose, resolutionScale, colorSpace, pixelFormat, adjustedCreationContext, imageBufferIdentifier);
#endif

if (!imageBuffer)
imageBuffer = allocateImageBufferInternal<ImageBuffer>(logicalSize, renderingMode, purpose, resolutionScale, colorSpace, pixelFormat, creationContext, imageBufferIdentifier);
imageBuffer = allocateImageBufferInternal<ImageBuffer>(logicalSize, renderingMode, purpose, resolutionScale, colorSpace, pixelFormat, adjustedCreationContext, imageBufferIdentifier);

return imageBuffer;
}
Expand All @@ -291,7 +293,7 @@ RefPtr<ImageBuffer> RemoteRenderingBackend::allocateImageBuffer(const FloatSize&
void RemoteRenderingBackend::createImageBuffer(const FloatSize& logicalSize, RenderingMode renderingMode, RenderingPurpose purpose, float resolutionScale, const DestinationColorSpace& colorSpace, PixelFormat pixelFormat, RenderingResourceIdentifier imageBufferIdentifier)
{
assertIsCurrent(workQueue());
RefPtr<ImageBuffer> imageBuffer = allocateImageBuffer(logicalSize, renderingMode, purpose, resolutionScale, colorSpace, pixelFormat, imageBufferIdentifier);
RefPtr<ImageBuffer> imageBuffer = allocateImageBuffer(logicalSize, renderingMode, purpose, resolutionScale, colorSpace, pixelFormat, { }, imageBufferIdentifier);

if (imageBuffer)
didCreateImageBuffer(imageBuffer.releaseNonNull());
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class RemoteRenderingBackend : private IPC::MessageSender, public IPC::StreamMes
RefPtr<WebCore::ImageBuffer> imageBuffer(WebCore::RenderingResourceIdentifier);
RefPtr<WebCore::ImageBuffer> takeImageBuffer(WebCore::RenderingResourceIdentifier);

RefPtr<WebCore::ImageBuffer> allocateImageBuffer(const WebCore::FloatSize& logicalSize, WebCore::RenderingMode, WebCore::RenderingPurpose, float resolutionScale, const WebCore::DestinationColorSpace&, WebCore::PixelFormat, WebCore::RenderingResourceIdentifier);
RefPtr<WebCore::ImageBuffer> allocateImageBuffer(const WebCore::FloatSize& logicalSize, WebCore::RenderingMode, WebCore::RenderingPurpose, float resolutionScale, const WebCore::DestinationColorSpace&, WebCore::PixelFormat, const WebCore::ImageBufferCreationContext&, WebCore::RenderingResourceIdentifier);

void terminateWebProcess(ASCIILiteral message);

Expand Down

0 comments on commit f8f66d2

Please sign in to comment.