Bug 19266 - [CAIRO] scaled images are ugly
Summary: [CAIRO] scaled images are ugly
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Pierre-Luc Beaudoin
URL:
Keywords:
: 31026 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-05-27 05:45 PDT by Marco Barisione
Modified: 2009-11-04 13:00 PST (History)
8 users (show)

See Also:


Attachments
Use Good filtering (2.18 KB, patch)
2008-05-27 08:58 PDT, Pierre-Luc Beaudoin
no flags Details | Formatted Diff | Diff
Use Good filtering (2.50 KB, patch)
2008-05-27 09:01 PDT, Pierre-Luc Beaudoin
alp: review-
Details | Formatted Diff | Diff
Address Alp and Dave's comments (2.32 KB, patch)
2008-05-29 12:55 PDT, Pierre-Luc Beaudoin
no flags Details | Formatted Diff | Diff
updated patch (7.86 KB, patch)
2009-11-04 12:22 PST, Benjamin Otte
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marco Barisione 2008-05-27 05:45:44 PDT
When zooming (via css or using the zoom patch in bug #18281) scaled images look ugly.
Comment 1 Pierre-Luc Beaudoin 2008-05-27 08:58:59 PDT
Created attachment 21361 [details]
Use Good filtering

Now that CAIRO_EXTEND_PAD have been implemented, we can use a better filter for stretched images.  I removed the references to bug #14017 since it doesn't apply anymore.
Comment 2 Pierre-Luc Beaudoin 2008-05-27 09:01:18 PDT
Created attachment 21362 [details]
Use Good filtering

Oups, forgot Copyrights
Comment 3 Alp Toker 2008-05-29 09:36:30 PDT
Comment on attachment 21362 [details]
Use Good filtering

CAIRO_EXTEND_PAD is defined but not supported for surface patterns in Cairo versions before 1.6, so this patch is a regression for users who don't yet have 1.6.

You need to wrap the use of CAIRO_EXTEND_PAD with either a run-time or compile-time Cairo version check.
Comment 4 Dave Hyatt 2008-05-29 12:04:25 PDT
Note that the engine now has a cross-platform notion of using high quality vs. low quality scaling.  If/when you add this to Cairo, you need to support the rendering of images using both scale modes.  Look at the low quality interpolation bool on the GraphicsContext drawImage method to see what I mean.

Comment 5 Pierre-Luc Beaudoin 2008-05-29 12:55:40 PDT
Created attachment 21419 [details]
Address Alp and Dave's comments

Add checks for Cairo >= 1.6.0 and check if low quality interpolation should be used (even though the current code in GraphicContext would always say no for cairo).
Comment 6 Alp Toker 2008-05-29 18:56:11 PDT
Comment on attachment 21419 [details]
Address Alp and Dave's comments

CAIRO_EXTEND_PAD causes very bizarre effects during image load, so we need to adjust the rect based on the current available height as CG does.

I have a WIP patch that does this (and also addresses the coding style change we discussed). We should probably land the two changes around the same time to avoid regressing trunk.

Clearing flag until the fix is up.
Comment 7 Alp Toker 2008-06-01 09:27:54 PDT
This is part of the fix, just to give you an idea of what I mean (not able to attach it right now, sorry):

+    IntSize selfSize = size();
+    FloatRect adjustedDestRect = dstRect;
+    // If the image is only partially loaded, then shrink the destination rect that we're drawing into accordingly.
+    float currHeight = cairo_image_surface_get_height(image);
+    if (currHeight < selfSize.height())
+        adjustedDestRect.setHeight(adjustedDestRect.height() * currHeight / selfSize.height());
Comment 8 Gustavo Noronha (kov) 2009-03-05 18:26:36 PST
Ping on this? I volunteer to try to get the patch up-to-date and push its inclusion, but would be good to have your WIP, Alp =).
Comment 9 Benjamin Otte 2009-11-03 02:49:35 PST
*** Bug 31026 has been marked as a duplicate of this bug. ***
Comment 10 Benjamin Otte 2009-11-04 12:22:10 PST
Created attachment 42509 [details]
updated patch

Here's a patch against current master respecting the comments from bug 31026.
It does not take care of imageInterpolationMode() as the previous patches to this bug, as I think this belongs in a separate patch.

I'm not sure anyway if imageInterpolationMode() should apply to only images or also to video.
Comment 11 Gustavo Noronha (kov) 2009-11-04 12:48:37 PST
Comment on attachment 42509 [details]
updated patch

Ah, progress!
Comment 12 WebKit Commit Bot 2009-11-04 13:00:19 PST
Comment on attachment 42509 [details]
updated patch

Clearing flags on attachment: 42509

Committed r50527: <http://trac.webkit.org/changeset/50527>
Comment 13 WebKit Commit Bot 2009-11-04 13:00:25 PST
All reviewed patches have been landed.  Closing bug.