Share via


Flipping Surfaces (Windows Embedded CE 6.0)

1/6/2010

Any surface in DirectDraw can be constructed as a flipping surface. A flipping surface is any piece of memory that can be swapped between a front buffer and a back buffer. (This construct is commonly referred to as a flipping chain). Often, the front buffer is the primary surface, but it does not have to be.

Typically, when you use the IDirectDrawSurface::Flip method to request a surface flip operation, the pointers to surface memory for the primary surface and back buffers are swapped. Flipping is performed by switching pointers that the display device uses for referencing memory, not by copying surface memory.

When a flipping chain contains a primary surface and more than one back buffer, the pointers are switched in a circular pattern, as shown in the following illustration.

Ee490108.5abe7f0f-eb36-466d-a9d5-09f5c7712cb5(en-US,WinEmbedded.60).gif

Other surfaces that are attached to a DirectDraw object, but not part of the flipping chain, are unaffected when the Flip method is called.

Remember, DirectDraw flips surfaces by swapping surface memory pointers within DirectDrawSurface objects, not by swapping the objects themselves.

This means that, to blit to the back buffer in any type of flipping scheme, you always use the same DirectDrawSurface object the one that was the back buffer when you created the flipping chain.

Conversely, you always perform a flip operation by calling the front surface's Flip method.

When working with visible surfaces, such as a primary surface flipping chain or a visible overlay surface flipping chain, the Flip method is asynchronous unless you include the DDFLIP_WAITNOTBUSY flag.

On these visible surfaces, the Flip method can return before the actual flip operation occurs in the hardware (because the hardware does not flip until the next vertical refresh occurs).

While the actual flip operation is pending, the back buffer behind the currently visible surface cannot be locked or blitted by calling the IDirectDrawSurface::Lock, IDirectDrawSurface::Blt, or IDirectDrawSurface::GetDC methods.

If you attempt to call these methods while a flip operation is pending, they will fail and return DirectDraw Return Values. However, if you are using a triple buffered scheme, the rearmost buffer is still available.

In order to rotate the screen while using primary surface page flipping, your application must call FlipToGDISurface prior to calling ChangeDisplaySettingsEx to rotate the screen. Otherwise, the flipping order may be changed by the call to Restore on the primary surface flipping chain, after that screen has been rotated.

See Also

Concepts

Creating Surfaces