1
0
Fork 0
forked from wry/wry

all: replace enum-map by linearize

This commit is contained in:
Julian Orth 2025-01-22 14:56:14 +01:00
parent b64bb52051
commit bd303a7ea5
6 changed files with 307 additions and 293 deletions

View file

@ -229,7 +229,7 @@ pub fn buf_to_bytes(
let mut encoder = Encoder::new(&mut out, buf.width as _, buf.height as _);
encoder.set_color(ColorType::Rgba);
encoder.set_depth(BitDepth::Eight);
encoder.set_srgb(SrgbRenderingIntent::Perceptual);
encoder.set_source_srgb(SrgbRenderingIntent::Perceptual);
let mut writer = encoder.write_header().unwrap();
writer.write_image_data(&image_data).unwrap();
}

View file

@ -24,8 +24,8 @@ use {
},
},
ahash::AHashMap,
enum_map::{enum_map, Enum, EnumMap},
jay_config::video::GfxApi,
linearize::{static_map, Linearize, StaticMap},
std::{
cell::{Cell, RefCell},
ffi::CString,
@ -60,13 +60,13 @@ impl TexProg {
}
}
#[derive(Copy, Clone, PartialEq, Enum)]
#[derive(Copy, Clone, PartialEq, Linearize)]
pub(in crate::gfx_apis::gl) enum TexCopyType {
Identity,
Multiply,
}
#[derive(Copy, Clone, PartialEq, Enum)]
#[derive(Copy, Clone, PartialEq, Linearize)]
pub(in crate::gfx_apis::gl) enum TexSourceType {
Opaque,
HasAlpha,
@ -79,8 +79,8 @@ pub(in crate::gfx_apis::gl) struct GlRenderContext {
pub(crate) render_node: Rc<CString>,
pub(crate) tex_internal: EnumMap<TexCopyType, EnumMap<TexSourceType, TexProg>>,
pub(crate) tex_external: Option<EnumMap<TexCopyType, EnumMap<TexSourceType, TexProg>>>,
pub(crate) tex_internal: StaticMap<TexCopyType, StaticMap<TexSourceType, TexProg>>,
pub(crate) tex_external: Option<StaticMap<TexCopyType, StaticMap<TexSourceType, TexProg>>>,
pub(crate) fill_prog: GlProgram,
pub(crate) fill_prog_pos: GLint,
@ -136,12 +136,12 @@ impl GlRenderContext {
Ok::<_, RenderError>(TexProg::from(prog, alpha_multiplier))
}
};
Ok::<_, RenderError>(enum_map! {
TexCopyType::Identity => enum_map! {
Ok::<_, RenderError>(static_map! {
TexCopyType::Identity => static_map! {
TexSourceType::Opaque => create_program(false, false)?,
TexSourceType::HasAlpha => create_program(false, true)?,
},
TexCopyType::Multiply => enum_map! {
TexCopyType::Multiply => static_map! {
TexSourceType::Opaque => create_program(true, false)?,
TexSourceType::HasAlpha => create_program(true, true)?,
},

View file

@ -43,8 +43,8 @@ use {
},
Device,
},
enum_map::{enum_map, Enum, EnumMap},
isnt::std_1::collections::IsntHashMapExt,
linearize::{static_map, Linearize, StaticMap},
std::{
cell::{Cell, RefCell},
fmt::{Debug, Formatter},
@ -109,13 +109,13 @@ pub(super) struct UsedTexture {
release_sync: ReleaseSync,
}
#[derive(Enum)]
#[derive(Linearize)]
pub(super) enum TexCopyType {
Identity,
Multiply,
}
#[derive(Enum)]
#[derive(Linearize)]
pub(super) enum TexSourceType {
Opaque,
HasAlpha,
@ -145,7 +145,7 @@ pub(super) struct PendingFrame {
pub(super) struct VulkanFormatPipelines {
pub(super) fill: Rc<VulkanPipeline>,
pub(super) tex: EnumMap<TexCopyType, EnumMap<TexSourceType, Rc<VulkanPipeline>>>,
pub(super) tex: StaticMap<TexCopyType, StaticMap<TexSourceType, Rc<VulkanPipeline>>>,
}
impl VulkanDevice {
@ -276,12 +276,12 @@ impl VulkanRenderer {
let tex_mult_alpha = create_tex_mult_pipeline(&self.tex_frag_mult_alpha_shader)?;
let pipelines = Rc::new(VulkanFormatPipelines {
fill,
tex: enum_map! {
TexCopyType::Identity => enum_map! {
tex: static_map! {
TexCopyType::Identity => static_map! {
TexSourceType::HasAlpha => tex_alpha.clone(),
TexSourceType::Opaque => tex_opaque.clone(),
},
TexCopyType::Multiply => enum_map! {
TexCopyType::Multiply => static_map! {
TexSourceType::HasAlpha => tex_mult_alpha.clone(),
TexSourceType::Opaque => tex_mult_opaque.clone(),
},

View file

@ -165,8 +165,9 @@ mod leaks {
objs.sort_by_key(|o| o.0);
log::info!("Client {} leaked {} objects", objs[0].1.client, objs.len());
for (_, obj) in objs {
let time =
chrono::NaiveDateTime::from_timestamp_opt(obj.time.0, obj.time.1).unwrap();
let time = chrono::DateTime::from_timestamp(obj.time.0, obj.time.1)
.unwrap()
.naive_utc();
log::info!(" [{}] {}", time.format("%H:%M:%S%.3f"), obj.ty,);
match find_allocation_containing(obj.addr) {
Some(mut alloc) => {