Changeset 174
- Timestamp:
- May 18, 2013, 11:19:04 PM (10 years ago)
- Location:
- trunk/Utilities/StressEvr
- Files:
-
- 3 added
- 2 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Utilities/StressEvr/MainDialog.h
r166 r174 15 15 16 16 #pragma comment(lib, "dxgi.lib") 17 18 //////////////////////////////////////////////////////////// 19 // CVmr7Window 20 21 class CVmr7Window : 22 public CControlWindowT<CVmr7Window> 23 { 24 public: 25 26 BEGIN_MSG_MAP_EX(CVmr7Window) 27 //CHAIN_MSG_MAP(CControlWindowT<CVmr7Window>) 28 MSG_WM_ERASEBKGND(OnEraseBkgnd) 29 MSG_WM_PAINT(OnPaint) 30 MSG_WM_DISPLAYCHANGE(OnDisplayChange) 31 MSG_WM_SIZE(OnSize) 32 MSG_WM_LBUTTONDBLCLK(OnLButtonDblClk) 33 END_MSG_MAP() 34 35 public: 36 CComPtr<IBaseFilter> m_pBaseFilter; 37 CComPtr<IVMRWindowlessControl> m_pVmrWindowlessControl; 38 39 public: 40 // CVmr7Window 41 static CLSID GetRendererClassIdentifier() throw() 42 { 43 return CLSID_VideoMixingRenderer; 44 } 45 static CComPtr<IBaseFilter> CoCreateBaseFilterInstance() 46 { 47 CComPtr<IBaseFilter> pBaseFilter; 48 __C(pBaseFilter.CoCreateInstance(GetRendererClassIdentifier())); 49 return pBaseFilter; 50 } 51 VOID Initialize(IBaseFilter* pBaseFilter) 52 { 53 _A(pBaseFilter); 54 _A(!m_pBaseFilter && !m_pVmrWindowlessControl); 55 m_pBaseFilter = pBaseFilter; 56 const CComQIPtr<IVMRFilterConfig> pVmrFilterConfig = pBaseFilter; 57 __D(pVmrFilterConfig, E_NOINTERFACE); 58 __C(pVmrFilterConfig->SetRenderingMode(VMRMode_Windowless)); 59 m_pVmrWindowlessControl = CComQIPtr<IVMRWindowlessControl>(m_pBaseFilter); 60 __D(m_pVmrWindowlessControl, E_NOINTERFACE); 61 __C(m_pVmrWindowlessControl->SetVideoClippingWindow(m_hWnd)); 62 CRect VideoPosition = GetVideoPosition(); 63 _Z4(atlTraceGeneral, 4, _T(".m_pVmrWindowlessControl 0x%p, VideoPosition at (%d, %d) size (%d, %d)\n"), m_pVmrWindowlessControl, VideoPosition.left, VideoPosition.top, VideoPosition.Width(), VideoPosition.Height()); 64 __C(m_pVmrWindowlessControl->SetVideoPosition(NULL, VideoPosition)); 65 } 66 VOID Terminate() throw() 67 { 68 m_pBaseFilter = NULL; 69 m_pVmrWindowlessControl = NULL; 70 } 71 CRect GetVideoPosition() const throw() 72 { 73 CRect Position; 74 _W(GetClientRect(Position)); 75 return Position; 76 } 77 78 // Window Message Handlers 79 LRESULT OnEraseBkgnd(CDCHandle Dc) 80 { 81 Dc; 82 if(m_pVmrWindowlessControl) 83 { 84 return TRUE; 85 } else 86 SetMsgHandled(FALSE); 87 return 0; 88 } 89 LRESULT OnPaint(CDCHandle) 90 { 91 if(m_pVmrWindowlessControl) 92 { 93 CPaintDC Dc(m_hWnd); 94 const HRESULT nRepaintVideoResult = m_pVmrWindowlessControl->RepaintVideo(m_hWnd, Dc); 95 _Z45_HRESULT(nRepaintVideoResult); 96 } else 97 SetMsgHandled(FALSE); 98 return 0; 99 } 100 LRESULT OnDisplayChange(UINT nDepth, CSize Extent) 101 { 102 if(m_pVmrWindowlessControl) 103 { 104 const HRESULT nDisplayModeChangedResult = m_pVmrWindowlessControl->DisplayModeChanged(); 105 _Z45_HRESULT(nDisplayModeChangedResult); 106 } 107 return 0; 108 } 109 LRESULT OnSize(UINT nType, CSize) 110 { 111 if(nType != SIZE_MINIMIZED) 112 if(m_pVmrWindowlessControl) 113 { 114 CRect VideoPosition = GetVideoPosition(); 115 const HRESULT nSetVideoPositionResult = m_pVmrWindowlessControl->SetVideoPosition(NULL, &VideoPosition); 116 _Z45_HRESULT(nSetVideoPositionResult); 117 } 118 return 0; 119 } 120 LRESULT OnLButtonDblClk(UINT, CPoint) 121 { 122 COlePropertyFrameDialog Dialog(m_pBaseFilter, _T("VMR-7")); 123 Dialog.SetObjectPages(); 124 Dialog.DoModal(m_hWnd); 125 return 0; 126 } 127 }; 17 128 18 129 //////////////////////////////////////////////////////////// … … 140 251 LRESULT OnLButtonDblClk(UINT, CPoint Position) 141 252 { 142 COlePropertyFrameDialog Dialog; 143 Dialog.SetObject(m_pBaseFilter); 253 COlePropertyFrameDialog Dialog(m_pBaseFilter, _T("EVR")); 144 254 Dialog.SetObjectPages(); 145 255 Dialog.DoModal(m_hWnd); … … 149 259 150 260 //////////////////////////////////////////////////////////// 151 // CVideoDialog 152 153 class CVideoDialog : 154 public CDialogImpl<CVideoDialog>, 155 public CDialogResize<CVideoDialog> 261 // CBaseVideoDialog 262 263 class CBaseVideoDialog 156 264 { 265 public: 266 // CBaseVideoDialog 267 virtual HWND Create(HWND hParentWindow) = 0; 268 virtual BOOL DestroyWindow() = 0; 269 virtual BOOL IsWindow() = 0; 270 virtual BOOL MoveWindow(const CRect& Position) = 0; 271 virtual INT ShowWindow(INT nShowCommand) = 0; 272 }; 273 274 //////////////////////////////////////////////////////////// 275 // CVideoDialogT 276 277 template <typename T, typename CVrWindow, LPCTSTR* t_ppszType> 278 class CVideoDialogT : 279 public CDialogImpl<T>, 280 public CDialogResize<T>, 281 public CBaseVideoDialog 282 { 283 typedef CVideoDialogT<T, CVrWindow, t_ppszType> CVideoDialog; 284 157 285 public: 158 286 enum { IDD = IDD_VIDEO }; … … 160 288 BEGIN_MSG_MAP_EX(CVideoDialog) 161 289 //CHAIN_MSG_MAP(CDialogImpl<CVideoDialog>) 162 CHAIN_MSG_MAP(CDialogResize< CVideoDialog>)290 CHAIN_MSG_MAP(CDialogResize<T>) 163 291 MSG_WM_INITDIALOG(OnInitDialog) 164 292 MSG_WM_DESTROY(OnDestroy) … … 379 507 CStatic m_AreaStatic; 380 508 CGenericFilterGraph m_FilterGraph; 381 CRoArrayT<C EvrWindow> m_EvrWindowArray;509 CRoArrayT<CVrWindow> m_VrWindowArray; 382 510 CButton m_RunButton; 383 511 CButton m_PauseButton; … … 441 569 public: 442 570 // CVideoDialog 443 CVideoDialog (const CMediaType& pMediaType, SIZE_T nLayout) :571 CVideoDialogT(const CMediaType& pMediaType, SIZE_T nLayout) : 444 572 m_pMediaType(pMediaType), 445 573 m_nLayout(nLayout) … … 447 575 _Z4(atlTraceRefcount, 4, _T("this 0x%p\n"), this); 448 576 } 449 ~CVideoDialog () throw()577 ~CVideoDialogT() throw() 450 578 { 451 579 _Z4(atlTraceRefcount, 4, _T("this 0x%p\n"), this); 580 } 581 582 // CDialogImpl 583 VOID OnFinalMessage(HWND) 584 { 585 T* pT = static_cast<T*>(this); 586 delete pT; 587 } 588 589 // CBaseVideoDialog 590 HWND Create(HWND hParentWindow) 591 { 592 return CDialogImpl<T>::Create(hParentWindow); 593 } 594 BOOL DestroyWindow() 595 { 596 return CDialogImpl<T>::DestroyWindow(); 597 } 598 BOOL IsWindow() 599 { 600 return CDialogImpl<T>::IsWindow(); 601 } 602 BOOL MoveWindow(const CRect& Position) 603 { 604 return CDialogImpl<T>::MoveWindow(Position); 605 } 606 INT ShowWindow(INT nShowCommand) 607 { 608 return CDialogImpl<T>::ShowWindow(nShowCommand); 452 609 } 453 610 … … 460 617 _W(ScreenToClient(Position)); 461 618 CDeferWindowPos DeferWindowPos; 462 _W(DeferWindowPos.Begin((INT) m_ EvrWindowArray.GetCount()));463 for(SIZE_T nIndex = 0; nIndex < m_ EvrWindowArray.GetCount(); nIndex++)464 _W(DeferWindowPos.SetWindowPos(m_ EvrWindowArray[nIndex], NULL, GetVideoPosition(Position, nIndex), SWP_NOZORDER | SWP_NOACTIVATE));619 _W(DeferWindowPos.Begin((INT) m_VrWindowArray.GetCount())); 620 for(SIZE_T nIndex = 0; nIndex < m_VrWindowArray.GetCount(); nIndex++) 621 _W(DeferWindowPos.SetWindowPos(m_VrWindowArray[nIndex], NULL, GetVideoPosition(Position, nIndex), SWP_NOZORDER | SWP_NOACTIVATE)); 465 622 _W(DeferWindowPos.End()); 466 623 } … … 478 635 m_FilterGraph.CoCreateInstance(); 479 636 const SIZE_T nCount = (m_nLayout + 1) * (m_nLayout + 1); // 1, 4, 9, 16, ... 480 _A(m_ EvrWindowArray.IsEmpty());481 _W(m_ EvrWindowArray.SetCount(0, (INT) nCount));637 _A(m_VrWindowArray.IsEmpty()); 638 _W(m_VrWindowArray.SetCount(0, (INT) nCount)); 482 639 for(SIZE_T nIndex = 0; nIndex < nCount; nIndex++) 483 640 { 484 C EvrWindow& EvrWindow = m_EvrWindowArray[m_EvrWindowArray.Add()];485 CComPtr<IBaseFilter> pBaseFilter = C EvrWindow::CoCreateBaseFilterInstance();641 CVrWindow& VrWindow = m_VrWindowArray[m_VrWindowArray.Add()]; 642 CComPtr<IBaseFilter> pBaseFilter = CVrWindow::CoCreateBaseFilterInstance(); 486 643 __C(m_FilterGraph->AddFilter(pBaseFilter, CT2CW(AtlFormatString(_T("Renderer %02d"), nIndex + 1)))); 487 EvrWindow.Create(m_hWnd);488 EvrWindow.ShowWindow(SW_SHOWNORMAL);489 EvrWindow.Initialize(pBaseFilter);644 VrWindow.Create(m_hWnd); 645 VrWindow.ShowWindow(SW_SHOWNORMAL); 646 VrWindow.Initialize(pBaseFilter); 490 647 CObjectPtr<CSourceFilter> pSourceFilter; 491 648 pSourceFilter.Construct()->Initialize(m_pMediaType); 492 649 __C(m_FilterGraph->AddFilter(pSourceFilter, CT2CW(AtlFormatString(_T("Source %02d"), nIndex + 1)))); 493 m_FilterGraph->Connect(pSourceFilter->GetOutputPin(), _FilterGraphHelper::GetFilterPin( EvrWindow.m_pBaseFilter));650 m_FilterGraph->Connect(pSourceFilter->GetOutputPin(), _FilterGraphHelper::GetFilterPin(VrWindow.m_pBaseFilter)); 494 651 } 495 652 __C(m_FilterGraph.m_pMediaEventEx->SetNotifyWindow((OAHWND) m_hWnd, WM_FILTERGRAPHEVENT, (LONG_PTR) this)); … … 501 658 GetWindowText(sCaption); 502 659 const CSize Extent = m_pMediaType.GetCompatibleVideoInfoHeader().GetExtent(); 503 SetWindowText(AtlFormatString(sCaption, nCount, Extent.cx, Extent.cy));660 SetWindowText(AtlFormatString(sCaption, nCount, *t_ppszType, Extent.cx, Extent.cy)); 504 661 return 0; 505 662 } … … 508 665 if(m_FilterGraph.m_pMediaControl) 509 666 _V(m_FilterGraph.m_pMediaControl->Stop()); 510 for(SIZE_T nIndex = 0; nIndex < m_ EvrWindowArray.GetCount(); nIndex++)511 m_ EvrWindowArray[nIndex].Terminate();667 for(SIZE_T nIndex = 0; nIndex < m_VrWindowArray.GetCount(); nIndex++) 668 m_VrWindowArray[nIndex].Terminate(); 512 669 m_FilterGraph.Release(); 670 CWindow OwnerWindow = GetWindow(GW_OWNER); 671 if(OwnerWindow.IsWindow()) 672 OwnerWindow.SendMessage(WM_COMMAND, 'CL', (LPARAM) (CBaseVideoDialog*) this); 513 673 return 0; 514 674 } … … 586 746 587 747 //////////////////////////////////////////////////////////// 748 // CVmr7VideoDialog, CEvrVideoDialog 749 750 LPCTSTR g_pszVmr7 = _T("VMR-7"); 751 752 class CVmr7VideoDialog : 753 public CVideoDialogT<CVmr7VideoDialog, CVmr7Window, &g_pszVmr7> 754 { 755 public: 756 // CVmr7VideoDialog 757 CVmr7VideoDialog(const CMediaType& pMediaType, SIZE_T nLayout) : 758 CVideoDialogT<CVmr7VideoDialog, CVmr7Window, &g_pszVmr7>(pMediaType, nLayout) 759 { 760 } 761 }; 762 763 LPCTSTR g_pszEvr = _T("EVR"); 764 765 class CEvrVideoDialog : 766 public CVideoDialogT<CEvrVideoDialog, CEvrWindow, &g_pszEvr> 767 { 768 public: 769 // CEvrVideoDialog 770 CEvrVideoDialog(const CMediaType& pMediaType, SIZE_T nLayout) : 771 CVideoDialogT<CEvrVideoDialog, CEvrWindow, &g_pszEvr>(pMediaType, nLayout) 772 { 773 } 774 }; 775 776 //////////////////////////////////////////////////////////// 588 777 // CMainDialog 589 778 … … 602 791 COMMAND_ID_HANDLER_EX(IDCANCEL, OnCommand) 603 792 COMMAND_ID_HANDLER_EX(IDC_CREATE, OnCreateButtonClicked) 793 COMMAND_ID_HANDLER_EX('CL', OnCloseVideoDialog) 604 794 REFLECT_NOTIFICATIONS() 605 795 END_MSG_MAP() … … 620 810 CComPtr<IDXGIFactory> m_pDxgiFactory; 621 811 CRect m_DefaultPosition; 622 CRoListT<C AutoPtr<CVideoDialog>> m_VideoDialogList;812 CRoListT<CBaseVideoDialog*> m_VideoDialogList; 623 813 624 814 public: … … 640 830 GetWindowText(sCaption); 641 831 #if defined(_WIN64) 642 sCaption.Append(_T(" (64-bit)"));832 sCaption.Append(_T(" (64-bit)")); 643 833 #else 644 if(SafeIsWow64Process())645 sCaption.Append(_T(" (32-bit)"));834 if(SafeIsWow64Process()) 835 sCaption.Append(_T(" (32-bit)")); 646 836 #endif // defined(_WIN64) 647 837 SetWindowText(sCaption); 648 838 } 649 839 _W(CenterWindow()); 840 CButton(GetDlgItem(IDC_TYPE_EVR)).SetCheck(TRUE); 650 841 CButton(GetDlgItem(IDC_RESOLUTION_19201080)).SetCheck(TRUE); 651 842 CButton(GetDlgItem(IDC_PIXELFORMAT_NV12)).SetCheck(TRUE); … … 677 868 for(POSITION Position = m_VideoDialogList.GetHeadPosition(); Position; m_VideoDialogList.GetNext(Position)) 678 869 { 679 C AutoPtr<CVideoDialog>&pVideoDialog = m_VideoDialogList.GetAt(Position);870 CBaseVideoDialog* pVideoDialog = m_VideoDialogList.GetAt(Position); 680 871 _A(pVideoDialog); 681 872 if(pVideoDialog->IsWindow()) … … 763 954 CWaitCursor WaitCursor; 764 955 #pragma region Query Controls 956 SIZE_T nType; 957 for(INT nIdentifier = IDC_TYPE_VMR7; nIdentifier <= IDC_TYPE_EVR; nIdentifier++) 958 if(IsDlgButtonChecked(nIdentifier)) 959 { 960 nType = nIdentifier - IDC_TYPE_VMR7; 961 break; 962 } 765 963 SIZE_T nResolution; 766 964 for(INT nIdentifier = IDC_RESOLUTION_720576; nIdentifier <= IDC_RESOLUTION_19201080; nIdentifier++) … … 790 988 CMediaType pMediaType; 791 989 pMediaType.AllocateVideoInfo(g_pExtents[nResolution], g_pnBitCounts[nPixelFormat], g_pnCompressions[nPixelFormat]); 792 CVideoDialog* pVideoDialog = new CVideoDialog(pMediaType, nLayout); 990 CBaseVideoDialog* pVideoDialog; 991 switch(nType) 992 { 993 case 0: // IDC_TYPE_VMR7 994 pVideoDialog = new CVmr7VideoDialog(pMediaType, nLayout); 995 break; 996 case 1: // IDC_TYPE_EVR 997 pVideoDialog = new CEvrVideoDialog(pMediaType, nLayout); 998 break; 999 default: 1000 __C(E_NOTIMPL); 1001 } 793 1002 _ATLTRY 794 1003 { … … 808 1017 _W(pVideoDialog->MoveWindow(Position)); 809 1018 pVideoDialog->ShowWindow(SW_SHOWNORMAL); 810 m_VideoDialogList. GetAt(m_VideoDialogList.AddTail()).Attach(pVideoDialog);1019 m_VideoDialogList.AddTail(pVideoDialog); 811 1020 } 812 1021 _ATLCATCHALL() … … 823 1032 return 0; 824 1033 } 1034 LRESULT OnCloseVideoDialog(UINT, INT, HWND hWindow) 1035 { 1036 CBaseVideoDialog* pBaseVideoDialog = (CBaseVideoDialog*) hWindow; 1037 POSITION Position; 1038 if(m_VideoDialogList.FindFirst(pBaseVideoDialog, &Position)) 1039 m_VideoDialogList.RemoveAt(Position); 1040 return 0; 1041 } 825 1042 }; -
trunk/Utilities/StressEvr/StressEvr.sln
r56 r174 1 1 2 2 Microsoft Visual Studio Solution File, Format Version 11.00 3 # Visual Studio 201 03 # Visual Studio 2012 4 4 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StressEvr", "StressEvr.vcxproj", "{D5F58BC2-453A-4C4E-888E-9C7C511D8FD4}" 5 5 EndProject -
trunk/Utilities/StressEvr/StressEvr_i.c
r166 r174 7 7 8 8 /* File created by MIDL compiler version 7.00.0555 */ 9 /* at Mon Jan 21 21:25:1420139 /* at Sun May 19 09:17:42 2013 10 10 */ 11 11 /* Compiler settings for StressEvr.idl: -
trunk/Utilities/StressEvr/StressEvr_i.h
r166 r174 5 5 6 6 /* File created by MIDL compiler version 7.00.0555 */ 7 /* at Mon Jan 21 21:25:1420137 /* at Sun May 19 09:17:42 2013 8 8 */ 9 9 /* Compiler settings for StressEvr.idl:
Note: See TracChangeset
for help on using the changeset viewer.