Skip to content

Commit

Permalink
Reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurenzV committed Nov 29, 2024
1 parent e8bec28 commit a2249f5
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 18 deletions.
2 changes: 1 addition & 1 deletion crates/krilla/src/font/bitmap.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//! Drawing bitmap-based glyphs to a surface.
use std::sync::Arc;
use crate::font::bitmap::utils::{BitmapData, BitmapFormat, BitmapStrikes, Origin};
use crate::font::Font;
use crate::object::image::Image;
use crate::surface::Surface;
use skrifa::{GlyphId, MetadataProvider};
use std::sync::Arc;
use tiny_skia_path::{Size, Transform};

/// Draw a bitmap-based glyph on a surface.
Expand Down
23 changes: 11 additions & 12 deletions crates/krilla/src/object/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
//! - GIF
//! - WEBP
use std::fmt::{Debug, Formatter};
use std::hash::{Hash, Hasher};
use crate::color::{ICCBasedColorSpace, ICCProfile, ICCProfileWrapper, DEVICE_CMYK, DEVICE_RGB};
use crate::object::color::DEVICE_GRAY;
use crate::resource::RegisterableResource;
use crate::serialize::SerializerContext;
use crate::stream::FilterStream;
use crate::util::{Deferred, NameExt, SipHashable};
use pdf_writer::{Chunk, Finish, Name, Ref};
use std::fmt::{Debug, Formatter};
use std::hash::{Hash, Hasher};
use std::ops::DerefMut;
use std::sync::Arc;
use zune_jpeg::zune_core::result::DecodingResult;
Expand Down Expand Up @@ -102,13 +102,13 @@ impl Repr {
struct ImageMetadata {
size: (u32, u32),
color_space: ImageColorspace,
icc: Option<ICCProfileWrapper>
icc: Option<ICCProfileWrapper>,
}

struct ImageRepr {
inner: Deferred<Option<Repr>>,
metadata: ImageMetadata,
sip: u128
sip: u128,
}

impl ImageRepr {
Expand Down Expand Up @@ -400,14 +400,13 @@ fn decode_jpeg(data: &[u8]) -> Option<Repr> {
let input_color_space = decoder.get_input_colorspace()?;

if matches!(
input_color_space,
ColorSpace::Luma
| ColorSpace::YCbCr
| ColorSpace::RGB
| ColorSpace::CMYK
| ColorSpace::YCCK
) {

input_color_space,
ColorSpace::Luma
| ColorSpace::YCbCr
| ColorSpace::RGB
| ColorSpace::CMYK
| ColorSpace::YCCK
) {
Some(Repr::Jpeg(JpegRepr {
// TODO: Avoid cloning here?
data: data.to_vec(),
Expand Down
2 changes: 1 addition & 1 deletion crates/krilla/src/svg/filter.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::sync::Arc;
use crate::object::image::Image;
use crate::surface::Surface;
use crate::svg::ProcessContext;
use std::sync::Arc;
use tiny_skia_path::{Size, Transform};

/// Render a filter into a surface by rasterizing it with `resvg` and drawing
Expand Down
20 changes: 16 additions & 4 deletions crates/krilla/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,19 +191,31 @@ pub fn rect_to_path(x1: f32, y1: f32, x2: f32, y2: f32) -> Path {
}

pub fn load_png_image(name: &str) -> Image {
Image::from_png(Arc::new(std::fs::read(ASSETS_PATH.join("images").join(name)).unwrap())).unwrap()
Image::from_png(Arc::new(
std::fs::read(ASSETS_PATH.join("images").join(name)).unwrap(),
))
.unwrap()
}

pub fn load_jpg_image(name: &str) -> Image {
Image::from_jpeg(Arc::new(std::fs::read(ASSETS_PATH.join("images").join(name)).unwrap())).unwrap()
Image::from_jpeg(Arc::new(
std::fs::read(ASSETS_PATH.join("images").join(name)).unwrap(),
))
.unwrap()
}

pub fn load_gif_image(name: &str) -> Image {
Image::from_gif(Arc::new(std::fs::read(ASSETS_PATH.join("images").join(name)).unwrap())).unwrap()
Image::from_gif(Arc::new(
std::fs::read(ASSETS_PATH.join("images").join(name)).unwrap(),
))
.unwrap()
}

pub fn load_webp_image(name: &str) -> Image {
Image::from_webp(Arc::new(std::fs::read(ASSETS_PATH.join("images").join(name)).unwrap())).unwrap()
Image::from_webp(Arc::new(
std::fs::read(ASSETS_PATH.join("images").join(name)).unwrap(),
))
.unwrap()
}

fn write_snapshot_to_store(name: &str, content: &[u8]) {
Expand Down

0 comments on commit a2249f5

Please sign in to comment.