brushrnd.cpp

来自「linux下的一款播放器」· C++ 代码 · 共 538 行 · 第 1/2 页

CPP
538
字号
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: brushrnd.cpp,v 1.5.2.1 2004/07/09 01:57:52 hubbe Exp $ *  * Portions Copyright (c) 1995-2004 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 (the "RPSL") available at * http://www.helixcommunity.org/content/rpsl unless you have licensed * the file under the current version of the RealNetworks Community * Source License (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. *  * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL") in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your version of * this file only under the terms of the GPL, and not to allow others * to use your version of this file under the terms of either the RPSL * or RCSL, indicate your decision by deleting the provisions above * and replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient may * use your version of this file under the terms of any one of the * RPSL, the RCSL or the GPL. *  * 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__;#endifconst 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;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?