Changeset 252136 in webkit


Ignore:
Timestamp:
Nov 6, 2019 5:13:10 AM (4 years ago)
Author:
commit-queue@webkit.org
Message:

[Cairo] Cairo graphics backend uses ImageBuffer::copyImage just to access native image buffer handles
https://bugs.webkit.org/show_bug.cgi?id=203884

Patch by Chris Lord <Chris Lord> on 2019-11-06
Reviewed by Carlos Garcia Campos.

The Cairo graphics backend uses ImageBuffer::copyImage(DontCopyBackingStore) frequently just to access
the native image pointer. This makes several functions unusable off-main-thread, so add an accessor
function to avoid doing this.

No new tests -- no change in behavior.

  • platform/graphics/ImageBuffer.h:
  • platform/graphics/cairo/CairoOperations.cpp:

(WebCore::Cairo::drawShadowLayerBuffer):
(WebCore::Cairo::drawShadowImage):
(WebCore::Cairo::fillShadowBuffer):

  • platform/graphics/cairo/GraphicsContextCairo.cpp:

(WebCore::GraphicsContext::clipToImageBuffer):

  • platform/graphics/cairo/GraphicsContextImplCairo.cpp:

(WebCore::GraphicsContextImplCairo::clipToImageBuffer):

  • platform/graphics/cairo/ImageBufferCairo.cpp:

(WebCore::ImageBuffer::nativeImage const):

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r252134 r252136  
     12019-11-06  Chris Lord  <clord@igalia.com>
     2
     3        [Cairo] Cairo graphics backend uses ImageBuffer::copyImage just to access native image buffer handles
     4        https://bugs.webkit.org/show_bug.cgi?id=203884
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        The Cairo graphics backend uses ImageBuffer::copyImage(DontCopyBackingStore) frequently just to access
     9        the native image pointer. This makes several functions unusable off-main-thread, so add an accessor
     10        function to avoid doing this.
     11
     12        No new tests -- no change in behavior.
     13
     14        * platform/graphics/ImageBuffer.h:
     15        * platform/graphics/cairo/CairoOperations.cpp:
     16        (WebCore::Cairo::drawShadowLayerBuffer):
     17        (WebCore::Cairo::drawShadowImage):
     18        (WebCore::Cairo::fillShadowBuffer):
     19        * platform/graphics/cairo/GraphicsContextCairo.cpp:
     20        (WebCore::GraphicsContext::clipToImageBuffer):
     21        * platform/graphics/cairo/GraphicsContextImplCairo.cpp:
     22        (WebCore::GraphicsContextImplCairo::clipToImageBuffer):
     23        * platform/graphics/cairo/ImageBufferCairo.cpp:
     24        (WebCore::ImageBuffer::nativeImage const):
     25
    1262019-11-06  Philippe Normand  <philn@igalia.com>
    227
  • trunk/Source/WebCore/platform/graphics/ImageBuffer.h

    r249217 r252136  
    117117    Vector<uint8_t> toBGRAData() const;
    118118
     119#if USE(CAIRO)
     120    NativeImagePtr nativeImage() const;
     121#endif
     122
    119123#if !USE(CG)
    120124    AffineTransform baseTransform() const { return AffineTransform(); }
  • trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp

    r249937 r252136  
    175175static void drawShadowLayerBuffer(PlatformContextCairo& platformContext, ImageBuffer& layerImage, const FloatPoint& layerOrigin, const FloatSize& layerSize, const ShadowState& shadowState)
    176176{
    177     RefPtr<Image> image = layerImage.copyImage(DontCopyBackingStore);
    178     if (!image)
    179         return;
    180 
    181     if (auto surface = image->nativeImageForCurrentFrame()) {
     177    if (auto surface = layerImage.nativeImage()) {
    182178        drawNativeImage(platformContext, surface.get(), FloatRect(roundedIntPoint(layerOrigin), layerSize), FloatRect(FloatPoint(), layerSize), { shadowState.globalCompositeOperator }, shadowState.globalAlpha, ShadowState());
    183179    }
     
    187183static void drawShadowImage(PlatformContextCairo& platformContext, ImageBuffer& layerImage, const FloatRect& destRect, const FloatRect& srcRect, const ShadowState& shadowState)
    188184{
    189     RefPtr<Image> image = layerImage.copyImage(DontCopyBackingStore);
    190     if (!image)
    191         return;
    192 
    193     if (auto surface = image->nativeImageForCurrentFrame()) {
     185    if (auto surface = layerImage.nativeImage()) {
    194186        drawNativeImage(platformContext, surface.get(), destRect, srcRect, { shadowState.globalCompositeOperator }, shadowState.globalAlpha, ShadowState());
    195187    }
     
    200192    save(platformContext);
    201193
    202     RefPtr<Image> image = layerImage.copyImage(DontCopyBackingStore);
    203     if (image) {
    204         if (auto surface = image->nativeImageForCurrentFrame())
    205             clipToImageBuffer(platformContext, surface.get(), FloatRect(layerOrigin, expandedIntSize(layerSize)));
    206     }
     194    if (auto surface = layerImage.nativeImage())
     195        clipToImageBuffer(platformContext, surface.get(), FloatRect(layerOrigin, expandedIntSize(layerSize)));
    207196
    208197    FillSource fillSource;
  • trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp

    r249217 r252136  
    268268    }
    269269
    270     RefPtr<Image> image = buffer.copyImage(DontCopyBackingStore);
    271     if (!image)
    272         return;
    273 
    274     ASSERT(hasPlatformContext());
    275     if (auto surface = image->nativeImageForCurrentFrame())
     270    ASSERT(hasPlatformContext());
     271    if (auto surface = buffer.nativeImage())
    276272        Cairo::clipToImageBuffer(*platformContext(), surface.get(), destRect);
    277273}
  • trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp

    r249217 r252136  
    412412void GraphicsContextImplCairo::clipToImageBuffer(ImageBuffer& buffer, const FloatRect& destRect)
    413413{
    414     RefPtr<Image> image = buffer.copyImage(DontCopyBackingStore);
    415     if (!image)
    416         return;
    417 
    418     if (auto surface = image->nativeImageForCurrentFrame())
     414    if (auto surface = buffer.nativeImage())
    419415        Cairo::clipToImageBuffer(m_platformContext, surface.get(), destRect);
    420416}
  • trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp

    r249217 r252136  
    260260}
    261261
     262NativeImagePtr ImageBuffer::nativeImage() const
     263{
     264    return m_data.m_surface.get();
     265}
     266
    262267ImageBuffer::ImageBuffer(const FloatSize& size, float resolutionScale, ColorSpace, RenderingMode renderingMode, const HostWindow*, bool& success)
    263268    : m_data(IntSize(size), renderingMode)
Note: See TracChangeset for help on using the changeset viewer.