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

Symbian

开发平台:

Visual C++

  1. /* ***** BEGIN LICENSE BLOCK *****
  2.  * Source last modified: $Id: mmacsurf.cpp,v 1.2.34.1 2004/07/09 01:59:02 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 "macblt.h"
  51. #include "coloracc.h"
  52. #if defined (HELIX_FEATURE_OPTIMIZED_VIDEO)
  53. #include "macyuvblt.h"
  54. #endif //HELIX_FEATURE_OPTIMIZED_VIDEO
  55. #if defined (HELIX_FEATURE_GDI_VIDEO)
  56. #include "macrgbblt.h"
  57. #endif //HELIX_FEATURE_GDI_VIDEO
  58. #include "minisurf.h"
  59. #include "mmacsurf.h"
  60. #define GET_OS_WINDOW() (HWND)(m_pSite->GetWindow()->window)
  61. CMiniMacSurface::CMiniMacSurface(IUnknown* pContext, CMiniBaseSite* pSite)
  62.  :  CMiniBaseSurface(pContext, pSite)
  63.  ,  m_pBlt(NULL)
  64.  ,  m_pRGBBlt(NULL)
  65.  ,  m_pYUVBlt(NULL)
  66. {
  67. }
  68. CMiniMacSurface::~CMiniMacSurface()
  69. {
  70.     _DestroyDestBuffer(0);
  71. }
  72. HX_RESULT CMiniMacSurface::_CreateDestBuffer(int cidIn,
  73.                                              int nWidth, int nHeight,
  74.                                              int& nCount)
  75. {
  76.     HX_RESULT hr = HXR_FAIL;
  77.     int cidOut;
  78.     int nCountIn = nCount;
  79.     // Try to create optimized surfaces and if it fails,
  80.     // try gdi.
  81.     for (int i=0; i<2; i++)
  82.     {
  83. #if defined (HELIX_FEATURE_OPTIMIZED_VIDEO)
  84.         // Only try optimized yuv the first time
  85.         if (i == 0 &&
  86.             !m_pBlt && 
  87.             !m_pYUVBlt)
  88.         {
  89.             m_pYUVBlt = new CMacYUVBlt();
  90.             m_pBlt = m_pYUVBlt;
  91.         }
  92. #endif //HELIX_FEATURE_OPTIMIZED_VIDEO
  93. #if defined (HELIX_FEATURE_GDI_VIDEO)
  94.         if (!m_pBlt && !m_pRGBBlt)
  95.         {
  96.             m_pRGBBlt = new CMacRGBBlt();
  97.             m_pBlt = m_pRGBBlt;
  98.         }
  99. #endif //HELIX_FEATURE_GDI_VIDEO
  100.     
  101.         if (m_pBlt)
  102.         {
  103.             hr =  m_pBlt->CreateSurface(cidIn, cidOut,
  104.                                         nWidth,nHeight,
  105.                                         0, GET_OS_WINDOW(),
  106.                                         nCountIn, nCount);
  107.         }
  108.         if (SUCCEEDED(hr))
  109.         {
  110.             break;
  111.         }
  112.         else
  113.         {
  114.             _DestroyDestBuffer(cidIn);
  115.         }
  116.     }
  117.     return hr;
  118. }
  119.   
  120. HX_RESULT CMiniMacSurface::_LockDestBuffer(UCHAR** ppDestPtr,
  121.                                            LONG32* pnDestPitch,
  122.                                            int& cid,
  123.                                            REF(HXxSize) dstSize,
  124.                                            int nIndex)
  125. {
  126.     return m_pBlt->LockSurface(ppDestPtr, pnDestPitch,
  127.                                cid, dstSize, nIndex);
  128. }
  129. HX_RESULT CMiniMacSurface::_TransferToDestBuffer(UCHAR* pSrcBuffer,
  130.                                                  HXBitmapInfoHeader* pBitmapInfo,
  131.                                                  HXxRect* prSrcRect,
  132.                                                  HXxRect* prDstRect,
  133.                                                  UCHAR* pDstBuffer,
  134.                                                  LONG32 nDstPitch)
  135. {
  136.     HXxSize rSrcSize = {pBitmapInfo->biWidth, pBitmapInfo->biHeight};
  137.     HX_RESULT hr = 
  138.     m_pBlt->FillSurface(m_nSrcCID,
  139.                         pSrcBuffer, &rSrcSize,
  140.                         prSrcRect,                                                                          
  141.                         pDstBuffer, nDstPitch,
  142.                         prDstRect);
  143.     if (FAILED(hr))
  144.     {
  145.     return CMiniBaseSurface::_TransferToDestBuffer(pSrcBuffer,
  146.                                                    pBitmapInfo,
  147.                                                    prSrcRect,
  148.                                                    prDstRect,
  149.                                                    pDstBuffer,
  150.                                                    nDstPitch);
  151.     }
  152.     return hr;
  153. }
  154. HX_RESULT CMiniMacSurface::_UnlockDestBuffer(UCHAR* pSurfPtr, int nIndex)
  155. {
  156.     return m_pBlt->UnlockSurface(pSurfPtr, nIndex);
  157. }
  158. HX_RESULT CMiniMacSurface::_RenderDestBuffer(HXxRect* prSrcRect,
  159.                                              HXxRect* prDstRect,
  160.                                              int nIndex)
  161. {
  162.     HX_RESULT hr = m_pBlt->RenderSurface(&m_dstBufSize,
  163.                                          prSrcRect,
  164.                                          prDstRect,
  165.                                          nIndex);
  166.     return hr;
  167. }
  168. HX_RESULT CMiniMacSurface::_DestroyDestBuffer(int cid, int nCount)
  169. {
  170.     HX_RESULT hr = HXR_OK;
  171.     
  172.     if (m_pBlt)
  173.     {
  174.         m_pBlt->DestroySurface(cid);
  175.         HX_DELETE(m_pRGBBlt);
  176.         HX_DELETE(m_pYUVBlt);
  177.         m_pBlt = NULL;
  178.     }
  179.     return hr;
  180. }
  181. int CMiniMacSurface::GetDstCID(int nIndex)
  182. {
  183.     return (m_pBlt ? m_pBlt->GetCID(nIndex) : CID_UNKNOWN);
  184. }