Bug 86675

Summary: Bad-quality antialiasing for PNG images
Product: LibreOffice Reporter: Thorsten Wagner <thorsten.wagner.4>
Component: UIAssignee: Not Assigned <libreoffice-bugs>
Status: NEW --- QA Contact:
Severity: major    
Priority: high CC: cno, fdbugs, philipz85, quikee
Version: 4.4.0.0.beta1Keywords: bisected, regression
Hardware: Other   
OS: All   
Whiteboard: bibisected
i915 platform: i915 features:
Bug Depends on:    
Bug Blocks: 74124    
Attachments: Screenshot 1: LibreOffice 4.4.0 Beta 1 without antialiasing
Screenshot 2: LibreOffice 4.3.4 with antialiasing
screen print with image in three versions
Sample document
Before and after screenshots

Description Thorsten Wagner 2014-11-24 23:39:31 UTC
Created attachment 109968 [details]
Screenshot 1: LibreOffice 4.4.0 Beta 1 without antialiasing

PNG images are displayed without antialiasing (see attached screenshot 1). The problem exists in all applications (Writer, Calc, Impress, etc.).

The problem appears on Mac OS X 10.9.5 with LibreOffice 4.4.0 Beta 1. It is not present in LibreOffice 4.3.4 (see screenshot 2).
Comment 1 Thorsten Wagner 2014-11-24 23:40:30 UTC
Created attachment 109969 [details]
Screenshot 2: LibreOffice 4.3.4 with antialiasing
Comment 2 Adolfo Jayme 2014-11-26 00:52:08 UTC
This is not a blocker. The reduced-quality antialiasing was enabled because of performance reasons AFAIK.
Comment 3 Thorsten Wagner 2014-11-26 01:40:33 UTC
Without antialiasing PNG images are looking very ugly. It would be very nice to reenable good quality antialising or to get the information how to do it.

As bad quality rendering is not state of the art today, I recommend to deal with it as a blocker for releasing LibreOffice 4.4 - expecially compared with LibreOffice 4.3.4.
Comment 4 Cor Nouws 2014-11-27 10:08:08 UTC
(In reply to Adolfo Jayme from comment #2)
> This is not a blocker. The reduced-quality antialiasing was enabled because
> of performance reasons AFAIK.

@Adolfo: I'm quite shocked when I paste an image in draw :\
Really looks bad.
We must be sure what is going on here, IMO.
Comment 5 Thorsten Wagner 2014-11-29 23:30:44 UTC
I doublechecked bad performace with image processing with the following results using LibreOffice 4.3.4 and Writer:

(1) Indeed performance of image handling is bad with larger images. It's not possible to scroll without bucking.

(2) Performance issues exist with PNG images as well as with other image formats too, e.g. JPEG.

With the same files (and images) no performance issus exist with AOO 4.1.1. Maybe a look at according AOO code makes sense.
Comment 6 Cor Nouws 2014-12-03 10:46:00 UTC
Created attachment 110400 [details]
screen print with image in three versions

For reference a screen print.
From what I understood, developers are working on OpenGL stuff currently, which is where this has to be fixed.
Comment 7 Matthew Francis 2014-12-30 06:50:09 UTC
The behaviour changed as of the below commit. Despite the discussion above, the commit message doesn't make it sound like decreased quality was an intended side effect or trade-off.

Adding Cc: to quikee@gmail.com (Tomaž Vajngerl). Could you possibly comment on this one? Thanks


commit 1b23e46051d8cc7c01fd8b4d0ea51bfec145db8e
Author: Tomaž Vajngerl <tomaz.vajngerl@collabora.com>
Date:   Sat May 31 21:03:34 2014 +0200

    vcl: Refactor scale "super" out of bitmap and make it independent
    
    Introduce BitmapFilter as a general bitmap filtering class, and
    make scale "super" algorithem independent as BitmapScaleSuper
    which uses BitmapFilter as superclass.
    
    This is an ongoing work to make some bitmap algorithms structured
    and more independent from the big bitmap class This will make them
    easier to work with, test and optimize.
    
    Change-Id: I37d29709b2af95cab2f6da21129302f5be79318b
Comment 8 Tomaz Vajngerl 2014-12-31 05:31:23 UTC
The commit in question just refactors the "super" bitmap scaler out of Bitmap to its own class. It is possible that I made a mistake and produced a bug when refactoring, but I don't see any difference in image scaling between 4.3.4 and 4.4 RC1 or master (tested on Linux). An example document would be helpful.
Comment 9 Matthew Francis 2014-12-31 06:56:23 UTC
Created attachment 111556 [details]
Sample document
Comment 10 Matthew Francis 2014-12-31 06:57:12 UTC
Created attachment 111557 [details]
Before and after screenshots
Comment 11 Matthew Francis 2014-12-31 07:01:31 UTC
(In reply to Tomaz Vajngerl from comment #8)

Please see the attached sample document and screenshots (attachment 111556 [details] and attachment 111557 [details]).

The screenshots are from builds exactly at (right) and one commit before (left) the commit I mentioned above. Current master still looks like the shot on the right to me.
Comment 12 Matthew Francis 2015-01-01 04:38:04 UTC
*** Bug 82870 has been marked as a duplicate of this bug. ***
Comment 13 Jay Philips 2015-01-01 09:16:58 UTC
@Matthew: My bug seems different then this as the problem in my bug is between 4.1 and 4.2+ as shown attachment 104986 [details].
Comment 14 Thorsten Wagner 2015-01-01 12:19:16 UTC
Unfortunately the problem shown in sceenshots 1 und 2 still exists using the current master.
Comment 15 Tomaz Vajngerl 2015-01-01 12:31:05 UTC
Ups.. I commited a fix under fdo#82870 and not this bug as I intended. Still this requires an explanation as it doesn't actually fix this or fdo#82879 bug.

There indeed was a bug in scale super which made "bilinear" scaling into "nearest neighbor" like scaling introduced in [1] but in a later commit [2] we reverted the fix that pre-scaled the images with our built-in scaler - instead of that a fast native "nearest neighbor" scaler is used. So indeed this is the issue Adolfo was talking about which now makes this bug a duplicate of [3]. 

I fixed the issue with super scaler in master by first reverting [2] and looking for the cause of the low quality. 

fdo#82870 is also a duplicate of this and [3] bug.. 

[1] http://cgit.freedesktop.org/libreoffice/core/commit/?id=1b23e46051d8cc7c01fd8b4d0ea51bfec145db8e

[2] http://cgit.freedesktop.org/libreoffice/core/commit/?id=ee36fc7add892690c95a969530ecdcfc1bc9decc

[3] https://bugs.freedesktop.org/show_bug.cgi?id=74124
Comment 16 Jan Holesovsky 2015-01-01 17:34:54 UTC
Tomaž: Let me dump some thoughts here...  The cause is the code at

http://cgit.freedesktop.org/libreoffice/core/tree/vcl/source/outdev/bitmap.cxx#n672

This started being used a lot after one of the Armin's/drawinglayer commits.  I tried to work that around by

http://cgit.freedesktop.org/libreoffice/core/commit/?id=3cf3700b7a903e88f5296076c40ae854bce91cdc ,

but that's not the correct fix here, and I'd avoid reverting

http://cgit.freedesktop.org/libreoffice/core/commit/?id=ee36fc7add892690c95a969530ecdcfc1bc9decc

Luckily the situation should be better at least on Windows now after

http://cgit.freedesktop.org/libreoffice/core/commit/?id=d87b163f8dc787d3bbb17d4a0008ef60c61fe6b0

and follow-up commits in this area, because now we use the native scaling and alpha rendering much more; but I guess on Linux it is still bad :-(

So if you can make the code around bitmap.cxx:672 using some better scaling algorithm while it still remains fast (enough), that would be awesome :-)  The ultimate solution would be that the drawinglayer would cache the scaled images, and consequently we wouldn't have to do any scaling here at all, but that's a big change...

Hope this helps - thanks so much for looking at this!
Comment 17 Jay Philips 2015-01-02 21:19:08 UTC
*** Bug 82870 has been marked as a duplicate of this bug. ***

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.