Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions src/capture/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,8 @@ impl FrameProcessor {
#[cfg(test)]
mod tests {
use super::*;
use crate::capture::scale::prepare_presentation_frame;
use crate::display::geometry::{PresentationGeometry, Size};
use crate::egfx::test_support::{
ack_frame, drain_gfx_pdus, negotiated_avc444_egfx, negotiated_egfx_with_policy,
negotiated_no_avc_egfx, process_avc444_capabilities, start_gfx_channel,
Expand All @@ -865,6 +867,7 @@ mod tests {
use crate::egfx::{
EgfxCodecPolicy, H264RateControl, HyprGfxFactory, DEFAULT_MAX_FRAMES_IN_FLIGHT,
};
use crate::input::OutputLayoutSnapshot;
use ironrdp_server::{DisplayUpdate, PixelFormat};
use ironrdp_server::{GfxServerFactory, ServerEventSender};
use std::sync::Arc;
Expand Down Expand Up @@ -956,6 +959,25 @@ mod tests {
frame[offset + 3] = 255;
}

fn output_layout_snapshot(
source: (u32, u32),
presentation: (u32, u32),
) -> OutputLayoutSnapshot {
let source_size = Size::new(source.0, source.1).unwrap();
let presentation_size = Size::new(presentation.0, presentation.1).unwrap();
OutputLayoutSnapshot {
output_name: "DP-1".into(),
output_w: source.0,
output_h: source.1,
layout_extent_w: source.0,
layout_extent_h: source.1,
output_offset_x: 0,
output_offset_y: 0,
presentation_geometry: PresentationGeometry::new(source_size, presentation_size),
geometry_generation: 0,
}
}

fn mutate_bgra_tile(
frame: &mut [u8],
width: usize,
Expand Down Expand Up @@ -1202,6 +1224,53 @@ mod tests {
);
}

#[test]
fn bitmap_output_downscaling_uses_presentation_dimensions_stride_and_payload() {
let source_width = 4;
let source_height = 2;
let source_stride = source_width * 4;
let source = gradient_bgra_frame(source_width, source_height, source_stride);
let prepared = prepare_presentation_frame(
&source,
source_width as u32,
source_height as u32,
source_stride as u32,
PixelFormat::BgrA32,
&[(0, 0, source_width as i32, source_height as i32)],
&output_layout_snapshot(
(source_width as u32, source_height as u32),
(source_width as u32, 4),
),
)
.expect("scaled frame prepares");

let (display_tx, mut display_rx) = mpsc::channel(4);
let mut processor = FrameProcessor::new(
None,
prepared.width,
prepared.height,
PixelFormat::BgrA32,
prepared.stride,
1_000_000,
23,
H264RateControl::Vbr,
30,
);
processor.queue_damage(&prepared.damage_regions);

assert!(processor.process(prepared.data.as_ref(), &display_tx));
assert!(processor.sent_first_frame);
assert!(processor.pending_damage_regions.is_empty());
assert_bitmap_update(
&mut display_rx,
prepared.width as usize,
prepared.height as usize,
prepared.stride as usize,
PixelFormat::BgrA32,
prepared.data.as_ref(),
);
}

#[test]
fn frame_processor_waits_for_egfx_negotiation_before_bitmap_fallback() {
let width = 16;
Expand Down
Loading
Loading