⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 276945 in webkit


Ignore:
Timestamp:
May 3, 2021, 9:08:22 PM (5 years ago)
Author:
timothy_horton@apple.com
Message:

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.

Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.h

    r275660 r276945  
    391391    WEBCORE_EXPORT void drawImageBuffer(ImageBuffer&, const FloatPoint& destination, const ImagePaintingOptions& = { });
    392392    void drawImageBuffer(ImageBuffer&, const FloatRect& destination, const ImagePaintingOptions& = { });
    393     void drawImageBuffer(ImageBuffer&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& = { });
     393    WEBCORE_EXPORT void drawImageBuffer(ImageBuffer&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& = { });
    394394
    395395    WEBCORE_EXPORT void drawConsumingImageBuffer(RefPtr<ImageBuffer>, const FloatPoint& destination, const ImagePaintingOptions& = { });
  • trunk/Source/WebKit/ChangeLog

    r276941 r276945  
     12021-05-03  Tim Horton  <timothy_horton@apple.com>
     2
     3        Use ImageBuffer scaling in RemoteLayerBackingStore, rather than handling scale in the class
     4        https://bugs.webkit.org/show_bug.cgi?id=225081
     5
     6        Reviewed by Said Abou-Hallawa.
     7
     8        No new tests, no behavior change.
     9
     10        * Shared/RemoteLayerTree/RemoteLayerBackingStore.h:
     11        * Shared/RemoteLayerTree/RemoteLayerBackingStore.mm:
     12        (WebKit::RemoteLayerBackingStore::swapToValidFrontBuffer):
     13        (WebKit::RemoteLayerBackingStore::display):
     14        (WebKit::RemoteLayerBackingStore::backingStoreSize const): Deleted.
     15        Make use of ImageBuffer's scaling support instead of scaling ourselves.
     16        This will be helpful for future patches where the backing store's ImageBuffer
     17        needs to know the presentation size, not just the backing store size.
     18        We also do the back->front copy in scaled space now, which simplifies the code a bit.
     19       
     20        We have to explicitly specify the source and destination rect for the copy, because
     21        GraphicsContext::drawImageBuffer's implicit source rect is computed using
     22        ImageBuffer::logicalSize(), which is a *truncated* IntSize.
     23
     24        * WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp:
     25        (WebKit::ImageBufferShareableBitmapBackend::ImageBufferShareableBitmapBackend):
     26        Apply the device scale factor to the GraphicsContext that ImageBufferShareableBitmapBackend
     27        adopts from ShareableBitmap. We don't need to flip because ShareableBitmap does that,
     28        but it doesn't know anything about scales at all.
     29
    1302021-05-03  Patrick Angle  <pangle@apple.com>
    231
  • trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h

    r269824 r276945  
    100100
    101101    WebCore::PixelFormat pixelFormat() const;
    102     WebCore::IntSize backingStoreSize() const;
    103102
    104103    PlatformCALayerRemote* m_layer;
  • trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm

    r274033 r276945  
    147147}
    148148
    149 WebCore::IntSize RemoteLayerBackingStore::backingStoreSize() const
    150 {
    151     WebCore::FloatSize scaledSize = m_size;
    152     scaledSize.scale(m_scale);
    153     return roundedIntSize(scaledSize);
    154 }
    155 
    156149WebCore::PixelFormat RemoteLayerBackingStore::pixelFormat() const
    157150{
     
    200193
    201194    if (WebProcess::singleton().shouldUseRemoteRenderingFor(WebCore::RenderingPurpose::DOM))
    202         m_frontBuffer.imageBuffer = m_layer->context()->ensureRemoteRenderingBackendProxy().createImageBuffer(backingStoreSize(), renderingMode, 1, WebCore::DestinationColorSpace::SRGB, pixelFormat());
     195        m_frontBuffer.imageBuffer = m_layer->context()->ensureRemoteRenderingBackendProxy().createImageBuffer(m_size, renderingMode, m_scale, WebCore::DestinationColorSpace::SRGB, pixelFormat());
    203196    else if (renderingMode == WebCore::RenderingMode::Accelerated)
    204         m_frontBuffer.imageBuffer = WebCore::ConcreteImageBuffer<AcceleratedImageBufferShareableMappedBackend>::create(backingStoreSize(), 1, WebCore::DestinationColorSpace::SRGB, pixelFormat(), nullptr);
     197        m_frontBuffer.imageBuffer = WebCore::ConcreteImageBuffer<AcceleratedImageBufferShareableMappedBackend>::create(m_size, m_scale, WebCore::DestinationColorSpace::SRGB, pixelFormat(), nullptr);
    205198    else
    206         m_frontBuffer.imageBuffer = WebCore::ConcreteImageBuffer<UnacceleratedImageBufferShareableBackend>::create(backingStoreSize(), 1, WebCore::DestinationColorSpace::SRGB, pixelFormat(), nullptr);
     199        m_frontBuffer.imageBuffer = WebCore::ConcreteImageBuffer<UnacceleratedImageBufferShareableBackend>::create(m_size, m_scale, WebCore::DestinationColorSpace::SRGB, pixelFormat(), nullptr);
    207200}
    208201
     
    220213    setBufferVolatility(BufferType::Front, false);
    221214
    222     WebCore::IntSize expandedScaledSize = backingStoreSize();
    223 
    224     if (m_dirtyRegion.isEmpty() || expandedScaledSize.isEmpty())
     215    if (m_dirtyRegion.isEmpty() || m_size.isEmpty())
    225216        return needToEncodeBackingStore;
    226217
     
    234225    }
    235226
    236     WebCore::IntRect expandedScaledLayerBounds(WebCore::IntPoint(), expandedScaledSize);
    237 
    238227    swapToValidFrontBuffer();
    239228    if (!m_frontBuffer.imageBuffer)
     
    241230
    242231    WebCore::GraphicsContext& context = m_frontBuffer.imageBuffer->context();
    243 
    244232    WebCore::GraphicsContextStateSaver stateSaver(context);
    245 
    246     WebCore::FloatSize scaledSize = m_size;
    247     scaledSize.scale(m_scale);
    248     WebCore::IntRect scaledLayerBounds(WebCore::IntPoint(), WebCore::roundedIntSize(scaledSize));
    249233
    250234    // If we have less than webLayerMaxRectsToPaint rects to paint and they cover less
     
    270254    if (!m_dirtyRegion.contains(layerBounds)) {
    271255        ASSERT(m_backBuffer.imageBuffer);
    272         context.drawImageBuffer(*m_backBuffer.imageBuffer, { 0, 0 }, { WebCore::CompositeOperator::Copy });
    273     }
    274 
    275     if (m_paintingRects.size() == 1) {
    276         WebCore::FloatRect scaledPaintingRect = m_paintingRects[0];
    277         scaledPaintingRect.scale(m_scale);
    278         context.clip(scaledPaintingRect);
    279     } else {
     256        context.drawImageBuffer(*m_backBuffer.imageBuffer, { {0, 0}, m_size }, { {0, 0}, m_size }, { WebCore::CompositeOperator::Copy });
     257    }
     258
     259    if (m_paintingRects.size() == 1)
     260        context.clip(m_paintingRects[0]);
     261    else {
    280262        WebCore::Path clipPath;
    281         for (auto rect : m_paintingRects) {
    282             rect.scale(m_scale);
     263        for (auto rect : m_paintingRects)
    283264            clipPath.addRect(rect);
    284         }
    285265        context.clipPath(clipPath);
    286266    }
    287267
    288268    if (!m_isOpaque)
    289         context.clearRect(scaledLayerBounds);
     269        context.clearRect(layerBounds);
    290270
    291271#ifndef NDEBUG
    292272    if (m_isOpaque)
    293         context.fillRect(scaledLayerBounds, WebCore::SRGBA<uint8_t> { 255, 47, 146 });
     273        context.fillRect(layerBounds, WebCore::SRGBA<uint8_t> { 255, 47, 146 });
    294274#endif
    295275
    296     context.scale(m_scale);
    297    
    298276    // FIXME: Clarify that WebCore::GraphicsLayerPaintSnapshotting is just about image decoding.
    299277    auto flags = m_layer->context() && m_layer->context()->nextRenderingUpdateRequiresSynchronousImageDecoding() ? WebCore::GraphicsLayerPaintSnapshotting : WebCore::GraphicsLayerPaintNormal;
  • trunk/Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp

    r275905 r276945  
    125125    , m_context(WTFMove(context))
    126126{
     127    // ShareableBitmap ensures that the coordinate space in the context that we're adopting
     128    // has a top-left origin, so we don't ever need to flip here, so we don't call setupContext().
     129    // However, ShareableBitmap does not have a notion of scale, so we must apply the device
     130    // scale factor to the context ourselves.
     131    m_context->applyDeviceScaleFactor(resolutionScale());
    127132}
    128133
Note: See TracChangeset for help on using the changeset viewer.