From 3c18e79c4c0eebc823fae48ba341cd302277b863 Mon Sep 17 00:00:00 2001 From: czadowanie <125468992+czadowanie@users.noreply.github.com> Date: Mon, 13 Nov 2023 23:12:47 +0100 Subject: [PATCH] feat: force tiny_skia with environment variable (#173) --- src/renderer.rs | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/renderer.rs b/src/renderer.rs index 8aa0efb8..d61b6816 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -68,19 +68,35 @@ impl Renderer { { let size = Size::new(size.width.max(1.0), size.height.max(1.0)); - let vger_err = match VgerRenderer::new(window, size.width as u32, size.height as u32, scale) + let force_tiny_skia = if let Some(val) = std::env::var("FLOEM_FORCE_TINY_SKIA") + .ok() + .map(|val| val.as_str() == "1") { - Ok(vger) => return Self::Vger(vger), - Err(vger_err) => vger_err, + val + } else { + false + }; + + let vger_err = if !force_tiny_skia { + match VgerRenderer::new(window, size.width as u32, size.height as u32, scale) { + Ok(vger) => return Self::Vger(vger), + Err(err) => Some(err), + } + } else { + None }; let tiny_skia_err = match TinySkiaRenderer::new(window, size.width as u32, size.height as u32, scale) { Ok(tiny_skia) => return Self::TinySkia(tiny_skia), - Err(vger_err) => vger_err, + Err(err) => err, }; - panic!("Failed to create VgerRenderer: {vger_err}\nFailed to create TinySkiaRenderer: {tiny_skia_err}") + if !force_tiny_skia { + panic!("Failed to create VgerRenderer: {}\nFailed to create TinySkiaRenderer: {tiny_skia_err}", vger_err.unwrap()); + } else { + panic!("Failed to create TinySkiaRenderer: {tiny_skia_err}"); + } } pub fn resize(&mut self, scale: f64, size: Size) {