mwinsurf.cpp
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:6k
源码类别:

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. #include "minisite.h"
  36. #include "hxvsurf.h"
  37. #include "winblt.h"
  38. #include "minisurf.h"
  39. #include "mwinsurf.h"
  40. #include "bltobjfact.h"
  41. #define GET_OS_WINDOW() (HWND)(m_pSite->GetWindow()->window)
  42. CMiniWinSurface::CMiniWinSurface(IUnknown* pContext, CMiniBaseSite* pSite)
  43.  :  CMiniBaseSurface(pContext, pSite)
  44.  ,  m_pBlt(NULL)
  45. {
  46. }
  47. CMiniWinSurface::~CMiniWinSurface()
  48. {
  49.     _DestroyDestBuffer(0);
  50. }
  51. HX_RESULT CMiniWinSurface::_CreateDestBuffer(int cidIn,
  52.                                              int nWidth, int nHeight,
  53.                                              int& nCount)
  54. {
  55.     HX_RESULT hr = HXR_FAIL;
  56.     int cidOut;
  57.     int nCountIn = nCount;
  58.     if (!m_pBlt)
  59.     {
  60.         m_pBlt = CreateBltObject();
  61.         if (!m_pBlt)
  62.         {
  63.             return HXR_OUTOFMEMORY;
  64.         }
  65.     }
  66.     hr =  m_pBlt->CreateSurface(cidIn, cidOut,
  67.                                 nWidth,nHeight,
  68.                                 0, GET_OS_WINDOW(),
  69.                                 nCountIn, nCount);
  70.     return hr;
  71. }
  72.   
  73. HX_RESULT CMiniWinSurface::_LockDestBuffer(UCHAR** ppDestPtr,
  74.                                            LONG32* pnDestPitch,
  75.                                            int& cid,
  76.                                            REF(HXxSize) srcSize,
  77.                                            int nIndex)
  78. {   
  79.     return m_pBlt->LockSurface(ppDestPtr, pnDestPitch,
  80.                                cid, srcSize, nIndex);
  81. }
  82. HX_RESULT CMiniWinSurface::_TransferToDestBuffer(UCHAR* pSrcBuffer,
  83.                                                  HXBitmapInfoHeader* pBitmapInfo,
  84.                                                  HXxRect* prSrcRect,
  85.                                                  HXxRect* prDstRect,
  86.                                                  UCHAR* pDstBuffer,
  87.                                                  LONG32 nDstPitch)
  88. {
  89.     HXxSize rSrcSize = {pBitmapInfo->biWidth, pBitmapInfo->biHeight};
  90.     HX_RESULT hr = 
  91.     m_pBlt->FillSurface(m_nSrcCID,
  92.                         pSrcBuffer, &rSrcSize,
  93.                         prSrcRect,                                                                          
  94.                         pDstBuffer, nDstPitch,
  95.                         prDstRect);
  96.     if (FAILED(hr))
  97.     {
  98.     return CMiniBaseSurface::_TransferToDestBuffer(pSrcBuffer,
  99.                                                    pBitmapInfo,
  100.                                                    prSrcRect,
  101.                                                    prDstRect,
  102.                                                    pDstBuffer,
  103.                                                    nDstPitch);
  104.     }
  105.     return hr;
  106. }
  107. HX_RESULT CMiniWinSurface::_UnlockDestBuffer(UCHAR* pSurfPtr, int nIndex)
  108. {
  109.     return m_pBlt->UnlockSurface(pSurfPtr, nIndex);
  110. }
  111. HX_RESULT CMiniWinSurface::_RenderDestBuffer(HXxRect* prSrcRect,
  112.                                              HXxRect* prDstRect,
  113.                                              int nIndex)
  114. {
  115.     return m_pBlt->RenderSurface(&m_dstBufSize,
  116.                                  prSrcRect,
  117.                                  prDstRect,
  118.                                  nIndex);
  119. }
  120. HX_RESULT CMiniWinSurface::_DestroyDestBuffer(int cid, int nCount)
  121. {
  122.     HX_RESULT hr = HXR_OK;
  123.     
  124.     if (m_pBlt)
  125.     {
  126.         m_pBlt->DestroySurface(cid);
  127.         DestroyBltObject(m_pBlt);
  128.         m_pBlt = NULL;
  129.     }
  130.     return hr;
  131. }
  132. int CMiniWinSurface::GetDstCID(int nIndex)
  133. {
  134.     return (m_pBlt ? m_pBlt->GetCID(nIndex) : CID_UNKNOWN);
  135. }
  136. BOOL CMiniWinSurface::ScaleDuringRender(int nCID)
  137. {
  138.     if (m_pBlt)
  139.         return m_pBlt->HasHardwareScaling(nCID);
  140.     else
  141.         return CMiniBaseSurface::ScaleDuringRender(nCID);
  142. }
  143. void CMiniWinSurface::_KeepScreenAlive()
  144. {
  145. #ifdef WINCE
  146.     SystemIdleTimerReset(); 
  147. #endif
  148. }