Bug 67729 - GeneratorGeneratedImage::drawPattern does not factor in its destination context's scale when generating its image tiles
Summary: GeneratorGeneratedImage::drawPattern does not factor in its destination conte...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac (Intel) OS X 10.7
: P2 Normal
Assignee: Matthew Delaney
URL: data:text/html,%3Cdiv%20style=%22heig...
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2011-09-07 13:04 PDT by Adam Roben (:aroben)
Modified: 2012-02-08 17:30 PST (History)
6 users (show)

See Also:


Attachments
Patch (5.65 KB, patch)
2012-02-08 15:30 PST, Matthew Delaney
bdakin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Roben (:aroben) 2011-09-07 13:04:51 PDT
To reproduce:

0. Have a display with a >1.0 scale factor
1. Go to data:text/html,%3Cdiv%20style=%22height:300px;width:300px;background-image:-webkit-repeating-linear-gradient(top%20left,%20red%2010%25,%20blue%2030%25);border:1px%20solid%22%3E

Note that the diagonal lines in the gradient look chunky. They should look nice and smooth instead! In fact, they *do* look smooth if you remove the border.
Comment 1 Radar WebKit Bug Importer 2011-09-07 13:05:11 PDT
<rdar://problem/10087050>
Comment 2 Simon Fraser (smfr) 2011-09-07 13:07:25 PDT
We need to audit all the places where we make ImageBuffers in the code to see if we need to use a scale factor. Or maybe we have ImageBuffer do this automatically.
Comment 3 Matthew Delaney 2012-02-08 15:28:14 PST
The difference in rendering quality seen here when there's a border is due to how we render generated images as backgrounds.

First, regardless of what type the background image is (in this case, a Gradient as GeneratorGeneratedImage) adding a border results in the background image being drawn as a pattern with more than one tile. If there were no border, we just draw the background image as one tile and hit the normal path. However, when there's a border, we pattern draw the background image so that it shows up behind the border as well with a padding-box-sized tile as is defined in the CSS spec (whether or not the border is opaque https://bugs.webkit.org/show_bug.cgi?id=78162)

In this pattern draw case, we end up hitting GeneratorGeneratedImage's drawPattern instead of draw. Since 'draw' renders directly into the destination context - where as drawPattern renders a tile first in an ImageBuffer to then use - the generated image has the benefit of being at the resolution of the context. In the drawPattern case, the ImageBuffer that is created hasn't factored in the scale of the destination context. Thus, my patch teaches drawPattern about the scale to make tiles at a resolution that will match that of the destination context.
Comment 4 Matthew Delaney 2012-02-08 15:30:37 PST
Created attachment 126165 [details]
Patch
Comment 5 Matthew Delaney 2012-02-08 17:30:59 PST
Committed r107157: <http://trac.webkit.org/changeset/107157>