mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Deprecate all usages of the Color struct representing gamma space values, fixing round-trip precision bugs (#4149)
* Deprecate all usages of the Color struct representing gamma space values, fixing round-trip precision bugs * Code review fixes
This commit is contained in:
@@ -13,6 +13,7 @@ use crate::shader_runtime::ShaderRuntime;
|
||||
use crate::texture_cache::TextureCache;
|
||||
use anyhow::Result;
|
||||
use core_types::Color;
|
||||
use core_types::color::SRGBA8;
|
||||
use futures::lock::Mutex;
|
||||
use glam::{Affine2, UVec2};
|
||||
use graphene_application_io::{ApplicationIo, EditorApi};
|
||||
@@ -55,9 +56,9 @@ impl WgpuExecutor {
|
||||
|
||||
let texture_view = texture.create_view(&wgpu::TextureViewDescriptor::default());
|
||||
|
||||
let [r, g, b, a] = background.unwrap_or(Color::TRANSPARENT).to_rgba8();
|
||||
let SRGBA8 { red, green, blue, alpha } = background.unwrap_or(Color::TRANSPARENT).into();
|
||||
let render_params = RenderParams {
|
||||
base_color: vello::peniko::Color::from_rgba8(r, g, b, a),
|
||||
base_color: vello::peniko::Color::from_rgba8(red, green, blue, alpha),
|
||||
width: size.x,
|
||||
height: size.y,
|
||||
antialiasing_method: AaConfig::Msaa16,
|
||||
|
||||
@@ -120,7 +120,9 @@ impl RasterGpuToRasterCpuConverter {
|
||||
let start = row * row_stride;
|
||||
let row_slice = &view[start..start + row_bytes];
|
||||
for px in row_slice.chunks_exact(4) {
|
||||
cpu_data.push(Color::from_rgba8_srgb(px[0], px[1], px[2], px[3]));
|
||||
// `Image<Color>` pixels are stored linear-light with associated (premultiplied) alpha
|
||||
let srgba = SRGBA8::new(px[0], px[1], px[2], px[3]);
|
||||
cpu_data.push(Color::from(srgba).apply_opacity(px[3] as f32 / 255.));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user