shared memory size use the max resolution of all displays (#8534)

The case of setting a monitor inserted later as the primary monitor is not taken into account

Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
21pages 2024-06-29 21:50:21 +08:00 committed by GitHub
parent 4b6ba7938f
commit 5114a9d369
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 3 deletions

View File

@ -3150,6 +3150,7 @@ impl Connection {
.map(|t| t.0 = Instant::now()); .map(|t| t.0 = Instant::now());
} }
#[cfg(feature = "hwcodec")]
fn update_supported_encoding(&mut self) { fn update_supported_encoding(&mut self) {
let Some(last) = &self.last_supported_encoding else { let Some(last) = &self.last_supported_encoding else {
return; return;

View File

@ -549,11 +549,15 @@ pub mod client {
let mut max_pixel = 0; let mut max_pixel = 0;
let align = 64; let align = 64;
for d in displays { for d in displays {
let pixel = utils::align(d.width(), align) * utils::align(d.height(), align); let resolutions = crate::platform::resolutions(&d.name());
for r in resolutions {
let pixel =
utils::align(r.width as _, align) * utils::align(r.height as _, align);
if max_pixel < pixel { if max_pixel < pixel {
max_pixel = pixel; max_pixel = pixel;
} }
} }
}
let shmem_size = utils::align(ADDR_CAPTURE_FRAME + max_pixel * 4, align); let shmem_size = utils::align(ADDR_CAPTURE_FRAME + max_pixel * 4, align);
// os error 112, no enough space // os error 112, no enough space
*SHMEM.lock().unwrap() = Some(crate::portable_service::SharedMemory::create( *SHMEM.lock().unwrap() = Some(crate::portable_service::SharedMemory::create(