sixtyfps_compilerlib/
embedded_resources.rs

1// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
2// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
3
4#[cfg(not(target_arch = "wasm32"))]
5pub use tiny_skia::IntRect as Rect;
6
7#[derive(Debug, Clone, Copy, Default)]
8pub struct Size {
9    pub width: u32,
10    pub height: u32,
11}
12
13#[derive(Clone, Copy, Debug)]
14pub enum PixelFormat {
15    // 24 bit RGB
16    Rgb,
17    // 32 bit RGBA
18    Rgba,
19    // 8bit alpha map with a given color
20    AlphaMap([u8; 3]),
21}
22
23#[cfg(not(target_arch = "wasm32"))]
24#[derive(Debug, Clone)]
25pub struct Texture {
26    pub total_size: Size,
27    pub rect: Rect,
28    pub data: Vec<u8>,
29    pub format: PixelFormat,
30}
31
32#[cfg(not(target_arch = "wasm32"))]
33impl Texture {
34    pub fn new_empty() -> Self {
35        Self {
36            total_size: Size::default(),
37            rect: Rect::from_xywh(0, 0, 1, 1).unwrap(),
38            data: vec![0, 0, 0, 0],
39            format: PixelFormat::Rgba,
40        }
41    }
42}
43
44#[derive(Debug, Clone)]
45pub enum EmbeddedResourcesKind {
46    /// Just put the file content as a resource
47    RawData,
48    /// The data has been processed in a texture
49    TextureData(#[cfg(not(target_arch = "wasm32"))] Texture),
50}
51
52#[derive(Debug, Clone)]
53pub struct EmbeddedResources {
54    /// unique integer id, that can be used by the generator for symbol generation.
55    pub id: usize,
56
57    pub kind: EmbeddedResourcesKind,
58}