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

📄 blt.cpp

📁 Freescale ARM11系列CPU MX31的WINCE 5.0下的BSP
💻 CPP
字号:
//------------------------------------------------------------------------------
//
//  Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
//  Use of this source code is subject to the terms of the Microsoft end-user
//  license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
//  If you did not accept the terms of the EULA, you are not authorized to use
//  this source code. For a copy of the EULA, please see the LICENSE.RTF on
//  your install media.
//
//------------------------------------------------------------------------------
//
//  Copyright (C) 2004-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:  blt.cpp
//
//  bitblt optimizations.
//
//------------------------------------------------------------------------------
#include <windows.h>
#include <ceddk.h>
#include <types.h>
#include <winddi.h>
#include <gpe.h>
#include "bsp.h"
#include "adc_init.h"
#include "ipu_adc.h"
#include "dispperf.h"


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


//------------------------------------------------------------------------------
// External Variables
extern "C" PCSP_IPU_REGS g_pIPU;


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


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


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


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


//------------------------------------------------------------------------------
//
// Function: IPU_SDC::BltPrepare
//
// This method identifies the appropriate functions needed to perform individual
// blits. This function executes before a sequence of clipped blit operations.
//
// Parameters:
//      pBltParms
//          [in] Pointer to a GPEBltParms structure containing parameters for
//               the blit operation.
//
// Returns:
//      S_OK if successful.
//
//------------------------------------------------------------------------------
SCODE IPU_ADC::BltPrepare(GPEBltParms *pBltParms)
{
    DispPerfStart(pBltParms->rop4);

    DEBUGMSG(GPE_ZONE_BLT_LO, (TEXT("+%s()\r\n"), __WFUNCTION__));

    if (m_iRotate) //if rotated
    {
        pBltParms->pBlt = (SCODE (GPE::*)(GPEBltParms *))EmulatedBltRotate;
        return S_OK;
    }

    pBltParms->pBlt = EmulatedBlt; // catch all

    // Performance Logging Type
    if (pBltParms->pBlt != EmulatedBlt)
    {
        DispPerfType(DISPPERF_ACCEL_HARDWARE);
    }

    DEBUGMSG(GPE_ZONE_BLT_LO, (TEXT("-%s()\r\n"), __WFUNCTION__));
    return S_OK;
}


//------------------------------------------------------------------------------
//
// Function: IPU_SDC::BltComplete
//
// This method executes to complete a blit sequence initiated by GPE::BltPrepare.
// GPE calls this method.
// Warning - No debug messages, system calls, etc allowed here if CE_SAVEBITS
// is used
//
// Parameters:
//      pBltParms
//          [in] Pointer to a GPEBltParms structure containing parameters for
//               the blit operation.
//
// Returns:
//      S_OK if successful.
//
//------------------------------------------------------------------------------
SCODE IPU_ADC::BltComplete(GPEBltParms *pBltParms)
{

    if (pBltParms->pDst == m_pPrimarySurface)
    {
        // Set DMA ADC Channel 2 as ready
        INSREG32BF(&g_pIPU->IPU_CHA_BUF0_RDY,
                   IPU_DMA_CHA_DMAADC_2,
                   IPU_DMA_CHA_READY);
    }

    DispPerfEnd(0);

    return S_OK;
}

//------------------------------------------------------------------------------
//
// Function: IPU_SDC::AcceleratedFillRect
//
// Optimized fill rectangle operation.
//
// Parameters:
//      pBltParms
//          [in] Pointer to a GPEBltParms structure containing parameters for
//               the blit operation.
//
// Returns:
//      S_OK if successful.
//
//------------------------------------------------------------------------------
SCODE IPU_ADC::AcceleratedFillRect(GPEBltParms *pBltParms)
{
    int dstX = pBltParms->prclDst->left;
    int dstY = pBltParms->prclDst->top;
    int width = pBltParms->prclDst->right - pBltParms->prclDst->left;
    int height = pBltParms->prclDst->bottom - pBltParms->prclDst->top;
    int bpp = EGPEFormatToBpp[pBltParms->pDst->Format()] / 8;
    unsigned char color;
    unsigned char* dstPtr;

    DEBUGMSG(GPE_ZONE_BLT_LO, (TEXT("+%s()\r\n"), __WFUNCTION__));

    // check for negative x or y direction and correct values accordingly
    if (!pBltParms->xPositive)
    {
        dstX += (width - 1);
    }

    if (!pBltParms->yPositive)
    {
        dstY += (height - 1);
    }

    switch (pBltParms->rop4)
    {
        case    0x0000: // BLACKNESS
            color = 0x00;
            break;

        case    0xFFFF: // WHITENESS
            color = 0xFF;
            break;
    }

    dstPtr = pBltParms->pDst->GetPtr(dstX, dstY);

    // Use memset() to fill the rectangle line by line
    while (height-- > 0) {
        memset(dstPtr, color, width * bpp);
        dstPtr += pBltParms->pDst->Stride();
    }

    DEBUGMSG(GPE_ZONE_BLT_LO, (TEXT("-%s()\r\n"), __WFUNCTION__));
    return  S_OK;
}


//------------------------------------------------------------------------------
//
// Function: IPU_ADC::AcceleratedSrcCopyBlt
//
// Optimized copy block transfer operation.
//
// Parameters:
//      pBltParms
//          [in] Pointer to a GPEBltParms structure containing parameters for
//               the blit operation.
//
// Returns:
//      S_OK if successful.
//
//------------------------------------------------------------------------------
SCODE IPU_ADC::AcceleratedSrcCopyBlt(GPEBltParms *pBltParms)
{
    int srcX = pBltParms->prclSrc->left;
    int srcY = pBltParms->prclSrc->top;
    int dstX = pBltParms->prclDst->left;
    int dstY = pBltParms->prclDst->top;
    int width = pBltParms->prclDst->right  - pBltParms->prclDst->left;
    int height = pBltParms->prclDst->bottom - pBltParms->prclDst->top;
    int bpp = EGPEFormatToBpp[pBltParms->pDst->Format()] / 8;
    unsigned char* srcPtr;
    unsigned char* dstPtr;

    DEBUGMSG(GPE_ZONE_BLT_LO, (TEXT("+%s()\r\n"), __WFUNCTION__));

    // check for negative x or y direction and correct values accordingly
    if (!pBltParms->xPositive)
    {
        srcX += (width - 1);
        dstX += (width - 1);
    }

    if (!pBltParms->yPositive)
    {
        srcY += (height - 1);
        dstY += (height - 1);
    }

    srcPtr = pBltParms->pSrc->GetPtr(srcX, srcY);
    dstPtr = pBltParms->pDst->GetPtr(dstX, dstY);

    // Using memcpy() to simulate DMA
    while (height-- > 0)
    {
        memcpy(dstPtr, srcPtr, width * bpp);
        srcPtr += pBltParms->pSrc->Stride();
        dstPtr += pBltParms->pDst->Stride();
    }

   DEBUGMSG(GPE_ZONE_BLT_LO, (TEXT("-%s()\r\n"), __WFUNCTION__));
   return  S_OK;
}

⌨️ 快捷键说明

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