📄 siteuser.cpp
字号:
/* ***** BEGIN LICENSE BLOCK *****
* Version: RCSL 1.0/RPSL 1.0
*
* Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved.
*
* The contents of this file, and the files included with this file, are
* subject to the current version of the RealNetworks Public Source License
* Version 1.0 (the "RPSL") available at
* http://www.helixcommunity.org/content/rpsl unless you have licensed
* the file under the RealNetworks Community Source License Version 1.0
* (the "RCSL") available at http://www.helixcommunity.org/content/rcsl,
* in which case the RCSL will apply. You may also obtain the license terms
* directly from RealNetworks. You may not use this file except in
* compliance with the RPSL or, if you have a valid RCSL with RealNetworks
* applicable to this file, the RCSL. Please see the applicable RPSL or
* RCSL for the rights, obligations and limitations governing use of the
* contents of the file.
*
* This file is part of the Helix DNA Technology. RealNetworks is the
* developer of the Original Code and owns the copyrights in the portions
* it created.
*
* This file, and the files included with this file, is distributed and made
* available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
*
* Technology Compatibility Kit Test Suite(s) Location:
* http://www.helixcommunity.org/content/tck
*
* Contributor(s):
*
* ***** END LICENSE BLOCK ***** */
// include
#include "hxtypes.h"
#include "hxwintyp.h"
#include "hxcom.h"
#include "hxwin.h"
#include "hxevent.h"
#include "hxvsurf.h"
#include "ihxpckts.h"
#include "hxcomm.h"
#include "hxerror.h"
#include "hlxclib/string.h"
// pnmisc
#include "hxtick.h"
// smlrendr
#include "siteuser.h"
// pndebug
#include "smlrmlog.h"
#include "hxassert.h"
#include "hxheap.h"
#ifdef _DEBUG
#undef HX_THIS_FILE
static const char HX_THIS_FILE[] = __FILE__;
#endif
CSmilSiteUser::CSmilSiteUser(CSmilSiteUserResponse* pResponse,
UINT32 ulBackgroundColor,
IUnknown* pContext,
BOOL bIsARoot,
const char* pszID)
{
m_lRefCount = 0;
m_pResponse = pResponse;
m_ulBackgroundColor = ulBackgroundColor;
m_bIsARoot = bIsARoot;
m_pSite = NULL;
m_pValues = NULL;
m_pszID = NULL;
m_ulLastMediaEndOverrideTime = 0;
m_pErrorMessages = NULL;
m_pBitmapInfoHeader = NULL;
m_pucBuffer = NULL;
m_ulLastBackgroundColor = 0;
HX_ASSERT(m_pResponse);
if (m_pResponse)
{
m_pResponse->AddRef();
}
if (pContext)
{
IHXCommonClassFactory* pFact = NULL;
pContext->QueryInterface(IID_IHXCommonClassFactory, (void**) &pFact);
if (pFact)
{
pFact->CreateInstance(CLSID_IHXValues, (void**) &m_pValues);
}
HX_RELEASE(pFact);
// QI for IHXErrorMessages - ok if we don't get it
pContext->QueryInterface(IID_IHXErrorMessages,
(void**) &m_pErrorMessages);
}
if (pszID)
{
m_pszID = new char [strlen(pszID) + 1];
if (m_pszID)
{
strcpy(m_pszID, pszID); /* Flawfinder: ignore */
}
}
// Allocate an HXBitmapInfoHeader
m_pBitmapInfoHeader = new HXBitmapInfoHeader;
if (m_pBitmapInfoHeader)
{
// Set up all the values
m_pBitmapInfoHeader->biSize = 40;
m_pBitmapInfoHeader->biWidth = 0;
m_pBitmapInfoHeader->biHeight = 0;
m_pBitmapInfoHeader->biPlanes = 1;
m_pBitmapInfoHeader->biBitCount = 32;
m_pBitmapInfoHeader->biCompression = HX_RGB;
m_pBitmapInfoHeader->biSizeImage = 0;
m_pBitmapInfoHeader->biXPelsPerMeter = 0;
m_pBitmapInfoHeader->biYPelsPerMeter = 0;
m_pBitmapInfoHeader->biClrUsed = 0;
m_pBitmapInfoHeader->biClrImportant = 0;
m_pBitmapInfoHeader->rcolor = 0;
m_pBitmapInfoHeader->gcolor = 0;
m_pBitmapInfoHeader->bcolor = 0;
}
}
CSmilSiteUser::~CSmilSiteUser()
{
Close();
}
STDMETHODIMP CSmilSiteUser::QueryInterface(REFIID riid, void** ppvObj)
{
HX_RESULT retVal = HXR_OK;
if(IsEqualIID(riid, IID_IUnknown))
{
AddRef();
*ppvObj = (IUnknown*) (IHXSiteUser*) this;
}
else if(IsEqualIID(riid, IID_IHXSiteUser))
{
AddRef();
*ppvObj = (IHXSiteUser*) this;
}
else if(IsEqualIID(riid, IID_IHXValues))
{
AddRef();
*ppvObj = (IHXValues*) this;
}
else
{
*ppvObj = NULL;
retVal = HXR_NOINTERFACE;
}
return retVal;
}
STDMETHODIMP_(ULONG32) CSmilSiteUser::AddRef()
{
return InterlockedIncrement(&m_lRefCount);
}
STDMETHODIMP_(ULONG32) CSmilSiteUser::Release()
{
if(InterlockedDecrement(&m_lRefCount) > 0)
{
return m_lRefCount;
}
delete this;
return 0;
}
STDMETHODIMP CSmilSiteUser::AttachSite(IHXSite* pSite)
{
HX_RESULT retVal = HXR_OK;
if (pSite && !m_pSite)
{
// Save the site
m_pSite = pSite;
m_pSite->AddRef();
// See if we have a new site that supports sub rects.
IHXSubRectSite* pSubRectSite = NULL;
m_pSite->QueryInterface(IID_IHXSubRectSite, (void**) &pSubRectSite);
if(pSubRectSite)
{
// If so, since IHXSubRectSite inheirits from IHXSite, lets just
// swap the pointers and sign up for the service.
HX_RELEASE(m_pSite);
m_pSite = pSubRectSite;
pSubRectSite->SendSubRectMessages(TRUE);
}
// Call back to the response interface
if (m_pResponse)
{
retVal = m_pResponse->SiteUserAttachSite(this, m_pSite);
}
}
return retVal;
}
STDMETHODIMP CSmilSiteUser::DetachSite()
{
HX_RESULT retVal = HXR_OK;
// Calling SiteUserDetachSite() may result in
// one of our own refs being released. Therefore,
// we will call AddRef() on ourselves until
// this method is finished.
AddRef();
// Call back to the response interface FIRST, since
// one of the actions of the response interface may
// be to delete children of this site.
if (m_pResponse)
{
retVal = m_pResponse->SiteUserDetachSite(this);
}
// Release the site
HX_RELEASE(m_pSite);
// Now we can safely release
Release();
return retVal;
}
STDMETHODIMP_(BOOL) CSmilSiteUser::NeedsWindowedSites()
{
return FALSE;
}
STDMETHODIMP CSmilSiteUser::HandleEvent(HXxEvent* pEvent)
{
HX_RESULT retVal = HXR_OK;
if (pEvent)
{
// Set defaults
pEvent->handled = FALSE;
pEvent->result = HXR_OK;
// Switch based on event type
switch (pEvent->event)
{
case HX_SURFACE_UPDATE:
{
pEvent->result = SetupBuffer();
if (SUCCEEDED(pEvent->result))
{
// Set up the src and dst rect
HXxRect cSrcRect = {0,
0,
m_pBitmapInfoHeader->biWidth,
m_pBitmapInfoHeader->biHeight};
HXxRect cDstRect = cSrcRect;
// Do the blt
IHXVideoSurface* pSurf = (IHXVideoSurface*) pEvent->param1;
if(pSurf)
{
MLOG_LAYOUT(m_pErrorMessages,
"CSmilSiteUser::HandleEvent() HX_SURFACE_UPDATE "
"region=%s root=%lu tick=%lu color=0x%08x\n",
m_pszID, m_bIsARoot, HX_GET_BETTERTICKCOUNT(), m_ulBackgroundColor);
pSurf->AddRef();
pEvent->result = pSurf->Blt(m_pucBuffer,
m_pBitmapInfoHeader,
cDstRect,
cSrcRect);
pSurf->Release();
if (SUCCEEDED(pEvent->result))
{
pEvent->handled = TRUE;
}
}
}
}
break;
case HX_SURFACE_UPDATE2:
{
pEvent->result = SetupBuffer();
if (SUCCEEDED(pEvent->result))
{
// Get the video surface and the expose info
IHXSubRectVideoSurface* pSurf = (IHXSubRectVideoSurface*) pEvent->param1;
HXxExposeInfo* pExpose = (HXxExposeInfo*) pEvent->param2;
// Since there is no scaling, our SRC and DEST rects
// are all the same. Since that is the case we can
// just pass the rect pointer from the Expose event
// into the BLT call.
if (pSurf && pExpose)
{
MLOG_LAYOUT(m_pErrorMessages,
"CSmilSiteUser::HandleEvent() HX_SURFACE_UPDATE2 "
"region=%s root=%lu tick=%lu color=0x%08x\n",
m_pszID, m_bIsARoot, HX_GET_BETTERTICKCOUNT(), m_ulBackgroundColor);
pSurf->AddRef();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -