Ejemplo n.º 1
0
static HRESULT WINAPI ddrawex_surface4_Restore(IDirectDrawSurface4 *iface)
{
    struct ddrawex_surface *surface = impl_from_IDirectDrawSurface4(iface);

    TRACE("iface %p.\n", iface);

    return IDirectDrawSurface4_Restore(surface->parent);
}
Ejemplo n.º 2
0
static Bool
winActivateAppShadowDDNL(ScreenPtr pScreen)
{
    winScreenPriv(pScreen);

    /*
     * Do we have a surface?
     * Are we active?
     * Are we full screen?
     */
    if (pScreenPriv != NULL
        && pScreenPriv->pddsPrimary4 != NULL && pScreenPriv->fActive) {
        /* Primary surface was lost, restore it */
        IDirectDrawSurface4_Restore(pScreenPriv->pddsPrimary4);
    }

    return TRUE;
}
static Bool
winBltExposedRegionsShadowDDNL (ScreenPtr pScreen)
{
  winScreenPriv(pScreen);
  winScreenInfo		*pScreenInfo = pScreenPriv->pScreenInfo;
  RECT			rcSrc, rcDest;
  POINT			ptOrigin;
  HDC			hdcUpdate;
  PAINTSTRUCT		ps;
  HRESULT		ddrval = DD_OK;
  Bool			fReturn = TRUE;
  int			i;

  /* Quite common case. The primary surface was lost (maybe because of depth
   * change). Try to create a new primary surface. Bail out if this fails */
  if (pScreenPriv->pddsPrimary4 == NULL && pScreenPriv->fRetryCreateSurface &&
      !winCreatePrimarySurfaceShadowDDNL(pScreen))
    {
      Sleep(100);
      return FALSE;
    }
  if (pScreenPriv->pddsPrimary4 == NULL)
    return FALSE;  
  
  /* BeginPaint gives us an hdc that clips to the invalidated region */
  hdcUpdate = BeginPaint (pScreenPriv->hwndScreen, &ps);
  if (hdcUpdate == NULL)
    {
      fReturn = FALSE;
      ErrorF ("winBltExposedRegionsShadowDDNL - BeginPaint () returned "
	      "a NULL device context handle.  Aborting blit attempt.\n");
      goto winBltExposedRegionsShadowDDNL_Exit;
    }

  /* Get the origin of the window in the screen coords */
  ptOrigin.x = pScreenInfo->dwXOffset;
  ptOrigin.y = pScreenInfo->dwYOffset;

  MapWindowPoints (pScreenPriv->hwndScreen,
		   HWND_DESKTOP,
		   (LPPOINT)&ptOrigin, 1);
  rcDest.left = ptOrigin.x;
  rcDest.right = ptOrigin.x + pScreenInfo->dwWidth;
  rcDest.top = ptOrigin.y;
  rcDest.bottom = ptOrigin.y + pScreenInfo->dwHeight;

  /* Source can be entire shadow surface, as Blt should clip for us */
  rcSrc.left = 0;
  rcSrc.top = 0;
  rcSrc.right = pScreenInfo->dwWidth;
  rcSrc.bottom = pScreenInfo->dwHeight;

  /* Try to regain the primary surface and blit again if we've lost it */
  for (i = 0; i <= WIN_REGAIN_SURFACE_RETRIES; ++i)
    {
      /* Our Blt should be clipped to the invalidated region */
      ddrval = IDirectDrawSurface4_Blt (pScreenPriv->pddsPrimary4,
					&rcDest,
					pScreenPriv->pddsShadow4,
					&rcSrc,
					DDBLT_WAIT,
					NULL);
      if (ddrval == DDERR_SURFACELOST)
	{
	  /* Surface was lost */
	  winErrorFVerb (1, "winBltExposedRegionsShadowDDNL - "
          "IDirectDrawSurface4_Blt reported that the primary "
          "surface was lost, trying to restore, retry: %d\n", i + 1);

	  /* Try to restore the surface, once */
	  
	  ddrval = IDirectDrawSurface4_Restore (pScreenPriv->pddsPrimary4);
	  winDebug ("winBltExposedRegionsShadowDDNL - "
		  "IDirectDrawSurface4_Restore returned: ");
	  if (ddrval == DD_OK)
	    winDebug ("DD_OK\n");
	  else if (ddrval == DDERR_WRONGMODE)
	    winDebug ("DDERR_WRONGMODE\n");
	  else if (ddrval == DDERR_INCOMPATIBLEPRIMARY)
	    winDebug ("DDERR_INCOMPATIBLEPRIMARY\n");
	  else if (ddrval == DDERR_UNSUPPORTED)
	    winDebug ("DDERR_UNSUPPORTED\n");
	  else if (ddrval == DDERR_INVALIDPARAMS)
	    winDebug ("DDERR_INVALIDPARAMS\n");
	  else if (ddrval == DDERR_INVALIDOBJECT)
	    winDebug ("DDERR_INVALIDOBJECT\n");
	  else
	    winDebug ("unknown error: %08x\n", (unsigned int) ddrval);
	  
	  /* Loop around to try the blit one more time */
	  continue;
	}  
      else if (FAILED (ddrval))
	{
	  fReturn = FALSE;
	  winErrorFVerb (1, "winBltExposedRegionsShadowDDNL - "
		  "IDirectDrawSurface4_Blt failed, but surface not "
		  "lost: %08x %d\n",
		  (unsigned int) ddrval, (int) ddrval);
	  goto winBltExposedRegionsShadowDDNL_Exit;
	}
      else
	{
	  /* Success, stop looping */
	  break;
	}
    }

 winBltExposedRegionsShadowDDNL_Exit:
  /* EndPaint frees the DC */
  if (hdcUpdate != NULL)
    EndPaint (pScreenPriv->hwndScreen, &ps);
  return fReturn;
}