Example #1
0
void WEHDR::Release()
{
    SAFE_RELEASE(m_pPSDownScale2x2Lum);
    SAFE_RELEASE(m_pPSDownScale3x3);
    SAFE_RELEASE(m_pPSBrightPass);
    SAFE_RELEASE(m_pPSFinalPass);
    SAFE_RELEASE(m_pPSBloom);
    SAFE_RELEASE(m_pcbBloom);

    SAFE_RELEASE(m_pSamplePoint);
    SAFE_RELEASE(m_pSampleLinear);

    ReleaseViews();
}
/**
 * See nsIObserver.idl
 */
NS_IMETHODIMP
sbMediaListViewMap::Observe(nsISupports* aSubject,
                          const char* aTopic,
                          const PRUnichar* aData)
{
  TRACE(("sbMediaListViewMap[0x%x] - Observe: %s", this, aTopic));

  nsresult rv;
  nsCOMPtr<nsIObserverService> observerService = 
    do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv);

  if (strcmp(aTopic, APPSTARTUP_TOPIC) == 0) {
    return NS_OK; // ???
  }
  else if (strcmp(aTopic, SB_LIBRARY_MANAGER_READY_TOPIC) == 0) {

    // Remove ourselves from the observer service.
    if (NS_SUCCEEDED(rv)) {
      observerService->RemoveObserver(this, SB_LIBRARY_MANAGER_READY_TOPIC);
    }

    // Startup
    mViewMap.Init();

    return NS_OK;
  }
  else if (strcmp(aTopic, SB_LIBRARY_MANAGER_BEFORE_SHUTDOWN_TOPIC) == 0) {

    // Remove ourselves from the observer service.
    if (NS_SUCCEEDED(rv)) {
      observerService->RemoveObserver(this, SB_LIBRARY_MANAGER_BEFORE_SHUTDOWN_TOPIC);
    }

    // Shutdown
    ReleaseViews( nsnull );

    return NS_OK;
  }

  NS_NOTREACHED("Observing a topic that wasn't handled!");
  return NS_OK;
}
Example #3
0
HRESULT WEHDR::CreateViews()
{
    HRESULT hr;

    if (!m_pd3dDevice)
        return S_FALSE;

    ReleaseViews();

    int nSampleLen = 1;
    for(int i = 0; i < NUM_TONEMAP_TEXTURES; i++)
    {
        D3D11_TEXTURE2D_DESC tmdesc;
        ZeroMemory(&tmdesc, sizeof(D3D11_TEXTURE2D_DESC));
        tmdesc.ArraySize = 1;
        tmdesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
        tmdesc.Usage = D3D11_USAGE_DEFAULT;
        tmdesc.Format = DXGI_FORMAT_R32_FLOAT;
        tmdesc.Width = nSampleLen;
        tmdesc.Height = nSampleLen;
        tmdesc.MipLevels = 1;
        tmdesc.SampleDesc.Count = 1;
        V_RETURN(m_pd3dDevice->CreateTexture2D(&tmdesc, NULL, &m_pTexToneMap[i]));

        // Create the render target view
        D3D11_RENDER_TARGET_VIEW_DESC DescRT;
        DescRT.Format = tmdesc.Format;
        DescRT.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
        DescRT.Texture2D.MipSlice = 0;
        V_RETURN(m_pd3dDevice->CreateRenderTargetView(m_pTexToneMap[i], &DescRT, &m_pTexToneMapRTV[i]));

        // Create the shader resource view
        D3D11_SHADER_RESOURCE_VIEW_DESC DescRV;
        DescRV.Format = tmdesc.Format;
        DescRV.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
        DescRV.Texture2D.MipLevels = 1;
        DescRV.Texture2D.MostDetailedMip = 0;
        V_RETURN(m_pd3dDevice->CreateShaderResourceView(m_pTexToneMap[i], &DescRV, &m_pTexToneMapRV[i]));

        nSampleLen *= 3;
    }

    UINT width, height;
    WE::D3D().GetScreen(&width, &height);

    // Create the temporary blooming effect textures for PS path and buffers for CS path
    for( int i = 0; i < NUM_BLOOM_TEXTURES; i++ )
    {
        // Texture for blooming effect in PS path
        D3D11_TEXTURE2D_DESC bmdesc;
        ZeroMemory( &bmdesc, sizeof( D3D11_TEXTURE2D_DESC ) );
        bmdesc.ArraySize = 1;
        bmdesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
        bmdesc.Usage = D3D11_USAGE_DEFAULT;
        bmdesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
        bmdesc.Width = width / 8;
        bmdesc.Height = height / 8;
        bmdesc.MipLevels = 1;
        bmdesc.SampleDesc.Count = 1;
        V_RETURN( m_pd3dDevice->CreateTexture2D( &bmdesc, NULL, &m_pTexBloom[i] ) );

        // Create the render target view
        D3D11_RENDER_TARGET_VIEW_DESC DescRT;
        DescRT.Format = bmdesc.Format;
        DescRT.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
        DescRT.Texture2D.MipSlice = 0;
        V_RETURN( m_pd3dDevice->CreateRenderTargetView( m_pTexBloom[i], &DescRT, &m_pTexBloomRTV[i] ) );
   
        // Create the shader resource view
        D3D11_SHADER_RESOURCE_VIEW_DESC DescRV;
        DescRV.Format = bmdesc.Format;
        DescRV.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
        DescRV.Texture2D.MipLevels = 1;
        DescRV.Texture2D.MostDetailedMip = 0;
        V_RETURN( m_pd3dDevice->CreateShaderResourceView( m_pTexBloom[i], &DescRV, &m_pTexBloomRV[i] ) );
    }


    // Create the final pass texture 
    D3D11_TEXTURE2D_DESC Desc;
    ZeroMemory( &Desc, sizeof( D3D11_TEXTURE2D_DESC ) );
    Desc.ArraySize = 1;
    Desc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
    Desc.Usage = D3D11_USAGE_DEFAULT;
    Desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
    Desc.Width = width;
    Desc.Height = height;
    Desc.MipLevels = 1;
    Desc.SampleDesc.Count = 1;
    V_RETURN( m_pd3dDevice->CreateTexture2D( &Desc, NULL, &m_pTexFinal ) ); 

    // Create the render target view
    D3D11_RENDER_TARGET_VIEW_DESC DescRT;
    DescRT.Format = Desc.Format;
    DescRT.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
    DescRT.Texture2D.MipSlice = 0;
    V_RETURN( m_pd3dDevice->CreateRenderTargetView( m_pTexFinal, &DescRT, &m_pTexFinalRTV ) );

    // Create the resource view
    D3D11_SHADER_RESOURCE_VIEW_DESC DescRV;
    DescRV.Format = Desc.Format;
    DescRV.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
    DescRV.Texture2D.MipLevels = 1;
    DescRV.Texture2D.MostDetailedMip = 0;
    V_RETURN( m_pd3dDevice->CreateShaderResourceView( m_pTexFinal, &DescRV, &m_pTexFinalRV ) );



    // Create the bright pass texture
    Desc.Width /= 8;
    Desc.Height /= 8;
    Desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
    V_RETURN( m_pd3dDevice->CreateTexture2D( &Desc, NULL, &m_pTexBrightPass ) );

    // Create the render target view
    DescRT.Format = Desc.Format;
    DescRT.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
    DescRT.Texture2D.MipSlice = 0;
    V_RETURN( m_pd3dDevice->CreateRenderTargetView( m_pTexBrightPass, &DescRT, &m_pTexBrightPassRTV ) );

    // Create the resource view
    DescRV.Format = Desc.Format;
    DescRV.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
    DescRV.Texture2D.MipLevels = 1;
    DescRV.Texture2D.MostDetailedMip = 0;
    V_RETURN( m_pd3dDevice->CreateShaderResourceView( m_pTexBrightPass, &DescRV, &m_pTexBrightPassRV ) );



    return S_OK;
}