extern "system" fn present_impl(
  this: *mut IDXGISwapChain,
  sync_interval: UINT,
  flags: UINT,
) -> HRESULT {
  // State transition the dxgi hook struct
  unsafe {
    DXGI_HOOK_STATE.replace(match DXGI_HOOK_STATE.take() {
      DxgiHookState::Uninitialized => {
        unreachable!("DXGI Hook State uninitialized in present_impl -- this should never happen!")
      }
      DxgiHookState::Hooked(present_trampoline, render_loop) => {
        match DxgiHook::initialize_dx(present_trampoline, this, render_loop) {
          Ok(dh) => DxgiHookState::Ok(Box::new(dh)),
          Err(e) => {
            error!("DXGI Hook initialization failed: {:?}", e);
            DxgiHookState::Errored(present_trampoline)
          }
        }
      }
      DxgiHookState::Errored(present_trampoline) => DxgiHookState::Errored(present_trampoline),
      DxgiHookState::Ok(dh) => DxgiHookState::Ok(dh),
    })
  };

  match unsafe { DXGI_HOOK_STATE.get_mut() } {
    DxgiHookState::Uninitialized => unreachable!(),
    DxgiHookState::Hooked(_, _) => unreachable!(),
    DxgiHookState::Errored(present_trampoline) => unsafe {
      present_trampoline(this, sync_interval, flags)
    },
    DxgiHookState::Ok(dxgi_hook) => dxgi_hook.render(this, sync_interval, flags),
  }
}
/// Implementation of the hooked `Present` function.
///
/// Implements a state machine to move the hook from uninitialized, to
/// hooked, to rendering or errored.
Implementation of the hooked `Present` function.
Implements a state machine to move the hook from uninitialized, to
hooked, to rendering or errored.
Implementation of the hooked ` Present ` function . Implements a state machine to move the hook from uninitialized to hooked to rendering or errored .
extern "system" fn present_impl(
  this: *mut IDXGISwapChain,
  sync_interval: UINT,
  flags: UINT,
) -> HRESULT {
  // State transition the dxgi hook struct
  unsafe {
    DXGI_HOOK_STATE.replace(match DXGI_HOOK_STATE.take() {
      DxgiHookState::Uninitialized => {
        unreachable!("DXGI Hook State uninitialized in present_impl -- this should never happen!")
      }
      DxgiHookState::Hooked(present_trampoline, render_loop) => {
        match DxgiHook::initialize_dx(present_trampoline, this, render_loop) {
          Ok(dh) => DxgiHookState::Ok(Box::new(dh)),
          Err(e) => {
            error!("DXGI Hook initialization failed: {:?}", e);
            DxgiHookState::Errored(present_trampoline)
          }
        }
      }
      DxgiHookState::Errored(present_trampoline) => DxgiHookState::Errored(present_trampoline),
      DxgiHookState::Ok(dh) => DxgiHookState::Ok(dh),
    })
  };
  match unsafe { DXGI_HOOK_STATE.get_mut() } {
    DxgiHookState::Uninitialized => unreachable!(),
    DxgiHookState::Hooked(_, _) => unreachable!(),
    DxgiHookState::Errored(present_trampoline) => unsafe {
      present_trampoline(this, sync_interval, flags)
    },
    DxgiHookState::Ok(dxgi_hook) => dxgi_hook.render(this, sync_interval, flags),
  }
}
extern " " fn present_impl ( this : * mut IDXGISwapChain , sync_interval : UINT , flags : UINT , ) -> HRESULT { // State transition the dxgi hook struct unsafe { DXGI_HOOK_STATE . replace ( match DXGI_HOOK_STATE . take ( ) { DxgiHookState :: Uninitialized => { unreachable ! ( " " ) } DxgiHookState :: Hooked ( present_trampoline , render_loop ) => { match DxgiHook :: initialize_dx ( present_trampoline , this , render_loop ) { Ok ( dh ) => DxgiHookState :: Ok ( Box :: new ( dh ) ) , Err ( e ) => { error ! ( " " e ) ; DxgiHookState :: Errored ( present_trampoline ) } } } DxgiHookState :: Errored ( present_trampoline ) => DxgiHookState :: Errored ( present_trampoline ) , DxgiHookState :: Ok ( dh ) => DxgiHookState :: Ok ( dh ) , } ) } ; match unsafe { DXGI_HOOK_STATE . get_mut ( ) } { DxgiHookState :: Uninitialized => unreachable ! ( ) , DxgiHookState :: Hooked ( _ , _ ) => unreachable ! ( ) , DxgiHookState :: Errored ( present_trampoline ) => unsafe { present_trampoline ( this , sync_interval , flags ) } , DxgiHookState :: Ok ( dxgi_hook ) => dxgi_hook . render ( this , sync_interval , flags ) , } }
Implementation of the hooked `Present` function.
Implementation of the hooked ` Present ` function .
this
*mut IDXGISwapChain
sync_interval
UINT
flags
UINT