backend/mock: fill buffer more efficiently
This commit is contained in:
parent
ee1d54a12b
commit
3dd5a28e28
1 changed files with 4 additions and 3 deletions
|
|
@ -23,7 +23,7 @@ use futures_channel::mpsc;
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashSet,
|
collections::HashSet,
|
||||||
fs,
|
fs,
|
||||||
io::Write,
|
io::{self, Write},
|
||||||
sync::{
|
sync::{
|
||||||
atomic::{AtomicUsize, Ordering},
|
atomic::{AtomicUsize, Ordering},
|
||||||
Arc,
|
Arc,
|
||||||
|
|
@ -38,7 +38,8 @@ use crate::utils;
|
||||||
struct MockObjectId(usize);
|
struct MockObjectId(usize);
|
||||||
|
|
||||||
fn create_solid_capture_image(r: u8, g: u8, b: u8) -> CaptureImage {
|
fn create_solid_capture_image(r: u8, g: u8, b: u8) -> CaptureImage {
|
||||||
let mut file = fs::File::from(utils::create_memfile().unwrap());
|
let file = fs::File::from(utils::create_memfile().unwrap());
|
||||||
|
let mut file = io::BufWriter::new(file);
|
||||||
|
|
||||||
for i in 0..512 * 512 {
|
for i in 0..512 * 512 {
|
||||||
file.write(&[b, g, r, 255]).unwrap();
|
file.write(&[b, g, r, 255]).unwrap();
|
||||||
|
|
@ -49,7 +50,7 @@ fn create_solid_capture_image(r: u8, g: u8, b: u8) -> CaptureImage {
|
||||||
height: 512,
|
height: 512,
|
||||||
wl_buffer: SubsurfaceBuffer::new(Arc::new(
|
wl_buffer: SubsurfaceBuffer::new(Arc::new(
|
||||||
Shmbuf {
|
Shmbuf {
|
||||||
fd: file.into(),
|
fd: file.into_inner().unwrap().into(),
|
||||||
offset: 0,
|
offset: 0,
|
||||||
width: 512,
|
width: 512,
|
||||||
height: 512,
|
height: 512,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue