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

📄 winsite.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
                    if (HXR_OK == pUnknown->QueryInterface(IID_IHXPlayer, (void**) &pPlayer))                    {                        bIsDone &= pPlayer->IsDone();                        HX_RELEASE(pPlayer);                    }                    HX_RELEASE(pUnknown);                }            }            HX_RELEASE(pEngine);        }        if (!bIsDone)        {            SafeSetWindowPos(hParent, HWND_TOPMOST, 0,0,0,0, SWP_NOSIZE | SWP_NOMOVE);        }        m_bWasTopMost = FALSE;    }    m_bInFullScreen = FALSE;    SetSize(m_windowSize);    m_pTopLevelSite->_ForceRedrawAll();    if (m_pStatusText)    {        m_pStatusText->ParentChangedSize();        m_pStatusText->Hide();    }    m_nDelayFillBorders = 0;    SetFocus((HWND)GetWindow()->window);    return HXR_OK;}HX_RESULT CHXWinSite::_TestFullScreen(void* hTestBitmap,const char* pszStatusText){    EnterCriticalSection(&(((CHXWinSite*)m_pTopLevelSite)->m_CriticalSection));    HX_RESULT retVal = HXR_FAIL;    CHXWinSite* pTempWindow = new CHXWinSite(m_pContext, FALSE);    zm_bInFullScreenTest = TRUE;    if (pTempWindow)    {        pTempWindow->AddRef();        retVal = pTempWindow->InternalTestFullScreen(hTestBitmap, pszStatusText);        zm_bInFullScreenTest = FALSE;        pTempWindow->Release();    }    LeaveCriticalSection(&(((CHXWinSite*)m_pTopLevelSite)->m_CriticalSection));    return retVal;}/* *  XXXAH all of this code that reads prefs can be move to the cross platform code. */HX_RESULT CHXWinSite::InternalTestFullScreen(LPVOID hTestBitmap,const char* pszStatusText){/* *       Check to see if we have a HWND. *       If not, create one, DirectDraw is going to require one. */    BOOL bInternalTestWindow = FALSE;    if (!m_pWindow || !m_pWindow->window)    {        bInternalTestWindow = TRUE;        Create(NULL, WS_POPUP);    }    /*     * Get the modes to be tested from the regestry.     */    IHXPreferences*    pPreferences    = NULL;    IHXBuffer*         pBuffer         = NULL;    char*               pszModesToTest  = NULL;    char                szBuffer[255]; /* Flawfinder: ignore */    m_pContext->QueryInterface(IID_IHXPreferences,(void**)&pPreferences);    SafeStrCpy(szBuffer, REGKEY_FULLSCREEN_DATA, 255);    SafeStrCat(szBuffer, "\\", 255);    SafeStrCat(szBuffer, REGKEY_FULLSCREEN_TEST_MODES, 255);    pPreferences->ReadPref(szBuffer, pBuffer);    // if we were called without a mode to test this means that    // the top level client wants to know what modes are    // availiable. So we will call enumerate modes fix-up the    // regestry and return.    if (pBuffer && strlen((char*)pBuffer->GetBuffer()))    {        char* pszModesToTest = (char*)pBuffer->GetBuffer();        /*         *  Test each of the modes which are in the Mode Description         *  String.         */        int stringLength = strlen(pszModesToTest);        char* pszTempString = new char[stringLength+1];        CHXSimpleList modesList;        memcpy(pszTempString, pszModesToTest, stringLength+1); /* Flawfinder: ignore */        // Whoops! Since we use strtok in the following calls we        // had better strtok this here and store the        // tokens in a list!        char* token = strtok( pszTempString, MODE_SEPERATOR);        while( token != NULL )        {            modesList.AddTail(token);            token  = strtok( NULL, MODE_SEPERATOR);        }        if (bInternalTestWindow)        {            ShowSite(TRUE);        }        CHXSimpleList::Iterator i;        for(i = modesList.Begin(); i!=modesList.End(); ++i)        {            TestMode((const char*) *i, hTestBitmap, pszStatusText);        }        delete[] pszTempString;    }    else    {        UpdateModes();    }    HX_RELEASE(pBuffer);    HX_RELEASE(pPreferences);    if (bInternalTestWindow)    {        Destroy();    }    return HXR_OK;}HX_RESULT CHXWinSite::TestMode(const char* pszModeDescription, void* hTestBitmap, const char* pszText){/* *       1st Parse the Modes Description string * */    INT32                       resolutionX     = 0;    INT32                       resolutionY     = 0;    INT32                       colorDepth      = 0;    IHXPreferences*    pPreferences    = NULL;    IHXBuffer*         pBuffer         = NULL;    char*               pszModesToTest  = NULL;    char                szBuffer[255]; /* Flawfinder: ignore */    if (HXR_OK == ConvertStringToXYDepth(pszModeDescription, resolutionX, resolutionY, colorDepth))    {        if (HXR_OK == m_pContext->QueryInterface(IID_IHXPreferences,(void**)&pPreferences))        {            /*             * Set the Size and Position             */            HXxSize     oldSize;            HXxPoint    oldPos;            HXxSize     newSize;            HXxPoint    newPosition;            memcpy(&oldSize, &m_size, sizeof(HXxSize)); /* Flawfinder: ignore */            GetPosition(oldPos);            newSize.cx  = GetSystemMetrics(SM_CXSCREEN);            newSize.cy  = GetSystemMetrics(SM_CYSCREEN);            SetSize(newSize);            memset(&newPosition,0,sizeof(HXxPoint));            SetPosition(newPosition);            /* tell full screen what mode to use */            pBuffer = new CHXBuffer();            pBuffer->Set((UCHAR*) pszModeDescription, strlen(pszModeDescription)+1);            SafeStrCpy(szBuffer, REGKEY_FULLSCREEN_DATA, 255);            SafeStrCat(szBuffer, "\\", 255);            SafeStrCat(szBuffer, REGKEY_FULLSCREEN_PREFERED_MODE, 255);            pPreferences->WritePref(szBuffer, pBuffer);            HX_RELEASE(pBuffer);            EnterFullScreen();            int testResult = TestFullScreenPerformance(hTestBitmap, pszText);            ExitFullScreen();            SetSize(oldSize);            SetPosition(oldPos);            // update the prefs.            if (testResult)            {                UpdatePrefs(resolutionX, resolutionY, colorDepth, testResult, testResult>TEST_THRESHOLD, 1);            }        }    }    return HXR_OK;}int CHXWinSite::TestFullScreenPerformance(void* hTestBitmap, const char* pszText){    HBITMAP hBitmap = (HBITMAP)hTestBitmap;    HXxRect destRect;    /*     *  Get the bits     */    HDC hDC = GetDC((HWND)GetWindow()->window);    CHXDIBits dib;    LPBITMAPINFOHEADER      pinfo = NULL;    UCHAR* pBits = NULL;    if (HXR_OK != dib.GetDIBits(hDC, hBitmap, pBits, pinfo))    {        return 0;    }    /*     *  Setup the font     */    HFONT hFont;    int oldMappingMode = SetMapMode( hDC, MM_TEXT );    int nHeight = -MulDiv(15, GetDeviceCaps(hDC, LOGPIXELSY), 72);    hFont = CreateFont(nHeight, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Ariel");    SetMapMode( hDC, oldMappingMode);    HFONT hOldFont = (HFONT)SelectObject(hDC, hFont);    SIZE textSize;    GetTextExtentPoint(hDC, "XXX", 4, &textSize);    int textHeight = textSize.cy + 2;    /*     * Setup our drawing tools     */    HBRUSH  hBlackBrush = (HBRUSH) GetStockObject(BLACK_BRUSH);    HBRUSH  hOldBrush   = (HBRUSH) SelectObject(hDC, hBlackBrush);    HPEN    hNullPen    = (HPEN) GetStockObject(NULL_PEN);    HPEN    hOldPen     = (HPEN) SelectObject(hDC, hNullPen);    COLORREF oldColor   = SetTextColor(hDC, 0x0000FF00);    COLORREF oldBkColor = SetBkColor(hDC, 0x00000000);    /*     *  Set up our rects     */    HXxRect srcRect;    memset(&destRect, 0, sizeof(HXxRect));    memset(&srcRect, 0, sizeof(HXxRect));    srcRect.right   = pinfo->biWidth;    srcRect.bottom  = pinfo->biHeight;    int offsetY = (GetSystemMetrics(SM_CYSCREEN) - pinfo->biHeight * 2) / 2;    int offsetX = (GetSystemMetrics(SM_CXSCREEN) - pinfo->biWidth * 2) / 2;    destRect.top    = (long) offsetY;    destRect.left   = (long) offsetX;    destRect.bottom = (long) offsetY + pinfo->biHeight * 2;    destRect.right  = (long) offsetX + pinfo->biWidth * 2;    /*     *  Start timing.     */    GetAsyncKeyState(VK_ESCAPE);    UINT32  nStartTime = HX_GET_TICKCOUNT();    UINT32  nNowTime;    UINT32  timeToUpdateCounter = 0;    char    szStatus[255]; /* Flawfinder: ignore */    int     counter = 0;    while(1)    {        m_pRootSurface->Lock(0);        m_pRootSurface->Blt((UCHAR*)pBits, (HXBitmapInfoHeader*) pinfo, destRect, srcRect, this);        m_pRootSurface->Unlock(0, GetWindow());        //      m_pVideoSurface->Blt((UCHAR*)pBits, (HXBitmapInfoHeader*) &info.bmiHeader, destRect, srcRect);        /*         *  Ok now blt to the primary surface         */        nNowTime = HX_GET_TICKCOUNT();        if (nNowTime - nStartTime > timeToUpdateCounter)        {            /*             * Update the display             */            RECT rect;            rect.left = 0;            rect.bottom = GetSystemMetrics(SM_CYSCREEN) + 1;            rect.top = rect.bottom - textHeight;            rect.right =  GetSystemMetrics(SM_CXSCREEN) + 1;            Rectangle(hDC, rect.left, rect.top, rect.right, rect.bottom);            timeToUpdateCounter += 1000;            SafeSprintf(szStatus, 255, "%s %d", pszText, (TEST_LENGTH - timeToUpdateCounter)/1000);            DrawText(hDC, szStatus, strlen(szStatus), &rect, DT_CENTER | DT_VCENTER);            if (timeToUpdateCounter == TEST_LENGTH)            {                break;            }        }        counter++;        /*         *  Was escape pressed? If so break         */        if (GetAsyncKeyState(VK_ESCAPE))        {            // eat the key stroke            MSG msg;            while (PeekMessage (&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE));            break;        }    }    SetTextColor(hDC, oldColor);    SetBkColor(hDC, oldBkColor);    SelectObject(hDC, hOldPen);    SelectObject(hDC, hOldBrush);    ReleaseDC((HWND)GetWindow()->window, hDC);    nNowTime = HX_GET_TICKCOUNT();    int bltsPerSecond = counter*1000 / CALCULATE_ELAPSED_TICKS(nStartTime, nNowTime);    return bltsPerSecond;#if 0    /*     *   The following code will take the given bit map and blt it     *   multiple times to the screen. Each time it will change the     *    saturation, and contrast causing the bitmap to fade in and out     *    at the same time it will shrink and expand the bitmap. This     *    will make a pretty animation.     *    However, this exercises the YUV->RGB code. This code has some problems     *    currently. When the YUV->RGB code is fixed we may re-instate this code.     *     */    /*     *  Get information on the bitmap     */    char szStatus[255]; /* Flawfinder: ignore */    HDC hDC = GetDC(NULL);    BITMAPINFO info;    memset(&info, 0, sizeof(BITMAPINFO));    info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);    int retVal = GetDIBits(hDC, (HBITMAP)hTestBitmap, 0, 1, NULL, &info, DIB_RGB_COLORS);    // add the relevant black border to the bitmap (the bitmap looks like crap if    // if is stretched to the whole width of the screen).    int bitmapX = info.bmiHeader.biWidth *2;    bitmapX +=  bitmapX % 8 ? 8 - bitmapX % 8 : 0;    int bitmapY = info.bmiHeader.biHeight * 2;    HBITMAP hBitmap = CreateCompatibleBitmap(hDC, bitmapX, bitmapY);    HDC hMemDC = CreateCompatibleDC(hDC);    HBITMAP hOldBitmap = (HBITMAP) SelectObject(hMemDC, hBitmap);    HBRUSH  hBlackBrush = (HBRUSH) GetStockObject(BLACK_BRUSH);    HBRUSH  hOldBrush   = (HBRUSH) SelectObject(hMemDC, hBlackBrush);    HPEN    hNullPen    = (HPEN) GetStockObject(NULL_PEN);    HPEN    hOldPen     = (HPEN) SelectObject(hMemDC, hNullPen);    Rectangle(hMemDC, 0, 0, bitmapX, bitmapY);    HXxRect destRect;    destRect.left   = (bitmapX - info.bmiHeader.biWidth) / 2;    destRect.top    = (bitmapY - info.bmiHeader.biHeight) / 2;    destRect.right  = destRect.left + info.bmiHeader.biWidth;    destRect.bottom = destRect.top + info.bmiHeader.biHeight;    HDC hMemDC2 = CreateCompatibleDC(hDC);    HBITMAP hOldBitmap2 = (HBITMAP) SelectObject(hMemDC2, (HBITMAP)hTestBitmap);    BitBlt(hMemDC, destRect.left, destRect.top, info.bmiHeader.biWidth, info.bmiHeader.biHeight, hMemDC2, 0, 0, SRCCOPY);    SelectObject(hMemDC, hOldPen);    SelectObject(hMemDC, hOldBrush);    SelectObject(hMemDC, hOldBitmap);    SelectObject(hMemDC2, hOldBitmap2);    DeleteDC(hMemDC);    DeleteDC(hMemDC2);    hOldPen             = (HPEN)SelectObject(hDC, hNullPen);    hOldBrush           = (HBRUSH)SelectObject(hDC, hBlackBrush);    COLORREF oldColor   = SetTextColor(hDC, 0x0000FF00);    COLORREF oldBkColor = SetBkColor(hDC, 0x00000000);    /*     *  Get the Bits     */    memset(&info, 0, sizeof(BITMAPINFO));    info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);    retVal = GetDIBits(hDC, (HBITMAP)hBitmap, 0, 1, NULL, &info, DIB_RGB_COLORS);    void* pBits = (void*) new char[info.bmiHeader.biSizeImage];    retVal = GetDIBits(hDC, (HBITMAP)hBitmap, 0, info.bmiHeader.biHeight, pBits, &info, DIB_RGB_COLORS);    DeleteObject(hBitmap);    // Create a YUV BITMAPINFO    BITMAPINFO YUVBmi;    memset(&YUVBmi, 0, sizeof (BITMAPINFO));    MakeBitmap((LPBITMAPINFO)&YUVBmi, sizeof(BMI), CID_I420, info.bmiHeader.biWidth, info.bmiHeader.biHeight, NULL, NULL);    // Convert to YUV    int pitchIn = GetBitmapPitch((LPBITMAPINFO)&info);    int pitchOut = GetBitmapPitch((LPBITMAPINFO)&YUVBmi);    int cidIn = GetBitmapColor((LPBITMAPINFO) &info);    void* pYUVBits = (void*) new char[info.bmiHeader.biSizeImage];    BOOL bConverter = zm_pColorAcc->CheckColorConverter(cidIn, CID_I420);    ColorConverterRequest(cidIn, CID_I420, bConverter);    int returnVal       = 0;    if (bConverter) 

⌨️ 快捷键说明

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