Rename "bezieroid" to "B-quad"
This commit is contained in:
parent
56101cea9a
commit
0edb604612
|
@ -6,7 +6,7 @@ use partitioner::Partitioner;
|
|||
use tessellator::{QuadTessLevels, Tessellator};
|
||||
use std::mem;
|
||||
use std::slice;
|
||||
use {AntialiasingMode, Bezieroid, ControlPoints, Endpoint, Subpath, Vertex};
|
||||
use {AntialiasingMode, BQuad, ControlPoints, Endpoint, Subpath, Vertex};
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[repr(C)]
|
||||
|
@ -53,14 +53,14 @@ pub unsafe extern fn pf_partitioner_partition<'a>(partitioner: *mut Partitioner<
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern fn pf_partitioner_bezieroids<'a>(partitioner: *mut Partitioner<'a>,
|
||||
out_bezieroid_count: *mut u32)
|
||||
-> *const Bezieroid {
|
||||
let bezieroids = (*partitioner).bezieroids();
|
||||
if !out_bezieroid_count.is_null() {
|
||||
*out_bezieroid_count = bezieroids.len() as u32
|
||||
pub unsafe extern fn pf_partitioner_b_quads<'a>(partitioner: *mut Partitioner<'a>,
|
||||
out_b_quad_count: *mut u32)
|
||||
-> *const BQuad {
|
||||
let b_quads = (*partitioner).b_quads();
|
||||
if !out_b_quad_count.is_null() {
|
||||
*out_b_quad_count = b_quads.len() as u32
|
||||
}
|
||||
bezieroids.as_ptr()
|
||||
b_quads.as_ptr()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
@ -68,7 +68,7 @@ pub unsafe extern fn pf_tessellator_new(endpoints: *const Endpoint,
|
|||
endpoint_count: u32,
|
||||
control_points: *const ControlPoints,
|
||||
control_points_count: u32,
|
||||
b_quads: *const Bezieroid,
|
||||
b_quads: *const BQuad,
|
||||
b_quad_count: u32,
|
||||
antialiasing_mode: AntialiasingMode)
|
||||
-> *mut Tessellator<'static> {
|
||||
|
|
|
@ -21,7 +21,7 @@ pub mod tessellator;
|
|||
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct Bezieroid {
|
||||
pub struct BQuad {
|
||||
pub upper_prev_endpoint: u32,
|
||||
pub upper_next_endpoint: u32,
|
||||
pub lower_prev_endpoint: u32,
|
||||
|
|
|
@ -7,14 +7,14 @@ use log::LogLevel;
|
|||
use std::collections::BinaryHeap;
|
||||
use std::cmp::{self, Ordering};
|
||||
use std::u32;
|
||||
use {Bezieroid, ControlPoints, Endpoint, Subpath};
|
||||
use {BQuad, ControlPoints, Endpoint, Subpath};
|
||||
|
||||
pub struct Partitioner<'a> {
|
||||
endpoints: &'a [Endpoint],
|
||||
control_points: &'a [ControlPoints],
|
||||
subpaths: &'a [Subpath],
|
||||
|
||||
bezieroids: Vec<Bezieroid>,
|
||||
b_quads: Vec<BQuad>,
|
||||
|
||||
heap: BinaryHeap<Point>,
|
||||
visited_points: BitVec,
|
||||
|
@ -29,7 +29,7 @@ impl<'a> Partitioner<'a> {
|
|||
control_points: &[],
|
||||
subpaths: &[],
|
||||
|
||||
bezieroids: vec![],
|
||||
b_quads: vec![],
|
||||
|
||||
heap: BinaryHeap::new(),
|
||||
visited_points: BitVec::new(),
|
||||
|
@ -51,7 +51,7 @@ impl<'a> Partitioner<'a> {
|
|||
}
|
||||
|
||||
pub fn partition(&mut self, first_subpath_index: u32, last_subpath_index: u32) {
|
||||
self.bezieroids.clear();
|
||||
self.b_quads.clear();
|
||||
self.heap.clear();
|
||||
self.active_edges.clear();
|
||||
|
||||
|
@ -61,8 +61,8 @@ impl<'a> Partitioner<'a> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn bezieroids(&self) -> &[Bezieroid] {
|
||||
&self.bezieroids
|
||||
pub fn b_quads(&self) -> &[BQuad] {
|
||||
&self.b_quads
|
||||
}
|
||||
|
||||
fn process_next_point(&mut self) -> bool {
|
||||
|
@ -124,7 +124,7 @@ impl<'a> Partitioner<'a> {
|
|||
|
||||
let endpoint = &self.endpoints[endpoint_index as usize];
|
||||
if self.should_fill_above_active_edge(next_active_edge_index) {
|
||||
self.emit_bezieroid_above(next_active_edge_index, endpoint.position.x)
|
||||
self.emit_b_quad_above(next_active_edge_index, endpoint.position.x)
|
||||
}
|
||||
|
||||
self.add_new_edges_for_min_point(endpoint_index, next_active_edge_index);
|
||||
|
@ -147,10 +147,10 @@ impl<'a> Partitioner<'a> {
|
|||
|
||||
let endpoint = &self.endpoints[endpoint_index as usize];
|
||||
if self.should_fill_below_active_edge(active_edge_index) {
|
||||
self.emit_bezieroid_below(active_edge_index, endpoint.position.x)
|
||||
self.emit_b_quad_below(active_edge_index, endpoint.position.x)
|
||||
}
|
||||
if self.should_fill_above_active_edge(active_edge_index) {
|
||||
self.emit_bezieroid_above(active_edge_index, endpoint.position.x)
|
||||
self.emit_b_quad_above(active_edge_index, endpoint.position.x)
|
||||
}
|
||||
|
||||
let prev_endpoint_index = self.prev_endpoint_of(endpoint_index);
|
||||
|
@ -185,13 +185,13 @@ impl<'a> Partitioner<'a> {
|
|||
let endpoint = &self.endpoints[endpoint_index as usize];
|
||||
|
||||
if self.should_fill_above_active_edge(active_edge_indices[0]) {
|
||||
self.emit_bezieroid_above(active_edge_indices[0], endpoint.position.x)
|
||||
self.emit_b_quad_above(active_edge_indices[0], endpoint.position.x)
|
||||
}
|
||||
if self.should_fill_above_active_edge(active_edge_indices[1]) {
|
||||
self.emit_bezieroid_above(active_edge_indices[1], endpoint.position.x)
|
||||
self.emit_b_quad_above(active_edge_indices[1], endpoint.position.x)
|
||||
}
|
||||
if self.should_fill_below_active_edge(active_edge_indices[1]) {
|
||||
self.emit_bezieroid_below(active_edge_indices[1], endpoint.position.x)
|
||||
self.emit_b_quad_below(active_edge_indices[1], endpoint.position.x)
|
||||
}
|
||||
|
||||
self.heap.pop();
|
||||
|
@ -205,10 +205,10 @@ impl<'a> Partitioner<'a> {
|
|||
|
||||
fn process_crossing_point(&mut self, x: f32, upper_active_edge_index: u32) {
|
||||
if self.should_fill_above_active_edge(upper_active_edge_index) {
|
||||
self.emit_bezieroid_above(upper_active_edge_index, x)
|
||||
self.emit_b_quad_above(upper_active_edge_index, x)
|
||||
}
|
||||
if self.should_fill_below_active_edge(upper_active_edge_index) {
|
||||
self.emit_bezieroid_below(upper_active_edge_index, x)
|
||||
self.emit_b_quad_below(upper_active_edge_index, x)
|
||||
}
|
||||
|
||||
// Swap the two edges.
|
||||
|
@ -285,23 +285,23 @@ impl<'a> Partitioner<'a> {
|
|||
active_edge_index % 2 == 1
|
||||
}
|
||||
|
||||
fn emit_bezieroid_below(&mut self, upper_active_edge_index: u32, right_x: f32) {
|
||||
self.emit_bezieroid_above(upper_active_edge_index + 1, right_x)
|
||||
fn emit_b_quad_below(&mut self, upper_active_edge_index: u32, right_x: f32) {
|
||||
self.emit_b_quad_above(upper_active_edge_index + 1, right_x)
|
||||
}
|
||||
|
||||
fn emit_bezieroid_above(&mut self, lower_active_edge_index: u32, right_x: f32) {
|
||||
fn emit_b_quad_above(&mut self, lower_active_edge_index: u32, right_x: f32) {
|
||||
// TODO(pcwalton): Assert that the green X position is the same on both edges.
|
||||
debug_assert!(lower_active_edge_index > 0,
|
||||
"Can't emit bezieroids above the top active edge");
|
||||
"Can't emit b_quads above the top active edge");
|
||||
let upper_active_edge_index = lower_active_edge_index - 1;
|
||||
|
||||
let new_bezieroid;
|
||||
let new_b_quad;
|
||||
|
||||
{
|
||||
let lower_active_edge = &self.active_edges[lower_active_edge_index as usize];
|
||||
let upper_active_edge = &self.active_edges[upper_active_edge_index as usize];
|
||||
|
||||
new_bezieroid = Bezieroid {
|
||||
new_b_quad = BQuad {
|
||||
upper_prev_endpoint: upper_active_edge.prev_endpoint_index(),
|
||||
upper_next_endpoint: upper_active_edge.next_endpoint_index(),
|
||||
lower_prev_endpoint: lower_active_edge.prev_endpoint_index(),
|
||||
|
@ -312,11 +312,11 @@ impl<'a> Partitioner<'a> {
|
|||
lower_right_time: self.solve_t_for_active_edge(lower_active_edge_index, right_x),
|
||||
};
|
||||
|
||||
self.bezieroids.push(new_bezieroid);
|
||||
self.b_quads.push(new_b_quad);
|
||||
}
|
||||
|
||||
self.active_edges[upper_active_edge_index as usize].time = new_bezieroid.upper_right_time;
|
||||
self.active_edges[lower_active_edge_index as usize].time = new_bezieroid.lower_right_time;
|
||||
self.active_edges[upper_active_edge_index as usize].time = new_b_quad.upper_right_time;
|
||||
self.active_edges[lower_active_edge_index as usize].time = new_b_quad.lower_right_time;
|
||||
}
|
||||
|
||||
fn already_visited_point(&self, point: &Point) -> bool {
|
||||
|
|
|
@ -45,14 +45,14 @@ struct pf_quad_tess_levels {
|
|||
|
||||
typedef struct pf_quad_tess_levels pf_quad_tess_levels_t;
|
||||
|
||||
struct pf_bezieroid {
|
||||
struct pf_b_quad {
|
||||
uint32_t upper_prev_endpoint, upper_next_endpoint;
|
||||
uint32_t lower_prev_endpoint, lower_next_endpoint;
|
||||
float upper_left_time, upper_right_time;
|
||||
float lower_left_time, lower_right_time;
|
||||
};
|
||||
|
||||
typedef struct pf_bezieroid pf_bezieroid_t;
|
||||
typedef struct pf_b_quad pf_b_quad_t;
|
||||
|
||||
struct pf_endpoint {
|
||||
pf_point2d_f32_t position;
|
||||
|
@ -99,14 +99,14 @@ void pf_partitioner_partition(pf_partitioner_t *partitioner,
|
|||
uint32_t first_subpath_index,
|
||||
uint32_t last_subpath_index);
|
||||
|
||||
const pf_bezieroid_t *pf_partitioner_bezieroids(pf_partitioner_t *partitioner,
|
||||
uint32_t *out_bezieroid_count);
|
||||
const pf_b_quad_t *pf_partitioner_b_quads(pf_partitioner_t *partitioner,
|
||||
uint32_t *out_b_quad_count);
|
||||
|
||||
pf_tessellator_t *pf_tessellator_new(const pf_endpoint_t *endpoints,
|
||||
uint32_t endpoint_count,
|
||||
const pf_control_points_t *control_points,
|
||||
uint32_t control_points_index,
|
||||
const pf_bezieroid_t *b_quads,
|
||||
const pf_b_quad_t *b_quads,
|
||||
uint32_t b_quad_count,
|
||||
pf_antialiasing_mode_t antialiasing_mode);
|
||||
|
||||
|
|
|
@ -6,14 +6,14 @@ use euclid::{Length, Transform2D};
|
|||
use half::{f16, self};
|
||||
use std::cmp;
|
||||
use std::u32;
|
||||
use {AntialiasingMode, Bezieroid, ControlPoints, Endpoint, Vertex};
|
||||
use {AntialiasingMode, BQuad, ControlPoints, Endpoint, Vertex};
|
||||
|
||||
const TOLERANCE: f32 = 0.25;
|
||||
|
||||
pub struct Tessellator<'a> {
|
||||
endpoints: &'a [Endpoint],
|
||||
control_points: &'a [ControlPoints],
|
||||
b_quads: &'a [Bezieroid],
|
||||
b_quads: &'a [BQuad],
|
||||
antialiasing_mode: AntialiasingMode,
|
||||
|
||||
tess_levels: Vec<QuadTessLevels>,
|
||||
|
@ -43,7 +43,7 @@ impl QuadTessLevels {
|
|||
impl<'a> Tessellator<'a> {
|
||||
pub fn new<'b>(endpoints: &'b [Endpoint],
|
||||
control_points: &'b [ControlPoints],
|
||||
b_quads: &'b [Bezieroid],
|
||||
b_quads: &'b [BQuad],
|
||||
antialiasing_mode: AntialiasingMode)
|
||||
-> Tessellator<'b> {
|
||||
Tessellator {
|
||||
|
|
Loading…
Reference in New Issue