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

Changeset 255477 in webkit


Ignore:
Timestamp:
Jan 30, 2020, 5:53:52 PM (7 years ago)
Author:
Fujii Hironori
Message:

[Cairo] Use CAIRO_FILTER_BILINEAR for image tile painting with InterpolationQuality::Default
https://bugs.webkit.org/show_bug.cgi?id=201326

Reviewed by Carlos Garcia Campos.

Mac port is using a better image interpolation method for painting
a single image than painting tiled images.

In Cairo port, CAIRO_FILTER_GOOD was used for both cases as
default. CAIRO_FILTER_GOOD is using separable convolution filter
for down-scaling (≤ 0.75 and ≠ 0.5), and bi-linear filter
otherwise. The separable convolution filter is better quality but
quite slower than bi-linear filter.

drawSurface of CairoOperations.cpp has the code to choose a filter
based on InterpolationQuality.
<https://trac.webkit.org/browser/webkit/trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp?rev=254506#L966>

This change copied the code to drawPatternToCairoContext, and
changed it to use CAIRO_FILTER_BILINEAR for
InterpolationQuality::Default.

  • platform/graphics/cairo/CairoOperations.cpp:

(WebCore::Cairo::drawPattern):

  • platform/graphics/cairo/CairoUtilities.cpp:

(WebCore::drawPatternToCairoContext): Set a filter by calling
cairo_pattern_set_filter based on InterpolationQuality.

  • platform/graphics/cairo/CairoUtilities.h: Added a InterpolationQuality argument.
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r255475 r255477  
     12020-01-30  Fujii Hironori  <Hironori.Fujii@sony.com>
     2
     3        [Cairo] Use CAIRO_FILTER_BILINEAR for image tile painting with InterpolationQuality::Default
     4        https://bugs.webkit.org/show_bug.cgi?id=201326
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Mac port is using a better image interpolation method for painting
     9        a single image than painting tiled images.
     10
     11        In Cairo port, CAIRO_FILTER_GOOD was used for both cases as
     12        default. CAIRO_FILTER_GOOD is using separable convolution filter
     13        for down-scaling (≤ 0.75 and ≠ 0.5), and bi-linear filter
     14        otherwise. The separable convolution filter is better quality but
     15        quite slower than bi-linear filter.
     16
     17        drawSurface of CairoOperations.cpp has the code to choose a filter
     18        based on InterpolationQuality.
     19        <https://trac.webkit.org/browser/webkit/trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp?rev=254506#L966>
     20
     21        This change copied the code to drawPatternToCairoContext, and
     22        changed it to use CAIRO_FILTER_BILINEAR for
     23        InterpolationQuality::Default.
     24
     25        * platform/graphics/cairo/CairoOperations.cpp:
     26        (WebCore::Cairo::drawPattern):
     27        * platform/graphics/cairo/CairoUtilities.cpp:
     28        (WebCore::drawPatternToCairoContext): Set a filter by calling
     29        cairo_pattern_set_filter based on InterpolationQuality.
     30        * platform/graphics/cairo/CairoUtilities.h: Added a InterpolationQuality argument.
     31
    1322020-01-30  Ross Kirsling  <ross.kirsling@sony.com>
    233
  • trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp

    r254506 r255477  
    917917{
    918918    // FIXME: Investigate why the size has to be passed in as an IntRect.
    919     drawPatternToCairoContext(platformContext.cr(), surface, size, tileRect, patternTransform, phase, toCairoOperator(options.compositeOperator(), options.blendMode()), destRect);
     919    drawPatternToCairoContext(platformContext.cr(), surface, size, tileRect, patternTransform, phase, toCairoOperator(options.compositeOperator(), options.blendMode()), options.interpolationQuality(), destRect);
    920920}
    921921
  • trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp

    r254506 r255477  
    203203
    204204void drawPatternToCairoContext(cairo_t* cr, cairo_surface_t* image, const IntSize& imageSize, const FloatRect& tileRect,
    205                                const AffineTransform& patternTransform, const FloatPoint& phase, cairo_operator_t op, const FloatRect& destRect)
     205    const AffineTransform& patternTransform, const FloatPoint& phase, cairo_operator_t op, InterpolationQuality imageInterpolationQuality, const FloatRect& destRect)
    206206{
    207207    // Avoid NaN
     
    222222
    223223    cairo_pattern_t* pattern = cairo_pattern_create_for_surface(image);
     224    switch (imageInterpolationQuality) {
     225    case InterpolationQuality::DoNotInterpolate:
     226    case InterpolationQuality::Low:
     227        cairo_pattern_set_filter(pattern, CAIRO_FILTER_FAST);
     228        break;
     229    case InterpolationQuality::Default:
     230        cairo_pattern_set_filter(pattern, CAIRO_FILTER_BILINEAR);
     231        break;
     232    case InterpolationQuality::Medium:
     233        cairo_pattern_set_filter(pattern, CAIRO_FILTER_GOOD);
     234        break;
     235    case InterpolationQuality::High:
     236        cairo_pattern_set_filter(pattern, CAIRO_FILTER_BEST);
     237        break;
     238    }
    224239    cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
    225240
  • trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.h

    r254506 r255477  
    8585cairo_operator_t toCairoOperator(CompositeOperator, BlendMode = BlendMode::Normal);
    8686void drawPatternToCairoContext(cairo_t* cr, cairo_surface_t* image, const IntSize& imageSize, const FloatRect& tileRect,
    87                                const AffineTransform& patternTransform, const FloatPoint& phase, cairo_operator_t op, const FloatRect& destRect);
     87    const AffineTransform& patternTransform, const FloatPoint& phase, cairo_operator_t, InterpolationQuality, const FloatRect& destRect);
    8888RefPtr<cairo_surface_t> copyCairoImageSurface(cairo_surface_t*);
    8989
Note: See TracChangeset for help on using the changeset viewer.