Beispiel #1
0
static boolean Overlay( LPDIRECTDRAWSURFACE src_surface, RECT * src_rect,
		 LPDIRECTDRAWSURFACE dst_surface, RECT * dst_rect,
		 COLORREF color_key )
{
  DWORD			dw_color_key;
  DDPIXELFORMAT		ddpf;
  DDOVERLAYFX		ddofx;
  int			flags;
  HRESULT		result;

  /* compute the colorkey pixel value from the RGB value we've got/
   * NOTE : based on videolan colorkey code */

  memset( &ddpf, 0, sizeof( DDPIXELFORMAT ));
  ddpf.dwSize = sizeof( DDPIXELFORMAT );
  result = IDirectDrawSurface_GetPixelFormat( dst_surface, &ddpf );
  if( result != DD_OK )
    {
      Error( 0, "IDirectDrawSurface_GetPixelFormat : could not get surface pixel format" );
      return FALSE;
    }

  dw_color_key = ( DWORD ) color_key;
  dw_color_key = ( DWORD ) ( ( ( dw_color_key * ddpf.dwRBitMask ) / 255 ) & ddpf.dwRBitMask );

  memset( &ddofx, 0, sizeof( DDOVERLAYFX ) );
  ddofx.dwSize = sizeof( DDOVERLAYFX );
  ddofx.dckDestColorkey.dwColorSpaceLowValue = dw_color_key;
  ddofx.dckDestColorkey.dwColorSpaceHighValue = dw_color_key;

  /* set our overlay flags */

  flags = DDOVER_SHOW | DDOVER_KEYDESTOVERRIDE;

  /* attempt to overlay the surface */

  result = IDirectDrawSurface_UpdateOverlay( src_surface, src_rect, dst_surface, dst_rect, flags, &ddofx );
  if( result != DD_OK )
    {
      if( result == DDERR_SURFACELOST )
	{
	  IDirectDrawSurface_Restore( src_surface );
	  IDirectDrawSurface_Restore( dst_surface );

	  IDirectDrawSurface_UpdateOverlay( src_surface, src_rect, dst_surface, dst_rect, flags, &ddofx );
	}
      else
	{
	  Error( 0, "IDirectDrawSurface_UpdateOverlay : error 0x%lx. You can try disable hardware acceleration (option video.directx.hwaccel).", result );
	  return FALSE;
	}
    }

  return TRUE;
}
Beispiel #2
0
Err GE2DHideOverlay()
{
	if (Thread)
	{
		ThreadRun = 0;
		if (Thread && WaitForSingleObject(Thread,5000) == WAIT_TIMEOUT)
			TerminateThread(Thread,0);
		Thread = NULL;
	}

	if (DDBuffer)
	{
		IDirectDrawSurface_UpdateOverlay(DDBuffer,&DDSrc,DDPrimary,&DDDst,DDOVER_HIDE,NULL);
		IDirectDrawSurface_Release(DDBuffer); 
		DDBuffer = NULL;
	}

	return 0;
}
Beispiel #3
0
static void DDUpdate(GE2DBitmapType *p)
{
	HWND Wnd = FindWindow("PalmOSEmulatorDisplay",NULL);
	POINT Origin = {0,0};
	if (Wnd)
		ClientToScreen(Wnd,&Origin);

	DDSrc.left = 0;
	DDSrc.top = 0;
	DDSrc.right = p->width;
	DDSrc.bottom = p->height;
 
	if (DDDst.left != DDLeft + Origin.x ||
		DDDst.top != DDTop + Origin.y)
	{
		DDDst.left = DDLeft + Origin.x;
		DDDst.top = DDTop + Origin.y;
		DDDst.right = DDDst.left + p->width;
		DDDst.bottom = DDDst.top + p->height;

		IDirectDrawSurface_UpdateOverlay(DDBuffer,&DDSrc,DDPrimary,&DDDst,DDOVER_SHOW,NULL);
	}
}
Beispiel #4
0
static int DxManageOverlay(void)
{
    HRESULT ddrval;
    DDOVERLAYFX ovfx;
    DWORD dwUpdateFlags = 0;

    int width, height;

    /* --------- fix to limit -------------- */
    rs.left = 0;
    rs.top = 0;
    rs.right = rs.left + g_image_width;
    rs.bottom = rs.top + g_image_height;
    if (g_align_src) {
        rs.right -= rs.right % g_align_src;
    }

    if (g_inited) {
        RECT cur;
        GetWindowRect(g_hwnd, &cur);
        if (cur.left != rd.left || cur.top != rd.top) {
            rd.left = cur.left;
            rd.top = cur.top;
            rd.right = cur.right;
            rd.bottom = cur.bottom;
        } else {
            rd.left = dx;
            rd.top = dy;
            rd.right = rd.left + dw;
            rd.bottom = rd.top + dh;
        }
    } else {
        rd.left = dx;
        rd.top = dy;
        rd.right = rd.left + dw;
        rd.bottom = rd.top + dh;
    }

    if (g_StretchFactor1000 > 1000) {
        rd.right = (rd.right * g_StretchFactor1000 + 999) / 1000;
        rd.bottom = rd.bottom * g_StretchFactor1000 / 1000;
    }
    if (g_align_dst) {
        rd.right = ((rd.right + g_align_dst - 1) / g_align_dst) * g_align_dst;
    }

    width = rd.right - rd.left;
    height = rd.bottom - rd.top;

    /*do not allow to zoom or shrink if hardware isn't able to do so */
    if ((width < g_image_width) && !g_allow_shrink_x) {
        rd.right = rd.left + g_image_width;
    } else if ((width > g_image_width) && !g_allow_zoom_x) {
        rd.right = rd.left + g_image_width;
    }
    if ((height < g_image_height) && !g_allow_shrink_y) {
        rd.bottom = rd.top + g_image_height;
    } else if ((height > g_image_height) && !g_allow_zoom_y) {
        rd.bottom = rd.top + g_image_height;
    }

    SetWindowPos(g_hwnd, HWND_TOPMOST, rd.left, rd.top, rd.right - rd.left,
                 rd.bottom - rd.top, SWP_NOOWNERZORDER);
    ShowWindow(g_hwnd, SW_SHOW);

    /* --------- setup update flags --------- */
    ZeroMemory(&ovfx, sizeof(ovfx));
    ovfx.dwSize = sizeof(ovfx);
    ovfx.dckDestColorkey.dwColorSpaceLowValue = 0;
    ovfx.dckDestColorkey.dwColorSpaceHighValue = 0;

    dwUpdateFlags = DDOVER_SHOW | DDOVER_DDFX;
    if (g_overlay_key) {
        dwUpdateFlags |= DDOVER_KEYDESTOVERRIDE;
    }

    ddrval = IDirectDrawSurface_UpdateOverlay(g_lpddsOverlay, &rs, g_lpddsPrimary,
             &rd, dwUpdateFlags, &ovfx);
    /*ok we can't do anything about it -> hide overlay */
    if (ddrval != DD_OK) {
        av_log(NULL, AV_LOG_ERROR, "update overlay faild , hide overlay\n");
        IDirectDrawSurface_UpdateOverlay(g_lpddsOverlay, NULL, g_lpddsPrimary, NULL,
                                         DDOVER_HIDE, NULL);
        return FALSE;
    }
    return TRUE;
}