This commit is contained in:
5
.cargo/config.toml
Normal file
5
.cargo/config.toml
Normal file
@@ -0,0 +1,5 @@
|
||||
[build]
|
||||
target = "x86_64-unknown-uefi"
|
||||
|
||||
[target.x86_64-unknown-uefi]
|
||||
runner = "bootuefi"
|
||||
19
.gitea/workflows/lint.yaml
Normal file
19
.gitea/workflows/lint.yaml
Normal file
@@ -0,0 +1,19 @@
|
||||
name: Lint
|
||||
run-name: ${{ gitea.actor }} is linting
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
- name: Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
components: rustfmt, clippy
|
||||
- name: Lint
|
||||
run: cargo clippy
|
||||
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/target
|
||||
/assets
|
||||
/vm
|
||||
5
src/config.rs
Normal file
5
src/config.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
use crate::enums::MediaType;
|
||||
|
||||
pub static DATA: &[u8] = include_bytes!("../assets/rainbow.png");
|
||||
pub static MEDIA_TYPE: MediaType = MediaType::ImagePNG;
|
||||
pub static SCALE: f32 = 1.0;
|
||||
5
src/enums.rs
Normal file
5
src/enums.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum MediaType {
|
||||
VideoGIF,
|
||||
ImagePNG,
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
use core::fmt::Debug;
|
||||
|
||||
use alloc::string::{String, ToString};
|
||||
|
||||
pub struct RenderError {
|
||||
@@ -13,3 +15,9 @@ impl RenderError {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Debug for RenderError {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
f.write_fmt(format_args!("[{}] {}", self.ident, self.message))
|
||||
}
|
||||
}
|
||||
|
||||
30
src/main.rs
30
src/main.rs
@@ -8,12 +8,16 @@ use codec::{
|
||||
transform::scale::ScaleTransformer,
|
||||
video::{VideoDecoder, gif::GifDecoder},
|
||||
};
|
||||
use config::{DATA, MEDIA_TYPE, SCALE};
|
||||
use enums::MediaType;
|
||||
use graphic::GraphicLoader;
|
||||
use log::info;
|
||||
use uefi::{allocator::Allocator, prelude::*};
|
||||
|
||||
mod codec;
|
||||
mod color;
|
||||
mod config;
|
||||
mod enums;
|
||||
mod error;
|
||||
mod graphic;
|
||||
mod util;
|
||||
@@ -21,8 +25,6 @@ mod util;
|
||||
#[global_allocator]
|
||||
static ALLOC: Allocator = Allocator;
|
||||
|
||||
static IMAGE: &[u8] = include_bytes!("../assets/pet.gif");
|
||||
|
||||
#[entry]
|
||||
fn main() -> Status {
|
||||
uefi::helpers::init().unwrap();
|
||||
@@ -30,13 +32,23 @@ fn main() -> Status {
|
||||
|
||||
let gl = GraphicLoader::new();
|
||||
|
||||
let data = GifDecoder.decode(IMAGE);
|
||||
match MEDIA_TYPE {
|
||||
MediaType::ImagePNG => {
|
||||
let data = PngDecoder
|
||||
.decode(DATA)
|
||||
.expect("Render Error")
|
||||
.transform(&ScaleTransformer::new(SCALE));
|
||||
gl.render(&data).unwrap();
|
||||
}
|
||||
MediaType::VideoGIF => {
|
||||
let data = GifDecoder
|
||||
.decode(DATA)
|
||||
.expect("Render Error")
|
||||
.transform(&ScaleTransformer::new(SCALE));
|
||||
gl.render_video(&data).unwrap();
|
||||
}
|
||||
};
|
||||
|
||||
if let Ok(data) = data {
|
||||
let data = data.transform(&ScaleTransformer::new(4.0));
|
||||
gl.render_video(&data);
|
||||
}
|
||||
|
||||
boot::stall(10_000_000);
|
||||
boot::stall(10_000_000_000);
|
||||
Status::SUCCESS
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user