chore: theme-v2 libcosmic update
This commit is contained in:
parent
667414bd92
commit
55d57ddba2
19 changed files with 609 additions and 386 deletions
|
|
@ -726,7 +726,7 @@ where
|
|||
return Ok(Vec::new());
|
||||
}
|
||||
let theme = shell_ref.theme().clone();
|
||||
let blur_strength = 9; // TODO
|
||||
let blur_strength = (theme.cosmic().frosted as u8 + 1) as usize;
|
||||
let scale = output.current_scale().fractional_scale();
|
||||
// we don't want to hold a shell lock across `cursor_elements`,
|
||||
// that is prone to deadlock with the main-thread on some grabs.
|
||||
|
|
|
|||
|
|
@ -117,21 +117,22 @@ impl BlurShaders {
|
|||
|
||||
type BlurTexture = Mutex<Option<GlesTexture>>;
|
||||
|
||||
struct BlurState {
|
||||
id: Id,
|
||||
renderer_id: Option<ContextId<GlesTexture>>,
|
||||
src: Size<f64, Buffer>,
|
||||
offset: f64,
|
||||
passes: usize,
|
||||
region: Vec<Rectangle<i32, Logical>>,
|
||||
commit: CommitCounter,
|
||||
#[derive(Debug)]
|
||||
pub struct BlurState {
|
||||
pub id: Id,
|
||||
pub renderer_id: Option<ContextId<GlesTexture>>,
|
||||
pub src: Size<f64, Buffer>,
|
||||
pub offset: f64,
|
||||
pub passes: usize,
|
||||
pub region: Vec<Rectangle<i32, Logical>>,
|
||||
pub commit: CommitCounter,
|
||||
}
|
||||
|
||||
unsafe impl Send for BlurState {}
|
||||
unsafe impl Sync for BlurState {}
|
||||
|
||||
impl BlurState {
|
||||
fn new() -> Self {
|
||||
impl Default for BlurState {
|
||||
fn default() -> Self {
|
||||
BlurState {
|
||||
id: Id::new(),
|
||||
renderer_id: None,
|
||||
|
|
@ -159,6 +160,27 @@ pub struct BlurElement {
|
|||
}
|
||||
|
||||
impl BlurElement {
|
||||
pub fn from_state<R: ImportAll + AsGlowRenderer>(
|
||||
renderer: &mut R,
|
||||
state: &mut BlurState,
|
||||
geometry: Rectangle<f64, Logical>,
|
||||
output_scale: f64,
|
||||
radii: [u8; 4],
|
||||
strength: usize,
|
||||
) -> Result<Option<Self>, R::Error> {
|
||||
let region = vec![Rectangle::from_size(geometry.size.to_i32_round())];
|
||||
|
||||
Self::internal(
|
||||
renderer,
|
||||
state,
|
||||
geometry,
|
||||
®ion,
|
||||
output_scale,
|
||||
radii,
|
||||
strength,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn from_surface<R: ImportAll + AsGlowRenderer>(
|
||||
renderer: &mut R,
|
||||
states: &SurfaceData,
|
||||
|
|
@ -172,9 +194,37 @@ impl BlurElement {
|
|||
return Ok(None);
|
||||
};
|
||||
|
||||
let state = states
|
||||
.data_map
|
||||
.get_or_insert_threadsafe::<Mutex<BlurState>, _>(Default::default);
|
||||
|
||||
Self::internal(
|
||||
renderer,
|
||||
&mut state.lock().unwrap(),
|
||||
geometry,
|
||||
region,
|
||||
output_scale,
|
||||
radii,
|
||||
strength,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn internal<R: ImportAll + AsGlowRenderer>(
|
||||
renderer: &mut R,
|
||||
state: &mut BlurState,
|
||||
geometry: Rectangle<f64, Logical>,
|
||||
region: &Vec<Rectangle<i32, Logical>>,
|
||||
output_scale: f64,
|
||||
radii: [u8; 4],
|
||||
strength: usize,
|
||||
) -> Result<Option<Self>, R::Error> {
|
||||
if strength == 0 {
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
let geo = geometry.to_physical_precise_round(output_scale);
|
||||
let mut extended_geo = geo;
|
||||
let radius = BLUR_PARAMS[strength.min(MAX_STEPS - 1)].extended_radius as f64;
|
||||
let radius = BLUR_PARAMS[(strength + 2).min(MAX_STEPS - 1)].extended_radius as f64;
|
||||
extended_geo.loc -= Point::<f64, Physical>::new(radius, radius);
|
||||
extended_geo.size += Size::<f64, Physical>::new(radius, radius).upscale(2.);
|
||||
|
||||
|
|
@ -217,32 +267,9 @@ impl BlurElement {
|
|||
Uniform::new("noise", UniformValue::_1f(NOISE)),
|
||||
];
|
||||
|
||||
let state = states
|
||||
.data_map
|
||||
.get_or_insert_threadsafe::<Mutex<BlurState>, _>(|| Mutex::new(BlurState::new()));
|
||||
let geometry = extended_geo.to_logical(output_scale);
|
||||
let extended_offset = Point::<f64, Physical>::new(radius, radius).to_logical(output_scale);
|
||||
|
||||
Ok(Some(Self::from_state(
|
||||
renderer,
|
||||
extended_geo.to_logical(output_scale),
|
||||
Point::<f64, Physical>::new(radius, radius).to_logical(output_scale),
|
||||
region,
|
||||
output_scale,
|
||||
&mut state.lock().unwrap(),
|
||||
uniforms,
|
||||
strength,
|
||||
)?))
|
||||
}
|
||||
|
||||
fn from_state<R: AsGlowRenderer>(
|
||||
renderer: &mut R,
|
||||
geometry: Rectangle<f64, Logical>,
|
||||
extended_offset: Point<f64, Logical>,
|
||||
region: &Vec<Rectangle<i32, Logical>>,
|
||||
output_scale: f64,
|
||||
state: &mut BlurState,
|
||||
uniforms: Vec<Uniform<'static>>,
|
||||
strength: usize,
|
||||
) -> Result<Self, R::Error> {
|
||||
let renderer_id = renderer.glow_renderer().context_id();
|
||||
let src = geometry.size.to_buffer(output_scale, Transform::Normal);
|
||||
let params = &BLUR_PARAMS[strength.min(MAX_STEPS - 1)];
|
||||
|
|
@ -265,7 +292,7 @@ impl BlurElement {
|
|||
state.commit.increment();
|
||||
}
|
||||
|
||||
Ok(BlurElement {
|
||||
Ok(Some(BlurElement {
|
||||
id: state.id.clone(),
|
||||
commit: state.commit,
|
||||
src,
|
||||
|
|
@ -284,7 +311,7 @@ impl BlurElement {
|
|||
})
|
||||
.collect(),
|
||||
uniforms,
|
||||
})
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -468,7 +495,7 @@ fn blit_from_active_fb(
|
|||
let mut fb = renderer.as_mut().bind(to_texture)?;
|
||||
std::mem::drop(renderer);
|
||||
|
||||
frame.blit_to(
|
||||
let sync = frame.blit_to(
|
||||
&mut fb_tmp,
|
||||
dst,
|
||||
Rectangle::from_size(dst.size),
|
||||
|
|
@ -480,6 +507,7 @@ fn blit_from_active_fb(
|
|||
let mut frame = renderer
|
||||
.as_mut()
|
||||
.render(&mut fb, tex_size, Transform::Normal)?;
|
||||
frame.wait(&sync)?;
|
||||
Frame::render_texture_from_to(
|
||||
&mut frame,
|
||||
&tmp_texture,
|
||||
|
|
@ -502,16 +530,14 @@ fn blit_from_active_fb(
|
|||
} else {
|
||||
let mut fb = frame.renderer().as_mut().bind(to_texture)?;
|
||||
|
||||
frame
|
||||
.blit_to(
|
||||
&mut fb,
|
||||
dst,
|
||||
src.to_logical(1., Transform::Normal, &src.size)
|
||||
.to_physical(1.)
|
||||
.to_i32_round(),
|
||||
TextureFilter::Linear,
|
||||
)
|
||||
.map(|_| SyncPoint::signaled())
|
||||
frame.blit_to(
|
||||
&mut fb,
|
||||
dst,
|
||||
src.to_logical(1., Transform::Normal, &src.size)
|
||||
.to_physical(1.)
|
||||
.to_i32_round(),
|
||||
TextureFilter::Linear,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue