Skip to content

Commit 8be3282

Browse files
committed
move surface/pixmap reallocation optimization to rupl
1 parent 103a853 commit 8be3282

5 files changed

Lines changed: 8 additions & 36 deletions

File tree

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ default=["skia-vulkan", "rug","fastnum", "vulkano-x11","x11", "wayland", "rayon"
3434
#default=["tiny-skia","rug","fastnum", "wayland", "softbuffer", "softbuffer-wayland"]
3535
egui=["dep:egui","dep:eframe","rupl/egui"]
3636
skia=["rupl/skia" ,"rupl/winit", "dep:winit"]
37-
tiny-skia=["rupl/tiny-skia" ,"rupl/winit", "dep:winit", "dep:tiny-skia", "rupl/tiny-skia-png", "rupl/tiny-skia-text"]
37+
tiny-skia=["rupl/tiny-skia" ,"rupl/winit", "dep:winit", "rupl/tiny-skia-png", "rupl/tiny-skia-text"]
3838
softbuffer = ["dep:softbuffer"]
3939
rayon=["dep:rayon", "rupl/rayon", "kalc-lib?/rayon"]
4040
bincode=["dep:bitcode", "dep:serde", "rupl/serde", "dep:dirs", "kalc-lib?/serde"]
@@ -65,5 +65,4 @@ rupl={version = "0.1.2",path="../rupl",default-features = false}
6565
kalc-lib={version="1.5.1",default-features=false,features = ["fastrand"],path="../kalc-lib",optional = true}
6666
wasm-bindgen = {version="0.2.100",optional = true}
6767
#console_error_panic_hook = { version = "0.1.7", optional = true }
68-
web-sys = { version = "0.3.77", features = ["CanvasRenderingContext2d"], optional = true }
69-
tiny-skia = {version = "0.11.4", default-features = false, optional = true}
68+
web-sys = { version = "0.3.77", features = ["CanvasRenderingContext2d"], optional = true }

src/app.rs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ impl App {
116116
}
117117
data.update(&mut plot);
118118
Self {
119-
#[cfg(feature = "tiny-skia")]
120-
canvas: None,
121119
plot,
122120
data,
123121
#[cfg(feature = "bincode")]
@@ -185,8 +183,6 @@ impl App {
185183
plot.mult = 1.0 / 16.0;
186184
data.update(&mut plot);
187185
Self {
188-
#[cfg(feature = "tiny-skia")]
189-
canvas: None,
190186
plot,
191187
data,
192188
#[cfg(feature = "bincode")]
@@ -268,12 +264,7 @@ impl App {
268264
self.plot.update(width, height, &mut buffer);
269265
#[cfg(feature = "tiny-skia")]
270266
{
271-
self.canvas = Some(self.plot.update(
272-
width,
273-
height,
274-
&mut buffer,
275-
std::mem::take(&mut self.canvas).unwrap(),
276-
));
267+
self.plot.update(width, height, &mut buffer);
277268
}
278269
buffer.present().unwrap();
279270
}
@@ -304,14 +295,12 @@ impl App {
304295
self.plot.update(width, height, &mut v);
305296
#[cfg(feature = "tiny-skia")]
306297
{
307-
self.canvas = Some(self.plot.update(
308-
width,
309-
height,
310-
&mut v,
311-
std::mem::take(&mut self.canvas).unwrap(),
312-
));
298+
self.plot.update(width, height, &mut v);
313299
}
314-
draw_buffer_web(self.window.as_ref().unwrap(), self.canvas.as_ref().unwrap());
300+
draw_buffer_web(
301+
self.window.as_ref().unwrap(),
302+
self.plot.canvas.as_ref().unwrap(),
303+
);
315304
if b {
316305
let name = self.name.clone();
317306
if let Some(w) = self.window() {

src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,6 @@ pub fn main() {
154154
struct App {
155155
plot: Graph,
156156
data: Data,
157-
#[cfg(feature = "tiny-skia")]
158-
#[cfg_attr(feature = "bincode", serde(skip))]
159-
canvas: Option<tiny_skia::Pixmap>,
160157
#[cfg(feature = "bincode")]
161158
tiny: Option<rupl::types::GraphTiny>,
162159
#[cfg(any(feature = "skia", feature = "tiny-skia"))]

src/window.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,6 @@ impl winit::application::ApplicationHandler for App {
113113
state.request_redraw();
114114
#[cfg(feature = "skia-vulkan")]
115115
self.plot.resize();
116-
#[cfg(feature = "tiny-skia")]
117-
{
118-
self.canvas = Some(tiny_skia::Pixmap::new(_d.width, _d.height).unwrap());
119-
}
120116
}
121117
#[cfg(not(any(feature = "wasm", feature = "skia-vulkan")))]
122118
{
@@ -132,10 +128,6 @@ impl winit::application::ApplicationHandler for App {
132128
std::num::NonZeroU32::new(_d.height).unwrap(),
133129
)
134130
.unwrap();
135-
#[cfg(feature = "tiny-skia")]
136-
{
137-
self.canvas = Some(tiny_skia::Pixmap::new(_d.width, _d.height).unwrap());
138-
}
139131
}
140132
}
141133
winit::event::WindowEvent::RedrawRequested => {
@@ -146,10 +138,6 @@ impl winit::application::ApplicationHandler for App {
146138
let size = state.inner_size();
147139
(size.width, size.height)
148140
};
149-
#[cfg(feature = "tiny-skia")]
150-
if self.canvas.is_none() {
151-
self.canvas = Some(tiny_skia::Pixmap::new(width, height).unwrap());
152-
}
153141
if self.touch_positions.len() > 1
154142
&& self.touch_positions.len() == self.last_touch_positions.len()
155143
{

0 commit comments

Comments
 (0)