mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-10 20:51:29 +11:00
commit
c939448348
750
Cargo.lock
generated
750
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -7,7 +7,7 @@ license = "MIT/Apache-2.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
ash = "0.30"
|
ash = "0.31"
|
||||||
once_cell = "1.3.1"
|
once_cell = "1.3.1"
|
||||||
ash-window = { git = "https://github.com/norse-rs/ash-window.git", branch = "dyn_trait" }
|
ash-window = "0.5"
|
||||||
raw-window-handle = "0.3"
|
raw-window-handle = "0.3"
|
||||||
|
|
|
@ -5,6 +5,7 @@ fn main() {
|
||||||
let (instance, _) = VkInstance::new(None).unwrap();
|
let (instance, _) = VkInstance::new(None).unwrap();
|
||||||
unsafe {
|
unsafe {
|
||||||
let device = instance.device(None).unwrap();
|
let device = instance.device(None).unwrap();
|
||||||
|
let fence = device.create_fence(false).unwrap();
|
||||||
let mem_flags = MemFlags::host_coherent();
|
let mem_flags = MemFlags::host_coherent();
|
||||||
let src = (0..256).map(|x| x + 1).collect::<Vec<u32>>();
|
let src = (0..256).map(|x| x + 1).collect::<Vec<u32>>();
|
||||||
let buffer = device
|
let buffer = device
|
||||||
|
@ -12,8 +13,10 @@ fn main() {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
device.write_buffer(&buffer, &src).unwrap();
|
device.write_buffer(&buffer, &src).unwrap();
|
||||||
let code = include_bytes!("./shader/collatz.spv");
|
let code = include_bytes!("./shader/collatz.spv");
|
||||||
let pipeline = device.create_simple_compute_pipeline(code, 1).unwrap();
|
let pipeline = device.create_simple_compute_pipeline(code, 1, 0).unwrap();
|
||||||
let descriptor_set = device.create_descriptor_set(&pipeline, &[&buffer]).unwrap();
|
let descriptor_set = device
|
||||||
|
.create_descriptor_set(&pipeline, &[&buffer], &[])
|
||||||
|
.unwrap();
|
||||||
let query_pool = device.create_query_pool(2).unwrap();
|
let query_pool = device.create_query_pool(2).unwrap();
|
||||||
let mut cmd_buf = device.create_cmd_buf().unwrap();
|
let mut cmd_buf = device.create_cmd_buf().unwrap();
|
||||||
cmd_buf.begin();
|
cmd_buf.begin();
|
||||||
|
@ -22,8 +25,11 @@ fn main() {
|
||||||
cmd_buf.dispatch(&pipeline, &descriptor_set, (256, 1, 1));
|
cmd_buf.dispatch(&pipeline, &descriptor_set, (256, 1, 1));
|
||||||
cmd_buf.write_timestamp(&query_pool, 1);
|
cmd_buf.write_timestamp(&query_pool, 1);
|
||||||
cmd_buf.finish();
|
cmd_buf.finish();
|
||||||
device.run_cmd_buf(&cmd_buf).unwrap();
|
device
|
||||||
let timestamps = device.reap_query_pool(query_pool);
|
.run_cmd_buf(&cmd_buf, &[], &[], Some(&fence))
|
||||||
|
.unwrap();
|
||||||
|
device.wait_and_reset(&[fence]).unwrap();
|
||||||
|
let timestamps = device.reap_query_pool(&query_pool);
|
||||||
let mut dst: Vec<u32> = Default::default();
|
let mut dst: Vec<u32> = Default::default();
|
||||||
device.read_buffer(&buffer, &mut dst).unwrap();
|
device.read_buffer(&buffer, &mut dst).unwrap();
|
||||||
for (i, val) in dst.iter().enumerate().take(16) {
|
for (i, val) in dst.iter().enumerate().take(16) {
|
||||||
|
|
|
@ -21,9 +21,9 @@ path = "../piet-gpu-hal"
|
||||||
path = "../piet-gpu-types"
|
path = "../piet-gpu-types"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
piet = "0.0.13"
|
piet = "0.2.0"
|
||||||
png = "0.16.2"
|
png = "0.16.2"
|
||||||
rand = "0.7.3"
|
rand = "0.7.3"
|
||||||
roxmltree = "0.11"
|
roxmltree = "0.13"
|
||||||
winit = "0.22"
|
winit = "0.23"
|
||||||
clap = "2.33"
|
clap = "2.33"
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::fs::File;
|
||||||
use std::io::BufWriter;
|
use std::io::BufWriter;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use clap::{Arg, App};
|
use clap::{App, Arg};
|
||||||
|
|
||||||
use piet_gpu_hal::vulkan::VkInstance;
|
use piet_gpu_hal::vulkan::VkInstance;
|
||||||
use piet_gpu_hal::{CmdBuf, Device, Error, MemFlags};
|
use piet_gpu_hal::{CmdBuf, Device, Error, MemFlags};
|
||||||
|
@ -22,18 +22,30 @@ fn dump_scene(buf: &[u8]) {
|
||||||
fn dump_state(buf: &[u8]) {
|
fn dump_state(buf: &[u8]) {
|
||||||
for i in 0..(buf.len() / 48) {
|
for i in 0..(buf.len() / 48) {
|
||||||
let j = i * 48;
|
let j = i * 48;
|
||||||
let floats = (0..11).map(|k| {
|
let floats = (0..11)
|
||||||
|
.map(|k| {
|
||||||
let mut buf_f32 = [0u8; 4];
|
let mut buf_f32 = [0u8; 4];
|
||||||
buf_f32.copy_from_slice(&buf[j + k * 4..j + k * 4 + 4]);
|
buf_f32.copy_from_slice(&buf[j + k * 4..j + k * 4 + 4]);
|
||||||
f32::from_le_bytes(buf_f32)
|
f32::from_le_bytes(buf_f32)
|
||||||
}).collect::<Vec<_>>();
|
})
|
||||||
println!("{}: [{} {} {} {} {} {}] ({}, {})-({} {}) {} {}",
|
.collect::<Vec<_>>();
|
||||||
|
println!(
|
||||||
|
"{}: [{} {} {} {} {} {}] ({}, {})-({} {}) {} {}",
|
||||||
i,
|
i,
|
||||||
floats[0], floats[1], floats[2], floats[3], floats[4], floats[5],
|
floats[0],
|
||||||
floats[6], floats[7], floats[8], floats[9],
|
floats[1],
|
||||||
floats[10], buf[j + 44]);
|
floats[2],
|
||||||
|
floats[3],
|
||||||
|
floats[4],
|
||||||
|
floats[5],
|
||||||
|
floats[6],
|
||||||
|
floats[7],
|
||||||
|
floats[8],
|
||||||
|
floats[9],
|
||||||
|
floats[10],
|
||||||
|
buf[j + 44]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Interpret the output of the binning stage, for diagnostic purposes.
|
/// Interpret the output of the binning stage, for diagnostic purposes.
|
||||||
|
@ -41,22 +53,31 @@ fn dump_state(buf: &[u8]) {
|
||||||
fn trace_merge(buf: &[u32]) {
|
fn trace_merge(buf: &[u32]) {
|
||||||
for bin in 0..256 {
|
for bin in 0..256 {
|
||||||
println!("bin {}:", bin);
|
println!("bin {}:", bin);
|
||||||
let mut starts = (0..16).map(|i| Some((bin * 16 + i) * 64)).collect::<Vec<Option<usize>>>();
|
let mut starts = (0..16)
|
||||||
|
.map(|i| Some((bin * 16 + i) * 64))
|
||||||
|
.collect::<Vec<Option<usize>>>();
|
||||||
loop {
|
loop {
|
||||||
let min_start = starts.iter().map(|st|
|
let min_start = starts
|
||||||
st.map(|st|
|
.iter()
|
||||||
|
.map(|st| {
|
||||||
|
st.map(|st| {
|
||||||
if buf[st / 4] == 0 {
|
if buf[st / 4] == 0 {
|
||||||
!0
|
!0
|
||||||
} else {
|
} else {
|
||||||
buf[st / 4 + 2]
|
buf[st / 4 + 2]
|
||||||
}).unwrap_or(!0)).min().unwrap();
|
}
|
||||||
|
})
|
||||||
|
.unwrap_or(!0)
|
||||||
|
})
|
||||||
|
.min()
|
||||||
|
.unwrap();
|
||||||
if min_start == !0 {
|
if min_start == !0 {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
let mut selected = !0;
|
let mut selected = !0;
|
||||||
for i in 0..16 {
|
for i in 0..16 {
|
||||||
if let Some(st) = starts[i] {
|
if let Some(st) = starts[i] {
|
||||||
if buf[st/4] != 0 && buf[st/4 + 2] == min_start {
|
if buf[st / 4] != 0 && buf[st / 4 + 2] == min_start {
|
||||||
selected = i;
|
selected = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -64,16 +85,15 @@ fn trace_merge(buf: &[u32]) {
|
||||||
}
|
}
|
||||||
let st = starts[selected].unwrap();
|
let st = starts[selected].unwrap();
|
||||||
println!("selected {}, start {:x}", selected, st);
|
println!("selected {}, start {:x}", selected, st);
|
||||||
for j in 0..buf[st/4] {
|
for j in 0..buf[st / 4] {
|
||||||
println!("{:x}", buf[st/4 + 2 + j as usize])
|
println!("{:x}", buf[st / 4 + 2 + j as usize])
|
||||||
}
|
}
|
||||||
if buf[st/4 + 1] == 0 {
|
if buf[st / 4 + 1] == 0 {
|
||||||
starts[selected] = None;
|
starts[selected] = None;
|
||||||
} else {
|
} else {
|
||||||
starts[selected] = Some(buf[st/4 + 1] as usize);
|
starts[selected] = Some(buf[st / 4 + 1] as usize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +123,10 @@ fn trace_ptcl(buf: &[u32]) {
|
||||||
let x1 = f32::from_bits(buf[segs / 4 + i * 5 + 2]);
|
let x1 = f32::from_bits(buf[segs / 4 + i * 5 + 2]);
|
||||||
let y1 = f32::from_bits(buf[segs / 4 + i * 5 + 3]);
|
let y1 = f32::from_bits(buf[segs / 4 + i * 5 + 3]);
|
||||||
let y_edge = f32::from_bits(buf[segs / 4 + i * 5 + 4]);
|
let y_edge = f32::from_bits(buf[segs / 4 + i * 5 + 4]);
|
||||||
println!(" ({:.3}, {:.3}) - ({:.3}, {:.3}) | {:.3}", x0, y0, x1, y1, y_edge);
|
println!(
|
||||||
|
" ({:.3}, {:.3}) - ({:.3}, {:.3}) | {:.3}",
|
||||||
|
x0, y0, x1, y1, y_edge
|
||||||
|
);
|
||||||
}
|
}
|
||||||
loop {
|
loop {
|
||||||
seg_chunk = buf[seg_chunk / 4 + 1] as usize;
|
seg_chunk = buf[seg_chunk / 4 + 1] as usize;
|
||||||
|
@ -115,7 +138,10 @@ fn trace_ptcl(buf: &[u32]) {
|
||||||
4 => {
|
4 => {
|
||||||
let line_width = f32::from_bits(buf[tile_offset / 4 + 2]);
|
let line_width = f32::from_bits(buf[tile_offset / 4 + 2]);
|
||||||
let rgba_color = buf[tile_offset / 4 + 3];
|
let rgba_color = buf[tile_offset / 4 + 3];
|
||||||
println!(" {:x}: stroke {:x} {}", tile_offset, rgba_color, line_width);
|
println!(
|
||||||
|
" {:x}: stroke {:x} {}",
|
||||||
|
tile_offset, rgba_color, line_width
|
||||||
|
);
|
||||||
let mut seg_chunk = buf[tile_offset / 4 + 1] as usize;
|
let mut seg_chunk = buf[tile_offset / 4 + 1] as usize;
|
||||||
let n = buf[seg_chunk / 4] as usize;
|
let n = buf[seg_chunk / 4] as usize;
|
||||||
let segs = buf[seg_chunk / 4 + 2] as usize;
|
let segs = buf[seg_chunk / 4 + 2] as usize;
|
||||||
|
@ -126,7 +152,10 @@ fn trace_ptcl(buf: &[u32]) {
|
||||||
let x1 = f32::from_bits(buf[segs / 4 + i * 5 + 2]);
|
let x1 = f32::from_bits(buf[segs / 4 + i * 5 + 2]);
|
||||||
let y1 = f32::from_bits(buf[segs / 4 + i * 5 + 3]);
|
let y1 = f32::from_bits(buf[segs / 4 + i * 5 + 3]);
|
||||||
let y_edge = f32::from_bits(buf[segs / 4 + i * 5 + 4]);
|
let y_edge = f32::from_bits(buf[segs / 4 + i * 5 + 4]);
|
||||||
println!(" ({:.3}, {:.3}) - ({:.3}, {:.3}) | {:.3}", x0, y0, x1, y1, y_edge);
|
println!(
|
||||||
|
" ({:.3}, {:.3}) - ({:.3}, {:.3}) | {:.3}",
|
||||||
|
x0, y0, x1, y1, y_edge
|
||||||
|
);
|
||||||
}
|
}
|
||||||
loop {
|
loop {
|
||||||
seg_chunk = buf[seg_chunk / 4 + 1] as usize;
|
seg_chunk = buf[seg_chunk / 4 + 1] as usize;
|
||||||
|
@ -152,18 +181,16 @@ fn trace_ptcl(buf: &[u32]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn main() -> Result<(), Error> {
|
fn main() -> Result<(), Error> {
|
||||||
let matches = App::new("piet-gpu test")
|
let matches = App::new("piet-gpu test")
|
||||||
.arg(Arg::with_name("INPUT")
|
.arg(Arg::with_name("INPUT").index(1))
|
||||||
.index(1))
|
.arg(Arg::with_name("flip").short("f").long("flip"))
|
||||||
.arg(Arg::with_name("flip")
|
.arg(
|
||||||
.short("f")
|
Arg::with_name("scale")
|
||||||
.long("flip"))
|
|
||||||
.arg(Arg::with_name("scale")
|
|
||||||
.short("s")
|
.short("s")
|
||||||
.long("scale")
|
.long("scale")
|
||||||
.takes_value(true))
|
.takes_value(true),
|
||||||
|
)
|
||||||
.get_matches();
|
.get_matches();
|
||||||
let (instance, _) = VkInstance::new(None)?;
|
let (instance, _) = VkInstance::new(None)?;
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -175,7 +202,8 @@ fn main() -> Result<(), Error> {
|
||||||
|
|
||||||
let mut ctx = PietGpuRenderContext::new();
|
let mut ctx = PietGpuRenderContext::new();
|
||||||
if let Some(input) = matches.value_of("INPUT") {
|
if let Some(input) = matches.value_of("INPUT") {
|
||||||
let mut scale = matches.value_of("scale")
|
let mut scale = matches
|
||||||
|
.value_of("scale")
|
||||||
.map(|scale| scale.parse().unwrap())
|
.map(|scale| scale.parse().unwrap())
|
||||||
.unwrap_or(8.0);
|
.unwrap_or(8.0);
|
||||||
if matches.is_present("flip") {
|
if matches.is_present("flip") {
|
||||||
|
@ -198,11 +226,16 @@ fn main() -> Result<(), Error> {
|
||||||
renderer.record(&mut cmd_buf, &query_pool);
|
renderer.record(&mut cmd_buf, &query_pool);
|
||||||
cmd_buf.copy_image_to_buffer(&renderer.image_dev, &image_buf);
|
cmd_buf.copy_image_to_buffer(&renderer.image_dev, &image_buf);
|
||||||
cmd_buf.finish();
|
cmd_buf.finish();
|
||||||
|
let start = std::time::Instant::now();
|
||||||
device.run_cmd_buf(&cmd_buf, &[], &[], Some(&fence))?;
|
device.run_cmd_buf(&cmd_buf, &[], &[], Some(&fence))?;
|
||||||
device.wait_and_reset(&[fence])?;
|
device.wait_and_reset(&[fence])?;
|
||||||
|
println!("elapsed = {:?}", start.elapsed());
|
||||||
let ts = device.reap_query_pool(&query_pool).unwrap();
|
let ts = device.reap_query_pool(&query_pool).unwrap();
|
||||||
println!("Element kernel time: {:.3}ms", ts[0] * 1e3);
|
println!("Element kernel time: {:.3}ms", ts[0] * 1e3);
|
||||||
println!("Tile allocation kernel time: {:.3}ms", (ts[1] - ts[0]) * 1e3);
|
println!(
|
||||||
|
"Tile allocation kernel time: {:.3}ms",
|
||||||
|
(ts[1] - ts[0]) * 1e3
|
||||||
|
);
|
||||||
println!("Coarse path kernel time: {:.3}ms", (ts[2] - ts[1]) * 1e3);
|
println!("Coarse path kernel time: {:.3}ms", (ts[2] - ts[1]) * 1e3);
|
||||||
println!("Backdrop kernel time: {:.3}ms", (ts[3] - ts[2]) * 1e3);
|
println!("Backdrop kernel time: {:.3}ms", (ts[3] - ts[2]) * 1e3);
|
||||||
println!("Binning kernel time: {:.3}ms", (ts[4] - ts[3]) * 1e3);
|
println!("Binning kernel time: {:.3}ms", (ts[4] - ts[3]) * 1e3);
|
||||||
|
|
|
@ -162,12 +162,20 @@ pub struct Renderer<D: Device> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D: Device> Renderer<D> {
|
impl<D: Device> Renderer<D> {
|
||||||
pub unsafe fn new(device: &D, scene: &[u8], n_paths: usize, n_pathseg: usize) -> Result<Self, Error> {
|
pub unsafe fn new(
|
||||||
|
device: &D,
|
||||||
|
scene: &[u8],
|
||||||
|
n_paths: usize,
|
||||||
|
n_pathseg: usize,
|
||||||
|
) -> Result<Self, Error> {
|
||||||
let host = MemFlags::host_coherent();
|
let host = MemFlags::host_coherent();
|
||||||
let dev = MemFlags::device_local();
|
let dev = MemFlags::device_local();
|
||||||
|
|
||||||
let n_elements = scene.len() / piet_gpu_types::scene::Element::fixed_size();
|
let n_elements = scene.len() / piet_gpu_types::scene::Element::fixed_size();
|
||||||
println!("scene: {} elements, {} paths, {} path_segments", n_elements, n_paths, n_pathseg);
|
println!(
|
||||||
|
"scene: {} elements, {} paths, {} path_segments",
|
||||||
|
n_elements, n_paths, n_pathseg
|
||||||
|
);
|
||||||
|
|
||||||
let scene_buf = device
|
let scene_buf = device
|
||||||
.create_buffer(std::mem::size_of_val(&scene[..]) as u64, host)
|
.create_buffer(std::mem::size_of_val(&scene[..]) as u64, host)
|
||||||
|
@ -256,17 +264,20 @@ impl<D: Device> Renderer<D> {
|
||||||
let coarse_pipeline = device.create_simple_compute_pipeline(coarse_code, 5, 0)?;
|
let coarse_pipeline = device.create_simple_compute_pipeline(coarse_code, 5, 0)?;
|
||||||
let coarse_ds = device.create_descriptor_set(
|
let coarse_ds = device.create_descriptor_set(
|
||||||
&coarse_pipeline,
|
&coarse_pipeline,
|
||||||
&[&anno_buf, &bin_buf, &tile_buf, &coarse_alloc_buf_dev, &ptcl_buf],
|
&[
|
||||||
|
&anno_buf,
|
||||||
|
&bin_buf,
|
||||||
|
&tile_buf,
|
||||||
|
&coarse_alloc_buf_dev,
|
||||||
|
&ptcl_buf,
|
||||||
|
],
|
||||||
&[],
|
&[],
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let k4_code = include_bytes!("../shader/kernel4.spv");
|
let k4_code = include_bytes!("../shader/kernel4.spv");
|
||||||
let k4_pipeline = device.create_simple_compute_pipeline(k4_code, 2, 1)?;
|
let k4_pipeline = device.create_simple_compute_pipeline(k4_code, 2, 1)?;
|
||||||
let k4_ds = device.create_descriptor_set(
|
let k4_ds =
|
||||||
&k4_pipeline,
|
device.create_descriptor_set(&k4_pipeline, &[&ptcl_buf, &tile_buf], &[&image_dev])?;
|
||||||
&[&ptcl_buf, &tile_buf],
|
|
||||||
&[&image_dev]
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(Renderer {
|
Ok(Renderer {
|
||||||
scene_buf,
|
scene_buf,
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
use std::borrow::Cow;
|
use std::{borrow::Cow, ops::RangeBounds};
|
||||||
|
|
||||||
use piet_gpu_types::encoder::{Encode, Encoder};
|
use piet_gpu_types::encoder::{Encode, Encoder};
|
||||||
|
|
||||||
use piet_gpu_types::scene::{CubicSeg, Element, Fill, LineSeg, QuadSeg, SetLineWidth, Stroke};
|
use piet_gpu_types::scene::{CubicSeg, Element, Fill, LineSeg, QuadSeg, SetLineWidth, Stroke};
|
||||||
|
|
||||||
use piet::kurbo::{Affine, PathEl, Point, Rect, Shape};
|
use piet::{
|
||||||
|
kurbo::Size,
|
||||||
|
kurbo::{Affine, PathEl, Point, Rect, Shape},
|
||||||
|
HitTestPosition, TextAttribute, TextStorage,
|
||||||
|
};
|
||||||
|
|
||||||
use piet::{
|
use piet::{
|
||||||
Color, Error, FixedGradient, Font, FontBuilder, HitTestPoint, HitTestTextPosition, ImageFormat,
|
Color, Error, FixedGradient, FontFamily, HitTestPoint, ImageFormat, InterpolationMode,
|
||||||
InterpolationMode, IntoBrush, LineMetric, RenderContext, StrokeStyle, Text, TextLayout,
|
IntoBrush, LineMetric, RenderContext, StrokeStyle, Text, TextLayout, TextLayoutBuilder,
|
||||||
TextLayoutBuilder,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct PietGpuImage;
|
pub struct PietGpuImage;
|
||||||
|
|
||||||
pub struct PietGpuFont;
|
|
||||||
|
|
||||||
pub struct PietGpuFontBuilder;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct PietGpuTextLayout;
|
pub struct PietGpuTextLayout;
|
||||||
|
|
||||||
pub struct PietGpuTextLayoutBuilder;
|
pub struct PietGpuTextLayoutBuilder;
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct PietGpuText;
|
pub struct PietGpuText;
|
||||||
|
|
||||||
pub struct PietGpuRenderContext {
|
pub struct PietGpuRenderContext {
|
||||||
|
@ -103,7 +103,7 @@ impl RenderContext for PietGpuRenderContext {
|
||||||
self.stroke_width = width;
|
self.stroke_width = width;
|
||||||
}
|
}
|
||||||
let brush = brush.make_brush(self, || shape.bounding_box()).into_owned();
|
let brush = brush.make_brush(self, || shape.bounding_box()).into_owned();
|
||||||
let path = shape.to_bez_path(TOLERANCE);
|
let path = shape.path_elements(TOLERANCE);
|
||||||
self.encode_path(path, false);
|
self.encode_path(path, false);
|
||||||
match brush {
|
match brush {
|
||||||
PietGpuBrush::Solid(rgba_color) => {
|
PietGpuBrush::Solid(rgba_color) => {
|
||||||
|
@ -126,7 +126,7 @@ impl RenderContext for PietGpuRenderContext {
|
||||||
|
|
||||||
fn fill(&mut self, shape: impl Shape, brush: &impl IntoBrush<Self>) {
|
fn fill(&mut self, shape: impl Shape, brush: &impl IntoBrush<Self>) {
|
||||||
let brush = brush.make_brush(self, || shape.bounding_box()).into_owned();
|
let brush = brush.make_brush(self, || shape.bounding_box()).into_owned();
|
||||||
let path = shape.to_bez_path(TOLERANCE);
|
let path = shape.path_elements(TOLERANCE);
|
||||||
self.encode_path(path, true);
|
self.encode_path(path, true);
|
||||||
match brush {
|
match brush {
|
||||||
PietGpuBrush::Solid(rgba_color) => {
|
PietGpuBrush::Solid(rgba_color) => {
|
||||||
|
@ -146,23 +146,7 @@ impl RenderContext for PietGpuRenderContext {
|
||||||
&mut self.inner_text
|
&mut self.inner_text
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_text(
|
fn draw_text(&mut self, _layout: &Self::TextLayout, _pos: impl Into<Point>) {}
|
||||||
&mut self,
|
|
||||||
_layout: &Self::TextLayout,
|
|
||||||
pos: impl Into<Point>,
|
|
||||||
brush: &impl IntoBrush<Self>,
|
|
||||||
) {
|
|
||||||
let _pos = pos.into();
|
|
||||||
|
|
||||||
let brush: PietGpuBrush = brush.make_brush(self, || Rect::ZERO).into_owned();
|
|
||||||
|
|
||||||
match brush {
|
|
||||||
PietGpuBrush::Solid(_rgba) => {
|
|
||||||
// TODO: draw text
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn save(&mut self) -> Result<(), Error> {
|
fn save(&mut self) -> Result<(), Error> {
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -335,70 +319,81 @@ impl PietGpuRenderContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Text for PietGpuText {
|
impl Text for PietGpuText {
|
||||||
type Font = PietGpuFont;
|
|
||||||
type FontBuilder = PietGpuFontBuilder;
|
|
||||||
type TextLayout = PietGpuTextLayout;
|
type TextLayout = PietGpuTextLayout;
|
||||||
type TextLayoutBuilder = PietGpuTextLayoutBuilder;
|
type TextLayoutBuilder = PietGpuTextLayoutBuilder;
|
||||||
|
|
||||||
fn new_font_by_name(&mut self, _name: &str, _size: f64) -> Self::FontBuilder {
|
fn load_font(&mut self, _data: &[u8]) -> Result<FontFamily, Error> {
|
||||||
unimplemented!();
|
Ok(FontFamily::default())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_text_layout(
|
fn new_text_layout(&mut self, _text: impl TextStorage) -> Self::TextLayoutBuilder {
|
||||||
&mut self,
|
PietGpuTextLayoutBuilder
|
||||||
_font: &Self::Font,
|
|
||||||
_text: &str,
|
|
||||||
_width: impl Into<Option<f64>>,
|
|
||||||
) -> Self::TextLayoutBuilder {
|
|
||||||
unimplemented!();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl Font for PietGpuFont {}
|
fn font_family(&mut self, _family_name: &str) -> Option<FontFamily> {
|
||||||
|
Some(FontFamily::default())
|
||||||
impl FontBuilder for PietGpuFontBuilder {
|
|
||||||
type Out = PietGpuFont;
|
|
||||||
|
|
||||||
fn build(self) -> Result<Self::Out, Error> {
|
|
||||||
unimplemented!();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TextLayoutBuilder for PietGpuTextLayoutBuilder {
|
impl TextLayoutBuilder for PietGpuTextLayoutBuilder {
|
||||||
type Out = PietGpuTextLayout;
|
type Out = PietGpuTextLayout;
|
||||||
|
|
||||||
|
fn max_width(self, _width: f64) -> Self {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
fn alignment(self, _alignment: piet::TextAlignment) -> Self {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
fn default_attribute(self, _attribute: impl Into<TextAttribute>) -> Self {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
fn range_attribute(
|
||||||
|
self,
|
||||||
|
_range: impl RangeBounds<usize>,
|
||||||
|
_attribute: impl Into<TextAttribute>,
|
||||||
|
) -> Self {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
fn build(self) -> Result<Self::Out, Error> {
|
fn build(self) -> Result<Self::Out, Error> {
|
||||||
unimplemented!()
|
Ok(PietGpuTextLayout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TextLayout for PietGpuTextLayout {
|
impl TextLayout for PietGpuTextLayout {
|
||||||
fn width(&self) -> f64 {
|
fn size(&self) -> Size {
|
||||||
0.0
|
Size::ZERO
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_width(&mut self, _new_width: impl Into<Option<f64>>) -> Result<(), Error> {
|
fn image_bounds(&self) -> Rect {
|
||||||
unimplemented!()
|
Rect::ZERO
|
||||||
}
|
}
|
||||||
|
|
||||||
fn line_text(&self, _line_number: usize) -> Option<&str> {
|
fn line_text(&self, _line_number: usize) -> Option<&str> {
|
||||||
unimplemented!()
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
fn line_metric(&self, _line_number: usize) -> Option<LineMetric> {
|
fn line_metric(&self, _line_number: usize) -> Option<LineMetric> {
|
||||||
unimplemented!()
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
fn line_count(&self) -> usize {
|
fn line_count(&self) -> usize {
|
||||||
unimplemented!()
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hit_test_point(&self, _point: Point) -> HitTestPoint {
|
fn hit_test_point(&self, _point: Point) -> HitTestPoint {
|
||||||
unimplemented!()
|
HitTestPoint::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hit_test_text_position(&self, _text_position: usize) -> Option<HitTestTextPosition> {
|
fn hit_test_text_position(&self, _text_position: usize) -> HitTestPosition {
|
||||||
unimplemented!()
|
HitTestPosition::default()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn text(&self) -> &str {
|
||||||
|
""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue