Пример #1
0
static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpicture)
{
    vout_display_sys_t *sys = vd->sys;

    assert(sys->display);

    /* Our surface can be lost so be sure to check this
     * and restore it if need be */
    if (IDirectDrawSurface2_IsLost(sys->display) == DDERR_SURFACELOST) {
        if (IDirectDrawSurface2_Restore(sys->display) == DD_OK) {
            if (sys->use_overlay)
                DirectXUpdateOverlay(vd, NULL);
        }
    }
    if (sys->restore_overlay)
        DirectXUpdateOverlay(vd, NULL);

    /* */
    DirectXUnlock(picture);

    if (sys->use_overlay) {
        /* Flip the overlay buffers if we are using back buffers */
        if (picture->p_sys->surface != picture->p_sys->front_surface) {
            HRESULT hr = IDirectDrawSurface2_Flip(picture->p_sys->front_surface,
                                                  NULL, DDFLIP_WAIT);
            if (hr != DD_OK)
                msg_Warn(vd, "could not flip overlay (error %li)", hr);
        }
    } else {
        /* Blit video surface to display with the NOTEARING option */
        DDBLTFX  ddbltfx;
        ZeroMemory(&ddbltfx, sizeof(ddbltfx));
        ddbltfx.dwSize = sizeof(ddbltfx);
        ddbltfx.dwDDFX = DDBLTFX_NOTEARING;

        HRESULT hr = IDirectDrawSurface2_Blt(sys->display,
                                             &sys->rect_dest_clipped,
                                             picture->p_sys->surface,
                                             &sys->rect_src_clipped,
                                             DDBLT_ASYNC, &ddbltfx);
        if (hr != DD_OK)
            msg_Warn(vd, "could not blit surface (error %li)", hr);
    }
    DirectXLock(picture);

    if (sys->is_first_display) {
        IDirectDraw_WaitForVerticalBlank(sys->ddobject,
                                         DDWAITVB_BLOCKBEGIN, NULL);
        if (sys->use_overlay) {
            HBRUSH brush = CreateSolidBrush(sys->i_rgb_colorkey);
            /* set the colorkey as the backgound brush for the video window */
            SetClassLongPtr(sys->hvideownd, GCLP_HBRBACKGROUND, (LONG_PTR)brush);
        }
    }
    CommonDisplay(vd);

    picture_Release(picture);
    VLC_UNUSED(subpicture);
}
Пример #2
0
int gr_palette_fade_in(ubyte *pal, int nsteps, int allow_keys)	
{
	HRESULT ddresult;
	int i,j;
	ubyte c;
	fix fade_palette[768];
	fix fade_palette_delta[768];

	allow_keys  = allow_keys;

	Assert(_lpDDPalActive!=0);

	if (!gr_palette_faded_out) return 0;

	#ifndef NDEBUG
	if (grd_fades_disabled) {
		gr_palette_load(pal);
		return 0;
	}
	#endif

	for (i=0; i<768; i++ )	{
		gr_current_pal[i] = pal[i];
		fade_palette[i] = 0;
		fade_palette_delta[i] = i2f(pal[i]+gr_palette_gamma) / nsteps;
	}

	for (j=0; j<nsteps; j++ )	{
		for (i=0; i<256; i++ )	{
			fade_palette[i*3] += fade_palette_delta[i*3];
			fade_palette[i*3+1] += fade_palette_delta[i*3+1];
			fade_palette[i*3+2] += fade_palette_delta[i*3+2];
			if (fade_palette[i*3] > i2f(pal[i*3]+gr_palette_gamma) )
				fade_palette[i*3] = i2f(pal[i*3]+gr_palette_gamma);
			if (fade_palette[i*3+1] > i2f(pal[i*3+1]+gr_palette_gamma) )
				fade_palette[i*3+1] = i2f(pal[i*3+1]+gr_palette_gamma);
			if (fade_palette[i*3+2] > i2f(pal[i*3+2]+gr_palette_gamma) )
				fade_palette[i*3+2] = i2f(pal[i*3+2]+gr_palette_gamma);

			c = f2i(fade_palette[i*3]);
			if ( c > 63 ) c = 63;
			PalGDIData.ScratchPal[i].peRed = c << 2;
			c = f2i(fade_palette[i*3+1]);
			if ( c > 63 ) c = 63;
			PalGDIData.ScratchPal[i].peGreen = c << 2;
			c = f2i(fade_palette[i*3+2]);
			if ( c > 63 ) c = 63;
			PalGDIData.ScratchPal[i].peBlue = c << 2;
			PalGDIData.ScratchPal[i].peFlags = 0;
		}
			
		if (!hPalGDI) {
			IDirectDraw_WaitForVerticalBlank(lpDD, DDWAITVB_BLOCKBEGIN, NULL);
			ddresult = IDirectDrawPalette_SetEntries(_lpDDPalActive, 0,
											0, 256,
											PalGDIData.ScratchPal);
			Assert (ddresult == DD_OK);
		}
		else {
			HDC hdc;
		
			hdc = GetDC(GetLibraryWindow());		
			SetPaletteEntries(hPalGDI, 0, PalGDIData.num, PalGDIData.ScratchPal);
			RealizePalette(hdc);
			ReleaseDC(GetLibraryWindow(), hdc);
		}
	}

	gr_palette_faded_out = 0;
	return 0;
}