forked from mirrors/gecko-dev
Bug 1880934 - Update aa-stroke to include f32 bezier flattener. r=lsalzman
This should slightly help performance and should not noticeably impact quality. Differential Revision: https://phabricator.services.mozilla.com/D202190
This commit is contained in:
parent
1a596d38ec
commit
95ba0fd6ee
6 changed files with 53 additions and 53 deletions
|
|
@ -5,9 +5,9 @@
|
|||
[source.crates-io]
|
||||
replace-with = "vendored-sources"
|
||||
|
||||
[source."git+https://github.com/FirefoxGraphics/aa-stroke?rev=96e66f91bb8e8efb80ff144eabd668002aa89650"]
|
||||
[source."git+https://github.com/FirefoxGraphics/aa-stroke?rev=d94278ed9c7020f50232689a26d1277eb0eb74d2"]
|
||||
git = "https://github.com/FirefoxGraphics/aa-stroke"
|
||||
rev = "96e66f91bb8e8efb80ff144eabd668002aa89650"
|
||||
rev = "d94278ed9c7020f50232689a26d1277eb0eb74d2"
|
||||
replace-with = "vendored-sources"
|
||||
|
||||
[source."git+https://github.com/FirefoxGraphics/wpf-gpu-raster?rev=99979da091fd58fba8477e7fcdf5ec0727102916"]
|
||||
|
|
|
|||
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -5,7 +5,7 @@ version = 3
|
|||
[[package]]
|
||||
name = "aa-stroke"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/FirefoxGraphics/aa-stroke?rev=96e66f91bb8e8efb80ff144eabd668002aa89650#96e66f91bb8e8efb80ff144eabd668002aa89650"
|
||||
source = "git+https://github.com/FirefoxGraphics/aa-stroke?rev=d94278ed9c7020f50232689a26d1277eb0eb74d2#d94278ed9c7020f50232689a26d1277eb0eb74d2"
|
||||
dependencies = [
|
||||
"euclid",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{"files":{".github/workflows/rust.yml":"6a9f1b122ea02367a2f1ff1fc7b9a728284ceb47fad12e1610cde9d760f4efc3","Cargo.toml":"f507cac11c3c26af28420d68ec3748a5453322d51ef1379a340fdd3b1c9b187a","README.md":"60b34cfa653114d5054009696df2ed2ea1d4926a6bc312d0cac4b84845c2beff","examples/simple.rs":"c196e79568fe4be31a08374aa451c70c9377db5428aef924a985e069c12ed91e","src/bezierflattener.rs":"61687da22490cb1bd901d0b5eb1de3a98802b46c03719ded4163c7a4997f0ad9","src/c_bindings.rs":"06225ddd132ae959eda1b445f4e375cead4d8e135c5cba81e828815fe6a5e88b","src/lib.rs":"fc7990e62434f3143b5162aba85ea828ceab51447c5fad5e26e8c6b06ec77050","src/tri_rasterize.rs":"fb6f595ab9340d8ea6429b41638c378bbd772c8e4d8f7793e225624c12cd3a21"},"package":null}
|
||||
{"files":{".github/workflows/rust.yml":"6a9f1b122ea02367a2f1ff1fc7b9a728284ceb47fad12e1610cde9d760f4efc3","Cargo.toml":"f507cac11c3c26af28420d68ec3748a5453322d51ef1379a340fdd3b1c9b187a","README.md":"60b34cfa653114d5054009696df2ed2ea1d4926a6bc312d0cac4b84845c2beff","examples/simple.rs":"c196e79568fe4be31a08374aa451c70c9377db5428aef924a985e069c12ed91e","src/bezierflattener.rs":"c7183a850d51525db4389d5c0badb76e1d8c4110697bfa51ef746fda6a858bb9","src/c_bindings.rs":"06225ddd132ae959eda1b445f4e375cead4d8e135c5cba81e828815fe6a5e88b","src/lib.rs":"3009746efe5f6753cd999258077a4baea30a740190e7a8ccaec0d78f4719fdfb","src/tri_rasterize.rs":"fb6f595ab9340d8ea6429b41638c378bbd772c8e4d8f7793e225624c12cd3a21"},"package":null}
|
||||
|
|
@ -16,8 +16,8 @@ pub type HRESULT = i32;
|
|||
pub const S_OK: i32 = 0;
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct GpPointR {
|
||||
pub x: f64,
|
||||
pub y: f64
|
||||
pub x: f32,
|
||||
pub y: f32
|
||||
}
|
||||
|
||||
impl Sub for GpPointR {
|
||||
|
|
@ -48,32 +48,32 @@ impl SubAssign for GpPointR {
|
|||
}
|
||||
}
|
||||
|
||||
impl MulAssign<f64> for GpPointR {
|
||||
fn mul_assign(&mut self, rhs: f64) {
|
||||
impl MulAssign<f32> for GpPointR {
|
||||
fn mul_assign(&mut self, rhs: f32) {
|
||||
*self = *self * rhs;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl Mul<f64> for GpPointR {
|
||||
impl Mul<f32> for GpPointR {
|
||||
type Output = Self;
|
||||
|
||||
fn mul(self, rhs: f64) -> Self::Output {
|
||||
fn mul(self, rhs: f32) -> Self::Output {
|
||||
GpPointR { x: self.x * rhs, y: self.y * rhs }
|
||||
}
|
||||
}
|
||||
|
||||
impl Div<f64> for GpPointR {
|
||||
impl Div<f32> for GpPointR {
|
||||
type Output = Self;
|
||||
|
||||
fn div(self, rhs: f64) -> Self::Output {
|
||||
fn div(self, rhs: f32) -> Self::Output {
|
||||
GpPointR { x: self.x / rhs, y: self.y / rhs }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl Mul for GpPointR {
|
||||
type Output = f64;
|
||||
type Output = f32;
|
||||
|
||||
fn mul(self, rhs: Self) -> Self::Output {
|
||||
self.x * rhs.x + self.y * rhs.y
|
||||
|
|
@ -81,17 +81,17 @@ impl Mul for GpPointR {
|
|||
}
|
||||
|
||||
impl GpPointR {
|
||||
pub fn ApproxNorm(&self) -> f64 {
|
||||
pub fn ApproxNorm(&self) -> f32 {
|
||||
self.x.abs().max(self.y.abs())
|
||||
}
|
||||
pub fn Norm(&self) -> f64 {
|
||||
pub fn Norm(&self) -> f32 {
|
||||
self.x.hypot(self.y)
|
||||
}
|
||||
}
|
||||
|
||||
// Relative to this is relative to the tolerance squared. In other words, a vector
|
||||
// whose length is less than .01*tolerance will be considered 0
|
||||
const SQ_LENGTH_FUZZ: f64 = 1.0e-4;
|
||||
const SQ_LENGTH_FUZZ: f32 = 1.0e-4;
|
||||
|
||||
// Some of these constants need further thinking
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ const SQ_LENGTH_FUZZ: f64 = 1.0e-4;
|
|||
const FUZZ_DOUBLE: f64 = 1.0e-12; // Double-precision relative 0
|
||||
const MIN_TOLERANCE: f64 = 1.0e-6;
|
||||
const DEFAULT_FLATTENING_TOLERANCE: f64 = 0.25;*/
|
||||
const TWICE_MIN_BEZIER_STEP_SIZE: f64 = 1.0e-3; // The step size in the Bezier flattener should
|
||||
const TWICE_MIN_BEZIER_STEP_SIZE: f32 = 1.0e-3; // The step size in the Bezier flattener should
|
||||
// never go below half this amount.
|
||||
//+-----------------------------------------------------------------------------
|
||||
//
|
||||
|
|
@ -318,7 +318,7 @@ pub trait CFlatteningSink {
|
|||
fn AcceptPoint(&mut self,
|
||||
pt: &GpPointR,
|
||||
// The point
|
||||
t: f64,
|
||||
t: f32,
|
||||
// Parameter we're at
|
||||
fAborted: &mut bool,
|
||||
lastPoint: bool
|
||||
|
|
@ -339,16 +339,16 @@ pub struct CBezierFlattener<'a>
|
|||
bezier: CBezier,
|
||||
// Flattening defining data
|
||||
m_pSink: &'a mut dyn CFlatteningSink, // The recipient of the flattening data
|
||||
m_rTolerance: f64, // Prescribed tolerance
|
||||
m_rTolerance: f32, // Prescribed tolerance
|
||||
m_fWithTangents: bool, // Generate tangent vectors if true
|
||||
m_rQuarterTolerance: f64,// Prescribed tolerance/4 (for doubling the step)
|
||||
m_rFuzz: f64, // Computational zero
|
||||
m_rQuarterTolerance: f32,// Prescribed tolerance/4 (for doubling the step)
|
||||
m_rFuzz: f32, // Computational zero
|
||||
|
||||
// Flattening working data
|
||||
m_ptE: [GpPointR; 4], // The moving basis of the curve definition
|
||||
m_cSteps: i32, // The number of steps left to the end of the curve
|
||||
m_rParameter: f64, // Parameter value
|
||||
m_rStepSize: f64, // Steps size in parameter domain
|
||||
m_rParameter: f32, // Parameter value
|
||||
m_rStepSize: f32, // Steps size in parameter domain
|
||||
}
|
||||
impl<'a> CBezierFlattener<'a> {
|
||||
/*fn new(
|
||||
|
|
@ -449,7 +449,7 @@ impl<'a> CBezierFlattener<'a> {
|
|||
pub fn new(bezier: &CBezier,
|
||||
pSink: &'a mut dyn CFlatteningSink,
|
||||
// The reciptient of the flattened data
|
||||
rTolerance: f64) // Flattening tolerance
|
||||
rTolerance: f32) // Flattening tolerance
|
||||
-> Self
|
||||
{
|
||||
let mut result = CBezierFlattener {
|
||||
|
|
|
|||
56
third_party/rust/aa-stroke/src/lib.rs
vendored
56
third_party/rust/aa-stroke/src/lib.rs
vendored
|
|
@ -230,8 +230,8 @@ fn arc_segment_tri(path: &mut PathBuilder, xc: f32, yc: f32, radius: f32, a: Vec
|
|||
|
||||
let h = (4. / 3.) * dot(perp(a), mid2) / dot(a, mid2);
|
||||
|
||||
let last_point = GpPointR { x: (xc + r_cos_a) as f64, y: (yc + r_sin_a) as f64 };
|
||||
let initial_normal = GpPointR { x: a.x as f64, y: a.y as f64 };
|
||||
let last_point = GpPointR { x: (xc + r_cos_a), y: (yc + r_sin_a) };
|
||||
let initial_normal = GpPointR { x: a.x, y: a.y };
|
||||
|
||||
|
||||
struct Target<'a, 'b> { last_point: GpPointR, last_normal: GpPointR, xc: f32, yc: f32, path: &'a mut PathBuilder<'b> }
|
||||
|
|
@ -253,24 +253,24 @@ fn arc_segment_tri(path: &mut PathBuilder, xc: f32, yc: f32, radius: f32, a: Vec
|
|||
let width = 0.5;
|
||||
|
||||
self.path.ramp(
|
||||
(pt.x - normal.x * width) as f32,
|
||||
(pt.y - normal.y * width) as f32,
|
||||
(pt.x + normal.x * width) as f32,
|
||||
(pt.y + normal.y * width) as f32,
|
||||
(self.last_point.x + self.last_normal.x * width) as f32,
|
||||
(self.last_point.y + self.last_normal.y * width) as f32,
|
||||
(self.last_point.x - self.last_normal.x * width) as f32,
|
||||
(self.last_point.y - self.last_normal.y * width) as f32, );
|
||||
pt.x - normal.x * width,
|
||||
pt.y - normal.y * width,
|
||||
pt.x + normal.x * width,
|
||||
pt.y + normal.y * width,
|
||||
self.last_point.x + self.last_normal.x * width,
|
||||
self.last_point.y + self.last_normal.y * width,
|
||||
self.last_point.x - self.last_normal.x * width,
|
||||
self.last_point.y - self.last_normal.y * width, );
|
||||
self.path.push_tri(
|
||||
(self.last_point.x - self.last_normal.x * 0.5) as f32,
|
||||
(self.last_point.y - self.last_normal.y * 0.5) as f32,
|
||||
(pt.x - normal.x * 0.5) as f32,
|
||||
(pt.y - normal.y * 0.5) as f32,
|
||||
self.last_point.x - self.last_normal.x * 0.5,
|
||||
self.last_point.y - self.last_normal.y * 0.5,
|
||||
pt.x - normal.x * 0.5,
|
||||
pt.y - normal.y * 0.5,
|
||||
self.xc, self.yc);
|
||||
self.last_normal = normal;
|
||||
|
||||
} else {
|
||||
self.path.push_tri(self.last_point.x as f32, self.last_point.y as f32, pt.x as f32, pt.y as f32, self.xc, self.yc);
|
||||
self.path.push_tri(self.last_point.x, self.last_point.y, pt.x, pt.y, self.xc, self.yc);
|
||||
}
|
||||
self.last_point = pt.clone();
|
||||
return S_OK;
|
||||
|
|
@ -279,19 +279,19 @@ fn arc_segment_tri(path: &mut PathBuilder, xc: f32, yc: f32, radius: f32, a: Vec
|
|||
fn AcceptPoint(&mut self,
|
||||
pt: &GpPointR,
|
||||
// The point
|
||||
_t: f64,
|
||||
_t: f32,
|
||||
// Parameter we're at
|
||||
_aborted: &mut bool,
|
||||
_last_point: bool) -> HRESULT {
|
||||
self.path.push_tri(self.last_point.x as f32, self.last_point.y as f32, pt.x as f32, pt.y as f32, self.xc, self.yc);
|
||||
self.path.push_tri(self.last_point.x, self.last_point.y, pt.x, pt.y, self.xc, self.yc);
|
||||
self.last_point = pt.clone();
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
let bezier = CBezier::new([GpPointR { x: (xc + r_cos_a) as f64, y: (yc + r_sin_a) as f64, },
|
||||
GpPointR { x: (xc + r_cos_a - h * r_sin_a) as f64, y: (yc + r_sin_a + h * r_cos_a) as f64, },
|
||||
GpPointR { x: (xc + r_cos_b + h * r_sin_b) as f64, y: (yc + r_sin_b - h * r_cos_b) as f64, },
|
||||
GpPointR { x: (xc + r_cos_b) as f64, y: (yc + r_sin_b) as f64, }]);
|
||||
let bezier = CBezier::new([GpPointR { x: (xc + r_cos_a), y: (yc + r_sin_a), },
|
||||
GpPointR { x: (xc + r_cos_a - h * r_sin_a), y: (yc + r_sin_a + h * r_cos_a), },
|
||||
GpPointR { x: (xc + r_cos_b + h * r_sin_b), y: (yc + r_sin_b - h * r_cos_b), },
|
||||
GpPointR { x: (xc + r_cos_b), y: (yc + r_sin_b), }]);
|
||||
if bezier.is_degenerate() {
|
||||
return;
|
||||
}
|
||||
|
|
@ -810,23 +810,23 @@ impl<'z> Stroker<'z> {
|
|||
fn AcceptPoint(&mut self,
|
||||
pt: &GpPointR,
|
||||
// The point
|
||||
_t: f64,
|
||||
_t: f32,
|
||||
// Parameter we're at
|
||||
_aborted: &mut bool,
|
||||
last_point: bool) -> HRESULT {
|
||||
if last_point && self.end {
|
||||
self.stroker.line_to_capped(Point::new(pt.x as f32, pt.y as f32));
|
||||
self.stroker.line_to_capped(Point::new(pt.x, pt.y));
|
||||
} else {
|
||||
self.stroker.line_to(Point::new(pt.x as f32, pt.y as f32));
|
||||
self.stroker.line_to(Point::new(pt.x, pt.y));
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
let cur_pt = self.cur_pt.unwrap_or(cx1);
|
||||
let bezier = CBezier::new([GpPointR { x: cur_pt.x as f64, y: cur_pt.y as f64, },
|
||||
GpPointR { x: cx1.x as f64, y: cx1.y as f64, },
|
||||
GpPointR { x: cx2.x as f64, y: cx2.y as f64, },
|
||||
GpPointR { x: pt.x as f64, y: pt.y as f64, }]);
|
||||
let bezier = CBezier::new([GpPointR { x: cur_pt.x, y: cur_pt.y, },
|
||||
GpPointR { x: cx1.x, y: cx1.y, },
|
||||
GpPointR { x: cx2.x, y: cx2.y, },
|
||||
GpPointR { x: pt.x, y: pt.y, }]);
|
||||
let mut t = Target{ stroker: self, end };
|
||||
let mut f = CBezierFlattener::new(&bezier, &mut t, 0.25);
|
||||
f.Flatten(false);
|
||||
|
|
|
|||
|
|
@ -101,7 +101,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 = "99979da091fd58fba8477e7fcdf5ec0727102916" }
|
||||
aa-stroke = { git = "https://github.com/FirefoxGraphics/aa-stroke", rev = "96e66f91bb8e8efb80ff144eabd668002aa89650" }
|
||||
aa-stroke = { git = "https://github.com/FirefoxGraphics/aa-stroke", rev = "d94278ed9c7020f50232689a26d1277eb0eb74d2" }
|
||||
|
||||
url = "2.5.0"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue