[英]Background Color Artifact in Window's Composition Engine (DWM)
Context from Kenny Kerr's blog :来自Kenny Kerr 博客的上下文:
Windows Vista introduced a service called the Desktop Window Manager.
Windows Vista 引入了一个名为 Desktop Window Manager 的服务。 The name was and continues to be misleading.
这个名字过去和现在都具有误导性。 Think of it as the Windows composition engine or compositor.
将其视为 Windows 合成引擎或合成器。 This composition engine completely changed the way application windows are rendered on the desktop.
这个合成引擎完全改变了应用程序 windows 在桌面上呈现的方式。 Rather than allowing each window to render directly to the display, or display adapter, every window renders to an off-screen surface or buffer.
不是让每个 window 直接渲染到显示器或显示适配器,而是每个 window 渲染到屏幕外表面或缓冲区。 The system allocates one such surface per top-level window and all GDI, Direct3D and, of course, Direct2D graphics are rendered to these surfaces.
系统为每个顶层 window 分配一个这样的表面,所有 GDI、Direct3D,当然还有 Direct2D 图形都被渲染到这些表面。 These off-screen surfaces are called redirection surfaces because GDI drawing commands and even Direct3D swap chain presentation requests are redirected or copied (within the GPU) to the redirection surface.
这些屏幕外表面称为重定向表面,因为 GDI 绘图命令甚至 Direct3D 交换链表示请求都被重定向或复制(在 GPU 内)到重定向表面。
At some point, independent of any given window, the composition engine decides it's time to compose the desktop given the latest batch of changes.
在某些时候,独立于任何给定的 window,组合引擎会根据最新的一批更改决定是时候组合桌面了。 This involves composing all of these redirection surfaces together, adding the non-client areas (often called window chrome), perhaps adding some shadows and other effects, and presenting the final result to the display adapter.
这涉及将所有这些重定向表面组合在一起,添加非客户区域(通常称为 window chrome),可能添加一些阴影和其他效果,并将最终结果呈现给显示适配器。
Background from previous SO question (see pictures) : 上一个 SO 问题的背景(见图片) :
When resizing down in DirectX there is an artifact of the win32 background appearing at the right/bottom edges.在 DirectX 中调整大小时,在右/下边缘会出现 win32 背景的伪影。 This can be corrected by applying the
WS_EX_NOREDIRECTIONBITMAP
style.这可以通过应用
WS_EX_NOREDIRECTIONBITMAP
样式来纠正。 Since it doesn't matter whether the swapchain is smaller or larger than the window, it appears that without WS_EX_NOREDIRECTIONBITMAP
the Composition Engine copies too small a rectangle to the Redirection Surface (because the window size lags behind the mouse position/"Drag rectangle").由于交换链比 window 小还是大都没有关系,看来没有
WS_EX_NOREDIRECTIONBITMAP
组合引擎将太小的矩形复制到重定向表面(因为 window 大小滞后于鼠标位置/“拖动矩形”) .
Actual Question实际问题
However, WS_EX_NOREDIRECTIONBITMAP
only works for top level windows and I'm trying to embed DirectX as a child window into WPF, and the artifact from the child window's background is still coming through.但是,
WS_EX_NOREDIRECTIONBITMAP
仅适用于顶级 windows 并且我正在尝试将 DirectX 作为子 window 嵌入到 WPF 背景中,并且仍然来自子窗口的背景。 This leads me to some relate questions:这让我想到了一些相关的问题:
What I missed was that there are two paths for pixels to get to the screen我错过的是像素有两条路径到达屏幕
Without WS_EX_NOREDIRECTIONBITMAP
the swapchain's contents get copied over the Redirection Surface's content.如果没有
WS_EX_NOREDIRECTIONBITMAP
,交换链的内容会被复制到重定向表面的内容上。 However, there is a bug when resizing down and the clipping to prevent the swapchain's contents, from extending past the window, clip too small a rectangle allowing the Redirection Surface to be seen.但是,在调整大小和剪辑以防止交换链的内容超出 window 时出现错误,将矩形剪辑得太小而无法看到重定向表面。 I realized this when I got the exact same behavior using
CreateSwapChainForComposition()
with DirectComposition as I got for CreateSwapChainForHwnd()
.当我使用带有 DirectComposition 的
CreateSwapChainForHwnd()
CreateSwapChainForComposition()
获得与 CreateSwapChainForHwnd() 完全相同的行为时,我意识到了这一点。
To answer my required questions: No, using the flip presentation model from a HwndHost
does not limit your to WPF's refresh rate.要回答我需要的问题:不,使用来自 HwndHost 的翻转演示
HwndHost
不会限制您使用 WPF 的刷新率。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.