Changeset 238379 in webkit


Ignore:
Timestamp:
Nov 19, 2018 1:22:51 PM (5 years ago)
Author:
commit-queue@webkit.org
Message:

[cairo] BackingStore::incorporateUpdate should use CompositeCopy to support drawsBackground=false in general Cairo ports
https://bugs.webkit.org/show_bug.cgi?id=191577

Patch by Tomoki Imai <Tomoki Imai> on 2018-11-19
Reviewed by Carlos Garcia Campos.

We should use CompositeCopy operator to update bitmap to overwrite existing bitmap even if source contains
transparent parts. It enables ports which uses Cairo to set drawsBackground to false.
GTK ports has custom background extension, and in such case, we need to use CompositeSourceOver to retain
custom background.

  • UIProcess/cairo/BackingStoreCairo.cpp:

(WebKit::BackingStore::incorporateUpdate): Use CompositeCopy operator to update bitmap.

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r238378 r238379  
     12018-11-19  Tomoki Imai  <Tomoki.Imai@sony.com>
     2
     3        [cairo] BackingStore::incorporateUpdate should use CompositeCopy to support drawsBackground=false in general Cairo ports
     4        https://bugs.webkit.org/show_bug.cgi?id=191577
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        We should use CompositeCopy operator to update bitmap to overwrite existing bitmap even if source contains
     9        transparent parts. It enables ports which uses Cairo to set drawsBackground to false.
     10        GTK ports has custom background extension, and in such case, we need to use CompositeSourceOver to retain
     11        custom background.
     12
     13        * UIProcess/cairo/BackingStoreCairo.cpp:
     14        (WebKit::BackingStore::incorporateUpdate): Use CompositeCopy operator to update bitmap.
     15
    1162018-11-19  Joseph Pecoraro  <pecoraro@apple.com>
    217
  • trunk/Source/WebKit/UIProcess/cairo/BackingStoreCairo.cpp

    r228373 r238379  
    9090    RefPtr<cairo_t> cairoContext = adoptRef(cairo_create(m_backend->surface()));
    9191    GraphicsContext graphicsContext(GraphicsContextImplCairo::createFactory(cairoContext.get()));
     92
     93    // When m_webPageProxy.drawsBackground() is false, bitmap contains transparent parts as a background of the webpage.
     94    // For such case, bitmap must be drawn using CompositeCopy to overwrite the existing surface.
     95    graphicsContext.setCompositeOperation(WebCore::CompositeCopy);
     96
    9297    for (const auto& updateRect : updateInfo.updateRects) {
    9398        IntRect srcRect = updateRect;
     
    96101        if (!m_webPageProxy.drawsBackground()) {
    97102            const WebCore::Color color = m_webPageProxy.backgroundColor();
    98             if (!color.isOpaque())
    99                 graphicsContext.clearRect(srcRect);
    100             if (color.isVisible())
     103            if (color.isVisible()) {
     104                // When the application sets the background color through m_webPageProxy.backgroundColor(), we update the surface in 2 steps.
     105                //   1. Fill the surface by m_webPageProxy.backgroundColor().
     106                //   2. Composite webpage's bitmap which has a transparent background.
     107                // In step 1, we use CompositeCopy as m_webPageProxy.backgroundColor() may not be opaque.
     108                // On the other hand, in step 2, bitmap should be composited by CompositeSourceOver
     109                // because it should be blended with m_webPageProxy.backgroundColor().
    101110                graphicsContext.fillRect(srcRect, color);
     111                graphicsContext.setCompositeOperation(WebCore::CompositeSourceOver);
     112                bitmap->paint(graphicsContext, deviceScaleFactor(), updateRect.location(), srcRect);
     113                graphicsContext.setCompositeOperation(WebCore::CompositeCopy);
     114                continue;
     115            }
    102116        }
    103117#endif
Note: See TracChangeset for help on using the changeset viewer.