winsurf2.h
上传用户:dangjiwu
上传日期:2013-07-19
资源大小:42019k
文件大小:12k
源码类别:

Symbian

开发平台:

Visual C++

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