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

Symbian

开发平台:

Visual C++

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