Bug 147589

Summary: feMorphology is not rendered correctly on Retina display
Product: WebKit Reporter: Said Abou-Hallawa <sabouhallawa>
Component: ImagesAssignee: Said Abou-Hallawa <sabouhallawa>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, dino, kondapallykalyan, rcombs, zimmermann
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
test case
none
Patch
none
Patch none

Description Said Abou-Hallawa 2015-08-03 14:06:49 PDT
Created attachment 258111 [details]
test case

Open the attached test case which contains an text SVG element with feMorphology filter on Retina display.

Result: The display is corrupted.
Note: If the same test case is opened on non-Retina display, the text is displayed fine.
Comment 1 Said Abou-Hallawa 2015-08-04 13:51:31 PDT
<rdar://problem/22098031>
Comment 2 Said Abou-Hallawa 2015-08-04 15:49:46 PDT
Created attachment 258224 [details]
Patch
Comment 3 Said Abou-Hallawa 2015-08-04 18:30:25 PDT
Created attachment 258254 [details]
Patch
Comment 4 WebKit Commit Bot 2015-08-11 12:27:33 PDT
Comment on attachment 258254 [details]
Patch

Clearing flags on attachment: 258254

Committed r188271: <http://trac.webkit.org/changeset/188271>
Comment 5 WebKit Commit Bot 2015-08-11 12:27:36 PDT
All reviewed patches have been landed.  Closing bug.
Comment 6 zalan 2015-08-12 19:11:10 PDT
Comment on attachment 258254 [details]
Patch

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

> Source/WebCore/platform/graphics/filters/FEMorphology.cpp:244
> +    paintingData.width = ceilf(effectDrawingRect.width() * filter.filterScale());
> +    paintingData.height = ceilf(effectDrawingRect.height() * filter.filterScale());
> +    paintingData.radiusX = ceilf(radiusX * filter.filterScale());
> +    paintingData.radiusY = ceilf(radiusY * filter.filterScale());

Why are we ceiling both the location and the dimension here?
Comment 7 Said Abou-Hallawa 2015-08-13 10:29:01 PDT
(In reply to comment #6)
> Comment on attachment 258254 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=258254&action=review
> 
> > Source/WebCore/platform/graphics/filters/FEMorphology.cpp:244
> > +    paintingData.width = ceilf(effectDrawingRect.width() * filter.filterScale());
> > +    paintingData.height = ceilf(effectDrawingRect.height() * filter.filterScale());
> > +    paintingData.radiusX = ceilf(radiusX * filter.filterScale());
> > +    paintingData.radiusY = ceilf(radiusY * filter.filterScale());
> 
> Why are we ceiling both the location and the dimension here?

Is it wrong to do ceiling here?

The filterScale() is set only to renderer().frame().page()->deviceScaleFactor() which is float. But it is 2 on Retina and 1 on none Retina. Can it be for example 1.5?  I do not know. So I assumed filterScale() is just a float and can be any value.

Now I have floating point calculations even the variables before scaling and after scaling are all integers. I thought it is safer to do ceiling to avoid not setting the bits of the last row or the last column if filterScale() has a fraction. And since we are dealing with a memory bitmap, we are sure that nothing will be drawn outside the image pre allocated area.