Skip to content

Commit e2ff46f

Browse files
committed
refined b2d_sfp related code
1 parent abad70b commit e2ff46f

3 files changed

Lines changed: 101 additions & 87 deletions

File tree

build.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
104104
let module = "blend2d"; // "blend2d_bindings";
105105

106106
let mut cc = cc::Build::new();
107-
#[cfg(feature = "b2d_sfp")] { //println!("cargo:rustc-cfg=feature=\"b2d_sfp\"");
108-
#[cfg(target_arch = "aarch64")] cc.flag("-mno-outline-atomics");
109-
cc.define("BLEND2D_NO_DFP", None).flag("-fsingle-precision-constant")
110-
.define("BL_BUILD_NO_TLS", None).flag("-Wno-uninitialized").compiler("g++-13");
107+
#[cfg(feature = "b2d_sfp")] { #[cfg(target_arch = "aarch64")]
108+
cc.define("BL_BUILD_NO_TLS", None).flag("-mno-outline-atomics");
109+
cc.define("BLEND2D_NO_DFP", None).flag("-fsingle-precision-constant").compiler("g++-15");
111110
bgen = bgen.clang_arg("-DBLEND2D_NO_DFP");
112111
} // refer to blend2d/CMakeLists.txt
113112

@@ -154,7 +153,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
154153
}
155154
}
156155
} else /*if compiler.is_like_gnu() || compiler.is_like_clang() */{
157-
cc//.flag("-Wall").flags("-Wextra").flag("-Wonversion") // ignore all warning flags
156+
#[cfg(not(feature = "b2d_sfp"))] cc.flags(["-Wconversion", "-Wdouble-promotion"]);
157+
cc .flags(["-Wduplicated-cond", "-Wduplicated-branches", "-Wlogical-op",
158+
"-Wlogical-not-parentheses", "-Wrestrict", "-Wbidi-chars=any", ])
158159
.flag("-fno-exceptions").flag("-fno-rtti").flag("-fvisibility=hidden")
159160
.flag("-fno-math-errno").flag("-fno-threadsafe-statics")
160161
.flag("-fmerge-all-constants").flag_if_supported("-ftree-vectorize")

src/blend2d.rs

Lines changed: 85 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@
99
#![allow(unused)] #![allow(clippy::new_without_default)]
1010

1111
//pub mod blend2d { // https://blend2d.com
12-
use core::{mem, ptr::{self, null, null_mut}};
1312
use std::ffi::CString;
13+
use core::{mem, ptr::{self, null, null_mut}};
1414

1515
pub use b2d_ffi::{BLFormat, BLPoint, BLMatrix2D, BLImageData, BLRgba, BLRgba64,
1616
BLRgba32, BLFillRule, BLStrokeCap, BLStrokeJoin, BLCompOp, BLImageScaleFilter,
1717
BLRect, BLBox, BLLine, BLArc, BLCircle, BLEllipse, BLTriangle, BLRoundRect, BLHitTest,
1818
BLLinearGradientValues, BLRadialGradientValues, BLConicGradientValues};
1919

20+
#[cfg(feature = "b2d_sfp")] #[allow(non_camel_case_types)] type f64 = f32;
21+
#[cfg(feature = "b2d_sfp")] type F32 = std::primitive::f64; // XXX: API wrapper differ in f32
22+
#[cfg(not(feature = "b2d_sfp"))] type F32 = f32;
23+
2024
#[allow(non_camel_case_types)] //#[allow(non_upper_case_globals)] // blend2d_bindings
2125
mod b2d_ffi { include!("../target/bindings/blend2d.rs"); } use b2d_ffi::*;
2226
// concat!(env!("OUT_DIR"), "/blend2d.rs") // BGEN_DIR
@@ -74,17 +78,17 @@ impl BLContext { // https://blend2d.com/doc/group__bl__rendering.html
7478
#[inline] pub fn set_fill_rule(&mut self, fill_rule: BLFillRule) {
7579
safe_dbg!(bl_context_set_fill_rule(&mut self.0, fill_rule));
7680
}
77-
#[inline] pub fn set_fill_alpha(&mut self, alpha: f32) {
81+
#[inline] pub fn set_fill_alpha(&mut self, alpha: f64) {
7882
safe_dbg!(bl_context_set_fill_alpha(&mut self.0, alpha as _));
7983
}
8084

81-
#[inline] pub fn set_stroke_alpha(&mut self, alpha: f32) {
85+
#[inline] pub fn set_stroke_alpha(&mut self, alpha: f64) {
8286
safe_dbg!(bl_context_set_stroke_alpha(&mut self.0, alpha as _));
8387
}
8488
#[inline] pub fn set_stroke_style(&mut self, style: &dyn B2DStyle) {
8589
safe_dbg!(bl_context_set_stroke_style(&mut self.0, style as *const _ as _));
8690
}
87-
#[inline] pub fn set_stroke_width(&mut self, width: f32) {
91+
#[inline] pub fn set_stroke_width(&mut self, width: f64) {
8892
safe_dbg!(bl_context_set_stroke_width(&mut self.0, width as _));
8993
}
9094
#[inline] pub fn set_stroke_caps(&mut self, caps: BLStrokeCap) {
@@ -99,12 +103,12 @@ impl BLContext { // https://blend2d.com/doc/group__bl__rendering.html
99103
#[inline] pub fn set_stroke_join(&mut self, join: BLStrokeJoin) {
100104
safe_dbg!(bl_context_set_stroke_join(&mut self.0, join));
101105
}
102-
#[inline] pub fn set_stroke_miter_limit(&mut self, miter_limit: f32) {
106+
#[inline] pub fn set_stroke_miter_limit(&mut self, miter_limit: f64) {
103107
safe_dbg!(bl_context_set_stroke_miter_limit(&mut self.0, miter_limit as _));
104108
}
105-
#[inline] pub fn set_stroke_dash(&mut self, offset: f32, dash: &[f32]) {
109+
#[inline] pub fn set_stroke_dash(&mut self, offset: f64, dash: &[f64]) {
106110
safe_dbg!(bl_context_set_stroke_dash_offset(&mut self.0, offset as _));
107-
safe_dbg!(bl_context_set_stroke_dash_array(&mut self.0, &BLDashArray::new(dash).0));
111+
safe_dbg!(bl_context_set_stroke_dash_array(&mut self.0, &BLArrayFP::new(dash).0));
108112
}
109113
#[inline] pub fn set_stroke_options(&mut self, options: BLStrokeOptions) {
110114
safe_dbg!(bl_context_set_stroke_options(&mut self.0, &options.0));
@@ -199,31 +203,25 @@ impl BLContext { // https://blend2d.com/doc/group__bl__rendering.html
199203
safe_dbg!(bl_context_apply_transform_op(&mut self.0,
200204
BLTransformOp::BL_TRANSFORM_OP_TRANSFORM, mat as *const _ as _));
201205
}
202-
#[inline] pub fn scale(&mut self, sx: f32, sy: f32) {
203-
#[cfg(feature = "b2d_sfp")] let scale = &[sx, sy];
204-
#[cfg(not(feature = "b2d_sfp"))] let scale = &[sx as _, sy as f64];
206+
#[inline] pub fn scale(&mut self, sx: f64, sy: f64) {
205207
safe_dbg!(bl_context_apply_transform_op(&mut self.0,
206-
BLTransformOp::BL_TRANSFORM_OP_SCALE, scale.as_ptr() as _));
208+
BLTransformOp::BL_TRANSFORM_OP_SCALE, BLArrayFP::new(&[sx, sy]).get_data()));
207209
}
208-
#[inline] pub fn translate(&mut self, tx: f32, ty: f32) {
209-
#[cfg(feature = "b2d_sfp")] let pos = &[tx, ty];
210-
#[cfg(not(feature = "b2d_sfp"))] let pos = &[tx as _, ty as f64];
210+
#[inline] pub fn translate(&mut self, tx: f64, ty: f64) {
211211
safe_dbg!(bl_context_apply_transform_op(&mut self.0,
212-
BLTransformOp::BL_TRANSFORM_OP_TRANSLATE, pos.as_ptr() as _));
212+
BLTransformOp::BL_TRANSFORM_OP_TRANSLATE, BLArrayFP::new(&[tx, ty]).get_data()));
213213
}
214-
#[inline] pub fn rotate(&mut self, angle: f32, orig: Option<(f32, f32)>) {
214+
#[inline] pub fn rotate(&mut self, angle: f64, orig: Option<(f64, f64)>) {
215215
let orig = orig.unwrap_or((0., 0.));
216-
#[cfg(feature = "b2d_sfp")] let rot = &[angle, orig.0, orig.1];
217-
#[cfg(not(feature = "b2d_sfp"))]
218-
let rot = &[angle as _, orig.0 as _, orig.1 as f64];
216+
let rot = BLArrayFP::new(&[angle, orig.0, orig.1]);
219217
safe_dbg!(bl_context_apply_transform_op(&mut self.0,
220-
BLTransformOp::BL_TRANSFORM_OP_ROTATE_PT, rot.as_ptr() as _));
218+
BLTransformOp::BL_TRANSFORM_OP_ROTATE_PT, rot.get_data()));
221219
}
222220

223221
#[inline] pub fn set_comp_op(&mut self, cop: BLCompOp) {
224222
safe_dbg!(bl_context_set_comp_op(&mut self.0, cop));
225223
}
226-
#[inline] pub fn set_global_alpha(&mut self, alpha: f32) {
224+
#[inline] pub fn set_global_alpha(&mut self, alpha: f64) {
227225
safe_dbg!(bl_context_set_global_alpha(&mut self.0, alpha as _));
228226
}
229227

@@ -282,7 +280,7 @@ impl BLImage { // https://blend2d.com/doc/group__bl__imaging.html
282280
}
283281

284282
#[inline] pub fn from_buffer(w: u32, h: u32, fmt: BLFormat, buf: &mut [u8],
285-
stride: u32) -> Self { let mut img = object_init();
283+
stride: i32) -> Self { let mut img = object_init();
286284
safe_dbg!(bl_image_init_as_from_data(&mut img, w as _, h as _, fmt, buf.as_mut_ptr() as _,
287285
stride as _, BLDataAccessFlags::BL_DATA_ACCESS_RW, None, null_mut())); Self(img)
288286
}
@@ -348,7 +346,7 @@ impl BLImageData {
348346
unsafe { std::slice::from_raw_parts(self.pixel_data as *const u8,
349347
(self.stride as i32 * self.size.h) as usize) }
350348
}
351-
#[inline] pub fn stride(&self) -> u32 { self.stride as _ }
349+
#[inline] pub fn stride(&self) -> i32 { self.stride as _ }
352350
#[inline] pub fn height(&self) -> u32 { self.size.h as _ }
353351
#[inline] pub fn width (&self) -> u32 { self.size.w as _ }
354352
//#[inline] pub fn format(&self) -> u32 { self.format }
@@ -407,8 +405,8 @@ impl BLStrokeOptions {
407405
safe_dbg!(bl_stroke_options_init(&mut option)); Self(option)
408406
}
409407

410-
#[inline] pub fn set_width(&mut self, width: f32) { self.0.width = width as _; }
411-
#[inline] pub fn set_miter_limit(&mut self, miter: f32) { self.0.miter_limit = miter as _; }
408+
#[inline] pub fn set_width(&mut self, width: f64) { self.0.width = width as _; }
409+
#[inline] pub fn set_miter_limit(&mut self, miter: f64) { self.0.miter_limit = miter as _; }
412410

413411
#[inline] pub fn set_options(&mut self, sc: BLStrokeCap, ec: BLStrokeCap,
414412
join: BLStrokeJoin/*, to: BLStrokeTransformOrder*/) { // XXX:
@@ -418,11 +416,11 @@ impl BLStrokeOptions {
418416
options.join = join as _; //options.transform_order = to as _;
419417
}
420418

421-
#[inline] pub fn set_dash(&mut self, offset: f32, dash: &[f32]) {
419+
#[inline] pub fn set_dash(&mut self, offset: f64, dash: &[f64]) {
422420
self.0.dash_offset = offset as _;
423-
//safe_dbg!(bl_array_assign_deep(&mut self.0.dash_array, &BLDashArray::new(dash).0));
421+
//safe_dbg!(bl_array_assign_deep(&mut self.0.dash_array, &BLArrayFP::new(dash).0));
424422
safe_dbg!(bl_array_assign_deep(&mut (&mut self.0.__bindgen_anon_2.dash_array)._base,
425-
&BLDashArray::new(dash).0));
423+
&BLArrayFP::new(dash).0));
426424
}
427425
}
428426

@@ -431,26 +429,33 @@ impl BLApproximationOptions {
431429
#[inline] fn new() -> Self { Self {
432430
flatten_mode: BLFlattenMode::BL_FLATTEN_MODE_DEFAULT as _,
433431
offset_mode: BLOffsetMode::BL_OFFSET_MODE_DEFAULT as _, reserved_flags: [0; 6],
434-
flatten_tolerance: 0.20, simplify_tolerance: 0.05, offset_parameter: 0.414213562
432+
flatten_tolerance: 0.20, simplify_tolerance: 0.05, offset_parameter: 0.414_213_56
435433
} }
436434
}
437435

438-
struct BLDashArray(BLArrayCore);
439-
impl Drop for BLDashArray {
436+
struct BLArrayFP(BLArrayCore);
437+
impl Drop for BLArrayFP {
440438
#[inline] fn drop(&mut self) { safe_dbg!(bl_array_destroy(&mut self.0)); }
441439
}
442-
impl BLDashArray { #[cfg(feature = "b2d_sfp")]
443-
#[inline] pub fn new(data: &[f32]) -> Self { let mut array = object_init();
444-
safe_dbg!(bl_array_init(&mut array, BLObjectType::BL_OBJECT_TYPE_ARRAY_FLOAT32));
445-
safe_dbg!(bl_array_append_data(&mut array, data.as_ptr() as _, data.len())); Self(array)
440+
impl BLArrayFP {
441+
#[inline] pub fn new(data: &[f64]) -> Self { let mut array = object_init();
442+
safe_dbg!(bl_array_reserve(&mut array, data.len()));
443+
//safe_dbg!(bl_array_assign_data(&mut array, data.as_ptr() as _, data.len()));
444+
//safe_dbg!(bl_array_append_data(&mut array, data_ptr, data.len()));
445+
446+
if cfg!(feature = "b2d_sfp") {
447+
safe_dbg!(bl_array_init(&mut array, BLObjectType::BL_OBJECT_TYPE_ARRAY_FLOAT32));
448+
data.iter().for_each(|v| {
449+
safe_dbg!(bl_array_append_f32(&mut array, *v as _)); });
450+
} else {
451+
safe_dbg!(bl_array_init(&mut array, BLObjectType::BL_OBJECT_TYPE_ARRAY_FLOAT64));
452+
data.iter().for_each(|v| {
453+
safe_dbg!(bl_array_append_f64(&mut array, *v as _)); });
454+
} Self(array)
446455
}
447456

448-
#[cfg(not(feature = "b2d_sfp"))]
449-
#[inline] pub fn new(data: &[f32]) -> Self { let mut array = object_init();
450-
safe_dbg!(bl_array_init(&mut array, BLObjectType::BL_OBJECT_TYPE_ARRAY_FLOAT64));
451-
let data = data.iter().map(|v| *v as f64).collect::<Vec<_>>();
452-
//safe_dbg!(bl_array_assign_data(&mut array, data.as_ptr() as _, data.len()));
453-
safe_dbg!(bl_array_append_data(&mut array, data.as_ptr() as _, data.len())); Self(array)
457+
#[inline] pub fn get_data(&self) -> *const std::os::raw::c_void {
458+
unsafe { bl_array_get_data(&self.0) }
454459
}
455460
}
456461

@@ -463,13 +468,13 @@ impl BLMatrix2D { // https://blend2d.com/doc/structBLMatrix2D.html
463468
#[inline] pub fn set_translation(&mut self, pos: &BLPoint) {
464469
safe_dbg!(bl_matrix2d_set_translation(self, pos.x, pos.y));
465470
}
466-
#[inline] pub fn set_scaling(&mut self, sx: f32, sy: f32) {
471+
#[inline] pub fn set_scaling(&mut self, sx: f64, sy: f64) {
467472
safe_dbg!(bl_matrix2d_set_scaling(self, sx as _, sy as _));
468473
}
469474
#[inline] pub fn set_skewing(&mut self, skew: &BLPoint) {
470475
safe_dbg!(bl_matrix2d_set_skewing(self, skew.x, skew.y));
471476
}
472-
#[inline] pub fn set_rotation(&mut self, radius: f32, origin: &BLPoint) {
477+
#[inline] pub fn set_rotation(&mut self, radius: f64, origin: &BLPoint) {
473478
safe_dbg!(bl_matrix2d_set_rotation(self, radius as _, origin.x, origin.y));
474479
}
475480

@@ -487,10 +492,9 @@ impl BLMatrix2D { // https://blend2d.com/doc/structBLMatrix2D.html
487492
#[inline] pub fn set_identity(&mut self) { safe_dbg!(bl_matrix2d_set_identity(self)); }
488493
#[inline] pub fn invert(&mut self, src: &Self) { safe_dbg!(bl_matrix2d_invert(self, src)); }
489494

490-
#[inline] pub fn get_scaling(&self) -> (f32, f32) {
495+
#[inline] pub fn get_scaling(&self) -> (f64, f64) {
491496
let mat = unsafe {
492-
&self.__bindgen_anon_1.__bindgen_anon_1 };
493-
(mat.m00 as _, mat.m10 as _)
497+
&self.__bindgen_anon_1.__bindgen_anon_1 }; (mat.m00 as _, mat.m10 as _)
494498
}
495499

496500
#[inline] pub fn map_pointd(&self, pt: &BLPoint) -> BLPoint {
@@ -523,11 +527,11 @@ impl BLPath {
523527
}
524528

525529
#[inline] pub fn arc_to(&mut self, center: &BLPoint, radius: &BLPoint,
526-
start: f32, sweep: f32) { //, force_move_to
527-
safe_dbg!(bl_path_arc_to(&mut self.0, center.x, center.y, radius.x, radius.y,
528-
start as _, sweep as _, false));
530+
start: f64, sweep: f64) {
531+
safe_dbg!(bl_path_arc_to(&mut self.0, center.x, center.y,
532+
radius.x, radius.y, start as _, sweep as _, false)); //, force_move_to
529533
}
530-
#[inline] pub fn elliptic_arc_to(&mut self, rp: &BLPoint, x_rot: f32, // svg_arc_to
534+
#[inline] pub fn elliptic_arc_to(&mut self, rp: &BLPoint, x_rot: f64, // svg_arc_to
531535
large: bool, sweep: bool, pt: &BLPoint) {
532536
safe_dbg!(bl_path_elliptic_arc_to(&mut self.0,
533537
rp.x, rp.y, x_rot as _, large, sweep, pt.x, pt.y));
@@ -549,6 +553,9 @@ impl BLPath {
549553
safe_dbg!(bl_path_transform(&mut self.0, null(), mat));
550554
}
551555

556+
#[inline] pub fn reserve(&mut self, capacity: u32) {
557+
safe_dbg!(bl_path_reserve(&mut self.0, capacity as _));
558+
}
552559
#[inline] pub fn get_size(&self) -> u32 { unsafe { bl_path_get_size(&self.0) as _ } }
553560
#[inline] pub fn get_last_vertex(&self) -> Option<BLPoint> {
554561
let mut pt = BLPoint { x: 0.0, y: 0.0 };
@@ -594,12 +601,12 @@ impl BLLine {
594601
}
595602
}
596603
impl BLArc {
597-
#[inline] pub fn new(c: &BLPoint, r: &BLPoint, start: f32, sweep: f32) -> Self {
604+
#[inline] pub fn new(c: &BLPoint, r: &BLPoint, start: f64, sweep: f64) -> Self {
598605
Self { cx: c.x, cy: c.y, rx: r.x, ry: r.y, start: start as _, sweep: sweep as _ }
599606
}
600607
}
601608
impl BLCircle {
602-
#[inline] pub fn new(c: &BLPoint, r: f32) -> Self { Self { cx: c.x, cy: c.y, r: r as _ } }
609+
#[inline] pub fn new(c: &BLPoint, r: f64) -> Self { Self { cx: c.x, cy: c.y, r: r as _ } }
603610
}
604611
impl BLEllipse {
605612
#[inline] pub fn new(c: &BLPoint, r: &BLPoint) -> Self {
@@ -612,7 +619,7 @@ impl BLTriangle {
612619
}
613620
}
614621
impl BLRoundRect {
615-
#[inline] pub fn new(rect: &BLRect, radius: f32) -> Self {
622+
#[inline] pub fn new(rect: &BLRect, radius: f64) -> Self {
616623
Self { x: rect.x, y: rect.y, w: rect.w, h: rect.h, rx: radius as _, ry: radius as _ }
617624
}
618625
}
@@ -621,10 +628,8 @@ impl BLBox { #[inline] pub fn new() -> Self { Self { x0: 0., y0: 0., x1: 0., y
621628
impl BLRect { #[inline] pub fn new() -> Self { Self { x : 0., y : 0., w: 0., h: 0. } } }
622629
impl BLPoint {
623630
#[inline] pub fn new() -> Self { Self { x : 0., y : 0. } }
624-
#[cfg(feature = "b2d_sfp")] #[inline] pub fn x(&self) -> f32 { self.x }
625-
#[cfg(feature = "b2d_sfp")] #[inline] pub fn y(&self) -> f32 { self.y }
626-
#[cfg(not(feature = "b2d_sfp"))] #[inline] pub fn x(&self) -> f64 { self.x }
627-
#[cfg(not(feature = "b2d_sfp"))] #[inline] pub fn y(&self) -> f64 { self.y }
631+
#[inline] pub fn x(&self) -> f64 { self.x as _ }
632+
#[inline] pub fn y(&self) -> f64 { self.y as _ }
628633
}
629634

630635
pub trait B2DGeometry { const GEOM_T: BLGeometryType; }
@@ -657,18 +662,21 @@ impl B2DGeometry for BLRoundRect {
657662
}
658663

659664
impl From<(f64, f64)> for BLPoint {
660-
#[inline] fn from((x, y): (f64, f64)) -> Self { Self { x, y } }
665+
#[inline] fn from((x, y): (f64, f64)) -> Self { Self { x: x as _, y: y as _ } }
661666
}
662-
impl From<(f32, f32)> for BLPoint {
663-
#[inline] fn from(v: (f32, f32)) -> Self { Self { x: v.0 as _, y: v.1 as _ } }
667+
impl From<(F32, F32)> for BLPoint {
668+
#[inline] fn from(v: (F32, F32)) -> Self { Self { x: v.0 as _, y: v.1 as _ } }
664669
}
665670
impl From<(u32, u32)> for BLPoint {
666671
#[inline] fn from(v: (u32, u32)) -> Self { Self { x: v.0 as _, y: v.1 as _ } }
667672
}
668673
impl From<(i32, i32)> for BLPoint {
669674
#[inline] fn from(v: (i32, i32)) -> Self { Self { x: v.0 as _, y: v.1 as _ } }
670675
}
671-
impl From<BLPoint> for (f32, f32) {
676+
impl From<BLPoint> for (f64, f64) {
677+
#[inline] fn from(val: BLPoint) -> Self { (val.x as _, val.y as _) }
678+
}
679+
impl From<BLPoint> for (F32, F32) {
672680
#[inline] fn from(val: BLPoint) -> Self { (val.x as _, val.y as _) }
673681
}
674682
impl Clone for BLPoint { #[inline] fn clone(&self) -> Self { *self } }
@@ -680,16 +688,19 @@ impl From<(i32, i32)> for BLSizeI {
680688
impl From<(u32, u32)> for BLSizeI {
681689
#[inline] fn from(v: (u32, u32)) -> Self { Self { w: v.0 as _, h: v.1 as _ } }
682690
}
683-
impl From<(f32, f32)> for BLSize {
684-
#[inline] fn from(v: (f32, f32)) -> Self { Self { w: v.0 as _, h: v.1 as _ } }
691+
impl From<(f64, f64)> for BLSize {
692+
#[inline] fn from(v: (f64, f64)) -> Self { Self { w: v.0 as _, h: v.1 as _ } }
693+
}
694+
impl From<(F32, F32)> for BLSize {
695+
#[inline] fn from(v: (F32, F32)) -> Self { Self { w: v.0 as _, h: v.1 as _ } }
685696
}
686697
impl From<(f64, f64, f64, f64)> for BLBox {
687698
#[inline] fn from(v: (f64, f64, f64, f64)) -> Self {
688-
Self { x0: v.0, y0: v.1, x1: v.2, y1: v.3 }
699+
Self { x0: v.0 as _, y0: v.1 as _, x1: v.2 as _, y1: v.3 as _ }
689700
}
690701
}
691-
impl From<(f32, f32, f32, f32)> for BLBox {
692-
#[inline] fn from(v: (f32, f32, f32, f32)) -> Self {
702+
impl From<(F32, F32, F32, F32)> for BLBox {
703+
#[inline] fn from(v: (F32, F32, F32, F32)) -> Self {
693704
Self { x0: v.0 as _, y0: v.1 as _, x1: v.2 as _, y1: v.3 as _ }
694705
}
695706
}
@@ -700,10 +711,12 @@ impl From<(u32, u32, u32, u32)> for BLBox {
700711
}
701712

702713
impl From<(f64, f64, f64, f64)> for BLRect {
703-
#[inline] fn from(v: (f64, f64, f64, f64)) -> Self { Self { x: v.0, y: v.1, w: v.2, h: v.3 } }
714+
#[inline] fn from(v: (f64, f64, f64, f64)) -> Self {
715+
Self { x: v.0 as _, y: v.1 as _, w: v.2 as _, h: v.3 as _ }
716+
}
704717
}
705-
impl From<(f32, f32, f32, f32)> for BLRect {
706-
#[inline] fn from(v: (f32, f32, f32, f32)) -> Self {
718+
impl From<(F32, F32, F32, F32)> for BLRect {
719+
#[inline] fn from(v: (F32, F32, F32, F32)) -> Self {
707720
Self { x: v.0 as _, y: v.1 as _, w: v.2 as _, h: v.3 as _ }
708721
}
709722
}
@@ -803,7 +816,7 @@ impl BLGradient {
803816
BLExtendMode::BL_EXTEND_MODE_PAD, null(), 0, null())); Self(grd)
804817
} //stops.as_ptr(), stops.len(),
805818

806-
#[inline] pub fn add_stop(&mut self, offset: f32, color: BLRgba32) {
819+
#[inline] pub fn add_stop(&mut self, offset: f64, color: BLRgba32) {
807820
safe_dbg!(bl_gradient_add_stop_rgba32(&mut self.0, offset as _, color.value));
808821
}
809822

@@ -830,12 +843,12 @@ impl BLLinearGradientValues {
830843
}
831844
}
832845
impl BLRadialGradientValues { // center/focal point
833-
#[inline] pub fn new(cp: &BLPoint, fp: &BLPoint, r0: f32, r1: f32) -> Self {
846+
#[inline] pub fn new(cp: &BLPoint, fp: &BLPoint, r0: f64, r1: f64) -> Self {
834847
Self { x0: cp.x, y0: cp.y, x1: fp.x, y1: fp.y, r0: r0 as _, r1: r1 as _ }
835848
}
836849
}
837850
impl BLConicGradientValues {
838-
#[inline] pub fn new(pt: &BLPoint, angle: f32, repeat: f32) -> Self {
851+
#[inline] pub fn new(pt: &BLPoint, angle: f64, repeat: f64) -> Self {
839852
Self { x0: pt.x, y0: pt.y, angle: angle as _, repeat: repeat as _ }
840853
}
841854
}

0 commit comments

Comments
 (0)