pub fn resolve(
wanted: &DisplayTarget,
surface: &DisplayTarget,
gpu: bool,
) -> ResolutionExpand description
What the viewport draws for, given what is wanted, what the surface expects and whether the GPU path runs: the surface’s encoding when it is supported (the stage converts the wanted content into it), sRGB otherwise; the fallback says what is lost.
use egui_pop_viewport::display::{self, ColorSpace, DisplayTarget, SurfaceFormat, TargetSource};
// eframe today: an 8-bit sRGB surface; P3 is drawn as sRGB, with the reason.
let r = display::resolve(&DisplayTarget::display_p3(), &DisplayTarget::srgb(), true);
assert_eq!(r.drawn.color_space(), Some(ColorSpace::Srgb));
assert!(r.reason().unwrap().contains("Display P3"));
// A surface configured as extended sRGB on half floats carries P3.
let ext = DisplayTarget::for_color_space(
ColorSpace::ExtendedSrgb, SurfaceFormat::Rgba16Float, 4.0, TargetSource::Wsi);
assert!(display::resolve(&DisplayTarget::display_p3(), &ext, true).faithful());