DirectDraw displays the YUV video. When Screen Saver is displayed, YUV cannot be displayed and the surface is lost.

Source: Internet
Author: User

The reason is:

The ddrawsurface is lost, and the ddraw surface is lost in many cases (for example, when other full-screen exclusive programs, screen saver, or screen lock programs are started ), surface loss is actually the memory or video memory used on the surface is released by the DirectDraw system and allocated to other programs. if the surface is lost, all operations on the surface will return dderr_surfacelost. At this time, you should call the idirectdrawsurface interface method restore to restore the surface (re-apply for memory or display memory ).

 

The pseudocode is as follows:

HR = m_lpddsoffscreen-> lock (rcdest, & ddsd, ddlock_surfacememoryptr | ddlock_wait, null );


If (hR = dderr_surfacelost)
{
HR = m_lpddsoffscreen-> restore ();
HR = m_lpddsoffscreen-> lock (rcdest, & ddsd, ddlock_wait, null );
}

If (failed (HR ))
{
Return dd_false;
}

 

// Copy the data to the off-screen surface and transmit it to the main surface using BLT blocks.

 

Hresult ddrval;
Ddrval = lpddsprimary-> BLT (null, lpddsoffscreen, null, ddblt_wait, null );

If (ddrval = dderr_surfacelost)
{

Lpddsprimary-> restore ();
}

 

In this way, when the screen saver, screen lock, modify the screen resolution, the surface can be restored, and the video is displayed normally

 

You can also use the ddraw object to restore all surfaces as follows:

Lpdd-> restoreallsurfaces ();

 

Where

Lpdirectdraw7 lpdd;

DirectDraw displays the YUV video. When Screen Saver is displayed, YUV cannot be displayed and the surface is lost.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.