Skip to content

Commit

Permalink
Implement fill_raw
Browse files Browse the repository at this point in the history
  • Loading branch information
jackpot51 committed Oct 22, 2024
1 parent 57598f2 commit a088df9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
11 changes: 10 additions & 1 deletion tiny_skia/src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::core::{
};
use crate::graphics::damage;
use crate::graphics::layer;
use crate::graphics::text::{Editor, Paragraph, Text};
use crate::graphics::text::{Editor, Paragraph, Raw, Text};
use crate::graphics::{self, Image};
use crate::Primitive;

Expand Down Expand Up @@ -115,6 +115,15 @@ impl Layer {
.push(Item::Cached(text, clip_bounds, transformation));
}

pub fn draw_raw(&mut self, raw: Raw, transformation: Transformation) {
let text = Text::Raw {
raw,
transformation,
};

self.text.push(Item::Live(text));
}

pub fn draw_image(&mut self, image: Image, transformation: Transformation) {
match image {
Image::Raster { handle, bounds } => {
Expand Down
5 changes: 4 additions & 1 deletion tiny_skia/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,10 @@ impl core::text::Renderer for Renderer {
layer.draw_text(text, position, color, clip_bounds, transformation);
}

fn fill_raw(&mut self, _raw: Self::Raw) {}
fn fill_raw(&mut self, raw: Self::Raw) {
let (layer, transformation) = self.layers.current_mut();
layer.draw_raw(raw, transformation);
}
}

#[cfg(feature = "geometry")]
Expand Down
11 changes: 10 additions & 1 deletion wgpu/src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::core::{
use crate::graphics;
use crate::graphics::color;
use crate::graphics::layer;
use crate::graphics::text::{Editor, Paragraph};
use crate::graphics::text::{Editor, Paragraph, Raw};
use crate::graphics::Mesh;
use crate::image::{self, Image};
use crate::primitive::{self, Primitive};
Expand Down Expand Up @@ -113,6 +113,15 @@ impl Layer {
self.pending_text.push(text);
}

pub fn draw_raw(&mut self, raw: Raw, transformation: Transformation) {
let text = Text::Raw {
raw,
transformation,
};

self.pending_text.push(text);
}

pub fn draw_image(&mut self, image: Image, transformation: Transformation) {
match image {
Image::Raster { handle, bounds } => {
Expand Down
3 changes: 2 additions & 1 deletion wgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,8 @@ impl core::text::Renderer for Renderer {
}

fn fill_raw(&mut self, raw: Self::Raw) {
// TODO
let (layer, transformation) = self.layers.current_mut();
layer.draw_raw(raw, transformation);
}
}

Expand Down

0 comments on commit a088df9

Please sign in to comment.