Skip to content

Commit 165b0ef

Browse files
carlosgcamposmagomez
authored andcommitted
[Cairo] Use CAIRO_FILTER_BILINEAR for low interpolation quality https://bugs.webkit.org/show_bug.cgi?id=264605 Reviewed by Fujii Hironori. We currently use CAIRO_FILTER_FAST which is the same as no interpolation. Bilinear provides reasonable quality with good enough performance. Also change the default interpolation quality of the canvas to Low (like CG does) which drastically improves the performance of downscaling high resolution images in the canvas with a reasonable output. See for example https://vsynctester.com * Source/WebCore/html/CanvasBase.cpp: * Source/WebCore/platform/graphics/cairo/CairoOperations.cpp: (WebCore::Cairo::drawSurface): Canonical link: https://commits.webkit.org/270586@main
1 parent 6113b55 commit 165b0ef

2 files changed

Lines changed: 3 additions & 7 deletions

File tree

Source/WebCore/html/CanvasBase.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,7 @@ static std::atomic<size_t> s_activePixelMemory { 0 };
4343

4444
namespace WebCore {
4545

46-
#if USE(CG)
47-
// FIXME: It seems strange that the default quality is not the one that is literally named "default".
48-
// Should fix names to make this easier to understand, or write an excellent comment here explaining why not.
4946
const InterpolationQuality defaultInterpolationQuality = InterpolationQuality::Low;
50-
#else
51-
const InterpolationQuality defaultInterpolationQuality = InterpolationQuality::Default;
52-
#endif
5347

5448
CanvasBase::CanvasBase(IntSize size)
5549
: m_size(size)

Source/WebCore/platform/graphics/cairo/CairoOperations.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,9 +936,11 @@ void drawSurface(GraphicsContextCairo& platformContext, cairo_surface_t* surface
936936

937937
switch (imageInterpolationQuality) {
938938
case InterpolationQuality::DoNotInterpolate:
939-
case InterpolationQuality::Low:
940939
cairo_pattern_set_filter(pattern.get(), CAIRO_FILTER_FAST);
941940
break;
941+
case InterpolationQuality::Low:
942+
cairo_pattern_set_filter(pattern.get(), CAIRO_FILTER_BILINEAR);
943+
break;
942944
case InterpolationQuality::Medium:
943945
case InterpolationQuality::Default:
944946
cairo_pattern_set_filter(pattern.get(), CAIRO_FILTER_GOOD);

0 commit comments

Comments
 (0)