Skip to content

Commit 2f77687

Browse files
authored
feat(egfx)!: switch SolidFill/SurfaceToSurface/SurfaceToCache rectangles to exclusive bounds (#1246)
1 parent d02d24a commit 2f77687

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

  • crates/ironrdp-egfx/src/pdu

crates/ironrdp-egfx/src/pdu/cmd.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use ironrdp_core::{
77
};
88
use ironrdp_dvc::DvcEncode;
99
use ironrdp_pdu::gcc::Monitor;
10-
use ironrdp_pdu::geometry::InclusiveRectangle;
10+
use ironrdp_pdu::geometry::{ExclusiveRectangle, InclusiveRectangle};
1111
use ironrdp_pdu::{DecodeError, cast_length, ensure_size, read_padding, write_padding};
1212
use tracing::warn;
1313

@@ -510,7 +510,9 @@ impl<'a> Decode<'a> for DeleteEncodingContextPdu {
510510
pub struct SolidFillPdu {
511511
pub surface_id: u16,
512512
pub fill_pixel: Color,
513-
pub rectangles: Vec<InclusiveRectangle>,
513+
/// Filled regions; each is an exclusive `RDPGFX_RECT16` per
514+
/// MS-RDPEGFX 2.2.1.4.1 (`right` / `bottom` are one-past-end).
515+
pub rectangles: Vec<ExclusiveRectangle>,
514516
}
515517

516518
impl SolidFillPdu {
@@ -551,8 +553,8 @@ impl<'a> Decode<'a> for SolidFillPdu {
551553
let fill_pixel = Color::decode(src)?;
552554
let rectangles_count = src.read_u16();
553555

554-
ensure_size!(in: src, size: usize::from(rectangles_count) * InclusiveRectangle::FIXED_PART_SIZE);
555-
let rectangles = iter::repeat_with(|| InclusiveRectangle::decode(src))
556+
ensure_size!(in: src, size: usize::from(rectangles_count) * ExclusiveRectangle::ENCODED_SIZE);
557+
let rectangles = iter::repeat_with(|| ExclusiveRectangle::decode(src))
556558
.take(usize::from(rectangles_count))
557559
.collect::<Result<_, _>>()?;
558560

@@ -571,14 +573,16 @@ impl<'a> Decode<'a> for SolidFillPdu {
571573
pub struct SurfaceToSurfacePdu {
572574
pub source_surface_id: u16,
573575
pub destination_surface_id: u16,
574-
pub source_rectangle: InclusiveRectangle,
576+
/// Source region; an exclusive `RDPGFX_RECT16` per MS-RDPEGFX 2.2.1.4.1
577+
/// (`right` / `bottom` are one-past-end).
578+
pub source_rectangle: ExclusiveRectangle,
575579
pub destination_points: Vec<Point>,
576580
}
577581

578582
impl SurfaceToSurfacePdu {
579583
const NAME: &'static str = "SurfaceToSurfacePdu";
580584

581-
const FIXED_PART_SIZE: usize = 2 /* SourceId */ + 2 /* DestId */ + InclusiveRectangle::FIXED_PART_SIZE /* SourceRect */ + 2 /* DestPointsCount */;
585+
const FIXED_PART_SIZE: usize = 2 /* SourceId */ + 2 /* DestId */ + ExclusiveRectangle::ENCODED_SIZE /* SourceRect */ + 2 /* DestPointsCount */;
582586
}
583587

584588
impl Encode for SurfaceToSurfacePdu {
@@ -612,7 +616,7 @@ impl<'a> Decode<'a> for SurfaceToSurfacePdu {
612616

613617
let source_surface_id = src.read_u16();
614618
let destination_surface_id = src.read_u16();
615-
let source_rectangle = InclusiveRectangle::decode(src)?;
619+
let source_rectangle = ExclusiveRectangle::decode(src)?;
616620
let destination_points_count = src.read_u16();
617621

618622
let destination_points = iter::repeat_with(|| Point::decode(src))
@@ -636,13 +640,15 @@ pub struct SurfaceToCachePdu {
636640
pub surface_id: u16,
637641
pub cache_key: u64,
638642
pub cache_slot: u16,
639-
pub source_rectangle: InclusiveRectangle,
643+
/// Source region; an exclusive `RDPGFX_RECT16` per MS-RDPEGFX 2.2.1.4.1
644+
/// (`right` / `bottom` are one-past-end).
645+
pub source_rectangle: ExclusiveRectangle,
640646
}
641647

642648
impl SurfaceToCachePdu {
643649
const NAME: &'static str = "SurfaceToCachePdu";
644650

645-
const FIXED_PART_SIZE: usize = 2 /* SurfaceId */ + 8 /* CacheKey */ + 2 /* CacheSlot */ + InclusiveRectangle::FIXED_PART_SIZE /* SourceRect */;
651+
const FIXED_PART_SIZE: usize = 2 /* SurfaceId */ + 8 /* CacheKey */ + 2 /* CacheSlot */ + ExclusiveRectangle::ENCODED_SIZE /* SourceRect */;
646652
}
647653

648654
impl Encode for SurfaceToCachePdu {
@@ -673,7 +679,7 @@ impl<'a> Decode<'a> for SurfaceToCachePdu {
673679
let surface_id = src.read_u16();
674680
let cache_key = src.read_u64();
675681
let cache_slot = src.read_u16();
676-
let source_rectangle = InclusiveRectangle::decode(src)?;
682+
let source_rectangle = ExclusiveRectangle::decode(src)?;
677683

678684
Ok(Self {
679685
surface_id,

0 commit comments

Comments
 (0)