1,295
edits
No edit summary |
No edit summary |
||
| Line 6: | Line 6: | ||
* An outer rectangle. | * An outer rectangle. | ||
* Horizontal and vertical radii for each corner. | * Horizontal and vertical radii for each corner. | ||
== Current Situation == | |||
nsCSSRenderingBorders.cpp has a lot of code that's fairly complex. It tries to handle various situations using "fast paths" but it's hard to follow and in many complex cases (which show up on real Web sites; e.g. GMail uses rounded borders, multiple colors per side and different colors on different sides all together) performance is rather slow because we use complex cairo operations such as PushGroup and OPERATOR_ADD. | |||
In many cases the borders we're drawing --- especially the difficult bits, the corners (as opposed to sides) --- actually don't cover many pixels. It's worth investigating an alternative approach where we compute the color value of each pixel directly as a function of its coordinates, one pixel at a time, instead of trying to draw the borders using cairo/gfxContext operations. | |||
== Approach == | == Approach == | ||
# Divide the border into 8 pieces (some of which may be empty): 4 corners and 4 straight sides. We can do simpler/faster things for the straight-sides pieces. | # Divide the border into 8 pieces (some of which may be empty): 4 corners and 4 straight sides. We can do simpler/faster things for the straight-sides pieces than for the corners. | ||
# For each pixel: | # For each corner and side: | ||
## Compute the value of the pixel as if all border styles are SOLID | ## For each pixel with coordinates (x,y) in that corner or side: | ||
## | ### Compute the value of the pixel as if all border styles are SOLID, based on x/y and knowing which corner or side the pixel belongs to | ||
### For DASHED/DOTTED styles, compute a mask alpha value indicating how much of the pixel is to be drawn --- 0 if the pixel is completely outside any dash/dot, 1 if the pixel is completely inside a dash/dot, some other values if it's on the edge | |||
=== Computing Color Values For Side Pixels === | === Computing Color Values For Side Pixels === | ||
edits