windowscompositionaerodouble-buffering

Is Double-buffering required with Desktop Composition enabled?


Is double-buffering still required when Desktop Composition is enabled?

In Microsoft's Application Compatibility Guide:

Graphical Device Interface (GDI)

Prior to Windows Vista and Windows Server 2008, a window handle (HWND) was painted directly to the screen, which had certain benefits, but limited how Windows could display and manage top-level windows. In Windows Vista and Windows Server 2008, all top-level windows are rendered to an off-screen bitmap (similar to WS_EX_LAYERED), and the Desktop Window Manager combines the images together to draw the desktop.

It sounds like all rendering is now done to an off-screen bitmap:

windows are rendered to an off-screen bitmap

Is this correct?

The reason i ask is because i still see flickering during the standard paint cycle:

while desktop composition is enabled:

alt text

i would have assumed that between the calls to

   BeginPaint(hWnd, paintStructure);
   ...
   EndPaint(hWnd, paintStructure);

that all painting would happen to a back buffer:

windows are rendered to an off-screen bitmap

Meanwhile the a front buffer would stay unaffected.


Solution

  • Is this correct?

    Yup (which is how the thumbnails can show you parts of the window that are currently obscured).

    DWM's rendering of the screen is double-buffered. However, if it grabs your buffer betewen erasing and painting... it's going to show up as a visible artefact. So you still need to double buffer. The double buffering occurs on the desktop (i.e. it draws the next desktop view completely and then flips), not on the off-screen buffers that each window is drawn to.