winsurf2.h
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:11k
源码类别:

Symbian

开发平台:

C/C++

  1. /* ***** BEGIN LICENSE BLOCK ***** 
  2.  * Version: RCSL 1.0/RPSL 1.0 
  3.  *  
  4.  * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. 
  5.  *      
  6.  * The contents of this file, and the files included with this file, are 
  7.  * subject to the current version of the RealNetworks Public Source License 
  8.  * Version 1.0 (the "RPSL") available at 
  9.  * http://www.helixcommunity.org/content/rpsl unless you have licensed 
  10.  * the file under the RealNetworks Community Source License Version 1.0 
  11.  * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, 
  12.  * in which case the RCSL will apply. You may also obtain the license terms 
  13.  * directly from RealNetworks.  You may not use this file except in 
  14.  * compliance with the RPSL or, if you have a valid RCSL with RealNetworks 
  15.  * applicable to this file, the RCSL.  Please see the applicable RPSL or 
  16.  * RCSL for the rights, obligations and limitations governing use of the 
  17.  * contents of the file.  
  18.  *  
  19.  * This file is part of the Helix DNA Technology. RealNetworks is the 
  20.  * developer of the Original Code and owns the copyrights in the portions 
  21.  * it created. 
  22.  *  
  23.  * This file, and the files included with this file, is distributed and made 
  24.  * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
  25.  * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
  26.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS 
  27.  * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 
  28.  * 
  29.  * Technology Compatibility Kit Test Suite(s) Location: 
  30.  *    http://www.helixcommunity.org/content/tck 
  31.  * 
  32.  * Contributor(s): 
  33.  *  
  34.  * ***** END LICENSE BLOCK ***** */ 
  35. #ifndef _WINSURF2_H_
  36. #define _WINSURF2_H_
  37. #include "winroot.h"
  38. #include "vidsurf2.h"
  39. //#define FILTER_SCAN_LINE
  40. #ifdef FILTER_SCAN_LINE
  41. #define SCAN_LINE_FILTER_DEPTH 8192
  42. #endif // FILTER_SCAN_LINE
  43. class CWinSurface2 : public CWinSurface,
  44.                      public CVideoSurface2
  45. {
  46. public:
  47.     friend class CWinRootSurface;
  48.     CWinSurface2(IUnknown* pContext, CHXBaseSite* pSite);
  49.     virtual ~CWinSurface2();
  50.     // IUnknown methods
  51.     STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj);
  52.     STDMETHOD_(ULONG32,AddRef)(THIS);
  53.     STDMETHOD_(ULONG32,Release)(THIS);
  54.     
  55.     // IHXVideoSurface Overrides for VS2->VS1 transitions
  56.     STDMETHOD(Blt)(THIS_
  57.                    UCHAR*               pImageData,
  58.                    HXBitmapInfoHeader* pBitmapInfo,
  59.                    REF(HXxRect)         rDestRect,
  60.                    REF(HXxRect)         rSrcRect);
  61.     STDMETHOD(BeginOptimizedBlt)(THIS_ HXBitmapInfoHeader* pBitmapInfo);
  62.     
  63.     virtual void        _CreateBuffer();
  64.     virtual HX_RESULT   _CreateOverlay(BOOL bOverlay, int cid, int x, int y);
  65.     virtual HX_RESULT 
  66.      ByPassCompositionSurface(UCHAR*               pImageData,
  67.                               HXBitmapInfoHeader* pBitmapInfo,
  68.                               HXxRect&             rDestRect,
  69.                               HXxRect&             rSrcRect,
  70.                               UCHAR*               pSurface,
  71.                               LONG32               nSurfPitch);
  72.     
  73.     virtual void        _ReleaseSurface(CBaseRootSurface* pSurface);
  74.     virtual void        _ReleaseSurface(CWinBaseRootSurface* pSurface);
  75.     virtual void        _ReleaseSurface();
  76.     
  77.     virtual void        ReInitSurfaces();
  78.     virtual BOOL        _IsDisplaySurfaceYuv();
  79.     virtual BOOL        _AllowsOverlayShrinking();
  80.     virtual void        _WaitForQueuedFrames();
  81.     virtual void        _LockBlitter();
  82.     virtual void        _UnlockBlitter();
  83.     virtual void        _FlushSurfaces();
  84.     
  85.     // IHXVideoSurface2 Methods
  86.     STDMETHOD (SetProperties) (THIS_ HXBitmapInfoHeader* bmi,
  87.                                      REF(UINT32) ulNumBuffers,
  88.                                      IHXRenderTimeLine* pTimeLine);
  89.     STDMETHOD (GetVideoMem) (THIS_
  90.                              VideoMemStruct* pVidMem,
  91.                              UINT32 ulFlags);
  92.     STDMETHOD (ColorConvert) (THIS_
  93.                               INT32 cidIn, 
  94.                               HXxSize *pSrcSize,
  95.                               HXxRect *prSrcRect,
  96.                               SourceInputStruct *pInput,
  97.                               INT32 cidOut,
  98.                               UCHAR *pDestBuffer, 
  99.                               HXxSize *pDestSize, 
  100.                               HXxRect *prDestRect, 
  101.                               int nDestPitch);
  102.     STDMETHOD (ReleaseVideoMem) (THIS_ VideoMemStruct* pVidMem);
  103.     STDMETHOD (Present) (THIS_
  104.                          VideoMemStruct* pVidMem,
  105.                          INT32 lTime,
  106.                          UINT32 ulFlags,
  107.                          HXxRect *prDestRect,
  108.                          HXxRect *prSrcRect);
  109.     STDMETHOD_(void, Flush)(THIS);
  110.     STDMETHOD (PresentIfReady) (THIS);
  111.     // CVideoSurface2 Methods
  112.     CHXBaseSite* GetSite() {return m_pSite;}
  113.     BOOL GetColorConverter(int cidIn, int cidOut);
  114.     BOOL GetColorConverter2(int cidIn, int cidOut);
  115.     int  ColorConvert(INT32 cidOut, unsigned char *dest_ptr,
  116.                       int dest_width, int dest_height,
  117.                       int dest_pitch, int dest_x, int dest_y,
  118.                       int dest_dx, int dest_dy,
  119.                       INT32 cidIn, unsigned char *src_ptr,
  120.                       int src_width, int src_height,
  121.                       int src_pitch, int src_x, int src_y,
  122.                       int src_dx, int src_dy);
  123.     int  ColorConvert2(INT32 cidOut, unsigned char *dest_ptr,
  124.                        int dest_width, int dest_height,
  125.                        int dest_pitch, int dest_x, int dest_y,
  126.                        int dest_dx, int dest_dy,
  127.                        INT32 cidIn, unsigned char *pY,
  128.                        unsigned char *pU, unsigned char *pV,
  129.                        int src_width, int src_height,
  130.                        int yPitch, int uPitch, int vPitch,
  131.                        int src_x, int src_y, int src_dx, int src_dy);
  132.     virtual HX_RESULT RelinquishOverlay();
  133.     virtual HX_RESULT AcquireOverlay();
  134. protected:
  135.     /*
  136.      *  Render thread members
  137.      */
  138.     static DWORD    WINAPI ThreadProc(CWinSurface2* pThis);
  139.     DWORD           RenThread();
  140.     HANDLE          m_hRenThread,
  141.                     m_hFrameSem,
  142.                     m_hReinit,
  143.                     m_hAbort,
  144.                     m_hForceRender,
  145.                     m_hSurfaceMutex;
  146.     BOOL            m_bCont,
  147.                     m_bBoostRenderThread,
  148.                     m_bDoAlphaCheck,
  149.                     m_bQueryMonitorFreq,
  150.                     m_bUseVBlankFlip,
  151.                     m_bIngnorePresentIfReady;
  152.     BOOL            m_bScratchSurface,
  153.                     m_bGDISurface;
  154.     INT32           m_nScratchIndex,
  155.                     m_nLastDisplayTime;
  156.     HXxRect         m_rcLast;
  157.     CHXSimpleList*  m_pListOfFrames;
  158.     
  159.     CRITICAL_SECTION m_csDisplay,
  160.                      m_csFallback,
  161.                      m_csList,
  162.                      m_csScale;
  163.     IHXRenderTimeLine* m_pTimeLine;
  164.     // double          m_bBaseTime;
  165.     // It's important to remake all of pnvideo if FILTER_SCAN_LINE is defined!
  166. #ifdef FILTER_SCAN_LINE
  167.     double          m_dMaxRegression;
  168.     double          m_dPhasePoint;
  169.     UINT32          m_ulScanLineFilterDepth;
  170.     double          m_scanLineFilter[SCAN_LINE_FILTER_DEPTH][2];
  171. #endif // FILTER_SCAN_LINE
  172.     BOOL            CanLockSurface(INT32 nIndex, int nBltMode, BOOL bBlock);
  173.     HX_RESULT       DisplayFrame(tFrameElement* pItem);
  174.     HX_RESULT       ForceUpdateOverlay(HXxRect *pDst, HXxRect *pSrc, DWORD dwFlags, BOOL bCheckPos=FALSE);
  175.     HX_RESULT       HandleDisplayModeChange();
  176.     BOOL            HandleDirectDrawLoss(BOOL bLockedTLSMutex);
  177.     HX_RESULT       ReleaseSurface(VideoMemStruct* pVidStruct, BOOL bDiscard=FALSE, BOOL bDeleteAlphaList=TRUE);
  178.     HX_RESULT       WaitForTimeLine(INT32 lTimeStamp);
  179.     HX_RESULT       WaitForQueuedFrames();
  180.     /*
  181.      *  Fall-back surface
  182.      */
  183.     HX_RESULT       CreateFallbackSurface(int nSurfaceCID, HXxSize* pSize, int *pcidList=NULL, int nListSize=0);
  184.     HX_RESULT       DestroyFallbackSurface();
  185.     HX_RESULT       LockFallbackSurface(UCHAR* &pVidMem, INT32 &nPitch, BOOL bBlock=TRUE);
  186.     HX_RESULT       TryNewFallback();
  187.     HX_RESULT       CreateSysMemSurface(int nSurfaceCID, HXxSize* pSize, int nBuffers);
  188.     HX_RESULT       LockSysMemSurface(UCHAR* &pVidMem, INT32 &nPitch, BOOL bBlock=TRUE);
  189.     HX_RESULT       DestroySysMemSurface();
  190.     INT32           GetBitsPerPixel(int nSurfaceID);
  191.     WINDRAWSURFACE  m_fallbackSurface;
  192.     HANDLE          m_hFallbackEmpty;
  193.     HXxSize         m_allocatedFallbackSize;
  194.     int             m_nFallbackSurfaceCID;
  195.     BOOL            m_bFallbackSurfaceCreated;
  196.     /*
  197.      *  System memory surface
  198.      */
  199.     typedef struct tagSysMemSurf
  200.     {
  201.         UCHAR   *pBuffer;
  202.         HANDLE  hEmpty;
  203.     } tSysMemSurf;
  204.     tSysMemSurf     *m_pSysMemSurf;
  205.     HXxSize         m_allocatedSysMemSurfSize;
  206.     INT32           m_nSysMemSurfCount,
  207.                     m_nSysMemSurfPitch,
  208.                     m_nSysMemSurfSize,
  209.                     m_nNextSysMemBuffer;
  210.     int             m_nSysMemSurfID;
  211.     BOOL            m_bUseSysMemSurface;
  212.     /*
  213.      *  GDI surface
  214.      */
  215.     HX_RESULT       CreateGdiSurface(HXxSize* pSize);
  216.     HX_RESULT       LockGdiSurface(UCHAR* &pVidMem, INT32 &nPitch, BOOL bBlock=TRUE);
  217.     HX_RESULT       DestroyGdiSurface();
  218.     WINDRAWSURFACE  m_GDIsurface;
  219.     HXxSize         m_allocatedGdiSize;
  220.     INT32           m_nGdiSurfaceCount,
  221.                     m_nLastGdiSurface,
  222.                     m_nNextGdiSurface;
  223.     int             m_nGdiSurfaceCID;
  224.     BOOL            m_bGdiSurfaceCreated;
  225.     /*
  226.      *  Misc
  227.      */
  228.     UINT32          m_ulFillColoryKeyCount;
  229.     BOOL            m_bFlushing,
  230.                     m_bFrameHasHWAlphaBlend,
  231.                     m_bSurfaceRequiresOverlay,
  232.                     m_bSwitchingingOverlay,
  233.                     m_bUseDDColorControls,
  234.                     m_bWaitingForFlush,
  235.                     m_bWasInVidSurf2;
  236.     double          m_dLastXScale,
  237.                     m_dLastYScale;
  238.     int             m_nOverlayBackBuffersCreated;
  239.     double          m_dLastBlitError;
  240.     int             GetBestBltMode();
  241.     BOOL            IsShrinking();
  242.     void            ResetBufferTimes(INT32 nTime);
  243.     void            SetLastScale(HXxRect *pSrc, HXxRect *pDest);
  244.     BOOL            SetYUVPriorityList(int cidIn);
  245.     void            _WaitForFlush();
  246.     void            CreateAlphaList(VideoMemStruct* pVidStruct);
  247.     void            YuvAlphaBlend(AlphaStruct* pList,
  248.                                   UINT32 ulCount,
  249.                                   UCHAR* pDest,
  250.                                   UINT32 ulFourCC,
  251.                                   INT32  lPitch,
  252.                                   HXxSize* pDestDim);
  253.     HX_RESULT       _ScheduleFrameForDisplay(void* pOsData,
  254.                                              tFrameElement* pItem,
  255.                                              UINT32 nResolution);
  256.     double          FilterScanLine(UINT32 ulScanLine, double dTickAtStreamTime,
  257.                                    WINDRAW* pWindraw, BOOL bResetFilter = FALSE);
  258. };
  259. #endif