Bug 58100 - 1px box-shadow looks ugly
Summary: 1px box-shadow looks ugly
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: All OS X 10.5
: P2 Normal
Assignee: Simon Fraser (smfr)
URL:
Keywords: InRadar
Depends on:
Blocks: 59782
  Show dependency treegraph
 
Reported: 2011-04-07 17:16 PDT by Simon Fraser (smfr)
Modified: 2011-04-28 23:41 PDT (History)
4 users (show)

See Also:


Attachments
Testcase (269 bytes, text/html)
2011-04-07 17:16 PDT, Simon Fraser (smfr)
no flags Details
Patch (24.62 KB, patch)
2011-04-28 12:45 PDT, Simon Fraser (smfr)
krit: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Fraser (smfr) 2011-04-07 17:16:31 PDT
Box-shadow with a 1px blur radius looks ugly, and rather different from a CG 1-px shadow.
Comment 1 Simon Fraser (smfr) 2011-04-07 17:16:45 PDT
Created attachment 88740 [details]
Testcase
Comment 2 Martin Robinson 2011-04-08 09:22:17 PDT
I wonder if this is due to the fact that ShadowBlur/ContextShadow does not yet support fractional blur radii.
Comment 3 Simon Fraser (smfr) 2011-04-27 12:02:50 PDT
I'm sure it is.
Comment 4 Simon Fraser (smfr) 2011-04-27 12:55:37 PDT
<rdar://problem/9076329>
Comment 5 Simon Fraser (smfr) 2011-04-27 14:06:22 PDT
The code is buggy for 1px radii. For an input of:


000 000 000 000 000 
000 255 255 255 000 
000 255 255 255 000 
000 255 255 255 000 
000 255 255 255 000 
000 255 255 255 000 
000 255 255 255 000 
000 255 255 255 000 
000 000 000 000 000 

the results are

043 070 088 079 061 
069 112 141 127 098 
096 154 194 175 135 
105 169 212 191 148 
105 169 212 191 148 
105 169 212 191 148 
096 154 194 175 135 
078 126 159 143 111 
060 098 123 111 086 

which is not symmetrical. For radii >=2 this problem does not happen.
Comment 6 Dirk Schulze 2011-04-27 20:11:20 PDT
I could compare the both shadows (ContextShadow and ShadowBlur) and the result of ContextShadow looked more sane. It also did not have big problems with 0-1px shadows. Is there a difference in the implementation?
Comment 7 Simon Fraser (smfr) 2011-04-28 09:53:10 PDT
Context Shadows's code gives:

Blur source:
000 000 000 000 000 
000 255 255 255 000 
000 255 255 255 000 
000 255 255 255 000 
000 255 255 255 000 
000 255 255 255 000 
000 255 255 255 000 
000 255 255 255 000 
000 000 000 000 000 

Blur result:
086 111 123 098 060 
111 143 159 126 078 
135 175 194 154 096 
148 191 212 169 105 
148 191 212 169 105 
148 191 212 169 105 
135 175 194 154 096 
098 127 141 112 069 
061 079 088 070 043 

which is still incorrect, but different (not sure why).
Comment 8 Simon Fraser (smfr) 2011-04-28 10:51:46 PDT
If I add 1px of padding so that the edge alpha is always zero, the issue goes away. I'll do that.
Comment 9 Simon Fraser (smfr) 2011-04-28 12:45:31 PDT
Created attachment 91539 [details]
Patch
Comment 10 Dirk Schulze 2011-04-28 20:35:11 PDT
Comment on attachment 91539 [details]
Patch

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

Can you please check if the pixel results for feDropShadow changed (they should) and update them? They are located at LayoutTests/svg/filter/feDropShadow.svg and LayoutTests/dynamic-updates/

r- for the test and the and the missing result updates. The fix itself looks good to me. If I should be wrong with tests just add a comment.

> LayoutTests/fast/box-shadow/single-pixel-shadow.html:15
> +      -webkit-transform-origin: -1px -1px;
> +      -webkit-transform: scale(20);

Do you really want a pixelation here? On SVG we try to avoid this and transform all affected objects to devicespace and apply shadows afterwards. So we always have a goof looking shadow. This definitely does not belong to this big. But if it gets changed in the future, the text would be useless. Have you checked what Firefox or Opera are doing? But I don't have an idea how to make a pixel with it. What about canvas? Is canvas using shadow? If you draw a shadow on canvas it should be pixelated on scaling, also in the future, no?
Comment 11 Dirk Schulze 2011-04-28 20:48:54 PDT
Comment on attachment 91539 [details]
Patch

Talked with Simon on IRC. We don't see a way to have constant results on shadows across platforms as long as not all platforms are using ShadowBlur. Even if we get resolution independent shadows, we should see if the shadow is broken, since the shadow radius gets scaled as well. Simon updates filter results on landing.
Comment 12 Simon Fraser (smfr) 2011-04-28 21:08:00 PDT
http://trac.webkit.org/changeset/85299