render: Switch from log to tracing

This commit is contained in:
Nathan Adams 2023-02-02 15:47:20 +01:00
parent f9b378b29a
commit a3a7f79f04
5 changed files with 10 additions and 8 deletions

2
Cargo.lock generated
View File

@ -3567,13 +3567,13 @@ dependencies = [
"gc-arena", "gc-arena",
"gif 0.12.0", "gif 0.12.0",
"jpeg-decoder", "jpeg-decoder",
"log",
"lyon", "lyon",
"png", "png",
"serde", "serde",
"smallvec", "smallvec",
"swf", "swf",
"thiserror", "thiserror",
"tracing",
"wasm-bindgen", "wasm-bindgen",
] ]

View File

@ -9,7 +9,7 @@ version.workspace = true
[dependencies] [dependencies]
swf = { path = "../swf"} swf = { path = "../swf"}
log = "0.4" tracing = "0.1.37"
gif = "0.12.0" gif = "0.12.0"
png = { version = "0.17.7" } png = { version = "0.17.7" }
flate2 = "1.0.25" flate2 = "1.0.25"

View File

@ -61,7 +61,7 @@ impl Bitmap {
// If the size is incorrect, either we screwed up or the decoder screwed up. // If the size is incorrect, either we screwed up or the decoder screwed up.
let expected_len = width as usize * height as usize * format.bytes_per_pixel(); let expected_len = width as usize * height as usize * format.bytes_per_pixel();
if data.len() != expected_len { if data.len() != expected_len {
log::warn!( tracing::warn!(
"Incorrect bitmap data size, expected {} bytes, got {}", "Incorrect bitmap data size, expected {} bytes, got {}",
data.len(), data.len(),
expected_len expected_len

View File

@ -8,6 +8,7 @@ use lyon::tessellation::{
FillTessellator, FillVertex, StrokeTessellator, StrokeVertex, StrokeVertexConstructor, FillTessellator, FillVertex, StrokeTessellator, StrokeVertex, StrokeVertexConstructor,
}; };
use lyon::tessellation::{FillOptions, StrokeOptions}; use lyon::tessellation::{FillOptions, StrokeOptions};
use tracing::instrument;
pub struct ShapeTessellator { pub struct ShapeTessellator {
fill_tess: FillTessellator, fill_tess: FillTessellator,
@ -30,6 +31,7 @@ impl ShapeTessellator {
} }
} }
#[instrument(level = "debug", skip_all)]
pub fn tessellate_shape( pub fn tessellate_shape(
&mut self, &mut self,
shape: DistilledShape, shape: DistilledShape,
@ -182,7 +184,7 @@ impl ShapeTessellator {
} }
Err(e) => { Err(e) => {
// This may simply be a degenerate path. // This may simply be a degenerate path.
log::error!("Tessellation failure: {:?}", e); tracing::error!("Tessellation failure: {:?}", e);
} }
} }
} }

View File

@ -32,7 +32,7 @@ pub fn decode_define_bits_jpeg(data: &[u8], alpha_data: Option<&[u8]>) -> Result
let format = determine_jpeg_tag_format(data); let format = determine_jpeg_tag_format(data);
if format != JpegTagFormat::Jpeg && alpha_data.is_some() { if format != JpegTagFormat::Jpeg && alpha_data.is_some() {
// Only DefineBitsJPEG3 with true JPEG data should have separate alpha data. // Only DefineBitsJPEG3 with true JPEG data should have separate alpha data.
log::warn!("DefineBitsJPEG contains non-JPEG data with alpha; probably incorrect") tracing::warn!("DefineBitsJPEG contains non-JPEG data with alpha; probably incorrect")
} }
match format { match format {
JpegTagFormat::Jpeg => decode_jpeg(data, alpha_data), JpegTagFormat::Jpeg => decode_jpeg(data, alpha_data),
@ -135,7 +135,7 @@ pub fn remove_invalid_jpeg_data(data: &[u8]) -> Cow<[u8]> {
if data.ends_with(&[0xFF, EOI]) { if data.ends_with(&[0xFF, EOI]) {
data data
} else { } else {
log::warn!("JPEG is missing EOI marker and may not decode properly"); tracing::warn!("JPEG is missing EOI marker and may not decode properly");
data.to_mut().extend_from_slice(&[0xFF, EOI]); data.to_mut().extend_from_slice(&[0xFF, EOI]);
data data
} }
@ -171,7 +171,7 @@ fn decode_jpeg(jpeg_data: &[u8], alpha_data: Option<&[u8]>) -> Result<Bitmap, Er
.collect(), .collect(),
jpeg_decoder::PixelFormat::L8 => decoded_data.iter().flat_map(|&c| [c, c, c]).collect(), jpeg_decoder::PixelFormat::L8 => decoded_data.iter().flat_map(|&c| [c, c, c]).collect(),
jpeg_decoder::PixelFormat::L16 => { jpeg_decoder::PixelFormat::L16 => {
log::warn!("Unimplemented L16 JPEG pixel format"); tracing::warn!("Unimplemented L16 JPEG pixel format");
decoded_data decoded_data
} }
}; };
@ -204,7 +204,7 @@ fn decode_jpeg(jpeg_data: &[u8], alpha_data: Option<&[u8]>) -> Result<Bitmap, Er
)); ));
} else { } else {
// Size isn't correct; fallback to RGB? // Size isn't correct; fallback to RGB?
log::error!("Size mismatch in DefineBitsJPEG3 alpha data"); tracing::error!("Size mismatch in DefineBitsJPEG3 alpha data");
} }
} }