HRESULT WINAPI D3D9ProxySwapChain::Present(CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion, DWORD dwFlags)
{
#ifdef _DEBUG
	OutputDebugString(__FUNCTION__);
	OutputDebugString("\n");
#endif;

	// Test only, StereoView needs to be properly integrated as part of SwapChain.
	// This test allowed deus ex menus and videos to work correctly. Lots of model rendering issues in game though
	D3DProxyDevice* pD3DProxyDev = static_cast<D3DProxyDevice*>(m_pOwningDevice);

	IDirect3DSurface9* pWrappedBackBuffer;

	try {
		GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &pWrappedBackBuffer);

		if (pD3DProxyDev->stereoView->initialized)
			pD3DProxyDev->stereoView->Draw(static_cast<D3D9ProxySurface*>(pWrappedBackBuffer));

		pWrappedBackBuffer->Release();
	}
	catch (std::out_of_range) {
		OutputDebugString("Present: No primary swap chain found. (Present probably called before device has been reset)");
	}


	return m_pActualSwapChain->Present(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags);
}
Exemple #2
0
//----------------------------------------------------------------------------
//! @brief	  	バックバッファへのポインタを取得します。
//! @param		buff : バックバッファへのポインタを返すためのバッファへのポインタ
//! @param		size : バッファのサイズを返す変数へのポインタ
//! @return		エラーコード
//----------------------------------------------------------------------------
HRESULT TBufferRenderer::GetBackBuffer( BYTE **buff, long *size )
{
	CAutoLock cAutoLock(&m_BufferLock);	// クリティカルセクション
	*buff = GetBackBuffer();
	*size = GetBufferSize();
	return S_OK;
}
SPointer<IGraphics> DDScreen::QueryIGraphics( const Rect &cut )
{
    return GetBackBuffer().Copy(cut);
}
Exemple #4
0
//----------------------------------------------------------------------------
//! @brief	  	A sample has been delivered. Copy it to the texture.
//! @param		pSample : サンプルの IMediaSample インターフェイスへのポインタ
//! @return		エラーコード
//----------------------------------------------------------------------------
HRESULT TBufferRenderer::DoRenderSample( IMediaSample * pSample )
{
	DWORD	*pBmpBuffer, *pTxtBuffer;	// Bitmap buffer, texture buffer
	BYTE	*pTxtOrgPos;

//	if( m_bEOS ) return S_OK;

	CAutoLock cAutoLock(&m_BufferLock);	// クリティカルセクション

	// Get the video bitmap buffer
	pSample->GetPointer( reinterpret_cast<BYTE**>(&pBmpBuffer) );

	// Get the texture buffer & pitch
	pTxtBuffer = reinterpret_cast<DWORD*>(GetBackBuffer());
	pTxtOrgPos = reinterpret_cast<BYTE*>(pTxtBuffer);

	HRESULT		hr;
	LONG		EventParam1 = -1;
	LONGLONG	TimeStart = 0;
	LONGLONG	TimeEnd = 0;

	if( SUCCEEDED(hr = pSample->GetMediaTime( &TimeStart, &TimeEnd )) )
	{
		EventParam1 = (LONG)TimeStart;
	}
	if( m_StopFrame && EventParam1 >= m_StopFrame )
		return S_OK;	// 再生しないフレーム

	if( pTxtBuffer == pBmpBuffer )	// 自前のアロケーターが使われている
	{
		SwapBuffer( pSample );	// FrontとBackバッファを入れ替える
		if( m_pSink )
			m_pSink->Notify( EC_UPDATE, EventParam1, NULL );
		return S_OK;
	}

	// 自前のアロケーターではないのでメモリをコピーする
#if 0
	// 下から上にコピー(上下反転化)
	{
		int		height = m_VideoHeight;
		int		width = m_VideoWidth;
		pBmpBuffer += width * (height-1);
		for( int j = 0; j < height; j++ )
		{
			for( int i = 0; i < width; i++ )
			{
				pTxtBuffer[i] = pBmpBuffer[i];
			}
			pBmpBuffer -= width;
			pTxtBuffer += width;
		}
	}
#else
	// 上から下にコピー
	{
		int		height = m_VideoHeight;
		int		width = m_VideoWidth;
		for( int j = 0; j < height; j++ )
		{
			for( int i = 0; i < width; i++ )
			{
				pTxtBuffer[i] = pBmpBuffer[i];
			}
			pBmpBuffer += width;
			pTxtBuffer += width;
		}
	}
#endif
	if( m_pSink )
		m_pSink->Notify( EC_UPDATE, EventParam1, NULL );
	SwapBuffer( pSample );	// FrontとBackバッファを入れ替える
	return S_OK;
}