MCPcopy Create free account
hub / github.com/Recordscript/recordscript / load_frame

Method load_frame

libs/scrap/src/dxgi/mod.rs:193–214  ·  view source on GitHub ↗
(&mut self, timeout: UINT)

Source from the content-addressed store, hash-verified

191 }
192
193 unsafe fn load_frame(&mut self, timeout: UINT) -> io::Result<(*const u8, i32)> {
194 let mut frame = ptr::null_mut();
195 #[allow(invalid_value)]
196 let mut info = mem::MaybeUninit::uninit().assume_init();
197
198 wrap_hresult((*self.duplication.0).AcquireNextFrame(timeout, &mut info, &mut frame))?;
199 let frame = ComPtr(frame);
200
201 if *info.LastPresentTime.QuadPart() == 0 {
202 return Err(std::io::ErrorKind::WouldBlock.into());
203 }
204
205 #[allow(invalid_value)]
206 let mut rect = mem::MaybeUninit::uninit().assume_init();
207 if self.fastlane {
208 wrap_hresult((*self.duplication.0).MapDesktopSurface(&mut rect))?;
209 } else {
210 self.surface = ComPtr(self.ohgodwhat(frame.0)?);
211 wrap_hresult((*self.surface.0).Map(&mut rect, DXGI_MAP_READ))?;
212 }
213 Ok((rect.pBits, rect.Pitch))
214 }
215
216 // copy from GPU memory to system memory
217 unsafe fn ohgodwhat(&mut self, frame: *mut IDXGIResource) -> io::Result<*mut IDXGISurface> {

Callers 1

get_pixelbufferMethod · 0.80

Calls 3

wrap_hresultFunction · 0.85
ComPtrClass · 0.85
ohgodwhatMethod · 0.80

Tested by

no test coverage detected