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

📄 ddipu_sdc_line.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_line.cpp
//
//  Implementation of DDIPU_SDC functions to draw lines.
//
//------------------------------------------------------------------------------
#include "precomp.h"


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


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


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


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


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


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


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


//------------------------------------------------------------------------------
//
// Function: Line
//
// This method executes before and after a sequence of line segments,
// which are drawn as a path.
//
// Parameters:
//      pLineParms
//          [in] A pointer to a DDGPELineParms structure.
//
//      phase
//          [in] Set to one of the values in the following table.
//
// Returns:
//      S_OK            successful
//      others          failed
//
//------------------------------------------------------------------------------
SCODE DDIPU_SDC::Line(GPELineParms * pLineParms, EGPEPhase phase)
{
    EnterCriticalSection(&m_csDrawLock);

    if (phase == gpeSingle || phase == gpePrepare)
    {
        if ((pLineParms->pDst != m_pPrimarySurface))
        {
            pLineParms->pLine = EmulatedLine;
        }
        else
        {
            pLineParms->pLine = (SCODE (GPE::*)(struct GPELineParms *)) WrappedEmulatedLine;
        }
    }

    LeaveCriticalSection(&m_csDrawLock);
    return S_OK;
}


//------------------------------------------------------------------------------
//
// Function: WrappedEmulatedLine
//
// This method executes the emulated line routine and modified the
// dirty rectangle if we are in TV mode.
//
// Parameters:
//      pBltParms
//          [in] A pointer to a DDGPELineParms structure.
//
// Returns:
//      S_OK            successful
//      others          failed
//
//------------------------------------------------------------------------------
SCODE DDIPU_SDC::WrappedEmulatedLine(GPELineParms *pLineParms)
{
    SCODE retval;

    // do emulated line
    retval = EmulatedLine (pLineParms);

    if (FAILED(retval))
        return retval;

    // handle the TV mode case for updates
    if(m_bTVModeActive)
    {
        // Now, calculate the dirty-rect to refresh to the actual hardware
        RECT bounds;
        int N_plus_1;           // Minor length of bounding rect + 1

        if( pLineParms->dN) // The line has a diagonal component (we'll refresh the bounding rect)
            N_plus_1 = 2 + ((pLineParms->cPels * pLineParms->dN) / pLineParms->dM);
        else
            N_plus_1 = 1;

        switch(pLineParms->iDir) {
        case 0:
            bounds.left = pLineParms->xStart;
            bounds.top = pLineParms->yStart;
//            bounds.right = pLineParms->xStart + pLineParms->cPels + 1;
            bounds.right = pLineParms->xStart + pLineParms->cPels;
            bounds.bottom = bounds.top + N_plus_1;
            break;
        case 1:
            bounds.left = pLineParms->xStart;
            bounds.top = pLineParms->yStart;
//            bounds.bottom = pLineParms->yStart + pLineParms->cPels + 1;
            bounds.bottom = pLineParms->yStart + pLineParms->cPels;
            bounds.right = bounds.left + N_plus_1;
            break;
        case 2:
            bounds.right = pLineParms->xStart + 1;
            bounds.top = pLineParms->yStart;
//            bounds.bottom = pLineParms->yStart + pLineParms->cPels + 1;
            bounds.bottom = pLineParms->yStart + pLineParms->cPels;
            bounds.left = bounds.right - N_plus_1;
            break;
        case 3:
            bounds.right = pLineParms->xStart + 1;
            bounds.top = pLineParms->yStart;
            bounds.left = pLineParms->xStart - pLineParms->cPels;
            bounds.bottom = bounds.top + N_plus_1;
            break;
        case 4:
            bounds.right = pLineParms->xStart + 1;
            bounds.bottom = pLineParms->yStart + 1;
            bounds.left = pLineParms->xStart - pLineParms->cPels;
            bounds.top = bounds.bottom - N_plus_1;
            break;
        case 5:
            bounds.right = pLineParms->xStart + 1;
            bounds.bottom = pLineParms->yStart + 1;
            bounds.top = pLineParms->yStart - pLineParms->cPels;
            bounds.left = bounds.right - N_plus_1;
            break;
        case 6:
            bounds.left = pLineParms->xStart;
            bounds.bottom = pLineParms->yStart + 1;
            bounds.top = pLineParms->yStart - pLineParms->cPels;
            bounds.right = bounds.left + N_plus_1;
            break;
        case 7:
            bounds.left = pLineParms->xStart;
            bounds.bottom = pLineParms->yStart + 1;
//            bounds.right = pLineParms->xStart + pLineParms->cPels + 1;
            bounds.right = pLineParms->xStart + pLineParms->cPels;
            bounds.top = bounds.bottom - N_plus_1;
            break;
        default:
            DEBUGMSG(GPE_ZONE_ERROR,(TEXT("Invalid direction: %d\r\n"),pLineParms->iDir));
            return E_INVALIDARG;
        }

        EnterCriticalSection(&m_csDirtyRect);

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

        // Signal to TV update thread that we can now be udpated.
        SetEvent(m_hTVUpdateRequest);

        LeaveCriticalSection(&m_csDirtyRect);

        UINT32 time;
        time = GetTickCount();
        //DEBUGMSG(1, (TEXT("%s: TV Update request sent at time %d:%d\r\n"), __WFUNCTION__, time/60, time%60));
    }

    return S_OK;
}

⌨️ 快捷键说明

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