зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1848532 - Update aa-stroke to fix butt caps. r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D186085
This commit is contained in:
Родитель
56b81cde72
Коммит
4647149548
|
@ -5,9 +5,9 @@
|
|||
[source.crates-io]
|
||||
replace-with = "vendored-sources"
|
||||
|
||||
[source."git+https://github.com/FirefoxGraphics/aa-stroke?rev=cfe9ee39f5af56ae26004835d90c4bb2973ce519"]
|
||||
[source."git+https://github.com/FirefoxGraphics/aa-stroke?rev=c1916bc1b5336438207881a362fc3dd921d915e4"]
|
||||
git = "https://github.com/FirefoxGraphics/aa-stroke"
|
||||
rev = "cfe9ee39f5af56ae26004835d90c4bb2973ce519"
|
||||
rev = "c1916bc1b5336438207881a362fc3dd921d915e4"
|
||||
replace-with = "vendored-sources"
|
||||
|
||||
[source."git+https://github.com/FirefoxGraphics/wpf-gpu-raster?rev=5ab6fe33d00021325ee920b3c10526dc8301cf46"]
|
||||
|
|
|
@ -5,7 +5,7 @@ version = 3
|
|||
[[package]]
|
||||
name = "aa-stroke"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/FirefoxGraphics/aa-stroke?rev=cfe9ee39f5af56ae26004835d90c4bb2973ce519#cfe9ee39f5af56ae26004835d90c4bb2973ce519"
|
||||
source = "git+https://github.com/FirefoxGraphics/aa-stroke?rev=c1916bc1b5336438207881a362fc3dd921d915e4#c1916bc1b5336438207881a362fc3dd921d915e4"
|
||||
dependencies = [
|
||||
"euclid",
|
||||
]
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"files":{".github/workflows/rust.yml":"e859b12cfed145b66e4fbf1571dde15880359717ca5b0a9720341229183f2c6f","Cargo.toml":"f507cac11c3c26af28420d68ec3748a5453322d51ef1379a340fdd3b1c9b187a","README.md":"60b34cfa653114d5054009696df2ed2ea1d4926a6bc312d0cac4b84845c2beff","examples/simple.rs":"c196e79568fe4be31a08374aa451c70c9377db5428aef924a985e069c12ed91e","src/bezierflattener.rs":"61687da22490cb1bd901d0b5eb1de3a98802b46c03719ded4163c7a4997f0ad9","src/c_bindings.rs":"23890f7bb5d40d87d72b28842821ada7b2e1509a3b37c9af8ed0055036ceadcc","src/lib.rs":"21d02fdcc8491a03b19ec90dfeae05fb569f73500cf1bb89ba71d6e838dc0b0d","src/tri_rasterize.rs":"fb6f595ab9340d8ea6429b41638c378bbd772c8e4d8f7793e225624c12cd3a21"},"package":null}
|
||||
{"files":{".github/workflows/rust.yml":"e859b12cfed145b66e4fbf1571dde15880359717ca5b0a9720341229183f2c6f","Cargo.toml":"f507cac11c3c26af28420d68ec3748a5453322d51ef1379a340fdd3b1c9b187a","README.md":"60b34cfa653114d5054009696df2ed2ea1d4926a6bc312d0cac4b84845c2beff","examples/simple.rs":"c196e79568fe4be31a08374aa451c70c9377db5428aef924a985e069c12ed91e","src/bezierflattener.rs":"61687da22490cb1bd901d0b5eb1de3a98802b46c03719ded4163c7a4997f0ad9","src/c_bindings.rs":"23890f7bb5d40d87d72b28842821ada7b2e1509a3b37c9af8ed0055036ceadcc","src/lib.rs":"022bf8fd13d9f097b5d905d01d3632258b41697c9b07c3674444bc4fa3e9e800","src/tri_rasterize.rs":"fb6f595ab9340d8ea6429b41638c378bbd772c8e4d8f7793e225624c12cd3a21"},"package":null}
|
|
@ -540,7 +540,7 @@ fn line_intersection(a: Point, a_perp: Vector, b: Point, b_perp: Vector) -> Opti
|
|||
|
||||
fn is_interior_angle(a: Vector, b: Vector) -> bool {
|
||||
/* angles of 180 and 0 degress will evaluate to 0, however
|
||||
* we to treat 180 as an interior angle and 180 as an exterior angle */
|
||||
* we to treat 0 as an interior angle and 180 as an exterior angle */
|
||||
dot(perp(a), b) > 0. || a == b /* 0 degrees is interior */
|
||||
}
|
||||
|
||||
|
@ -659,7 +659,9 @@ impl<'z> Stroker<'z> {
|
|||
pub fn line_to_capped(&mut self, pt: Point) {
|
||||
if let Some(cur_pt) = self.cur_pt {
|
||||
let normal = compute_normal(cur_pt, pt).unwrap_or(self.last_normal);
|
||||
self.line_to(if self.stroked_path.aa && self.style.cap == LineCap::Butt { pt - flip(normal) * 0.5} else { pt });
|
||||
// if we have a butt cap end the line half a pixel early so we have room to put the cap.
|
||||
// XXX: this will probably mess things up if the line is shorter than 1/2 pixel long
|
||||
self.line_to(if self.stroked_path.aa && self.style.cap == LineCap::Butt { pt + perp(normal) * 0.5} else { pt });
|
||||
if let (Some(cur_pt), Some((_point, _normal))) = (self.cur_pt, self.start_point) {
|
||||
// cap end
|
||||
cap_line(&mut self.stroked_path, &self.style, cur_pt, self.last_normal);
|
||||
|
@ -686,10 +688,13 @@ impl<'z> Stroker<'z> {
|
|||
if self.start_point.is_none() {
|
||||
if !self.closed_subpath {
|
||||
// cap beginning
|
||||
cap_line(stroked_path, &self.style, cur_pt, flip(normal));
|
||||
let mut cur_pt = cur_pt;
|
||||
if stroked_path.aa && self.style.cap == LineCap::Butt {
|
||||
|
||||
// adjust the starting point to make room for the cap
|
||||
// XXX: this will probably mess things up if the line is shorter than 1/2 pixel long
|
||||
cur_pt += perp(flip(normal)) * 0.5;
|
||||
}
|
||||
cap_line(stroked_path, &self.style, cur_pt, flip(normal));
|
||||
}
|
||||
self.start_point = Some((cur_pt, normal));
|
||||
} else {
|
||||
|
@ -888,6 +893,21 @@ fn curve() {
|
|||
assert_eq!(stroked.len(), 1089);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn butt_cap() {
|
||||
let mut stroker = Stroker::new(&StrokeStyle{
|
||||
cap: LineCap::Butt,
|
||||
join: LineJoin::Bevel,
|
||||
width: 1.,
|
||||
..Default::default()});
|
||||
stroker.move_to(Point::new(20., 20.5), false);
|
||||
stroker.line_to_capped(Point::new(40., 20.5));
|
||||
let result = stroker.finish();
|
||||
for v in result {
|
||||
assert!(v.y == 20.5 || v.y == 19.5 || v.y == 21.5);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn width_one_radius_arc() {
|
||||
// previously this caused us to try to flatten an arc with radius 0
|
||||
|
|
|
@ -95,7 +95,7 @@ processtools = { path = "../../../components/processtools" }
|
|||
qcms = { path = "../../../../gfx/qcms", features = ["c_bindings", "neon"], default-features = false }
|
||||
|
||||
wpf-gpu-raster = { git = "https://github.com/FirefoxGraphics/wpf-gpu-raster", rev = "5ab6fe33d00021325ee920b3c10526dc8301cf46" }
|
||||
aa-stroke = { git = "https://github.com/FirefoxGraphics/aa-stroke", rev = "cfe9ee39f5af56ae26004835d90c4bb2973ce519" }
|
||||
aa-stroke = { git = "https://github.com/FirefoxGraphics/aa-stroke", rev = "c1916bc1b5336438207881a362fc3dd921d915e4" }
|
||||
|
||||
# Force url to stay at 2.1.0. See bug 1734538.
|
||||
url = "=2.1.0"
|
||||
|
|
Загрузка…
Ссылка в новой задаче