Bug 45722 - Lower the default canvas interpolation quality for platforms that use CG
Summary: Lower the default canvas interpolation quality for platforms that use CG
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.5
: P2 Normal
Assignee: Matthew Delaney
Depends on: 46243
  Show dependency treegraph
Reported: 2010-09-13 17:14 PDT by Matthew Delaney
Modified: 2011-03-28 09:10 PDT (History)
8 users (show)

See Also:

Patch (4.97 KB, patch)
2010-09-14 05:25 PDT, Matthew Delaney
no flags Details | Formatted Diff | Diff
Patch (4.10 KB, patch)
2010-09-23 14:11 PDT, Matthew Delaney
no flags Details | Formatted Diff | Diff
Patch (2.84 KB, patch)
2010-09-23 16:53 PDT, Matthew Delaney
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Delaney 2010-09-13 17:14:51 PDT
Currently Safari is using CG's "high" interpolation quality setting as the default for canvas. Dropping it down to "low" speeds up many canvas demos (including GUIMark 2 bitmap, IE Asteroid, etc.) without any noticeable degradation of quality. As a result, the speedups for animations make the apparent quality seem much better. Also, CG's low interpolation quality setting is equivalent to most other browsers' default or high settings.

Note: Dropping the interpolation quality down to low still causes the drawing of large images to go slowly if they're scaled down when drawn into the canvas. This will be addressed in a followup bug that will block on this one.
Comment 1 Matthew Delaney 2010-09-14 05:25:07 PDT
Created attachment 67542 [details]
Comment 2 Matthew Delaney 2010-09-14 05:26:54 PDT
This patch is likely WIP due to it possibly causing a small issue in 2 of the canvas layout tests. Will investigate very soon.
Comment 3 Geoffrey Garen 2010-09-14 13:50:33 PDT
Comment on attachment 67542 [details]

r- due to layout test failures.
Comment 4 Adam Roben (:aroben) 2010-09-20 11:43:47 PDT
Why not do this on Windows, too?
Comment 5 Geoffrey Garen 2010-09-20 11:48:19 PDT
Why not on all platforms?
Comment 6 Oliver Hunt 2010-09-20 11:50:31 PDT
(In reply to comment #5)
> Why not on all platforms?

It should be PLATFORM(CG) as the specific problem is that CG's high quality is higher quality (and hence slower) than any other graphics libraries high quality.  Medium quality in CG is trilinear filtering, which is higher quality than anything firefox, et al use anywhere afaik
Comment 7 Matthew Delaney 2010-09-20 12:16:32 PDT
Yes, Oliver said it well. This is specifically to address CG. 

Cross-platform, there is a concept of basically 4 possible "Interpolation Quality" settings: none, low, medium, and high. Per platform, these quality settings match to different scaling algorithms. CG's low setting happens to be others' high/medium settings which is quantized bilinear interpolation. AFAIK, everywhere else in webkit, we're using CG's high setting. This patch is just changing the quality setting used in the CG version of canvas.
Comment 8 Matthew Delaney 2010-09-23 14:11:00 PDT
Created attachment 68584 [details]
Comment 9 Oliver Hunt 2010-09-23 16:32:45 PDT
Comment on attachment 68584 [details]

View in context: https://bugs.webkit.org/attachment.cgi?id=68584&action=review

> WebCore/html/canvas/CanvasRenderingContext2D.cpp:140
> +    if (GraphicsContext* c = drawingContext())
> +        c->setImageInterpolationQuality(DefaultInterpolationQuality);

We deliberately delayed creation of the underlying ImageBuffer in the canvas so that we don't end up doing a whole lot of work on an imagebuffer that is going to be thrown out.  Also this means when we do throw out the buffer and then recreate it we won't reset the interpolation quality.

The existing location of the call to setInterpolation quality is the correct one.
Comment 10 Matthew Delaney 2010-09-23 16:53:05 PDT
Created attachment 68624 [details]
Comment 11 WebKit Commit Bot 2010-09-23 17:29:47 PDT
Comment on attachment 68624 [details]

Clearing flags on attachment: 68624

Committed r68221: <http://trac.webkit.org/changeset/68221>
Comment 12 WebKit Commit Bot 2010-09-23 17:29:53 PDT
All reviewed patches have been landed.  Closing bug.
Comment 13 Caio Marcelo de Oliveira Filho 2011-03-28 09:10:38 PDT
Revision r68221 cherry-picked into qtwebkit-2.1-x with commit 318b799eee638d69247276fa8b9ba48027562bcd <http://gitorious.org/webkit/qtwebkit/commit/318b799eee638d69247276fa8b9ba48027562bcd>