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

Method read_and_invalidate

libs/scrap/src/dxgi/mod.rs:474–535  ·  view source on GitHub ↗

No Adapter => Some(None) Non-Empty Adapter => Some(Some(OUTPUT)) End of Adapter => None

(&mut self)

Source from the content-addressed store, hash-verified

472 // Non-Empty Adapter => Some(Some(OUTPUT))
473 // End of Adapter => None
474 fn read_and_invalidate(&mut self) -> Option<Option<Display>> {
475 // If there is no adapter, there is nothing left for us to do.
476
477 if self.adapter.is_null() {
478 return Some(None);
479 }
480
481 // Otherwise, we get the next output of the current adapter.
482
483 let output = unsafe {
484 let mut output = ptr::null_mut();
485 (*self.adapter.0).EnumOutputs(self.ndisplay, &mut output);
486 ComPtr(output)
487 };
488
489 // If the current adapter is done, we free it.
490 // We return None so the caller gets the next adapter and tries again.
491
492 if output.is_null() {
493 self.adapter = ComPtr(ptr::null_mut());
494 return None;
495 }
496
497 // Advance to the next display.
498
499 self.ndisplay += 1;
500
501 // We get the display's details.
502
503 let desc = unsafe {
504 #[allow(invalid_value)]
505 let mut desc = mem::MaybeUninit::uninit().assume_init();
506 (*output.0).GetDesc(&mut desc);
507 desc
508 };
509
510 // We cast it up to the version needed for desktop duplication.
511
512 let mut inner: *mut IDXGIOutput1 = ptr::null_mut();
513 unsafe {
514 (*output.0).QueryInterface(&IID_IDXGIOutput1, &mut inner as *mut *mut _ as *mut *mut _);
515 }
516
517 // If it's null, we have an error.
518 // So we act like the adapter is done.
519
520 if inner.is_null() {
521 self.adapter = ComPtr(ptr::null_mut());
522 return None;
523 }
524
525 unsafe {
526 (*self.adapter.0).AddRef();
527 }
528
529 Some(Some(Display {
530 inner: ComPtr(inner),
531 adapter: ComPtr(self.adapter.0),

Callers 1

nextMethod · 0.80

Calls 2

ComPtrClass · 0.85
is_nullMethod · 0.45

Tested by

no test coverage detected