Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (276944 => 276945)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h 2021-05-04 04:04:23 UTC (rev 276944)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h 2021-05-04 04:08:22 UTC (rev 276945)
@@ -390,7 +390,7 @@
WEBCORE_EXPORT void drawImageBuffer(ImageBuffer&, const FloatPoint& destination, const ImagePaintingOptions& = { });
void drawImageBuffer(ImageBuffer&, const FloatRect& destination, const ImagePaintingOptions& = { });
- void drawImageBuffer(ImageBuffer&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& = { });
+ WEBCORE_EXPORT void drawImageBuffer(ImageBuffer&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& = { });
WEBCORE_EXPORT void drawConsumingImageBuffer(RefPtr<ImageBuffer>, const FloatPoint& destination, const ImagePaintingOptions& = { });
void drawConsumingImageBuffer(RefPtr<ImageBuffer>, const FloatRect& destination, const ImagePaintingOptions& = { });
Modified: trunk/Source/WebKit/ChangeLog (276944 => 276945)
--- trunk/Source/WebKit/ChangeLog 2021-05-04 04:04:23 UTC (rev 276944)
+++ trunk/Source/WebKit/ChangeLog 2021-05-04 04:08:22 UTC (rev 276945)
@@ -1,3 +1,32 @@
+2021-05-03 Tim Horton <timothy_hor...@apple.com>
+
+ Use ImageBuffer scaling in RemoteLayerBackingStore, rather than handling scale in the class
+ https://bugs.webkit.org/show_bug.cgi?id=225081
+
+ Reviewed by Said Abou-Hallawa.
+
+ No new tests, no behavior change.
+
+ * Shared/RemoteLayerTree/RemoteLayerBackingStore.h:
+ * Shared/RemoteLayerTree/RemoteLayerBackingStore.mm:
+ (WebKit::RemoteLayerBackingStore::swapToValidFrontBuffer):
+ (WebKit::RemoteLayerBackingStore::display):
+ (WebKit::RemoteLayerBackingStore::backingStoreSize const): Deleted.
+ Make use of ImageBuffer's scaling support instead of scaling ourselves.
+ This will be helpful for future patches where the backing store's ImageBuffer
+ needs to know the presentation size, not just the backing store size.
+ We also do the back->front copy in scaled space now, which simplifies the code a bit.
+
+ We have to explicitly specify the source and destination rect for the copy, because
+ GraphicsContext::drawImageBuffer's implicit source rect is computed using
+ ImageBuffer::logicalSize(), which is a *truncated* IntSize.
+
+ * WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp:
+ (WebKit::ImageBufferShareableBitmapBackend::ImageBufferShareableBitmapBackend):
+ Apply the device scale factor to the GraphicsContext that ImageBufferShareableBitmapBackend
+ adopts from ShareableBitmap. We don't need to flip because ShareableBitmap does that,
+ but it doesn't know anything about scales at all.
+
2021-05-03 Patrick Angle <pan...@apple.com>
Web Inspector: [Cocoa] Grid overlay area names aren't centered within areas.
Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm (276944 => 276945)
--- trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm 2021-05-04 04:04:23 UTC (rev 276944)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm 2021-05-04 04:08:22 UTC (rev 276945)
@@ -146,13 +146,6 @@
setNeedsDisplay(WebCore::IntRect(WebCore::IntPoint(), WebCore::expandedIntSize(m_size)));
}
-WebCore::IntSize RemoteLayerBackingStore::backingStoreSize() const
-{
- WebCore::FloatSize scaledSize = m_size;
- scaledSize.scale(m_scale);
- return roundedIntSize(scaledSize);
-}
-
WebCore::PixelFormat RemoteLayerBackingStore::pixelFormat() const
{
#if HAVE(IOSURFACE_RGB10)
@@ -199,11 +192,11 @@
auto renderingMode = m_acceleratesDrawing ? WebCore::RenderingMode::Accelerated : WebCore::RenderingMode::Unaccelerated;
if (WebProcess::singleton().shouldUseRemoteRenderingFor(WebCore::RenderingPurpose::DOM))
- m_frontBuffer.imageBuffer = m_layer->context()->ensureRemoteRenderingBackendProxy().createImageBuffer(backingStoreSize(), renderingMode, 1, WebCore::DestinationColorSpace::SRGB, pixelFormat());
+ m_frontBuffer.imageBuffer = m_layer->context()->ensureRemoteRenderingBackendProxy().createImageBuffer(m_size, renderingMode, m_scale, WebCore::DestinationColorSpace::SRGB, pixelFormat());
else if (renderingMode == WebCore::RenderingMode::Accelerated)
- m_frontBuffer.imageBuffer = WebCore::ConcreteImageBuffer<AcceleratedImageBufferShareableMappedBackend>::create(backingStoreSize(), 1, WebCore::DestinationColorSpace::SRGB, pixelFormat(), nullptr);
+ m_frontBuffer.imageBuffer = WebCore::ConcreteImageBuffer<AcceleratedImageBufferShareableMappedBackend>::create(m_size, m_scale, WebCore::DestinationColorSpace::SRGB, pixelFormat(), nullptr);
else
- m_frontBuffer.imageBuffer = WebCore::ConcreteImageBuffer<UnacceleratedImageBufferShareableBackend>::create(backingStoreSize(), 1, WebCore::DestinationColorSpace::SRGB, pixelFormat(), nullptr);
+ m_frontBuffer.imageBuffer = WebCore::ConcreteImageBuffer<UnacceleratedImageBufferShareableBackend>::create(m_size, m_scale, WebCore::DestinationColorSpace::SRGB, pixelFormat(), nullptr);
}
bool RemoteLayerBackingStore::display()
@@ -219,9 +212,7 @@
// Make the previous front buffer non-volatile early, so that we can dirty the whole layer if it comes back empty.
setBufferVolatility(BufferType::Front, false);
- WebCore::IntSize expandedScaledSize = backingStoreSize();
-
- if (m_dirtyRegion.isEmpty() || expandedScaledSize.isEmpty())
+ if (m_dirtyRegion.isEmpty() || m_size.isEmpty())
return needToEncodeBackingStore;
WebCore::IntRect layerBounds(WebCore::IntPoint(), WebCore::expandedIntSize(m_size));
@@ -233,20 +224,13 @@
m_dirtyRegion.unite(indicatorRect);
}
- WebCore::IntRect expandedScaledLayerBounds(WebCore::IntPoint(), expandedScaledSize);
-
swapToValidFrontBuffer();
if (!m_frontBuffer.imageBuffer)
return true;
WebCore::GraphicsContext& context = m_frontBuffer.imageBuffer->context();
-
WebCore::GraphicsContextStateSaver stateSaver(context);
- WebCore::FloatSize scaledSize = m_size;
- scaledSize.scale(m_scale);
- WebCore::IntRect scaledLayerBounds(WebCore::IntPoint(), WebCore::roundedIntSize(scaledSize));
-
// If we have less than webLayerMaxRectsToPaint rects to paint and they cover less
// than webLayerWastedSpaceThreshold of the total dirty area, we'll repaint each rect separately.
// Otherwise, repaint the entire bounding box of the dirty region.
@@ -269,32 +253,26 @@
if (!m_dirtyRegion.contains(layerBounds)) {
ASSERT(m_backBuffer.imageBuffer);
- context.drawImageBuffer(*m_backBuffer.imageBuffer, { 0, 0 }, { WebCore::CompositeOperator::Copy });
+ context.drawImageBuffer(*m_backBuffer.imageBuffer, { {0, 0}, m_size }, { {0, 0}, m_size }, { WebCore::CompositeOperator::Copy });
}
- if (m_paintingRects.size() == 1) {
- WebCore::FloatRect scaledPaintingRect = m_paintingRects[0];
- scaledPaintingRect.scale(m_scale);
- context.clip(scaledPaintingRect);
- } else {
+ if (m_paintingRects.size() == 1)
+ context.clip(m_paintingRects[0]);
+ else {
WebCore::Path clipPath;
- for (auto rect : m_paintingRects) {
- rect.scale(m_scale);
+ for (auto rect : m_paintingRects)
clipPath.addRect(rect);
- }
context.clipPath(clipPath);
}
if (!m_isOpaque)
- context.clearRect(scaledLayerBounds);
+ context.clearRect(layerBounds);
#ifndef NDEBUG
if (m_isOpaque)
- context.fillRect(scaledLayerBounds, WebCore::SRGBA<uint8_t> { 255, 47, 146 });
+ context.fillRect(layerBounds, WebCore::SRGBA<uint8_t> { 255, 47, 146 });
#endif
- context.scale(m_scale);
-
// FIXME: Clarify that WebCore::GraphicsLayerPaintSnapshotting is just about image decoding.
auto flags = m_layer->context() && m_layer->context()->nextRenderingUpdateRequiresSynchronousImageDecoding() ? WebCore::GraphicsLayerPaintSnapshotting : WebCore::GraphicsLayerPaintNormal;
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp (276944 => 276945)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp 2021-05-04 04:04:23 UTC (rev 276944)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp 2021-05-04 04:08:22 UTC (rev 276945)
@@ -124,6 +124,11 @@
, m_bitmap(WTFMove(bitmap))
, m_context(WTFMove(context))
{
+ // ShareableBitmap ensures that the coordinate space in the context that we're adopting
+ // has a top-left origin, so we don't ever need to flip here, so we don't call setupContext().
+ // However, ShareableBitmap does not have a notion of scale, so we must apply the device
+ // scale factor to the context ourselves.
+ m_context->applyDeviceScaleFactor(resolutionScale());
}
ImageBufferBackendHandle ImageBufferShareableBitmapBackend::createImageBufferBackendHandle() const