Add retained paints and shared text selection

This commit is contained in:
iris committed 2026-09-10 18:35:24 -04:00
1 parent 1e6d3b1edd
commit a33fbca966
42 files changed
+2424 -470

No files matched your search

+29 -17
View File
@@ -4,7 +4,7 @@ use android_view::{
jni::{JavaVM, objects::GlobalRef},
ndk::native_window::NativeWindow,
};
use iris_core::{FrameParts, UiData, UiRenderNode, UiRenderState};
use iris_core::{FrameParts, LinearRgba, UiData, UiRenderNode, UiRenderState};
use pollster::FutureExt;
use std::time::Instant;
use wgpu::{
@@ -12,7 +12,7 @@ use wgpu::{
*,
};
pub const CLEAR_COLOR: Color = Color::BLACK;
pub const CLEAR_COLOR: LinearRgba = LinearRgba::BLACK;
/// `NativeWindow` (from the surface android-view hands over in
/// `surfaceChanged`) has a window handle but not a display one -- there is
@@ -46,6 +46,7 @@ pub struct AndroidRenderer {
device: Device,
queue: Queue,
config: SurfaceConfiguration,
view_format: TextureFormat,
encoder: CommandEncoder,
pub ui: UiRenderNode,
pub adapter_name: String,
@@ -73,6 +74,7 @@ pub struct AndroidRenderer {
pub struct FrameDiagnostics {
pub masks_resized: bool,
pub moves_resized: bool,
pub paints_resized: bool,
pub atlas_pages_grown_prev: u64,
pub image_bind_group_creates_prev: u64,
}
@@ -189,30 +191,33 @@ impl AndroidRenderer {
);
let surface_caps = surface.get_capabilities(&adapter);
let surface_format = surface_caps
.formats
.iter()
.copied()
.find(|f| f.is_srgb())
.unwrap_or(surface_caps.formats[0]);
let formats = iris_core::srgb_surface_format(&surface_caps)?;
log::info!(
"iris renderer: surface={:?}, view={:?}, color_space=Srgb",
formats.surface,
formats.view,
);
let config = SurfaceConfiguration {
usage: TextureUsages::RENDER_ATTACHMENT,
format: surface_format,
format: formats.surface,
// wgpu 30's new field; `Auto` is what every earlier version did.
color_space: SurfaceColorSpace::Auto,
color_space: SurfaceColorSpace::Srgb,
width,
height,
present_mode: PresentMode::AutoVsync,
alpha_mode: surface_caps.alpha_modes[0],
desired_maximum_frame_latency: 2,
view_formats: vec![],
view_formats: (formats.view != formats.surface)
.then_some(formats.view)
.into_iter()
.collect(),
};
surface.configure(&device, &config);
let encoder = Self::create_encoder(&device);
let window_size = iris_core::util::Vec2::new(width as f32, height as f32);
let ui = match UiRenderNode::new(&device, &queue, &config, window_size) {
let ui = match UiRenderNode::new(&device, &queue, formats.view, window_size) {
Ok(ui) => ui,
Err(wgpu_error) => return Err(Self::diagnostic(&adapter, &wgpu_error)),
};
@@ -222,6 +227,7 @@ impl AndroidRenderer {
device,
queue,
config,
view_format: formats.view,
encoder,
ui,
adapter_name,
@@ -289,8 +295,10 @@ impl AndroidRenderer {
format!(
"iris diagnostics. Copy this text and send it to Iris.\n\n\
adapter: {name} ({backend:?}), driver: {driver}\n\
surface: {surface:?}, view: {view:?}, color_space: Srgb\n\
content_scale: {content_scale}\n\
atlas format: Rgba8Unorm, views live: {views}\n\
paint format: linear vec4<f32>\n\
atlas/image format: Rgba8UnormSrgb, views live: {views}\n\
fonts: {families_found} families found, default={default_family:?} \
mono={default_mono_family:?}\n\
fonts resolved: regular={regular:?} bold={bold:?} italic={italic:?} \
@@ -301,6 +309,8 @@ impl AndroidRenderer {
name = self.adapter_name,
backend = self.adapter_backend,
driver = self.adapter_driver,
surface = self.config.format,
view = self.view_format,
content_scale = self.content_scale,
views = self.ui.view_count(),
families_found = font.families_found,
@@ -328,6 +338,7 @@ impl AndroidRenderer {
FrameDiagnostics {
masks_resized: stats.masks_resized,
moves_resized: stats.moves_resized,
paints_resized: stats.paints_resized,
atlas_pages_grown_prev,
image_bind_group_creates_prev,
}
@@ -348,9 +359,10 @@ impl AndroidRenderer {
other => panic!("no surface texture to draw into: {other:?}"),
};
let acquire = acquire_start.elapsed();
let view = output
.texture
.create_view(&TextureViewDescriptor::default());
let view = output.texture.create_view(&TextureViewDescriptor {
format: Some(self.view_format),
..Default::default()
});
let mut encoder = std::mem::replace(&mut self.encoder, Self::create_encoder(&self.device));
{
@@ -359,7 +371,7 @@ impl AndroidRenderer {
view: &view,
resolve_target: None,
ops: Operations {
load: LoadOp::Clear(CLEAR_COLOR),
load: LoadOp::Clear(CLEAR_COLOR.to_wgpu()),
store: StoreOp::Store,
},
depth_slice: None,