mirror of
https://github.com/servo/servo.git
synced 2025-08-01 11:40:30 +01:00
Auto merge of #7679 - bjwbell:reftest-twitter-fail-whale, r=pcwalton
Add css twitter fail whale html test & update ellipse_to_bezier comment cgaebel had a TODO for a css twitter fail whale reftest, which depended on elliptical border-radius support. I didn't see any feasible way other than a reference image for border_twitter_fail_whale_b.html. r? @pcwalton <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7679) <!-- Reviewable:end -->
This commit is contained in:
commit
c91c0188f2
2 changed files with 1430 additions and 81 deletions
|
@ -484,7 +484,81 @@ impl<'a> PaintContext<'a> {
|
|||
radius.width <= 0. || radius.height <= 0.
|
||||
}
|
||||
|
||||
// Adapted from gecko:gfx/2d/PathHelpers.h:EllipseToBezier
|
||||
// The following comment is wonderful, and stolen from
|
||||
// gecko:gfx/thebes/gfxContext.cpp:RoundedRectangle for reference.
|
||||
// ---------------------------------------------------------------
|
||||
//
|
||||
// For CW drawing, this looks like:
|
||||
//
|
||||
// ...******0** 1 C
|
||||
// ****
|
||||
// *** 2
|
||||
// **
|
||||
// *
|
||||
// *
|
||||
// 3
|
||||
// *
|
||||
// *
|
||||
//
|
||||
// Where 0, 1, 2, 3 are the control points of the Bezier curve for
|
||||
// the corner, and C is the actual corner point.
|
||||
//
|
||||
// At the start of the loop, the current point is assumed to be
|
||||
// the point adjacent to the top left corner on the top
|
||||
// horizontal. Note that corner indices start at the top left and
|
||||
// continue clockwise, whereas in our loop i = 0 refers to the top
|
||||
// right corner.
|
||||
//
|
||||
// When going CCW, the control points are swapped, and the first
|
||||
// corner that's drawn is the top left (along with the top segment).
|
||||
//
|
||||
// There is considerable latitude in how one chooses the four
|
||||
// control points for a Bezier curve approximation to an ellipse.
|
||||
// For the overall path to be continuous and show no corner at the
|
||||
// endpoints of the arc, points 0 and 3 must be at the ends of the
|
||||
// straight segments of the rectangle; points 0, 1, and C must be
|
||||
// collinear; and points 3, 2, and C must also be collinear. This
|
||||
// leaves only two free parameters: the ratio of the line segments
|
||||
// 01 and 0C, and the ratio of the line segments 32 and 3C. See
|
||||
// the following papers for extensive discussion of how to choose
|
||||
// these ratios:
|
||||
//
|
||||
// Dokken, Tor, et al. "Good approximation of circles by
|
||||
// curvature-continuous Bezier curves." Computer-Aided
|
||||
// Geometric Design 7(1990) 33--41.
|
||||
// Goldapp, Michael. "Approximation of circular arcs by cubic
|
||||
// polynomials." Computer-Aided Geometric Design 8(1991) 227--238.
|
||||
// Maisonobe, Luc. "Drawing an elliptical arc using polylines,
|
||||
// quadratic, or cubic Bezier curves."
|
||||
// http://www.spaceroots.org/documents/ellipse/elliptical-arc.pdf
|
||||
//
|
||||
// We follow the approach in section 2 of Goldapp (least-error,
|
||||
// Hermite-type approximation) and make both ratios equal to
|
||||
//
|
||||
// 2 2 + n - sqrt(2n + 28)
|
||||
// alpha = - * ---------------------
|
||||
// 3 n - 4
|
||||
//
|
||||
// where n = 3( cbrt(sqrt(2)+1) - cbrt(sqrt(2)-1) ).
|
||||
//
|
||||
// This is the result of Goldapp's equation (10b) when the angle
|
||||
// swept out by the arc is pi/2, and the parameter "a-bar" is the
|
||||
// expression given immediately below equation (21).
|
||||
//
|
||||
// Using this value, the maximum radial error for a circle, as a
|
||||
// fraction of the radius, is on the order of 0.2 x 10^-3.
|
||||
// Neither Dokken nor Goldapp discusses error for a general
|
||||
// ellipse; Maisonobe does, but his choice of control points
|
||||
// follows different constraints, and Goldapp's expression for
|
||||
// 'alpha' gives much smaller radial error, even for very flat
|
||||
// ellipses, than Maisonobe's equivalent.
|
||||
//
|
||||
// For the various corners and for each axis, the sign of this
|
||||
// constant changes, or it might be 0 -- it's multiplied by the
|
||||
// appropriate multiplier from the list before using.
|
||||
// ---------------------------------------------------------------
|
||||
//
|
||||
// Code adapted from gecko:gfx/2d/PathHelpers.h:EllipseToBezier
|
||||
fn ellipse_to_bezier(path_builder: &mut PathBuilder,
|
||||
origin: Point2D<AzFloat>,
|
||||
radius: Size2D<AzFloat>,
|
||||
|
@ -629,86 +703,6 @@ impl<'a> PaintContext<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
// The following comment is wonderful, and stolen from
|
||||
// gecko:gfx/thebes/gfxContext.cpp:RoundedRectangle for reference.
|
||||
//
|
||||
// It does not currently apply to the code, but will be extremely useful in
|
||||
// the future when the below TODO is addressed.
|
||||
//
|
||||
// TODO(cgaebel): Switch from arcs to beziers for drawing the corners.
|
||||
// Then, add http://www.subcide.com/experiments/fail-whale/
|
||||
// to the reftest suite.
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
//
|
||||
// For CW drawing, this looks like:
|
||||
//
|
||||
// ...******0** 1 C
|
||||
// ****
|
||||
// *** 2
|
||||
// **
|
||||
// *
|
||||
// *
|
||||
// 3
|
||||
// *
|
||||
// *
|
||||
//
|
||||
// Where 0, 1, 2, 3 are the control points of the Bezier curve for
|
||||
// the corner, and C is the actual corner point.
|
||||
//
|
||||
// At the start of the loop, the current point is assumed to be
|
||||
// the point adjacent to the top left corner on the top
|
||||
// horizontal. Note that corner indices start at the top left and
|
||||
// continue clockwise, whereas in our loop i = 0 refers to the top
|
||||
// right corner.
|
||||
//
|
||||
// When going CCW, the control points are swapped, and the first
|
||||
// corner that's drawn is the top left (along with the top segment).
|
||||
//
|
||||
// There is considerable latitude in how one chooses the four
|
||||
// control points for a Bezier curve approximation to an ellipse.
|
||||
// For the overall path to be continuous and show no corner at the
|
||||
// endpoints of the arc, points 0 and 3 must be at the ends of the
|
||||
// straight segments of the rectangle; points 0, 1, and C must be
|
||||
// collinear; and points 3, 2, and C must also be collinear. This
|
||||
// leaves only two free parameters: the ratio of the line segments
|
||||
// 01 and 0C, and the ratio of the line segments 32 and 3C. See
|
||||
// the following papers for extensive discussion of how to choose
|
||||
// these ratios:
|
||||
//
|
||||
// Dokken, Tor, et al. "Good approximation of circles by
|
||||
// curvature-continuous Bezier curves." Computer-Aided
|
||||
// Geometric Design 7(1990) 33--41.
|
||||
// Goldapp, Michael. "Approximation of circular arcs by cubic
|
||||
// polynomials." Computer-Aided Geometric Design 8(1991) 227--238.
|
||||
// Maisonobe, Luc. "Drawing an elliptical arc using polylines,
|
||||
// quadratic, or cubic Bezier curves."
|
||||
// http://www.spaceroots.org/documents/ellipse/elliptical-arc.pdf
|
||||
//
|
||||
// We follow the approach in section 2 of Goldapp (least-error,
|
||||
// Hermite-type approximation) and make both ratios equal to
|
||||
//
|
||||
// 2 2 + n - sqrt(2n + 28)
|
||||
// alpha = - * ---------------------
|
||||
// 3 n - 4
|
||||
//
|
||||
// where n = 3( cbrt(sqrt(2)+1) - cbrt(sqrt(2)-1) ).
|
||||
//
|
||||
// This is the result of Goldapp's equation (10b) when the angle
|
||||
// swept out by the arc is pi/2, and the parameter "a-bar" is the
|
||||
// expression given immediately below equation (21).
|
||||
//
|
||||
// Using this value, the maximum radial error for a circle, as a
|
||||
// fraction of the radius, is on the order of 0.2 x 10^-3.
|
||||
// Neither Dokken nor Goldapp discusses error for a general
|
||||
// ellipse; Maisonobe does, but his choice of control points
|
||||
// follows different constraints, and Goldapp's expression for
|
||||
// 'alpha' gives much smaller radial error, even for very flat
|
||||
// ellipses, than Maisonobe's equivalent.
|
||||
//
|
||||
// For the various corners and for each axis, the sign of this
|
||||
// constant changes, or it might be 0 -- it's multiplied by the
|
||||
// appropriate multiplier from the list before using.
|
||||
#[allow(non_snake_case)]
|
||||
fn create_border_path_segment(&self,
|
||||
path_builder: &mut PathBuilder,
|
||||
|
|
1355
tests/html/border_twitter_fail_whale.html
Normal file
1355
tests/html/border_twitter_fail_whale.html
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue