gemini feat: optimize drawing performance by caching layer styles during strokes and improve UI/UX for layer styles and menus, improved drop shadow
This commit is contained in:
@@ -151,9 +151,19 @@ pub fn composite_layers_parallel(layers: &[Layer], canvas_width: u32, canvas_hei
|
||||
let base_idx = base_indices[i];
|
||||
|
||||
// Apply layer effects if present
|
||||
let fx_effects: Vec<hcie_fx::LayerEffect> = layer.effects.iter().map(protocol_to_hcie_fx_effect).collect();
|
||||
let effect_pixels = if (!fx_effects.is_empty() || layer.fill_opacity < 1.0) && !is_adj {
|
||||
Some(hcie_fx::apply_layer_effects(&layer.pixels, layer.width, layer.height, &fx_effects, layer.fill_opacity))
|
||||
let has_effects = !layer.effects.is_empty() || !layer.styles.is_empty() || (layer.fill_opacity < 1.0);
|
||||
let effect_pixels = if has_effects && !is_adj {
|
||||
if let Ok(Some(cached)) = layer.effects_cache.lock().as_deref() {
|
||||
if cached.width == layer.width && cached.height == layer.height {
|
||||
Some(cached.rendered.clone())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else {
|
||||
let mut fx_effects: Vec<hcie_fx::LayerEffect> = layer.effects.iter().map(hcie_fx::protocol_to_hcie_fx_effect).collect();
|
||||
fx_effects.extend(layer.styles.iter().filter_map(|s| hcie_fx::layer_style_to_effect(s)));
|
||||
Some(hcie_fx::apply_layer_effects(&layer.pixels, layer.width, layer.height, &fx_effects, layer.fill_opacity))
|
||||
}
|
||||
} else {
|
||||
None
|
||||
};
|
||||
@@ -292,9 +302,19 @@ pub fn composite_layers_region_parallel(
|
||||
let is_adj = layer.adjustment.is_some();
|
||||
|
||||
// Apply layer effects if present
|
||||
let fx_effects: Vec<hcie_fx::LayerEffect> = layer.effects.iter().map(protocol_to_hcie_fx_effect).collect();
|
||||
let effect_pixels = if (!fx_effects.is_empty() || layer.fill_opacity < 1.0) && !is_adj {
|
||||
Some(hcie_fx::apply_layer_effects(&layer.pixels, layer.width, layer.height, &fx_effects, layer.fill_opacity))
|
||||
let has_effects = !layer.effects.is_empty() || !layer.styles.is_empty() || (layer.fill_opacity < 1.0);
|
||||
let effect_pixels = if has_effects && !is_adj {
|
||||
if let Ok(Some(cached)) = layer.effects_cache.lock().as_deref() {
|
||||
if cached.width == layer.width && cached.height == layer.height {
|
||||
Some(cached.rendered.clone())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else {
|
||||
let mut fx_effects: Vec<hcie_fx::LayerEffect> = layer.effects.iter().map(hcie_fx::protocol_to_hcie_fx_effect).collect();
|
||||
fx_effects.extend(layer.styles.iter().filter_map(|s| hcie_fx::layer_style_to_effect(s)));
|
||||
Some(hcie_fx::apply_layer_effects(&layer.pixels, layer.width, layer.height, &fx_effects, layer.fill_opacity))
|
||||
}
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
@@ -117,8 +117,9 @@ pub fn composite_tiled_into(
|
||||
// If layer has effects or non-default fill_opacity, compute effects buffer.
|
||||
// Prefer the cached `effects_cache` when available to avoid re-running the
|
||||
// expensive effects pipeline on every partial composite.
|
||||
let has_effects = !layer.effects.is_empty() || (layer.fill_opacity < 1.0);
|
||||
let fx_effects: Vec<hcie_fx::LayerEffect> = layer.effects.iter().map(protocol_to_hcie_fx_effect).collect();
|
||||
let has_effects = !layer.effects.is_empty() || !layer.styles.is_empty() || (layer.fill_opacity < 1.0);
|
||||
let mut fx_effects: Vec<hcie_fx::LayerEffect> = layer.effects.iter().map(hcie_fx::protocol_to_hcie_fx_effect).collect();
|
||||
fx_effects.extend(layer.styles.iter().filter_map(|s| hcie_fx::layer_style_to_effect(s)));
|
||||
let effect_buf = if has_effects {
|
||||
if let Ok(Some(cached)) = layer.effects_cache.lock().as_deref() {
|
||||
if cached.width == layer.width && cached.height == layer.height {
|
||||
|
||||
Reference in New Issue
Block a user