Merge pull request #218 from s3bk/master
fixes and a possible canvas addition
This commit is contained in:
commit
842348c65f
|
@ -8,4 +8,7 @@ addons:
|
||||||
- cmake
|
- cmake
|
||||||
script:
|
script:
|
||||||
- cargo build
|
- cargo build
|
||||||
# - cargo test # todo: fix tests
|
- cargo test
|
||||||
|
env:
|
||||||
|
global:
|
||||||
|
- HARFBUZZ_SYS_NO_PKG_CONFIG=true
|
||||||
|
|
29
Cargo.toml
29
Cargo.toml
|
@ -31,3 +31,32 @@ members = [
|
||||||
"utils/svg-to-skia",
|
"utils/svg-to-skia",
|
||||||
"utils/convert",
|
"utils/convert",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
default-members = [
|
||||||
|
"c",
|
||||||
|
"canvas",
|
||||||
|
"content",
|
||||||
|
"demo/common",
|
||||||
|
"demo/native",
|
||||||
|
"examples/canvas_glutin_minimal",
|
||||||
|
"examples/canvas_minimal",
|
||||||
|
"examples/canvas_moire",
|
||||||
|
"examples/canvas_text",
|
||||||
|
"examples/lottie_basic",
|
||||||
|
"examples/swf_basic",
|
||||||
|
"geometry",
|
||||||
|
"gl",
|
||||||
|
"gpu",
|
||||||
|
"lottie",
|
||||||
|
"export",
|
||||||
|
"renderer",
|
||||||
|
"simd",
|
||||||
|
"svg",
|
||||||
|
"swf",
|
||||||
|
"text",
|
||||||
|
"ui",
|
||||||
|
"utils/area-lut",
|
||||||
|
"utils/gamma-lut",
|
||||||
|
"utils/svg-to-skia",
|
||||||
|
"utils/convert",
|
||||||
|
]
|
||||||
|
|
|
@ -102,6 +102,16 @@ impl CanvasRenderingContext2D {
|
||||||
TextMetrics { width: self.layout_text(string).width() }
|
TextMetrics { width: self.layout_text(string).width() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn fill_layout(&mut self, layout: &Layout, transform: Transform2F) {
|
||||||
|
let paint_id = self.scene.push_paint(&self.current_state.fill_paint);
|
||||||
|
drop(self.scene.push_layout(&layout,
|
||||||
|
&TextStyle { size: self.current_state.font_size },
|
||||||
|
&(transform * self.current_state.transform),
|
||||||
|
TextRenderMode::Fill,
|
||||||
|
HintingOptions::None,
|
||||||
|
paint_id));
|
||||||
|
}
|
||||||
|
|
||||||
fn fill_or_stroke_text(&mut self,
|
fn fill_or_stroke_text(&mut self,
|
||||||
string: &str,
|
string: &str,
|
||||||
mut position: Vector2F,
|
mut position: Vector2F,
|
||||||
|
|
|
@ -14,7 +14,9 @@
|
||||||
pub trait Executor {
|
pub trait Executor {
|
||||||
/// Like the Rayon snippet:
|
/// Like the Rayon snippet:
|
||||||
///
|
///
|
||||||
|
/// ```norun
|
||||||
/// (0..length).into_par_iter().flat_map(builder).collect()
|
/// (0..length).into_par_iter().flat_map(builder).collect()
|
||||||
|
/// ```
|
||||||
fn flatten_into_vector<T, F>(&self, length: usize, builder: F) -> Vec<T>
|
fn flatten_into_vector<T, F>(&self, length: usize, builder: F) -> Vec<T>
|
||||||
where T: Send, F: Fn(usize) -> Vec<T> + Send + Sync;
|
where T: Send, F: Fn(usize) -> Vec<T> + Send + Sync;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,9 +77,11 @@ impl SceneProxy {
|
||||||
///
|
///
|
||||||
/// Exactly equivalent to:
|
/// Exactly equivalent to:
|
||||||
///
|
///
|
||||||
|
/// ```norun
|
||||||
/// for command in scene_proxy.build_with_stream(options) {
|
/// for command in scene_proxy.build_with_stream(options) {
|
||||||
/// renderer.render_command(&command)
|
/// renderer.render_command(&command)
|
||||||
/// }
|
/// }
|
||||||
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn build_and_render<D>(&self, renderer: &mut Renderer<D>, build_options: BuildOptions)
|
pub fn build_and_render<D>(&self, renderer: &mut Renderer<D>, build_options: BuildOptions)
|
||||||
where D: Device {
|
where D: Device {
|
||||||
|
|
|
@ -94,12 +94,12 @@ impl Shape {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn first(&self) -> LineSegment {
|
fn first(&self) -> LineSegment {
|
||||||
self.outline.first().unwrap()
|
*self.outline.first().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn last(&self) -> LineSegment {
|
fn last(&self) -> LineSegment {
|
||||||
self.outline.last().unwrap()
|
*self.outline.last().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
Loading…
Reference in New Issue