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

📄 ddipu_sdc_rotate.cpp

📁 Freescale ARM11系列CPU MX31的WINCE 5.0下的BSP
💻 CPP
字号:
//-----------------------------------------------------------------------------
//  Copyright (C) 2004-2005, MOTOROLA, INC. All Rights Reserved
//  THIS SOURCE CODE IS CONFIDENTIAL AND PROPRIETARY AND MAY NOT
//  BE USED OR DISTRIBUTED WITHOUT THE WRITTEN PERMISSION OF
//  MOTOROLA, INC.
//------------------------------------------------------------------------------
//
//  Copyright (C) 2005-2006, Freescale Semiconductor, Inc. All Rights Reserved.
//  THIS SOURCE CODE, AND ITS USE AND DISTRIBUTION, IS SUBJECT TO THE TERMS
//  AND CONDITIONS OF THE APPLICABLE LICENSE AGREEMENT
//
//------------------------------------------------------------------------------
//
//  File:  ddipu_sdc_rotate.cpp
//
//  Implementation of DDIPU_SDC screen rotation operations when
//  not in DirectDraw mode.
//
//------------------------------------------------------------------------------
#include "precomp.h"


//------------------------------------------------------------------------------
// External Functions


//------------------------------------------------------------------------------
// External Variables


//------------------------------------------------------------------------------
// Defines


//------------------------------------------------------------------------------
// Types


//------------------------------------------------------------------------------
// Global Variables


//------------------------------------------------------------------------------
// Local Variables


//------------------------------------------------------------------------------
// Local Functions


//------------------------------------------------------------------------------
//
// Function: GetRotateModeFromReg
//
// This function is used to read the registry to get the initial
// rotation angle.
//
// Parameters:
//      None.
//
// Returns:
//      returns default rotation angle.
//
//------------------------------------------------------------------------------
int DDIPU_SDC::GetRotateModeFromReg(VOID)
{
    HKEY hKey;
    int iRotate;

    if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SYSTEM\\GDI\\ROTATION"), 0, 0, &hKey))
    {
        DWORD dwSize, dwAngle, dwType = REG_DWORD;
        dwSize = sizeof(DWORD);
        if (ERROR_SUCCESS == RegQueryValueEx(hKey,
                                             TEXT("ANGLE"),
                                             NULL,
                                             &dwType,
                                             (LPBYTE)&dwAngle,
                                             &dwSize))
        {
            switch (dwAngle)
            {
                case 0:
                    iRotate = DMDO_0;
                    break;

                case 90:
                    iRotate = DMDO_90;
                    break;

                case 180:
                    iRotate = DMDO_180;
                    break;

                case 270:
                    iRotate = DMDO_270;
                    break;

                default:
                    iRotate = DMDO_0;
                    break;
            }
        }

        RegCloseKey(hKey);
    }
    else
    {
        iRotate = DMDO_0;
    }

    return iRotate;
}


//------------------------------------------------------------------------------
//
// Function: SetRotateParms
//
// This function is used to set up the screen width and height
// based on the current rotation angle.
//
// Parameters:
//      None.
//
// Returns:
//      None.
//
//------------------------------------------------------------------------------
VOID DDIPU_SDC::SetRotateParams(VOID)
{
    switch(m_iRotate)
    {
    case DMDO_90:
    case DMDO_270:
        m_pMode->height = m_nScreenWidthSave;
        m_pMode->width = m_nScreenHeightSave;
        break;

    case DMDO_0:
    case DMDO_180:
    default:
        m_pMode->width = m_nScreenWidthSave;
        m_pMode->height = m_nScreenHeightSave;
        break;
    }

    return;
}


//------------------------------------------------------------------------------
//
// Function: IsRotated
//
// Return whether the display memory is currently rotated or not.
//
// Parameters:
//      None.
//
// Returns:
//      TRUE if rotated, FALSE if not rotated.
//
//------------------------------------------------------------------------------
BOOL DDIPU_SDC::IsRotated(VOID)
{
    // TODO: If below is correct, this is the same as IsRotate(). Note: is the panel was landscape-addressed, this might get more complex.
    switch (m_iRotate)
    {
    case DMDO_0: case DMDO_180:
        return FALSE;
        break;

    case DMDO_270: case DMDO_90:
        return TRUE;
        break;

    default:
        return FALSE;
    }
}

//------------------------------------------------------------------------------
//
// Function: SetRotation
//
// This function Rotates the screen.
//
// Parameters:
//      dwMode
//          [in] Current display mode.
//      dwRotation
//          [in] Current display orientation
//
// Returns:
//      DISP_CHANGE_SUCCESSFUL
//
//------------------------------------------------------------------------------
int DDIPU_SDC::SetRotation(DWORD dwMode, DWORD dwRotation)
{
    // A DirectDraw supported driver based on the DDGPE class is
    // incompatible with rotation.  To support rotation, this BSP
    // flag must be set to TRUE to override and allow rotation.
    if (!BSP_DIRECTDRAW_SUPPORT_ROTATION)
    {
        return DISP_CHANGE_BADMODE;
    }

    if (dwMode != DISPLAY_MODE_DEVICE && dwRotation != DMDO_270)
    {
        return DISP_CHANGE_FAILED;
    }


    // Return if no change is needed
    if (m_iRotate == dwRotation)
    {
        return DISP_CHANGE_SUCCESSFUL;
    }

    // Update the rotation
    m_iRotate = dwRotation;

    CursorOff();
    BOOL cond1 = (dwMode == DISPLAY_MODE_DEVICE) ? TRUE : FALSE;

    SetRotateParams();

    m_nScreenWidth = m_pMode->width;
    m_nScreenHeight = m_pMode->height;

    // Update the surface
    DDIPU_SDCSurf *pSurf = (DDIPU_SDCSurf *) m_pPrimarySurface;

    // Clear the virtual memory for the primary surface
    memset((PUCHAR)(m_pLAW + pSurf->OffsetInVideoMemory()), 0, m_nScreenHeight * m_nScreenWidth * (m_nScreenBpp / 8));

#if 0
    // Blank the surface (TODO...)

    ZeroMemory(m_pPrimaryDirtyBuffer, m_iFrameBufferSize);

    // TODO: Following? or the code below it?
    //for(DWORD i = 0; i < m_dwRegionCount; i++)
    //{
    //    // nothing is dirty right now
    //    m_bDirtyRegions[i] = false;
    //}

    EnterCriticalSection(&m_csDirtyRect);

    DEBUGCHK(m_pDirtyRect != NULL);
    if(m_pDirtyRect)
        m_pDirtyRect->SetDirtyRegion((LPRECT)&bounds);

    // TODO: Is this only a TV thing? What about when on LCD? Is no update required?
    // Signal to TV update thread that we can now be udpated.
    SetEvent(m_hTVUpdateRequest);

    LeaveCriticalSection(&m_csDirtyRect);
#endif

    pSurf->SetRotation(m_nScreenWidth, m_nScreenHeight, dwRotation);

    CursorOn();

    return DISP_CHANGE_SUCCESSFUL;
}

⌨️ 快捷键说明

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