Skip to content

Commit

Permalink
[Cairo] Use CAIRO_FILTER_BILINEAR for low interpolation quality
Browse files Browse the repository at this point in the history
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
  • Loading branch information
carlosgcampos committed Nov 11, 2023
1 parent 985d780 commit 135e0e4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
5 changes: 0 additions & 5 deletions Source/WebCore/html/CanvasBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,7 @@ static std::atomic<size_t> s_activePixelMemory { 0 };

namespace WebCore {

#if USE(CG)
constexpr InterpolationQuality defaultInterpolationQuality = InterpolationQuality::Low;
#else
constexpr InterpolationQuality defaultInterpolationQuality = InterpolationQuality::Medium;
#endif

static std::optional<size_t> maxCanvasAreaForTesting;

CanvasBase::CanvasBase(IntSize size, const std::optional<NoiseInjectionHashSalt>& noiseHashSalt)
Expand Down
4 changes: 3 additions & 1 deletion Source/WebCore/platform/graphics/cairo/CairoOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -900,9 +900,11 @@ void drawSurface(GraphicsContextCairo& platformContext, cairo_surface_t* surface

switch (imageInterpolationQuality) {
case InterpolationQuality::DoNotInterpolate:
case InterpolationQuality::Low:
cairo_pattern_set_filter(pattern.get(), CAIRO_FILTER_FAST);
break;
case InterpolationQuality::Low:
cairo_pattern_set_filter(pattern.get(), CAIRO_FILTER_BILINEAR);
break;
case InterpolationQuality::Medium:
case InterpolationQuality::Default:
cairo_pattern_set_filter(pattern.get(), CAIRO_FILTER_GOOD);
Expand Down

0 comments on commit 135e0e4

Please sign in to comment.