smlfctry.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 "hxtypes.h"
  36. #include "hxwintyp.h"
  37. #include "hxcom.h"
  38. #include "hxcomm.h"
  39. #include "hxplugn.h"
  40. #include "hxver.h"
  41. #include "ihxpckts.h"
  42. #include "hxrendr.h"
  43. #include "hxcore.h"
  44. #include "hxhyper.h"
  45. #include "hxasm.h"
  46. #include "hxerror.h"
  47. #include "hxvsurf.h"
  48. #include "hxformt.h"
  49. #include "smiltype.h"
  50. #include "hxsm2sm.h"
  51. #include "baseobj.h"
  52. #include "hxstring.h"
  53. #include "baserend.h"
  54. #include "vbasernd.h"
  55. #if defined(HELIX_FEATURE_SMIL2_BRUSH)
  56. #include "brushff.h"
  57. #include "brushrnd.h"
  58. #endif /* #if defined(HELIX_FEATURE_SMIL2_BRUSH) */
  59. // CSmil1DocumentRenderer needs this fof proxying CSmilDocumentRenderer:
  60. #include "hxgroup.h"
  61. #if defined(HELIX_FEATURE_SMIL2)
  62. #include "smlrendr.h"
  63. #endif /* #if defined(HELIX_FEATURE_SMIL2) */
  64. #if defined(HELIX_FEATURE_SMIL1)
  65. #include "sm1rendr.h"
  66. #endif /* #if defined(HELIX_FEATURE_SMIL1) */
  67. #include "smlfctry.h"
  68. #include "hxheap.h"
  69. #ifdef _DEBUG
  70. #undef HX_THIS_FILE
  71. static char HX_THIS_FILE[] = __FILE__;
  72. #endif
  73. HX_RESULT (STDAPICALLTYPE* const CSmilPluginFactory::m_fpCreateInstanceArray[])(IUnknown**) =
  74. {
  75. #if defined(HELIX_FEATURE_SMIL2)
  76.     CSmilRenderer::HXCreateInstance,
  77. #endif /* #if defined(HELIX_FEATURE_SMIL2) */
  78. #if defined(HELIX_FEATURE_SMIL1)
  79.     CSmil1Renderer::HXCreateInstance,
  80. #endif /* #if defined(HELIX_FEATURE_SMIL1) */
  81. #if defined(HELIX_FEATURE_SMIL2_BRUSH)
  82.     CBrushFileFormat::HXCreateInstance,
  83.     CBrushRenderer::HXCreateInstance,
  84. #endif /* #if defined(HELIX_FEATURE_SMIL2_BRUSH) */
  85.     NULL
  86. };
  87. HX_RESULT (STDAPICALLTYPE* const CSmilPluginFactory::m_fpUnloadArray[])(void) =
  88. {
  89. #if defined(HELIX_FEATURE_SMIL2)
  90.     CSmilRenderer::CanUnload2,
  91. #endif /* #if defined(HELIX_FEATURE_SMIL2) */
  92. #if defined(HELIX_FEATURE_SMIL1)
  93.     CSmil1Renderer::CanUnload2,
  94. #endif /* #if defined(HELIX_FEATURE_SMIL1) */
  95. #if defined(HELIX_FEATURE_SMIL2_BRUSH)
  96.     CBrushFileFormat::CanUnload2,
  97.     CBrushRenderer::CanUnload2,
  98. #endif /* #if defined(HELIX_FEATURE_SMIL2_BRUSH) */
  99.     NULL
  100. };
  101. STDAPI ENTRYPOINT(HXCREATEINSTANCE)(IUnknown** ppIUnknown)
  102. {
  103.     HX_RESULT retVal = HXR_FAIL;
  104.     if (ppIUnknown)
  105.     {
  106.         CSmilPluginFactory* pFactory = new CSmilPluginFactory();
  107.         if (pFactory)
  108.         {
  109.             retVal = pFactory->QueryInterface(IID_IUnknown, (void**) ppIUnknown);
  110.         }
  111.     }
  112.     return retVal;
  113. }
  114. STDAPI ENTRYPOINT(CanUnload2)(void)
  115. {
  116.     for(int i=0; CSmilPluginFactory::m_fpUnloadArray[i]; i++)
  117.     {
  118.         if( HXR_OK != (CSmilPluginFactory::m_fpUnloadArray[i])() )
  119.         {
  120.             return HXR_FAIL;
  121.         }
  122.     }
  123.     return HXR_OK;
  124. }
  125. CSmilPluginFactory::CSmilPluginFactory()
  126. {
  127.     m_lRefCount = 0;
  128.     for (m_usNumPlugins = 0; m_fpCreateInstanceArray[m_usNumPlugins]; m_usNumPlugins++);
  129. }
  130. CSmilPluginFactory::~CSmilPluginFactory()
  131. {
  132. }
  133. STDMETHODIMP CSmilPluginFactory::QueryInterface(REFIID riid, void** ppvObj)
  134. {
  135.     HX_RESULT retVal = HXR_OK;
  136.     if (ppvObj)
  137.     {
  138.         // Set default
  139.         *ppvObj = NULL;
  140.         // Check for IID type
  141.         if (IsEqualIID(riid, IID_IUnknown))
  142.         {
  143.             AddRef();
  144.             *ppvObj = (IUnknown*) (IHXPluginFactory*) this;
  145.         }
  146.         else if (IsEqualIID(riid, IID_IHXPluginFactory))
  147.         {
  148.             AddRef();
  149.             *ppvObj = (IHXPluginFactory*) this;
  150.         }
  151.         else
  152.         {
  153.             retVal = HXR_NOINTERFACE;
  154.         }
  155.     }
  156.     else
  157.     {
  158.         retVal = HXR_FAIL;
  159.     }
  160.     return retVal;
  161. }
  162. STDMETHODIMP_(UINT32) CSmilPluginFactory::AddRef()
  163. {
  164.     return InterlockedIncrement(&m_lRefCount);
  165. }
  166. STDMETHODIMP_(UINT32) CSmilPluginFactory::Release()
  167. {
  168.     if (InterlockedDecrement(&m_lRefCount) > 0)
  169.     {
  170.         return m_lRefCount;
  171.     }
  172.     delete this;
  173.     return 0;
  174. }
  175. STDMETHODIMP_(UINT16) CSmilPluginFactory::GetNumPlugins()
  176. {
  177.     return m_usNumPlugins;
  178. }
  179. STDMETHODIMP CSmilPluginFactory::GetPlugin(UINT16 usIndex, IUnknown** ppPlugin)
  180. {
  181.     HX_RESULT retVal = HXR_FAIL;
  182.     if (usIndex < m_usNumPlugins && ppPlugin)
  183.     {
  184.         retVal = m_fpCreateInstanceArray[usIndex](ppPlugin);
  185.     }
  186.     return retVal;
  187. }