Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

136 lines
4.8 KiB

  1. /*************************************************************************/
  2. /* Helper function */
  3. /*************************************************************************/
  4. #include "resource.h" // main symbols
  5. #include <atlctl.h>
  6. #include "MSWebDVD.h"
  7. #include "msdvd.h"
  8. class CDDrawDVD;
  9. /////////////////////////////////////////////////////////////////////////////
  10. // COverlayCallback
  11. class ATL_NO_VTABLE COverlayCallback :
  12. public CComObjectRootEx<CComSingleThreadModel>,
  13. public CComCoClass<COverlayCallback, &CLSID_OverlayCallback>,
  14. public IDispatchImpl<IOverlayCallback, &IID_IOverlayCallback, &LIBID_MSWEBDVDLib>,
  15. public IObjectWithSiteImplSec<COverlayCallback>,
  16. public IDDrawExclModeVideoCallback
  17. {
  18. public:
  19. COverlayCallback()
  20. {
  21. m_dwWidth = 0;
  22. m_dwHeight = 0;
  23. m_dwARWidth = 1;
  24. m_dwARHeight = 1;
  25. m_pDDrawDVD = NULL;
  26. }
  27. DECLARE_REGISTRY_RESOURCEID(IDR_OVERLAYCALLBACK)
  28. DECLARE_PROTECT_FINAL_CONSTRUCT()
  29. BEGIN_COM_MAP(COverlayCallback)
  30. COM_INTERFACE_ENTRY(IOverlayCallback)
  31. COM_INTERFACE_ENTRY(IDispatch)
  32. COM_INTERFACE_ENTRY(IObjectWithSite)
  33. COM_INTERFACE_ENTRY(IDDrawExclModeVideoCallback)
  34. END_COM_MAP()
  35. // IOverlayCallback
  36. public:
  37. STDMETHOD(SetDDrawDVD)(VARIANT pDDrawDVD);
  38. //IDDrawExclModeVideoCallback
  39. HRESULT STDMETHODCALLTYPE OnUpdateOverlay(BOOL bBefore,
  40. DWORD dwFlags,
  41. BOOL bOldVisible,
  42. const RECT *prcSrcOld,
  43. const RECT *prcDestOld,
  44. BOOL bNewVisible,
  45. const RECT *prcSrcNew,
  46. const RECT *prcDestNew);
  47. HRESULT STDMETHODCALLTYPE OnUpdateColorKey(COLORKEY const *pKey, DWORD dwColor);
  48. HRESULT STDMETHODCALLTYPE OnUpdateSize(DWORD dwWidth, DWORD dwHeight,
  49. DWORD dwARWidth, DWORD dwARHeight);
  50. private:
  51. CDDrawDVD *m_pDDrawDVD;
  52. DWORD m_dwWidth;
  53. DWORD m_dwHeight;
  54. DWORD m_dwARWidth;
  55. DWORD m_dwARHeight;
  56. };
  57. //
  58. // DDraw object class to paint color key, flip etc etc.
  59. //
  60. class CDDrawDVD {
  61. public:
  62. CDDrawDVD(CMSWebDVD *pDVD);
  63. ~CDDrawDVD();
  64. HRESULT SetupDDraw(const AMDDRAWGUID* lpDDGUID, HWND hWnd);
  65. HRESULT SetColorKey(COLORREF dwColorKey);
  66. COLORREF GetColorKey();
  67. HRESULT CreateDIBBrush(COLORREF rgb, HBRUSH *phBrush);
  68. inline CMSWebDVD* GetDVD() {return m_pDVD;};
  69. inline IDirectDraw* GetDDrawObj(){return ((IDirectDraw*) m_pDDObject);}
  70. inline IDirectDrawSurface* GetDDrawSurf(){return ((IDirectDrawSurface*) m_pPrimary);}
  71. inline IDDrawExclModeVideoCallback * GetCallbackInterface() {
  72. CComQIPtr<IDDrawExclModeVideoCallback, &IID_IDDrawExclModeVideoCallback> pIDDrawExclModeVideoCallback(m_pOverlayCallback);
  73. return (IDDrawExclModeVideoCallback*) pIDDrawExclModeVideoCallback ;
  74. } ;
  75. HRESULT DDColorMatchOffscreen(COLORREF rgb, DWORD* dwColor);
  76. HRESULT HasOverlay();
  77. HRESULT HasAvailableOverlay();
  78. HRESULT GetOverlayMaxStretch(DWORD *pdwMaxStretch);
  79. private:
  80. CComPtr<IDirectDraw> m_pDDObject; // ddraw object
  81. CComPtr<IDirectDrawSurface> m_pPrimary; // primary ddraw surface
  82. CComPtr<IOverlayCallback> m_pOverlayCallback ; // overlay callback handler interface
  83. COLORREF m_VideoKeyColor ;
  84. CMSWebDVD *m_pDVD;
  85. };
  86. #define DibFree(pdib) GlobalFreePtr(pdib)
  87. #define DibWidth(lpbi) _abs((int)(LONG)(((LPBITMAPINFOHEADER)(lpbi))->biWidth))
  88. #define DibHeight(lpbi) _abs((int)(LONG)(((LPBITMAPINFOHEADER)(lpbi))->biHeight))
  89. #define DibBitCount(lpbi) (UINT)(((LPBITMAPINFOHEADER)(lpbi))->biBitCount)
  90. #define DibCompression(lpbi) (DWORD)(((LPBITMAPINFOHEADER)(lpbi))->biCompression)
  91. #define DibWidthBytesN(lpbi, n) (UINT)WIDTHBYTES((UINT)(lpbi)->biWidth * (UINT)(n))
  92. #define DibWidthBytes(lpbi) DibWidthBytesN(lpbi, (lpbi)->biBitCount)
  93. #define DibSizeImage(lpbi) ((lpbi)->biSizeImage == 0 \
  94. ? ((DWORD)(UINT)DibWidthBytes(lpbi) * (DWORD)DibHeight(lpbi)) \
  95. : (lpbi)->biSizeImage)
  96. #define DibSize(lpbi) ((lpbi)->biSize + (lpbi)->biSizeImage + (int)(lpbi)->biClrUsed * sizeof(RGBQUAD))
  97. #define DibPaletteSize(lpbi) (DibNumColors(lpbi) * sizeof(RGBQUAD))
  98. #define DibFlipY(lpbi, y) ((int)_abs((lpbi)->biHeight)-1-(y))
  99. //HACK for NT BI_BITFIELDS DIBs
  100. #ifdef WIN32
  101. #define DibPtr(lpbi) ((lpbi)->biCompression == BI_BITFIELDS \
  102. ? (LPVOID)(DibColors(lpbi) + 3) : (LPVOID)(DibColors(lpbi) + (UINT)(lpbi)->biClrUsed))
  103. #else
  104. #define DibPtr(lpbi) (LPVOID)(DibColors(lpbi) + (UINT)(lpbi)->biClrUsed)
  105. #endif
  106. #define DibColors(lpbi) ((RGBQUAD FAR *)((LPBYTE)(lpbi) + (int)(lpbi)->biSize))
  107. #define DibNumColors(lpbi) ((lpbi)->biClrUsed == 0 && (lpbi)->biBitCount <= 8 \
  108. ? (int)(1 << (int)(lpbi)->biBitCount) \
  109. : (int)(lpbi)->biClrUsed)