Bug 148501 - Rendering of shape 'Octagon Bevel' is faulty
Summary: Rendering of shape 'Octagon Bevel' is faulty
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Draw (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:7.4.0 target:7.3.4
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-10 19:55 UTC by Regina Henschel
Modified: 2022-05-10 21:05 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
File generated with OOo2.1 (14.17 KB, application/vnd.oasis.opendocument.graphics)
2022-04-10 19:55 UTC, Regina Henschel
Details
How Bevel shapes looked in various versions (88.16 KB, application/vnd.oasis.opendocument.presentation)
2022-04-18 17:59 UTC, Regina Henschel
Details
Variants with 2 darken values (27.86 KB, application/pdf)
2022-04-19 13:26 UTC, Regina Henschel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Regina Henschel 2022-04-10 19:55:00 UTC
Created attachment 179444 [details]
File generated with OOo2.1

Open attached file. It has a shape 'Octagon Bevel' and a screenshot of this shape in OpenOffice.org 2.1.

You see the same error, when you compare the thumbnail of this shape in Gallery section 'shapes' with an actually inserted shape. The shape is also available in the set "Symbol shapes" in the toolbar.

It is a principle error in rendering shapes of type "col-n1234567". Fortunately only for this shape the error is such obvious. The other shape of this kind in the UI is "Diamond Bevel".

For more details about this type of shape see https://bz.apache.org/ooo/show_bug.cgi?id=33139.

This report is the LO version of bug report https://bz.apache.org/ooo/show_bug.cgi?id=80216.
Comment 1 Xisco Faulí 2022-04-11 09:25:22 UTC
Reproduced in

Version: 7.4.0.0.alpha0+ / LibreOffice Community
Build ID: b812150696c574aea0a173d11f178e8d458b1a3e
CPU threads: 8; OS: Linux 5.10; UI render: default; VCL: gtk3
Locale: es-ES (es_ES.UTF-8); UI: en-US
Calc: threaded

and

LibreOffice 3.3
Comment 2 Regina Henschel 2022-04-18 17:59:50 UTC
Created attachment 179647 [details]
How Bevel shapes looked in various versions

The attached file has in the first row the shapes. Left side is the shape "Square Bevel" (= quad-bevel = mso_sptBevel). On the right side are the shapes "Octagon Bevel" (= col-60da8460) and "Diamond Bevel" (= col-502ad400). The next rows contain screenshots, how these shapes look in various versions.

All three use for shading nColorData. "Square Bevel" gets it from assignment, "Octagon Bevel" and "Diamond Bevel" gets it from the type.

The shape "Octagon Bevel" has the color encoding 60da8460. The starting number 6 gives the number of color changes. The changes are then 0=original color 0%, d=-30%, a=-60%, 8=-80%, 4=40%, 6=60%, 0 unused. A negative value means darken, a positive value lighten.
The segments of the shape are drawn in the order
center (I), top-right and bottom-left (II), right and bottom (III), bottom-right (IV), left and top (V), left-top (VI).

Between OOo 2.1 (about June 2006) and OOo2.4.3 (about August 2007) the way changed how the geometry of the shape is transformed to PolyPolygons. The changes are likely in fix for AOO bug #i76201 (Armin). Now a segment, which has stroke and fill are rendered by two PolyPolygons, one for the stroke and one for the fill.
The center segment of shape "Octagon Bevel" has no stroke, but the others have stroke and fill. The last color change is repeated, if there are more PolyPolygons than color changes. So you get:

Color change | OOo2.1 | new way
0%     | (I)   | (I) 
-30%   | (II)  | (II) stroke
-60%   | (III) | (II) fill
-80%   | (IV)  | (III) stroke
40%    | (V)   | (III) fill
60%    | (VI)  | (IV) stroke
60%    |       | (IV) fill
60%    |       | (V) stroke
60%    |       | (V) fill
60%    |       | (VI) stroke
60%    |       | (VI) fill

My solution is to skip those PolyPolygons which are not filled.

After applying my solution the shadings are still not the same as in OOo2.1. The reason is, that the way, how the color adaption is calculated was changed, likely in fix for AOO bug #i102797 (Thorsten). Those changes were made to get rendering of shapes with darken/lighten parts nearer to rendering in PowerPoint. Because that is necessary for shapes of type "mso-", I think it should not be changed.

My suggestion is to live with the too dark colors in shape type "col-60da8460" and "col-502ad400", but in our preset group "Symbol Shapes" and in Gallery themes "private://gallery/hidden/imgppt" and "Shapes" replace the shapes "Octagon Bevel" and "Diamond Bevel" with shapes that uses only shades compatible with OOXML. I'll write a new bug for that.
Comment 3 Regina Henschel 2022-04-18 18:31:58 UTC
Follow up report is bug 148655.
Patch is in https://gerrit.libreoffice.org/c/core/+/133132.
Comment 4 Regina Henschel 2022-04-18 22:15:56 UTC
Another option to avoid the too dark segments would be a change in code, so that the Type values "col-502ad400" and "col-60da8460" are only used to detect the shapes "Diamond Bevel" and "Octagon Bevel" and then set their actual ColorData directly, same as done for the "mso_spt*" Types around line #778 in EnhancedCustomShape2d.cxx.
Comment 5 Regina Henschel 2022-04-19 13:26:17 UTC
Created attachment 179666 [details]
Variants with 2 darken values

The too dark shadings are introduced with #i102797.
https://bz.apache.org/ooo/show_bug.cgi?id=102797
https://cgit.freedesktop.org/libreoffice/core/diff/svx/source/customshapes/EnhancedCustomShape2d.cxx?id=c048fcfc8b1c68a0d652e17847a40804cb955940

That introduces a new method for calculating the shading. The ColorData of the "mso_spt*" shapes are adapted to the new calculation. But there was no change for other shape types.

In the long run, the shapes "Octagon Bevel" and "Diamond Bevel" should be replaced by ones that contain the shading information inside the <enhanced-path> element.
ColorData allows 7 grades of lighten and 8 grades of darken. But OOXML and our API for element <enhanced-path> has only 2 grades of lighten and 2 grades of darken. "Diamond Bevel" has 2 lighten and 2 darken values. That works directly. But "Octagon Bevel" has 2 lighten and 3 darken values. Some variants to reduce it are shown in the attachment. The current version of the patch uses variant B.
Comment 6 Commit Notification 2022-04-20 09:06:20 UTC
Regina Henschel committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/d5fb8d502e77c1dfc77b2c7bdda4bb1540f3ddaf

tdf#148501 color shades only for filled PolyPolygons

It will be available in 7.4.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 7 Commit Notification 2022-04-26 19:13:49 UTC
Regina Henschel committed a patch related to this issue.
It has been pushed to "libreoffice-7-3":

https://git.libreoffice.org/core/commit/a9d8f86488dcd44bef4d6f8cee1d6c803f237f9c

tdf#148501 color shades only for filled PolyPolygons

It will be available in 7.3.4.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.