Bug 119263 - [Qt] Images are down-scaled badly
Summary: [Qt] Images are down-scaled badly
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Qt (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Allan Sandfeld Jensen
URL:
Keywords:
Depends on: 119392
Blocks:
  Show dependency treegraph
 
Reported: 2013-07-30 09:06 PDT by Allan Sandfeld Jensen
Modified: 2013-08-01 05:42 PDT (History)
4 users (show)

See Also:


Attachments
Patch (3.53 KB, patch)
2013-07-31 03:01 PDT, Allan Sandfeld Jensen
no flags Details | Formatted Diff | Diff
Patch (3.68 KB, patch)
2013-07-31 03:15 PDT, Allan Sandfeld Jensen
no flags Details | Formatted Diff | Diff
Patch (3.71 KB, patch)
2013-07-31 03:42 PDT, Allan Sandfeld Jensen
no flags Details | Formatted Diff | Diff
Patch (4.03 KB, patch)
2013-07-31 06:30 PDT, Allan Sandfeld Jensen
jturcotte: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Allan Sandfeld Jensen 2013-07-30 09:06:21 PDT
If images are scaled down more than 2x the scaled result becomes increasingly worse. This is probably caused by QPainter using bilinear sampling, see https://bugreports.qt-project.org/browse/QTBUG-30682 .

To avoid the issue we can prescale the image before sending it to QPainter.
Comment 1 Allan Sandfeld Jensen 2013-07-31 03:01:50 PDT
Created attachment 207823 [details]
Patch
Comment 2 WebKit Commit Bot 2013-07-31 03:03:04 PDT
Attachment 207823 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCore/platform/graphics/qt/ImageQt.cpp']" exit_code: 1
Source/WebCore/platform/graphics/qt/ImageQt.cpp:273:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
Source/WebCore/platform/graphics/qt/ImageQt.cpp:274:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
Source/WebCore/platform/graphics/qt/ImageQt.cpp:275:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
Source/WebCore/platform/graphics/qt/ImageQt.cpp:276:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
Total errors found: 4 in 2 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Early Warning System Bot 2013-07-31 03:07:48 PDT
Comment on attachment 207823 [details]
Patch

Attachment 207823 [details] did not pass qt-ews (qt):
Output: http://webkit-queues.appspot.com/results/1292609
Comment 4 Early Warning System Bot 2013-07-31 03:08:59 PDT
Comment on attachment 207823 [details]
Patch

Attachment 207823 [details] did not pass qt-wk2-ews (qt-wk2):
Output: http://webkit-queues.appspot.com/results/1293620
Comment 5 Allan Sandfeld Jensen 2013-07-31 03:15:47 PDT
Created attachment 207824 [details]
Patch
Comment 6 WebKit Commit Bot 2013-07-31 03:17:47 PDT
Attachment 207824 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCore/platform/graphics/qt/ImageQt.cpp']" exit_code: 1
Source/WebCore/platform/graphics/qt/ImageQt.cpp:273:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
Source/WebCore/platform/graphics/qt/ImageQt.cpp:274:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
Source/WebCore/platform/graphics/qt/ImageQt.cpp:275:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
Source/WebCore/platform/graphics/qt/ImageQt.cpp:276:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
Total errors found: 4 in 2 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 7 Early Warning System Bot 2013-07-31 03:21:24 PDT
Comment on attachment 207824 [details]
Patch

Attachment 207824 [details] did not pass qt-ews (qt):
Output: http://webkit-queues.appspot.com/results/1289715
Comment 8 Early Warning System Bot 2013-07-31 03:21:30 PDT
Comment on attachment 207824 [details]
Patch

Attachment 207824 [details] did not pass qt-wk2-ews (qt-wk2):
Output: http://webkit-queues.appspot.com/results/1275021
Comment 9 Allan Sandfeld Jensen 2013-07-31 03:24:24 PDT
(In reply to comment #8)
> (From update of attachment 207824 [details])
> Attachment 207824 [details] did not pass qt-wk2-ews (qt-wk2):
> Output: http://webkit-queues.appspot.com/results/1275021

Seems the EWS bot is building with Qt 5.0.
Comment 10 Allan Sandfeld Jensen 2013-07-31 03:42:59 PDT
Created attachment 207828 [details]
Patch

Fix build with Qt 5.0
Comment 11 Jocelyn Turcotte 2013-07-31 05:41:57 PDT
Comment on attachment 207828 [details]
Patch

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

> Source/WebCore/ChangeLog:8
> +        Prescale images before painting and cache the result in the pixmap cache.

Please add a note here or in the code explaining the difference of behavior between QPixmap and QPainter when down-scaling.

> Source/WebCore/platform/graphics/qt/ImageQt.cpp:272
> +        && (normalizedDst.width() * 1.5 * pixelRatio < normalizedSrc.width()
> +            || normalizedDst.height() * 1.5 * pixelRatio < normalizedSrc.height())) {

1.0 / 0.5 == 2.0, I'm not following why you're using 1.5 here.
Comment 12 Allan Sandfeld Jensen 2013-07-31 06:16:06 PDT
(In reply to comment #11)
> (From update of attachment 207828 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=207828&action=review
> 
> > Source/WebCore/ChangeLog:8
> > +        Prescale images before painting and cache the result in the pixmap cache.
> 
> Please add a note here or in the code explaining the difference of behavior between QPixmap and QPainter when down-scaling.
> 
I will update the comments and ChangeLog.

> > Source/WebCore/platform/graphics/qt/ImageQt.cpp:272
> > +        && (normalizedDst.width() * 1.5 * pixelRatio < normalizedSrc.width()
> > +            || normalizedDst.height() * 1.5 * pixelRatio < normalizedSrc.height())) {
> 
> 1.0 / 0.5 == 2.0, I'm not following why you're using 1.5 here.

It is mentioned in the comment above. 

// We prescale before hitting 0.5x because prescaling quality is already better at 0.5x, and with caching often
// faster than transforms in the raster paint engine.
Comment 13 Allan Sandfeld Jensen 2013-07-31 06:30:57 PDT
Created attachment 207848 [details]
Patch

Improve ChangeLog, and restrict prescaling to 0.5x and below. Quality can be better before, but the pixelation issues only trigger after.
Comment 14 Allan Sandfeld Jensen 2013-07-31 07:38:30 PDT
Committed r153522: <http://trac.webkit.org/changeset/153522>