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

Changeset 126344 in webkit


Ignore:
Timestamp:
Aug 22, 2012, 1:24:56 PM (14 years ago)
Author:
abarth@webkit.org
Message:

WebWidget should be able to paint into a zoomed canvas without aliasing
https://bugs.webkit.org/show_bug.cgi?id=92043

Reviewed by James Robinson.

If accelerated compositing is enabled, WebWidget::paint reads back from
the compositor rather than re-painting the widget. That approach works
well if the canvas we're rendering into is at a similar resolution to
the pixels in the compositor, but if the canvas has been scaled (e.g.,
to help the user disambiguate links), then reading back from the
compositor will cause aliasing artifacts.

This patch adds an option to paint to let the embedder request a
software re-rendering of the widget to avoid these aliasing artifacts.

  • public/WebWidget.h:

(WebKit::WebWidget::paint):

  • src/WebPagePopupImpl.cpp:

(WebKit::WebPagePopupImpl::paint):

  • src/WebPagePopupImpl.h:

(WebPagePopupImpl):

  • src/WebPopupMenuImpl.cpp:

(WebKit::WebPopupMenuImpl::paint):

  • src/WebPopupMenuImpl.h:
  • src/WebViewImpl.cpp:

(WebKit::canvasBackgroundForTransparencey):
(WebKit):
(WebKit::WebViewImpl::paint):

  • src/WebViewImpl.h:

(WebViewImpl):

Location:
trunk/Source/WebKit/chromium
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/chromium/ChangeLog

    r126340 r126344  
     12012-08-22  Adam Barth  <abarth@webkit.org>
     2
     3        WebWidget should be able to paint into a zoomed canvas without aliasing
     4        https://bugs.webkit.org/show_bug.cgi?id=92043
     5
     6        Reviewed by James Robinson.
     7
     8        If accelerated compositing is enabled, WebWidget::paint reads back from
     9        the compositor rather than re-painting the widget. That approach works
     10        well if the canvas we're rendering into is at a similar resolution to
     11        the pixels in the compositor, but if the canvas has been scaled (e.g.,
     12        to help the user disambiguate links), then reading back from the
     13        compositor will cause aliasing artifacts.
     14
     15        This patch adds an option to paint to let the embedder request a
     16        software re-rendering of the widget to avoid these aliasing artifacts.
     17
     18        * public/WebWidget.h:
     19        (WebKit::WebWidget::paint):
     20        * src/WebPagePopupImpl.cpp:
     21        (WebKit::WebPagePopupImpl::paint):
     22        * src/WebPagePopupImpl.h:
     23        (WebPagePopupImpl):
     24        * src/WebPopupMenuImpl.cpp:
     25        (WebKit::WebPopupMenuImpl::paint):
     26        * src/WebPopupMenuImpl.h:
     27        * src/WebViewImpl.cpp:
     28        (WebKit::canvasBackgroundForTransparencey):
     29        (WebKit):
     30        (WebKit::WebViewImpl::paint):
     31        * src/WebViewImpl.h:
     32        (WebViewImpl):
     33
    1342012-08-22  Eric Penner  <epenner@google.com>
    235
  • trunk/Source/WebKit/chromium/public/WebWidget.h

    r126111 r126344  
    4242#define WEBKIT_HAS_NEW_FULLSCREEN_API 1
    4343#define WEBWIDGET_HAS_SETCOMPOSITORSURFACEREADY 1
     44#define WEBWIDGET_HAS_PAINT_OPTIONS 1
    4445
    4546namespace WebKit {
     
    9192    virtual void layout() { }
    9293
     94    enum PaintOptions {
     95        // Attempt to fulfill the painting request by reading back from the
     96        // compositor, assuming we're using a compositor to render.
     97        ReadbackFromCompositorIfAvailable,
     98
     99        // Force the widget to rerender onto the canvas using software. This
     100        // mode ignores 3d transforms and ignores GPU-resident content, such
     101        // as video, canvas, and WebGL.
     102        //
     103        // Note: This option exists on OS(ANDROID) and will hopefully be
     104        //       removed once the link disambiguation feature renders using
     105        //       the compositor.
     106        ForceSoftwareRenderingAndIgnoreGPUResidentContent,
     107    };
     108
    93109    // Called to paint the rectangular region within the WebWidget
    94110    // onto the specified canvas at (viewPort.x,viewPort.y). You MUST call
     
    98114    // processed, it should be assumed that another call to layout is
    99115    // warranted before painting again).
    100     virtual void paint(WebCanvas*, const WebRect& viewPort) { }
     116    virtual void paint(WebCanvas*, const WebRect& viewPort, PaintOptions = ReadbackFromCompositorIfAvailable) { }
    101117
    102118    // In non-threaded compositing mode, triggers compositing of the current
  • trunk/Source/WebKit/chromium/src/WebPagePopupImpl.cpp

    r126111 r126344  
    226226}
    227227
    228 void WebPagePopupImpl::paint(WebCanvas* canvas, const WebRect& rect)
     228void WebPagePopupImpl::paint(WebCanvas* canvas, const WebRect& rect, PaintOptions)
    229229{
    230230    PageWidgetDelegate::paint(m_page.get(), 0, canvas, rect, PageWidgetDelegate::Opaque);
  • trunk/Source/WebKit/chromium/src/WebPagePopupImpl.h

    r126111 r126344  
    7373    virtual void composite(bool) OVERRIDE;
    7474    virtual void layout() OVERRIDE;
    75     virtual void paint(WebCanvas*, const WebRect&) OVERRIDE;
     75    virtual void paint(WebCanvas*, const WebRect&, PaintOptions = ReadbackFromCompositorIfAvailable) OVERRIDE;
    7676    virtual void resize(const WebSize&) OVERRIDE;
    7777    virtual void close() OVERRIDE;
  • trunk/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp

    r126111 r126344  
    194194}
    195195
    196 void WebPopupMenuImpl::paint(WebCanvas* canvas, const WebRect& rect)
     196void WebPopupMenuImpl::paint(WebCanvas* canvas, const WebRect& rect, PaintOptions)
    197197{
    198198    if (!m_widget)
  • trunk/Source/WebKit/chromium/src/WebPopupMenuImpl.h

    r126111 r126344  
    7474    virtual void animate(double frameBeginTime) OVERRIDE;
    7575    virtual void layout() OVERRIDE;
    76     virtual void paint(WebCanvas*, const WebRect&) OVERRIDE;
     76    virtual void paint(WebCanvas*, const WebRect&, PaintOptions = ReadbackFromCompositorIfAvailable) OVERRIDE;
    7777    virtual void themeChanged() OVERRIDE;
    7878    virtual void setCompositorSurfaceReady() OVERRIDE;
  • trunk/Source/WebKit/chromium/src/WebViewImpl.cpp

    r126323 r126344  
    16861686#endif
    16871687
    1688 void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect)
    1689 {
    1690     if (isAcceleratedCompositingActive()) {
     1688void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect, PaintOptions option)
     1689{
     1690#if !OS(ANDROID)
     1691    // ReadbackFromCompositorIfAvailable is the only option available on non-Android.
     1692    // Ideally, Android would always use ReadbackFromCompositorIfAvailable as well.
     1693    ASSERT(option == ReadbackFromCompositorIfAvailable);
     1694#endif
     1695
     1696    if (option == ReadbackFromCompositorIfAvailable && isAcceleratedCompositingActive()) {
    16911697#if USE(ACCELERATED_COMPOSITING)
    16921698        // If a canvas was passed in, we use it to grab a copy of the
     
    17001706#endif
    17011707    } else {
     1708        FrameView* view = page()->mainFrame()->view();
     1709        PaintBehavior oldPaintBehavior = view->paintBehavior();
     1710        if (isAcceleratedCompositingActive()) {
     1711            ASSERT(option == ForceSoftwareRenderingAndIgnoreGPUResidentContent);           
     1712            view->setPaintBehavior(oldPaintBehavior | PaintBehaviorFlattenCompositingLayers);
     1713        }
     1714
    17021715        double paintStart = currentTime();
    17031716        PageWidgetDelegate::paint(m_page.get(), pageOverlays(), canvas, rect, isTransparent() ? PageWidgetDelegate::Translucent : PageWidgetDelegate::Opaque);
     
    17061719        WebKit::Platform::current()->histogramCustomCounts("Renderer4.SoftwarePaintDurationMS", (paintEnd - paintStart) * 1000, 0, 120, 30);
    17071720        WebKit::Platform::current()->histogramCustomCounts("Renderer4.SoftwarePaintMegapixPerSecond", pixelsPerSec / 1000000, 10, 210, 30);
     1721
     1722        if (isAcceleratedCompositingActive()) {
     1723            ASSERT(option == ForceSoftwareRenderingAndIgnoreGPUResidentContent);           
     1724            view->setPaintBehavior(oldPaintBehavior);
     1725        }
    17081726    }
    17091727}
  • trunk/Source/WebKit/chromium/src/WebViewImpl.h

    r126323 r126344  
    144144    virtual void animate(double);
    145145    virtual void layout(); // Also implements WebLayerTreeViewClient::layout()
    146     virtual void paint(WebCanvas*, const WebRect&);
     146    virtual void paint(WebCanvas*, const WebRect&, PaintOptions = ReadbackFromCompositorIfAvailable);
    147147    virtual void themeChanged();
    148148    virtual void composite(bool finish);
Note: See TracChangeset for help on using the changeset viewer.