JFLib

plat/win_gpuout.rs (Windows)#

Source: lib/plat/win_gpuout.rs

win_gpuout -- the child window a window's GPU output draws on (lib/ui's presenter, docs/GPU.md)

  win_gpu_child(w) -> NativeWindow     the child of window w for a swapchain, created hidden on
                                       the first call and given the client size of w
  win_gpu_child_show(w, show)          show it (sized to the client area) / hide it
  win_gpu_child_destroy(w)             destroy it (a swapchain on it must be gone)
  win_release_kept(w)                  free the copy WM_PAINT repaints from (the child shows
                                       the window; the next win_present makes a new copy)
  win_in_sizemove()                    the modal move / size loop runs
  win_display_adapter(w) -> (vendor id, device id)   the GPU that drives the window's monitor
  win_remote_session()                 this is a Remote Desktop session
  gpu_wait(deadline_us)                pump the messages until then (Linux: linux_gpuout.rs)

Why a child: once a swapchain has presented on a window, what GDI draws on that window stays
invisible, also after the swapchain and its surface are destroyed (measured: DWM keeps showing
the last image; gputest and tests/ of uigputest).  So the top-level window stays the CPU path
for its whole life; the swapchain lives on a child that covers its client area.  Hiding the
child shows at once what the CPU path last drew; a child that is shown before its first
present shows that too (a child has no redirection surface of its own and this one never
paints).

The child takes no input: WS_DISABLED and HTTRANSPARENT send everything to the parent (hit
tests with the parent's resize band included), WindowFromPoint does not find it, it never has
the focus.  It is destroyed together with its parent.
  • fn win_gpu_child(w: i32) -> Option<NativeWindow> (gpu) the child window of window w for its swapchain: hidden when new, the client size of w (None: no such window, or the child could not be made)

  • fn win_gpu_child_show(w: i32, show: bool) (gpu) show the child of window w over its client area (sized to it), or hide it: what the window's CPU present last drew is what shows then

  • fn win_gpu_child_destroy(w: i32) (gpu) destroy the child of window w (the swapchain on it must be gone)

  • fn win_release_kept(w: i32) (gpu) window w's copy for WM_PAINT is not needed while the child shows the window (the next win_present makes a new one)

  • fn gpu_wait(deadline_us: u64) the modal move / size loop of a window runs (the program's own loop waits for its end)

  • fn win_gpu_child_later(_w: i32) -> bool no child now, but it may come (the host or the next frame wakes the loop): only Android

  • fn win_gpu_child_alone(_w: i32) -> bool the window still shows on its child alone: here always

  • fn gpu_out_state(_state: u32) how the output came up (GPU_STATE_*): Android keeps it across runs

  • fn gpu_thread_spawn(stack: usize, f: alloc::boxed::Box<dyn FnOnce() + Send>) -> Option<crate::Thread> a thread for the output's jobs

  • fn win_in_sizemove() -> bool

  • fn win_remote_session() -> bool this program runs in a Remote Desktop session (the GPU output stays off)

  • fn win_display_adapter(w: i32) -> Option<(u32, u32)> the PCI vendor and device id of the GPU that drives the monitor window w is on (None: not known, not a PCI device)

Source: docs/API.md in the JFLib repository.