- Revision
- 255477
- Author
- [email protected]
- Date
- 2020-01-30 17:53:52 -0800 (Thu, 30 Jan 2020)
Log 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.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (255476 => 255477)
--- trunk/Source/WebCore/ChangeLog 2020-01-31 00:58:37 UTC (rev 255476)
+++ trunk/Source/WebCore/ChangeLog 2020-01-31 01:53:52 UTC (rev 255477)
@@ -1,3 +1,34 @@
+2020-01-30 Fujii Hironori <[email protected]>
+
+ [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.
+
2020-01-30 Ross Kirsling <[email protected]>
[CMake] Add SQLite::SQLite3 target
Modified: trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp (255476 => 255477)
--- trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp 2020-01-31 00:58:37 UTC (rev 255476)
+++ trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp 2020-01-31 01:53:52 UTC (rev 255477)
@@ -916,7 +916,7 @@
void drawPattern(PlatformContextCairo& platformContext, cairo_surface_t* surface, const IntSize& size, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const ImagePaintingOptions& options)
{
// FIXME: Investigate why the size has to be passed in as an IntRect.
- drawPatternToCairoContext(platformContext.cr(), surface, size, tileRect, patternTransform, phase, toCairoOperator(options.compositeOperator(), options.blendMode()), destRect);
+ drawPatternToCairoContext(platformContext.cr(), surface, size, tileRect, patternTransform, phase, toCairoOperator(options.compositeOperator(), options.blendMode()), options.interpolationQuality(), destRect);
}
void drawSurface(PlatformContextCairo& platformContext, cairo_surface_t* surface, const FloatRect& destRect, const FloatRect& originalSrcRect, InterpolationQuality imageInterpolationQuality, float globalAlpha, const ShadowState& shadowState)
Modified: trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp (255476 => 255477)
--- trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp 2020-01-31 00:58:37 UTC (rev 255476)
+++ trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp 2020-01-31 01:53:52 UTC (rev 255477)
@@ -202,7 +202,7 @@
}
void drawPatternToCairoContext(cairo_t* cr, cairo_surface_t* image, const IntSize& imageSize, const FloatRect& tileRect,
- const AffineTransform& patternTransform, const FloatPoint& phase, cairo_operator_t op, const FloatRect& destRect)
+ const AffineTransform& patternTransform, const FloatPoint& phase, cairo_operator_t op, InterpolationQuality imageInterpolationQuality, const FloatRect& destRect)
{
// Avoid NaN
if (!std::isfinite(phase.x()) || !std::isfinite(phase.y()))
@@ -221,6 +221,21 @@
}
cairo_pattern_t* pattern = cairo_pattern_create_for_surface(image);
+ switch (imageInterpolationQuality) {
+ case InterpolationQuality::DoNotInterpolate:
+ case InterpolationQuality::Low:
+ cairo_pattern_set_filter(pattern, CAIRO_FILTER_FAST);
+ break;
+ case InterpolationQuality::Default:
+ cairo_pattern_set_filter(pattern, CAIRO_FILTER_BILINEAR);
+ break;
+ case InterpolationQuality::Medium:
+ cairo_pattern_set_filter(pattern, CAIRO_FILTER_GOOD);
+ break;
+ case InterpolationQuality::High:
+ cairo_pattern_set_filter(pattern, CAIRO_FILTER_BEST);
+ break;
+ }
cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
// Due to a limitation in pixman, cairo cannot handle transformation matrices with values bigger than 32768. If the value is
Modified: trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.h (255476 => 255477)
--- trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.h 2020-01-31 00:58:37 UTC (rev 255476)
+++ trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.h 2020-01-31 01:53:52 UTC (rev 255477)
@@ -84,7 +84,7 @@
void appendRegionToCairoContext(cairo_t*, const cairo_region_t*);
cairo_operator_t toCairoOperator(CompositeOperator, BlendMode = BlendMode::Normal);
void drawPatternToCairoContext(cairo_t* cr, cairo_surface_t* image, const IntSize& imageSize, const FloatRect& tileRect,
- const AffineTransform& patternTransform, const FloatPoint& phase, cairo_operator_t op, const FloatRect& destRect);
+ const AffineTransform& patternTransform, const FloatPoint& phase, cairo_operator_t, InterpolationQuality, const FloatRect& destRect);
RefPtr<cairo_surface_t> copyCairoImageSurface(cairo_surface_t*);
void copyRectFromCairoSurfaceToContext(cairo_surface_t* from, cairo_t* to, const IntSize& offset, const IntRect&);