theme: store colors in linear space
This commit is contained in:
parent
b7f93b37a6
commit
135f37dbcd
27 changed files with 221 additions and 135 deletions
|
|
@ -435,7 +435,7 @@ impl GfxFramebuffer for TestGfxFb {
|
|||
a = 255;
|
||||
}
|
||||
staging[(y * width + x) as usize] =
|
||||
Color::from_rgba_premultiplied(r, g, b, a);
|
||||
Color::from_srgba_premultiplied(r, g, b, a);
|
||||
}
|
||||
data = data.add(stride as usize);
|
||||
}
|
||||
|
|
@ -446,7 +446,7 @@ impl GfxFramebuffer for TestGfxFb {
|
|||
for y in 0..height {
|
||||
for x in 0..width {
|
||||
let [r, g, b, a] =
|
||||
staging[(y * width + x) as usize].to_rgba_premultiplied();
|
||||
staging[(y * width + x) as usize].to_srgba_premultiplied();
|
||||
*data.add((x * 4) as usize).cast::<[u8; 4]>() = [b, g, r, a];
|
||||
}
|
||||
data = data.add(stride as usize);
|
||||
|
|
@ -499,7 +499,7 @@ impl GfxFramebuffer for TestGfxFb {
|
|||
if !t_format.has_alpha {
|
||||
a = 255;
|
||||
}
|
||||
let mut color = Color::from_rgba_premultiplied(r, g, b, a);
|
||||
let mut color = Color::from_srgba_premultiplied(r, g, b, a);
|
||||
if let Some(alpha) = c.alpha {
|
||||
color = color * alpha;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ pub struct TestShmBuffer {
|
|||
|
||||
impl TestShmBuffer {
|
||||
pub fn fill(&self, color: Color) {
|
||||
let [cr, cg, cb, ca] = color.to_rgba_premultiplied();
|
||||
let [cr, cg, cb, ca] = color.to_srgba_premultiplied();
|
||||
for [b, g, r, a] in self.deref().array_chunks_ext::<4>() {
|
||||
r.set(cr);
|
||||
g.set(cg);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use {
|
|||
test_error::TestResult, test_ifs::test_buffer::TestBuffer, test_object::TestObject,
|
||||
test_transport::TestTransport,
|
||||
},
|
||||
theme::Color,
|
||||
theme::{Color, TransferFunction},
|
||||
wire::{WpSinglePixelBufferManagerV1Id, wp_single_pixel_buffer_manager_v1::*},
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
|
|
@ -31,13 +31,14 @@ impl TestSinglePixelBufferManager {
|
|||
destroyed: Cell::new(false),
|
||||
});
|
||||
let map = |c: f32| (c as f64 * u32::MAX as f64) as u32;
|
||||
let [r, g, b, a] = color.to_array(TransferFunction::Srgb);
|
||||
self.tran.send(CreateU32RgbaBuffer {
|
||||
self_id: self.id,
|
||||
id: obj.id,
|
||||
r: map(color.r),
|
||||
g: map(color.g),
|
||||
b: map(color.b),
|
||||
a: map(color.a),
|
||||
r: map(r),
|
||||
g: map(g),
|
||||
b: map(b),
|
||||
a: map(a),
|
||||
})?;
|
||||
self.tran.add_obj(obj.clone())?;
|
||||
Ok(obj)
|
||||
|
|
|
|||
|
|
@ -39,6 +39,6 @@ impl TestSurfaceExt {
|
|||
}
|
||||
|
||||
pub fn set_color(&self, r: u8, g: u8, b: u8, a: u8) {
|
||||
self.color.set(Color::from_rgba_straight(r, g, b, a));
|
||||
self.color.set(Color::from_srgba_straight(r, g, b, a));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ async fn test(run: Rc<TestRun>) -> Result<(), TestError> {
|
|||
|
||||
let buffer = client
|
||||
.spbm
|
||||
.create_buffer(Color::from_rgba_straight(255, 255, 255, 255))?;
|
||||
.create_buffer(Color::from_srgba_straight(255, 255, 255, 255))?;
|
||||
|
||||
child.attach(buffer.id)?;
|
||||
child_viewport.set_source(0, 0, 1, 1)?;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ async fn test(run: Rc<TestRun>) -> Result<(), TestError> {
|
|||
let win1 = client.create_window().await?;
|
||||
win1.map2().await?;
|
||||
|
||||
let buffer = client.spbm.create_buffer(Color::from_rgb(255, 0, 0))?;
|
||||
let buffer = client.spbm.create_buffer(Color::from_srgb(255, 0, 0))?;
|
||||
let surface = client.comp.create_surface().await?;
|
||||
let vp = client.viewporter.get_viewport(&surface)?;
|
||||
vp.set_destination(100, 100)?;
|
||||
|
|
|
|||
|
|
@ -36,11 +36,11 @@ async fn test(run: Rc<TestRun>) -> TestResult {
|
|||
}};
|
||||
}
|
||||
|
||||
let buf1 = client.spbm.create_buffer(Color::from_rgb(0, 255, 0))?;
|
||||
let buf1 = client.spbm.create_buffer(Color::from_srgb(0, 255, 0))?;
|
||||
let (ss1, alpha1) = create_surface!(&buf1, 0, 0);
|
||||
|
||||
let buf2 = client.shm.create_buffer(1, 1)?;
|
||||
buf2.fill(Color::from_rgb(0, 255, 0));
|
||||
buf2.fill(Color::from_srgb(0, 255, 0));
|
||||
let (ss2, alpha2) = create_surface!(&buf2.buffer, 100, 0);
|
||||
|
||||
client.compare_screenshot("1", false).await?;
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue