📄 brushrnd.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 "hxcomm.h"
#include "ihxpckts.h"
#include "hxplugn.h"
#include "hxrendr.h"
#include "hxvsurf.h"
#include "hxhyper.h"
#include "hxwin.h"
#include "hxver.h"
#include "hxasm.h"
#include "hxprefs.h"
#include "hxmon.h"
#include "hxupgrd.h"
#include "hxcore.h"
#include "hxerror.h"
// pnmisc
#include "baseobj.h"
#include "hxparse.h"
// pxcomlib
#include "pxtransp.h"
// baserend
#include "baserend.h"
#include "vbasernd.h"
// brushrnd
#include "brushrnd.h"
#include "brushrnd.ver"
// pndebug
#include "errdbg.h"
#include "hxheap.h"
// runtime
#include "hlxclib/string.h"
#ifdef _DEBUG
#undef HX_THIS_FILE
static const char HX_THIS_FILE[] = __FILE__;
#endif
const char* const CBrushRenderer::m_pszName = "Brush";
const char* const CBrushRenderer::m_pszDescription = "RealNetworks Brush Renderer Plugin";
const char* const CBrushRenderer::m_ppszMimeType[] = {"application/vnd.rn-brushstream", NULL};
CBrushRenderer::CBrushRenderer() : CRNVisualBaseRenderer()
{
m_ulColor = 0x00000000;
m_pHeader = NULL;
m_ulChromaKey = 0x00000000;
m_ulChromaKeyTolerance = 0x00000000;
m_ulChromaKeyOpacity = 0;
m_ulLastColor = 0;
m_pucBuffer = NULL;
m_bFirstDraw = TRUE;
m_bChromaKeySpecified = FALSE;
m_bNullBrush = FALSE;
};
CBrushRenderer::~CBrushRenderer()
{
HX_DELETE(m_pHeader);
HX_VECTOR_DELETE(m_pucBuffer);
};
STDMETHODIMP CBrushRenderer::QueryInterface(REFIID riid, void** ppvObj)
{
// If we ever have any new interfaces to add which
// are specific to the brush renderer, then we'll need
// to add them here. Until then we simply proxy the
// visual base renderer.
return CRNVisualBaseRenderer::QueryInterface(riid, ppvObj);
}
STDMETHODIMP_(UINT32) CBrushRenderer::AddRef()
{
return CRNVisualBaseRenderer::AddRef();
}
STDMETHODIMP_(UINT32) CBrushRenderer::Release()
{
return CRNVisualBaseRenderer::Release();
}
STDMETHODIMP CBrushRenderer::OnHeader(IHXValues* pHeader)
{
HX_RESULT retVal = HXR_FAIL;
if (pHeader)
{
// Check presentation stream and content versions
retVal = CheckStreamVersions(pHeader);
if (SUCCEEDED(retVal))
{
// Allocate a bitmap info header
HX_DELETE(m_pHeader);
m_pHeader = new HXBitmapInfoHeader;
if (m_pHeader)
{
// Set up the bitmap info header
m_pHeader->biSize = 40;
m_pHeader->biWidth = 1;
m_pHeader->biHeight = 1;
m_pHeader->biPlanes = 1;
m_pHeader->biBitCount = 32;
m_pHeader->biCompression = HX_RGB;
m_pHeader->biSizeImage = 0;
m_pHeader->biXPelsPerMeter = 0;
m_pHeader->biYPelsPerMeter = 0;
m_pHeader->biClrUsed = 0;
m_pHeader->biClrImportant = 0;
m_pHeader->rcolor = 0;
m_pHeader->gcolor = 0;
m_pHeader->bcolor = 0;
// See if we are a null brush
UINT32 ulTmp = 0;
HX_RESULT rv = pHeader->GetPropertyULONG32("NullBrush", ulTmp);
if (SUCCEEDED(rv) && ulTmp)
{
m_bNullBrush = TRUE;
}
// Get the opaque data from the stream header
IHXBuffer* pBuffer = NULL;
pHeader->GetPropertyBuffer("OpaqueData", pBuffer);
if (pBuffer)
{
// XXXMEH - TODO - make more robust parsing. Since
// we are creating this "file" in the SMIL renderer,
// then we can afford to do simple parsing.
const char* pszStr = (const char*) pBuffer->GetBuffer();
char* pTmp = new char [strlen(pszStr) + 1];
if (pTmp)
{
// Copy the string
strcpy(pTmp, pszStr); /* Flawfinder: ignore */
// Look for " separators
const char* pSep = "\"";
char* pToken = strtok(pTmp, pSep);
BOOL bNext = FALSE;
while (pToken)
{
if (bNext)
{
UINT32 ulColor = 0;
HX_RESULT rv = HXParseColorUINT32(pToken, ulColor);
if (SUCCEEDED(rv))
{
m_ulColor = ulColor;
// Initialize some persistent properties
CRNBaseRenderer::SetPropertyULONG32("color", m_ulColor);
CRNBaseRenderer::SetPropertyULONG32("mediaOpacity", 255);
CRNBaseRenderer::SetPropertyULONG32("backgroundOpacity", 255);
}
break;
}
if (strstr(pToken, "color"))
{
bNext = TRUE;
}
pToken = strtok(NULL, pSep);
}
}
HX_VECTOR_DELETE(pTmp);
}
HX_RELEASE(pBuffer);
}
else
{
retVal = HXR_OUTOFMEMORY;
}
}
else
{
AddMimeToUpgradeCollection(m_ppszMimeType[0]);
}
}
return retVal;
}
STDMETHODIMP CBrushRenderer::OnPacketNoOffset(IHXPacket* pPacket)
{
HX_RESULT retVal = HXR_OK;
return retVal;
}
STDMETHODIMP CBrushRenderer::OnTimeSyncOffset(UINT32 ulTime)
{
// We should force a redraw ONLY on
// the first time sync
if (m_bFirstDraw && !m_bNullBrush)
{
// Redraw our data by damaging the entire area of our data
HXxSize size;
m_pSite->GetSize(size);
HXxRect cRect = {0, 0, size.cx, size.cy};
m_pSite->DamageRect(cRect);
m_pSite->ForceRedraw();
// Clear the first draw flag
m_bFirstDraw = FALSE;
}
return HXR_OK;
}
STDMETHODIMP CBrushRenderer::GetDisplayType(REF(HX_DISPLAY_TYPE) rulFlags,
REF(IHXBuffer*) pBuffer)
{
if (m_bNullBrush)
{
rulFlags = HX_DISPLAY_NONE;
}
else
{
rulFlags = GetDisplayFlags();
}
return HXR_OK;
}
STDMETHODIMP CBrushRenderer::GetWindowSize(REF(HXxSize) rSize)
{
rSize.cx = 1;
rSize.cy = 1;
return HXR_OK;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -