aboutsummaryrefslogtreecommitdiff
path: root/src/ui/screenshot_ui.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-03-24 11:11:15 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2024-03-24 11:25:48 +0400
commit5f23d344d5d20d238eea65cd9e7189a2baf499c8 (patch)
tree19a938ba207eccd17e38be1000f062a4e4935350 /src/ui/screenshot_ui.rs
parente43e10f44ed085f3b489318e5f84ad0948eaefb2 (diff)
downloadniri-5f23d344d5d20d238eea65cd9e7189a2baf499c8.tar.gz
niri-5f23d344d5d20d238eea65cd9e7189a2baf499c8.tar.bz2
niri-5f23d344d5d20d238eea65cd9e7189a2baf499c8.zip
Make screenshot UI render target-aware
Diffstat (limited to 'src/ui/screenshot_ui.rs')
-rw-r--r--src/ui/screenshot_ui.rs34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/ui/screenshot_ui.rs b/src/ui/screenshot_ui.rs
index 79245387..5892fde1 100644
--- a/src/ui/screenshot_ui.rs
+++ b/src/ui/screenshot_ui.rs
@@ -19,6 +19,7 @@ use smithay::utils::{Physical, Point, Rectangle, Size, Transform};
use crate::niri_render_elements;
use crate::render_helpers::primary_gpu_texture::PrimaryGpuTextureRenderElement;
+use crate::render_helpers::RenderTarget;
const BORDER: i32 = 2;
@@ -42,8 +43,9 @@ pub struct OutputData {
size: Size<i32, Physical>,
scale: i32,
transform: Transform,
- texture: GlesTexture,
- texture_buffer: TextureBuffer<GlesTexture>,
+ // Output, screencast, screen capture.
+ texture: [GlesTexture; 3],
+ texture_buffer: [TextureBuffer<GlesTexture>; 3],
buffers: [SolidColorBuffer; 8],
locations: [Point<i32, Physical>; 8],
}
@@ -65,7 +67,8 @@ impl ScreenshotUi {
pub fn open(
&mut self,
renderer: &GlesRenderer,
- screenshots: HashMap<Output, GlesTexture>,
+ // Output, screencast, screen capture.
+ screenshots: HashMap<Output, [GlesTexture; 3]>,
default_output: Output,
) -> bool {
if screenshots.is_empty() {
@@ -110,13 +113,9 @@ impl ScreenshotUi {
let output_mode = output.current_mode().unwrap();
let size = transform.transform_size(output_mode.size);
let scale = output.current_scale().integer_scale();
- let texture_buffer = TextureBuffer::from_texture(
- renderer,
- texture.clone(),
- scale,
- Transform::Normal,
- None,
- );
+ let texture_buffer = texture.clone().map(|texture| {
+ TextureBuffer::from_texture(renderer, texture, scale, Transform::Normal, None)
+ });
let buffers = [
SolidColorBuffer::new((0, 0), [1., 1., 1., 1.]),
SolidColorBuffer::new((0, 0), [1., 1., 1., 1.]),
@@ -243,7 +242,11 @@ impl ScreenshotUi {
}
}
- pub fn render_output(&self, output: &Output) -> ArrayVec<ScreenshotUiRenderElement, 9> {
+ pub fn render_output(
+ &self,
+ output: &Output,
+ target: RenderTarget,
+ ) -> ArrayVec<ScreenshotUiRenderElement, 9> {
let _span = tracy_client::span!("ScreenshotUi::render_output");
let Self::Open { output_data, .. } = self else {
@@ -269,10 +272,15 @@ impl ScreenshotUi {
}));
// The screenshot itself goes last.
+ let index = match target {
+ RenderTarget::Output => 0,
+ RenderTarget::Screencast => 1,
+ RenderTarget::ScreenCapture => 2,
+ };
elements.push(
PrimaryGpuTextureRenderElement(TextureRenderElement::from_texture_buffer(
(0., 0.),
- &output_data.texture_buffer,
+ &output_data.texture_buffer[index],
None,
None,
None,
@@ -307,7 +315,7 @@ impl ScreenshotUi {
.to_buffer(1, Transform::Normal, &data.size.to_logical(1));
let mapping = renderer
- .copy_texture(&data.texture, buf_rect, Fourcc::Abgr8888)
+ .copy_texture(&data.texture[0], buf_rect, Fourcc::Abgr8888)
.context("error copying texture")?;
let copy = renderer
.map_texture(&mapping)