⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 minisymbiansurf.cpp

📁 著名的 helix realplayer 基于手机 symbian 系统的 播放器全套源代码
💻 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 "minisite.h"
#include "hxvsurf.h"
#include "coloracc.h"
#include "hxtick.h"

#include "minisurf.h"
#include "minisymbiansurf.h"
#include "minisymbiansite.h"
#include "minifmt.h"
#include "nostatic/colorlib.h"

#include <e32std.h>  //for User::InfoPrint()
#include <eikenv.h> 
#include <eikdef.h> 
#include <gdi.h> 
#include <fbs.h> 

CMiniSymbianSurface::CMiniSymbianSurface(IUnknown* pContext, CMiniBaseSite* pSite)
    :  CMiniBaseSurface(pContext, pSite),
       m_nCompositionPitch(0),
       m_pGC(NULL),
       m_pBitMap(NULL),
       m_DisplayMode(EColor4K),
       m_pBS(NULL),
       m_ulLastResetTime(0)
{
    memset(&m_surfaceSize, 0, sizeof(m_surfaceSize) );
    memset(&m_ColorData, 0, sizeof(m_ColorData) );
}

CMiniSymbianSurface::~CMiniSymbianSurface()
{
    m_nCompositionPitch = 0;
    memset(&m_surfaceSize, 0, sizeof( m_surfaceSize ) );
    HX_DELETE(m_pBitMap);
    if( m_pBS )
        m_pBS->Disconnect();
    HX_DELETE(m_pBS); 
}

color_data_t* CMiniSymbianSurface::GetColorData()
{
    return &m_ColorData;
}


HX_RESULT CMiniSymbianSurface::_CreateDestBuffer( int cidIn,
                                                  int nWidth,
                                                  int nHeight,
                                                  int& nCount)
{
    
    HX_ASSERT( m_pSite );

    m_surfaceSize.cx = nWidth;
    m_surfaceSize.cy = nHeight;

    //Get our GC, and Region.
    m_DisplayMode = EColor4K; //hardcoded for emulator right now.

    HX_RESULT retVal = HXR_OK;
    if( m_pImageHelper )
    {
        HXBitmapInfo bmiTemp;
        m_pImageHelper->MakeBitmap( &bmiTemp,
                                    sizeof(bmiTemp),
                                    CID_RGB444,
                                    m_surfaceSize.cx,
                                    m_surfaceSize.cy,
                                    NULL,
                                    0);

        m_nCompositionPitch = m_pImageHelper->GetBitmapPitch(&bmiTemp); 
        HX_ASSERT( m_pImageHelper->GetBitmapColor(&bmiTemp) == CID_RGB444 ); 
    }
    else
    {
        retVal = HXR_OUTOFMEMORY;
    }

    //Create our bitmap.
    if( !m_pBS )
    {
        m_pBS = new RFbsSession();
        if(!m_pBS)
        {
            retVal = HXR_OUTOFMEMORY;
        }
        else
        {
            m_pBS->Connect();
        }
    }

    HX_ASSERT(m_pBS);
    if( retVal == HXR_OK )
    {
        HX_ASSERT(!m_pBitMap);
        HX_DELETE(m_pBitMap);
        m_pBitMap = new CFbsBitmap();
        HX_ASSERT(m_pBitMap);
        if(!m_pBitMap)
        {
            retVal = HXR_OUTOFMEMORY;
        }
        else
        {
            TInt err = m_pBitMap->Create(TSize(m_surfaceSize.cx,m_surfaceSize.cy), m_DisplayMode);
            HX_ASSERT( err == KErrNone );
            
            if( err != KErrNone )
            {
                retVal = HXR_OUTOFMEMORY;
            }
        }
    }

    HX_ASSERT(retVal==HXR_OK);
    if( FAILED(retVal) )
    {
        if( m_pBS )
        {
            m_pBS->Disconnect();
        }
        HX_DELETE(m_pBS);
        HX_DELETE(m_pBitMap);
    }

    return retVal;
}

HX_RESULT CMiniSymbianSurface::_LockDestBuffer( UCHAR** ppDestPtr,
                                                LONG32* pnDestPitch,
                                                int& cid,
                                                REF(HXxSize) srcSize,
                                                int nIndex)
{
    HX_RESULT res = HXR_OK;

    HX_ASSERT(m_pBitMap != 0);
    *ppDestPtr   = (UCHAR*)m_pBitMap->DataAddress();
    *pnDestPitch = m_nCompositionPitch;
    cid          = CID_RGB444;

    return res;
}

         
HX_RESULT CMiniSymbianSurface::_TransferToDestBuffer( UCHAR*   pSrcBuffer,
                                                      HXBitmapInfoHeader* pBitmapInfo,
                                                      HXxRect* prSrcRect,
                                                      HXxRect* prDstRect,
                                                      UCHAR*   pDstBuffer,
                                                      LONG32   nDstPitch)
{
    HX_RESULT res = HXR_OK;

    res =  CMiniBaseSurface::_TransferToDestBuffer( pSrcBuffer,
                                                    pBitmapInfo,
                                                    prSrcRect,
                                                    prDstRect,
                                                    pDstBuffer,
                                                    nDstPitch);
    HX_ASSERT(res == HXR_OK);
    
    return res;
}

         
HX_RESULT CMiniSymbianSurface::_UnlockDestBuffer(UCHAR* pSurfPtr, int nIndex)
{
    //Nothing to do here for symbian.....
    return HXR_OK;
}

         
HX_RESULT CMiniSymbianSurface::_RenderDestBuffer( HXxRect* prSrcRect,
                                                  HXxRect* prDestRect,
                                                  int nIndex)
{
    HXxWindow* pHXWin  = m_pSite->GetWindow();
    RWindow*   pWin    = (RWindow*)pHXWin->window;
    TPoint     topleft = pWin->Position();
    HX_RESULT  res     = HXR_OK;
    HXxPoint   point;
    RRegion*   clipReg = NULL;
    CDirectScreenAccess* pDirectScreen = pHXWin->iDSA;
    
    HX_ASSERT(m_pSite);

#if defined(HELIX_FEATURE_SMIL_SITE)    
    point = *(m_pSite->GetOrigin());
#else
    m_pSite->GetPosition(point);
#endif    
    
    //Force an update. This is required for WINS but it may not
    //be needed on all hardware. It *is* needed for Nokia 3650.
    CFbsScreenDevice*& pSD = pDirectScreen->ScreenDevice();
    if( pSD )
    {
        m_pGC     = pDirectScreen->Gc();
        clipReg   = pDirectScreen->DrawingRegion();
        if( clipReg )
        {
            
#if defined(HELIX_FEATURE_SMIL_SITE)
            //Generate a TRegion from our site's region and only blt to the
            //intersection of the two.
            RRegion trTmp;
            HXREGION* reg = m_pSite->GetRegion();
            if( !HXEmptyRegion(reg))
            {
                //Add each rectangle...
                for(int i =0; i< reg->numRects; i++)
                {
                    TRect rect( reg->rects[i].x1+topleft.iX,
                                reg->rects[i].y1+topleft.iY,
                                reg->rects[i].x2+topleft.iX,
                                reg->rects[i].y2+topleft.iY
                                );
                    trTmp.AddRect(rect);
                }
                trTmp.Intersect(*clipReg);
            }
            clipReg = &trTmp;
#endif    
            m_pGC->SetClippingRegion(clipReg); 
            m_pGC->BitBlt(TPoint(point.x, point.y), m_pBitMap );
            pSD->Update();
#if defined(HELIX_FEATURE_SMIL_SITE)
            trTmp.Close();
#endif            
        }
    }
    
    return res;
}


void CMiniSymbianSurface::_KeepScreenAlive()
{
    ULONG32 ulNow = HX_GET_TICKCOUNT();

    //While we are BLT'ing video frames make sure the screen doesn't
    //dim on us. Do this every 10 seconds for now.
    //XXXGfw need to query the timeout and base the calls on that #.
    if( ulNow-m_ulLastResetTime > 10*1000)
    {
        User::ResetInactivityTime();
        m_ulLastResetTime = ulNow;
    }
}

HX_RESULT CMiniSymbianSurface::_DestroyDestBuffer(int cid, int nCount)
{
    HX_DELETE(m_pBitMap);
    m_nCompositionPitch   = 0;
    return HXR_OK;
}

int CMiniSymbianSurface::GetDstCID(int nIndex)
{
    //XXXgfw need more intelligent detection of screen depth.
    return CID_RGB444;
}


⌨️ 快捷键说明

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