dlls/quartz/vmr9.c
/* Recreate all surfaces (If allocated as D3DPOOL_DEFAULT) and survive! */
Recreate all surfaces (If allocated as D3DPOOL_DEFAULT) and survive!
Recreate all surfaces ( If allocated as D3DPOOL_DEFAULT ) and survive!
static HRESULT VMR9_SurfaceAllocator_UpdateDeviceReset(VMR9DefaultAllocatorPresenterImpl *This)
{
    struct VERTEX t_vert[4];
    UINT width, height;
    unsigned int i;
    void *bits = NULL;
    D3DPRESENT_PARAMETERS d3dpp;
    HRESULT hr;
    if (!This->pVMR9->baseControlWindow.baseWindow.hWnd)
    {
        ERR("No window\n");
        return E_FAIL;
    }
    if (!This->d3d9_surfaces || !This->reset)
        return S_OK;
    This->reset = FALSE;
    TRACE("RESETTING\n");
    if (This->d3d9_vertex)
    {
        IDirect3DVertexBuffer9_Release(This->d3d9_vertex);
        This->d3d9_vertex = NULL;
    }
    for (i = 0; i < This->num_surfaces; ++i)
    {
        IDirect3DSurface9 *surface = This->d3d9_surfaces[i];
        TRACE("Releasing surface %p\n", surface);
        if (surface)
            IDirect3DSurface9_Release(surface);
    }
    ZeroMemory(This->d3d9_surfaces, sizeof(IDirect3DSurface9 *) * This->num_surfaces);
    ZeroMemory(&d3dpp, sizeof(d3dpp));
    d3dpp.Windowed = TRUE;
    d3dpp.hDeviceWindow = This->pVMR9->baseControlWindow.baseWindow.hWnd;
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    if (This->d3d9_dev)
        IDirect3DDevice9_Release(This->d3d9_dev);
    This->d3d9_dev = NULL;
    hr = IDirect3D9_CreateDevice(This->d3d9_ptr, d3d9_adapter_from_hwnd(This->d3d9_ptr, This->pVMR9->baseControlWindow.baseWindow.hWnd, &This->hMon), D3DDEVTYPE_HAL, NULL, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &This->d3d9_dev);
    if (FAILED(hr))
    {
        hr = IDirect3D9_CreateDevice(This->d3d9_ptr, d3d9_adapter_from_hwnd(This->d3d9_ptr, This->pVMR9->baseControlWindow.baseWindow.hWnd, &This->hMon), D3DDEVTYPE_HAL, NULL, D3DCREATE_MIXED_VERTEXPROCESSING, &d3dpp, &This->d3d9_dev);
        if (FAILED(hr))
        {
            ERR("--> Creating device: %08x\n", hr);
            return S_OK;
        }
    }
    IVMRSurfaceAllocatorNotify9_ChangeD3DDevice(This->SurfaceAllocatorNotify, This->d3d9_dev, This->hMon);
    IVMRSurfaceAllocatorNotify9_AllocateSurfaceHelper(This->SurfaceAllocatorNotify, &This->info, &This->num_surfaces, This->d3d9_surfaces);
    This->reset = FALSE;
    if (!(This->info.dwFlags & VMR9AllocFlag_TextureSurface))
        return S_OK;
    hr = IDirect3DDevice9_CreateVertexBuffer(This->d3d9_dev, 4 * sizeof(struct VERTEX), D3DUSAGE_WRITEONLY, USED_FVF,
                                             This->info.Pool, &This->d3d9_vertex, NULL);
    width = This->info.dwWidth;
    height = This->info.dwHeight;
    for (i = 0; i < sizeof(t_vert) / sizeof(t_vert[0]); ++i)
    {
        if (i % 2)
        {
            t_vert[i].x = (float)This->pVMR9->target_rect.right - (float)This->pVMR9->target_rect.left - 0.5f;
            t_vert[i].u = (float)This->pVMR9->source_rect.right / (float)width;
        }
        else
        {
            t_vert[i].x = -0.5f;
            t_vert[i].u = (float)This->pVMR9->source_rect.left / (float)width;
        }
        if (i % 4 < 2)
        {
            t_vert[i].y = -0.5f;
            t_vert[i].v = (float)This->pVMR9->source_rect.bottom / (float)height;
        }
        else
        {
            t_vert[i].y = (float)This->pVMR9->target_rect.bottom - (float)This->pVMR9->target_rect.top - 0.5f;
            t_vert[i].v = (float)This->pVMR9->source_rect.top / (float)height;
        }
        t_vert[i].z = 0.0f;
        t_vert[i].rhw = 1.0f;
    }
    FIXME("Vertex rectangle:\n");
    FIXME("X, Y: %f, %f\n", t_vert[0].x, t_vert[0].y);
    FIXME("X, Y: %f, %f\n", t_vert[3].x, t_vert[3].y);
    FIXME("TOP, LEFT: %f, %f\n", t_vert[0].u, t_vert[0].v);
    FIXME("DOWN, BOTTOM: %f, %f\n", t_vert[3].u, t_vert[3].v);
    IDirect3DVertexBuffer9_Lock(This->d3d9_vertex, 0, sizeof(t_vert), &bits, 0);
    memcpy(bits, t_vert, sizeof(t_vert));
    IDirect3DVertexBuffer9_Unlock(This->d3d9_vertex);
    return S_OK;
}
static HRESULT VMR9_SurfaceAllocator_UpdateDeviceReset ( VMR9DefaultAllocatorPresenterImpl * This ) { struct VERTEX t_vert [ 4 ] ; UINT width , height ; unsigned int i ; void * bits = NULL ; D3DPRESENT_PARAMETERS d3dpp ; HRESULT hr ; if ( ! This -> pVMR9 -> baseControlWindow . baseWindow . hWnd ) { ERR ( " \n " ) ; return E_FAIL ; } if ( ! This -> d3d9_surfaces || ! This -> reset ) return S_OK ; This -> reset = FALSE ; TRACE ( " \n " ) ; if ( This -> d3d9_vertex ) { IDirect3DVertexBuffer9_Release ( This -> d3d9_vertex ) ; This -> d3d9_vertex = NULL ; } for ( i = 0 ; i < This -> num_surfaces ; ++ i ) { IDirect3DSurface9 * surface = This -> d3d9_surfaces [ i ] ; TRACE ( " \n " , surface ) ; if ( surface ) IDirect3DSurface9_Release ( surface ) ; } ZeroMemory ( This -> d3d9_surfaces , sizeof ( IDirect3DSurface9 * ) * This -> num_surfaces ) ; ZeroMemory ( & d3dpp , sizeof ( d3dpp ) ) ; d3dpp . Windowed = TRUE ; d3dpp . hDeviceWindow = This -> pVMR9 -> baseControlWindow . baseWindow . hWnd ; d3dpp . SwapEffect = D3DSWAPEFFECT_DISCARD ; if ( This -> d3d9_dev ) IDirect3DDevice9_Release ( This -> d3d9_dev ) ; This -> d3d9_dev = NULL ; hr = IDirect3D9_CreateDevice ( This -> d3d9_ptr , d3d9_adapter_from_hwnd ( This -> d3d9_ptr , This -> pVMR9 -> baseControlWindow . baseWindow . hWnd , & This -> hMon ) , D3DDEVTYPE_HAL , NULL , D3DCREATE_HARDWARE_VERTEXPROCESSING , & d3dpp , & This -> d3d9_dev ) ; if ( FAILED ( hr ) ) { hr = IDirect3D9_CreateDevice ( This -> d3d9_ptr , d3d9_adapter_from_hwnd ( This -> d3d9_ptr , This -> pVMR9 -> baseControlWindow . baseWindow . hWnd , & This -> hMon ) , D3DDEVTYPE_HAL , NULL , D3DCREATE_MIXED_VERTEXPROCESSING , & d3dpp , & This -> d3d9_dev ) ; if ( FAILED ( hr ) ) { ERR ( " \n " , hr ) ; return S_OK ; } } IVMRSurfaceAllocatorNotify9_ChangeD3DDevice ( This -> SurfaceAllocatorNotify , This -> d3d9_dev , This -> hMon ) ; IVMRSurfaceAllocatorNotify9_AllocateSurfaceHelper ( This -> SurfaceAllocatorNotify , & This -> info , & This -> num_surfaces , This -> d3d9_surfaces ) ; This -> reset = FALSE ; if ( ! ( This -> info . dwFlags & VMR9AllocFlag_TextureSurface ) ) return S_OK ; hr = IDirect3DDevice9_CreateVertexBuffer ( This -> d3d9_dev , 4 * sizeof ( struct VERTEX ) , D3DUSAGE_WRITEONLY , USED_FVF , This -> info . Pool , & This -> d3d9_vertex , NULL ) ; width = This -> info . dwWidth ; height = This -> info . dwHeight ; for ( i = 0 ; i < sizeof ( t_vert ) / sizeof ( t_vert [ 0 ] ) ; ++ i ) { if ( i % 2 ) { t_vert [ i ] . x = ( float ) This -> pVMR9 -> target_rect . right - ( float ) This -> pVMR9 -> target_rect . left - 0.5f ; t_vert [ i ] . u = ( float ) This -> pVMR9 -> source_rect . right / ( float ) width ; } else { t_vert [ i ] . x = -0.5f ; t_vert [ i ] . u = ( float ) This -> pVMR9 -> source_rect . left / ( float ) width ; } if ( i % 4 < 2 ) { t_vert [ i ] . y = -0.5f ; t_vert [ i ] . v = ( float ) This -> pVMR9 -> source_rect . bottom / ( float ) height ; } else { t_vert [ i ] . y = ( float ) This -> pVMR9 -> target_rect . bottom - ( float ) This -> pVMR9 -> target_rect . top - 0.5f ; t_vert [ i ] . v = ( float ) This -> pVMR9 -> source_rect . top / ( float ) height ; } t_vert [ i ] . z = 0.0f ; t_vert [ i ] . rhw = 1.0f ; } FIXME ( " \n " ) ; FIXME ( " \n " , t_vert [ 0 ] . x , t_vert [ 0 ] . y ) ; FIXME ( " \n " , t_vert [ 3 ] . x , t_vert [ 3 ] . y ) ; FIXME ( " \n " , t_vert [ 0 ] . u , t_vert [ 0 ] . v ) ; FIXME ( " \n " , t_vert [ 3 ] . u , t_vert [ 3 ] . v ) ; IDirect3DVertexBuffer9_Lock ( This -> d3d9_vertex , 0 , sizeof ( t_vert ) , & bits , 0 ) ; memcpy ( bits , t_vert , sizeof ( t_vert ) ) ; IDirect3DVertexBuffer9_Unlock ( This -> d3d9_vertex ) ; return S_OK ; }
Recreate all surfaces (If allocated as D3DPOOL_DEFAULT) and survive!
Recreate all surfaces ( If allocated as D3DPOOL_DEFAULT ) and survive!
/* Now try to create the d3d9 device */