[xiph-commits] r16965 - trunk/oggdsf/src/lib/plugin/AxPlayer
cristianadam at svn.xiph.org
cristianadam at svn.xiph.org
Fri Mar 12 16:37:25 PST 2010
Author: cristianadam
Date: 2010-03-12 16:37:24 -0800 (Fri, 12 Mar 2010)
New Revision: 16965
Modified:
trunk/oggdsf/src/lib/plugin/AxPlayer/DShowVideoPlayer.cpp
trunk/oggdsf/src/lib/plugin/AxPlayer/DShowVideoPlayer.h
trunk/oggdsf/src/lib/plugin/AxPlayer/FilterGraph.cpp
trunk/oggdsf/src/lib/plugin/AxPlayer/VideoTagBehavior.cpp
trunk/oggdsf/src/lib/plugin/AxPlayer/VideoTagBehavior.h
Log:
More performance tweaks regarding VMR9.
Modified: trunk/oggdsf/src/lib/plugin/AxPlayer/DShowVideoPlayer.cpp
===================================================================
--- trunk/oggdsf/src/lib/plugin/AxPlayer/DShowVideoPlayer.cpp 2010-03-11 23:28:34 UTC (rev 16964)
+++ trunk/oggdsf/src/lib/plugin/AxPlayer/DShowVideoPlayer.cpp 2010-03-13 00:37:24 UTC (rev 16965)
@@ -122,33 +122,41 @@
CComPtr<IDirect3DSurface9>& DShowVideoPlayer::GetScalingSurface(const CSize &aSize)
{
- if (m_scalingBuffer && aSize != m_scalingSize)
+ if (m_scalingBuffer && m_presentBuffer && aSize != m_scalingSize)
{
- LOG(logDEBUG3) << __FUNCTIONW__ << " Releasing old scaling surface";
+ LOG(logDEBUG3) << __FUNCTIONW__ << " Releasing old scaling surfaces";
m_scalingBuffer = 0;
+ m_presentBuffer = 0;
}
- if (!m_scalingBuffer)
+ if (!m_scalingBuffer && !m_presentBuffer)
{
- LOG(logDEBUG3) << __FUNCTIONW__ << " Creating new scaling surface";
+ LOG(logDEBUG3) << __FUNCTIONW__ << " Creating new scaling surfaces";
D3DDISPLAYMODE displayMode = {};
CHECK_HR(m_d3d->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &displayMode));
CHECK_HR(GetDevice()->CreateRenderTarget(aSize.cx, aSize.cy, displayMode.Format,
- D3DMULTISAMPLE_NONE, 0, TRUE, &m_scalingBuffer, 0));
+ D3DMULTISAMPLE_NONE, 0, FALSE, &m_scalingBuffer, 0));
+ CHECK_HR(GetDevice()->CreateOffscreenPlainSurface(aSize.cx, aSize.cy, displayMode.Format,
+ D3DPOOL_SYSTEMMEM, &m_presentBuffer, 0));
+
m_scalingSize = aSize;
}
return m_scalingBuffer;
}
-HRESULT DShowVideoPlayer::Draw(RECT rcBounds, RECT rcUpdate, LONG lDrawFlags, HDC hdc, LPVOID pvDrawObject)
+HRESULT DShowVideoPlayer::Draw(RECT rcBounds, RECT rcWindow, LONG lDrawFlags, HDC hdc, LPVOID pvDrawObject)
{
CRect rect(rcBounds);
+ LOG(logDEBUG4) << __FUNCTIONW__
+ << " [" << rect.left << "," << rect.top << " x " << rect.right << "," << rect.bottom << "] ->"
+ << " [" << rcWindow.left << "," << rcWindow.top << " x " << rcWindow.right << "," << rcWindow.bottom << "]";
+
HRESULT hr = S_OK;
try
{
@@ -157,9 +165,10 @@
// Use a third buffer to scale the picture
CComPtr<IDirect3DSurface9> scaledSurface = GetScalingSurface(CSize(rect.Width(), rect.Height()));
CHECK_HR(GetDevice()->StretchRect(m_backBuffer, 0, scaledSurface, 0, m_textureFilterType));
+ CHECK_HR(GetDevice()->GetRenderTargetData(scaledSurface, m_presentBuffer));
- HDC scalingBufferDC;
- CHECK_HR(m_scalingBuffer->GetDC(&scalingBufferDC));
+ HDC presentBufferDC;
+ CHECK_HR(m_presentBuffer->GetDC(&presentBufferDC));
// Do not paint when the current displayed line is passing
// our rect, when it does and we draw we get tearing.
@@ -178,7 +187,7 @@
break;
}
- if (rasterStatus.ScanLine >= (DWORD)rcUpdate.top && rasterStatus.ScanLine <= (DWORD)rcUpdate.bottom)
+ if (rasterStatus.ScanLine >= (DWORD)rcWindow.top && rasterStatus.ScanLine <= (DWORD)rcWindow.bottom)
{
Sleep(1);
continue;
@@ -187,9 +196,9 @@
break;
}
- ::BitBlt(hdc, rect.left, rect.top, rect.Width(), rect.Height(), scalingBufferDC, 0, 0, SRCCOPY);
+ ::BitBlt(hdc, rect.left, rect.top, rect.Width(), rect.Height(), presentBufferDC, 0, 0, SRCCOPY);
- CHECK_HR(m_scalingBuffer->ReleaseDC(scalingBufferDC));
+ CHECK_HR(m_presentBuffer->ReleaseDC(presentBufferDC));
}
}
catch (const CAtlException& except)
Modified: trunk/oggdsf/src/lib/plugin/AxPlayer/DShowVideoPlayer.h
===================================================================
--- trunk/oggdsf/src/lib/plugin/AxPlayer/DShowVideoPlayer.h 2010-03-11 23:28:34 UTC (rev 16964)
+++ trunk/oggdsf/src/lib/plugin/AxPlayer/DShowVideoPlayer.h 2010-03-13 00:37:24 UTC (rev 16965)
@@ -112,6 +112,7 @@
CComPtr<IDirect3DDevice9> m_direct3dDevice;
CComPtr<IDirect3DSurface9> m_backBuffer;
CComPtr<IDirect3DSurface9> m_scalingBuffer;
+ CComPtr<IDirect3DSurface9> m_presentBuffer;
CSize m_scalingSize;
int m_width;
Modified: trunk/oggdsf/src/lib/plugin/AxPlayer/FilterGraph.cpp
===================================================================
--- trunk/oggdsf/src/lib/plugin/AxPlayer/FilterGraph.cpp 2010-03-11 23:28:34 UTC (rev 16964)
+++ trunk/oggdsf/src/lib/plugin/AxPlayer/FilterGraph.cpp 2010-03-13 00:37:24 UTC (rev 16965)
@@ -352,4 +352,4 @@
void FilterGraph::SetD3D(const CComPtr<IDirect3D9>& val)
{
m_d3d = val;
-}
\ No newline at end of file
+}
Modified: trunk/oggdsf/src/lib/plugin/AxPlayer/VideoTagBehavior.cpp
===================================================================
--- trunk/oggdsf/src/lib/plugin/AxPlayer/VideoTagBehavior.cpp 2010-03-11 23:28:34 UTC (rev 16964)
+++ trunk/oggdsf/src/lib/plugin/AxPlayer/VideoTagBehavior.cpp 2010-03-13 00:37:24 UTC (rev 16965)
@@ -140,6 +140,7 @@
CHECK_HR(HTMLEvents::DispEventAdvise(m_element));
AcquireEmbeddedAx();
+ AcquireHtmlWindow3();
}
break;
}
@@ -152,6 +153,19 @@
return S_OK;
}
+void VideoTagBehavior::AcquireHtmlWindow3()
+{
+ CComPtr<IDispatch> disp;
+ CComPtr<IHTMLDocument2> document2;
+ CComPtr<IHTMLWindow2> window2;
+
+ CHECK_HR(m_element->get_document(&disp));
+ CHECK_HR(disp->QueryInterface(IID_IHTMLDocument2, (LPVOID *) &document2));
+ CHECK_HR(document2->get_parentWindow(&window2));
+
+ CHECK_HR(window2->QueryInterface(&m_htmlWindow3));
+}
+
HRESULT __stdcall VideoTagBehavior::Detach()
{
LOG(logDEBUG) << this << ": " << __FUNCTIONW__;
@@ -280,10 +294,14 @@
pInfo->lFlags =
HTMLPAINTER_NOSAVEDC |
HTMLPAINTER_SUPPORTS_XFORM |
- HTMLPAINTER_HITTEST;
+ HTMLPAINTER_HITTEST |
+ HTMLPAINTER_SURFACE |
+ HTMLPAINTER_OVERLAY;
pInfo->lZOrder = HTMLPAINT_ZORDER_REPLACE_ALL;
+ pInfo->iidDrawObject = IID_IDirectDrawSurface;
+
pInfo->rcExpand.left = 0;
pInfo->rcExpand.top = 0;
pInfo->rcExpand.right = 0;
@@ -295,13 +313,24 @@
HRESULT __stdcall VideoTagBehavior::OnEmbeddedDraw(RECT rect, HDC hdc)
{
- CRect windowRect(0, 0, m_width, m_height);
- if (m_hWnd != 0)
+ HRESULT hr = S_OK;
+ try
{
- GetWindowRect(&windowRect);
+ long screenLeft = 0;
+ long screenTop = 0;
+ CHECK_HR(m_htmlWindow3->get_screenLeft(&screenLeft));
+ CHECK_HR(m_htmlWindow3->get_screenTop(&screenTop));
+
+ CRect clientRect(rect);
+ CRect windowRect(screenLeft, screenTop, screenLeft + clientRect.Width(), screenTop + clientRect.Height());
+
+ CHECK_HR(m_videoPlayer.Draw(clientRect, windowRect, 0, hdc, 0));
}
+ catch (const CAtlException& except)
+ {
+ hr = except.m_hr;
+ }
- HRESULT hr = m_videoPlayer.Draw(rect, windowRect, 0, hdc, 0);
return hr;
}
@@ -310,13 +339,30 @@
// This is called only in Quirks mode
m_standardsMode = false;
- CRect windowRect(0, 0, m_width, m_height);
- if (m_hWnd != 0)
+ HRESULT hr = S_OK;
+ try
{
- GetWindowRect(&windowRect);
+ long screenLeft = 0;
+ long screenTop = 0;
+ CHECK_HR(m_htmlWindow3->get_screenLeft(&screenLeft));
+ CHECK_HR(m_htmlWindow3->get_screenTop(&screenTop));
+
+ CRect clientRect(rcBounds);
+ CRect windowRect(screenLeft, screenTop, screenLeft + clientRect.Width(), screenTop + clientRect.Height());
+
+ CComPtr<IDirectDrawSurface> destSurface;
+ destSurface = reinterpret_cast<IDirectDrawSurface*>(pvDrawObject);
+
+ HDC destSurfaceDC;
+ CHECK_HR(destSurface->GetDC(&destSurfaceDC));
+ CHECK_HR(m_videoPlayer.Draw(clientRect, windowRect, lDrawFlags, destSurfaceDC, pvDrawObject));
+ CHECK_HR(destSurface->ReleaseDC(destSurfaceDC));
}
+ catch (const CAtlException& except)
+ {
+ hr = except.m_hr;
+ }
- HRESULT hr = m_videoPlayer.Draw(rcBounds, windowRect, lDrawFlags, hdc, pvDrawObject);
return hr;
}
@@ -773,4 +819,4 @@
LRESULT VideoTagBehavior::OnEraseBkgnd( UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/ )
{
return FALSE;
-}
\ No newline at end of file
+}
Modified: trunk/oggdsf/src/lib/plugin/AxPlayer/VideoTagBehavior.h
===================================================================
--- trunk/oggdsf/src/lib/plugin/AxPlayer/VideoTagBehavior.h 2010-03-11 23:28:34 UTC (rev 16964)
+++ trunk/oggdsf/src/lib/plugin/AxPlayer/VideoTagBehavior.h 2010-03-13 00:37:24 UTC (rev 16965)
@@ -219,6 +219,7 @@
void AdjustElementDimensions(const CSize &movieSize);
void AcquireEmbeddedAx();
+ void AcquireHtmlWindow3();
CString GetSiteURL();
bool IsRelativeURL(const CString& url);
@@ -229,6 +230,7 @@
CComPtr<IHTMLPaintSite> m_paintSite;
CComPtr<IHTMLElement> m_element;
CComPtr<IOleClientSite> m_oleClientSite;
+ CComPtr<IHTMLWindow3> m_htmlWindow3;
CString m_embeddedAxGuid;
CComPtr<IHTMLElement> m_embeddedAxElement;
More information about the commits
mailing list