📄 brushrnd.cpp
字号:
}
STDMETHODIMP CBrushRenderer::IsMouseOverActiveLink(INT16 x, INT16 y, REF(BOOL) rbActive, REF(IHXBuffer*) rpLink)
{
HX_RESULT retVal = HXR_OK;
rbActive = FALSE;
return retVal;
}
STDMETHODIMP CBrushRenderer::RMASurfaceUpdate(IHXVideoSurface* pSurface)
{
HX_RESULT retVal = HXR_FAIL;
if (pSurface && m_pHeader && !m_bNullBrush)
{
retVal = SetupBuffer();
if (SUCCEEDED(retVal))
{
// Set up the src and dst rect
HXxRect rSrcRect = {0, 0, m_pHeader->biWidth, m_pHeader->biHeight};
HXxRect rDstRect = rSrcRect;
// Blit to the video surface
retVal = pSurface->Blt(m_pucBuffer,
m_pHeader,
rDstRect,
rSrcRect);
}
}
return retVal;
}
STDMETHODIMP CBrushRenderer::HandleClick(INT16 x, INT16 y)
{
return HXR_OK;
}
STDMETHODIMP CBrushRenderer::SetPropertyULONG32(const char* pName, ULONG32 ulVal)
{
HX_RESULT retVal = HXR_OK;
if (pName)
{
// Clear the flag
BOOL bChromaKeyUpdate = FALSE;
// Switch based on property name
if (!strcmp(pName, "color"))
{
// Preserve the current alpha from the
// color and set the color from ulVal
m_ulColor = (m_ulColor & 0xFF000000) |
(ulVal & 0x00FFFFFF);
}
else if (!strcmp(pName, "mediaOpacity") ||
!strcmp(pName, "backgroundOpacity"))
{
// Cap the opacity
if (ulVal > 255) ulVal = 255;
// Update the color
m_ulColor = (m_ulColor & 0x00FFFFFF) |
(((255 - ulVal) << 24) & 0xFF000000);
}
else if (!strcmp(pName, "chromaKey"))
{
// Save the value
m_ulChromaKey = ulVal;
m_bChromaKeySpecified = TRUE;
// We do need to update the color
bChromaKeyUpdate = TRUE;
}
else if (!strcmp(pName, "chromaKeyTolerance"))
{
// Save the value
m_ulChromaKeyTolerance = ulVal & 0x00FFFFFF;
// If we have a chroma key already specified, then update
if (m_bChromaKeySpecified)
{
bChromaKeyUpdate = TRUE;
}
}
else if (!strcmp(pName, "chromaKeyOpacity"))
{
// Cap the value
if (ulVal > 255) ulVal = 255;
// Save the value
m_ulChromaKeyOpacity = ulVal;
// If we have a chroma key already specified, then update
if (m_bChromaKeySpecified)
{
bChromaKeyUpdate = TRUE;
}
}
// If we need to update the color because of
// chroma key changes, then do it now
if (bChromaKeyUpdate &&
DoesChromaKeyMatch(m_ulColor, m_ulChromaKey, m_ulChromaKeyTolerance))
{
// Update the color
m_ulColor = (m_ulColor & 0x00FFFFFF) |
(((255 - m_ulChromaKeyOpacity) << 24) & 0xFF000000);
}
// Now pass this on to our base class
retVal = CRNBaseRenderer::SetPropertyULONG32(pName, ulVal);
}
else
{
retVal = HXR_FAIL;
}
return retVal;
}
HX_RESULT STDAPICALLTYPE CBrushRenderer::HXCreateInstance(IUnknown** ppIUnknown)
{
HX_RESULT retVal = HXR_FAIL;
if (ppIUnknown)
{
// Create the object
CBrushRenderer* pObj = new CBrushRenderer();
if (pObj)
{
// QI for IUnknown
retVal = pObj->QueryInterface(IID_IUnknown, (void**) ppIUnknown);
}
}
return retVal;
}
HX_RESULT STDAPICALLTYPE CBrushRenderer::CanUnload2()
{
return ((CHXBaseCountingObject::ObjectsActive() > 0) ? HXR_FAIL : HXR_OK );
}
HX_RESULT CBrushRenderer::RMASurfaceUpdate2(IHXSubRectVideoSurface* pSurface,
HXxRect* pExtents,
HXxBoxRegion* pDirtyRegion)
{
HX_RESULT retVal = HXR_FAIL;
if (pSurface && m_pHeader && !m_bNullBrush)
{
retVal = SetupBuffer();
if (SUCCEEDED(retVal))
{
retVal = pSurface->BltSubRects(m_pucBuffer,
m_pHeader,
pDirtyRegion,
pDirtyRegion,
1.0,1.0 );
}
}
return retVal;
}
void CBrushRenderer::_AttachSite()
{
if (m_pSite)
{
// Subscribe to the sub rect messages, HX_SURFACE_UPDATE2.
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);
}
}
}
HX_RESULT CBrushRenderer::SetupBuffer()
{
HX_RESULT retVal = HXR_FAIL;
if (m_pSite && m_pHeader)
{
// Get the site's current size
HXxSize cSize = {0, 0};
m_pSite->GetSize(cSize);
// Make sure the site has non-zero dimensions
if (cSize.cx > 0 && cSize.cy > 0)
{
// Do we need to allocate a buffer?
BOOL bAllocated = FALSE;
if (!m_pucBuffer ||
m_pHeader->biWidth != cSize.cx ||
m_pHeader->biHeight != cSize.cy)
{
UINT32 ulNumBytes = (UINT32) cSize.cx * cSize.cy * 4;
HX_VECTOR_DELETE(m_pucBuffer);
m_pucBuffer = new BYTE [ulNumBytes];
if (m_pucBuffer)
{
m_pHeader->biWidth = cSize.cx;
m_pHeader->biHeight = cSize.cy;
m_pHeader->biSizeImage = ulNumBytes;
bAllocated = TRUE;
}
}
if (m_pucBuffer)
{
// Do we need to fill in the color?
if (bAllocated || m_ulLastColor != m_ulColor)
{
// Fill in the buffer
UINT32 ulNumPix = (UINT32) cSize.cx * cSize.cy;
UINT32* pPix = (UINT32*) m_pucBuffer;
while (ulNumPix--)
{
*pPix++ = m_ulColor;
}
// Save this color
m_ulLastColor = m_ulColor;
// Set the bitmap info header compression
m_pHeader->biCompression = (m_ulColor & 0xFF000000 ? HX_ARGB : HX_RGB);
}
// Clear the return value
retVal = HXR_OK;
}
}
}
return retVal;
}
STDMETHODIMP CBrushRenderer::GetName(REF(const char*) rpszName)
{
rpszName = (const char*) m_pszName;
return HXR_OK;
}
STDMETHODIMP CBrushRenderer::GetDescription(REF(const char*) rpszDescription)
{
rpszDescription = (const char*) m_pszDescription;
return HXR_OK;
}
STDMETHODIMP CBrushRenderer::GetMimeTypes(REF(const char**) rppszMimeType)
{
rppszMimeType = (const char**) m_ppszMimeType;
return HXR_OK;
}
STDMETHODIMP_(UINT32) CBrushRenderer::GetPluginVersion()
{
return TARVER_ULONG32_VERSION;
}
STDMETHODIMP_(UINT32) CBrushRenderer::GetInitialGranularity()
{
return 200;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -