Skip to content
This repository was archived by the owner on Jun 23, 2022. It is now read-only.

Commit 8a83cf5

Browse files
committed
Refactor the bitmap backend to multiple files
1 parent af4d02b commit 8a83cf5

File tree

10 files changed

+1327
-1281
lines changed

10 files changed

+1327
-1281
lines changed

src/bitmap.rs

Lines changed: 9 additions & 1278 deletions
Large diffs are not rendered by default.

src/bitmap/target.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
use std::path::Path;
2+
use std::marker::PhantomData;
3+
#[cfg(all(feature = "gif", not(target_arch = "wasm32"), feature = "image"))]
4+
use crate::gif_support;
5+
6+
pub(super) enum Target<'a> {
7+
#[cfg(all(not(target_arch = "wasm32"), feature = "image"))]
8+
File(&'a Path),
9+
Buffer(PhantomData<&'a u32>),
10+
#[cfg(all(feature = "gif", not(target_arch = "wasm32"), feature = "image"))]
11+
Gif(Box<gif_support::GifFile>),
12+
}
13+
14+
pub(super) enum Buffer<'a> {
15+
#[cfg(all(not(target_arch = "wasm32"), feature = "image"))]
16+
Owned(Vec<u8>),
17+
Borrowed(&'a mut [u8]),
18+
}
19+
20+
impl<'a> Buffer<'a> {
21+
#[inline(always)]
22+
pub(super) fn borrow_buffer(&mut self) -> &mut [u8] {
23+
match self {
24+
#[cfg(all(not(target_arch = "wasm32"), feature = "image"))]
25+
Buffer::Owned(buf) => &mut buf[..],
26+
Buffer::Borrowed(buf) => *buf,
27+
}
28+
}
29+
}
30+

0 commit comments

Comments
 (0)