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

📄 gpeaccel.cpp

📁 收集到的orion_ep93xx_wince_bsp_1-3-507显示驱动源码,未作测试
💻 CPP
📖 第 1 页 / 共 3 页
字号:
                pBltParms->pBlt         = (SCODE (GPE::*) (struct GPEBltParms *)) AcceleratedFillRect;
                bTryAccelSoft           = FALSE;
                break;

            case    0xFFFF: // WHITENESS
                pBltParms->solidColor   = 0xffffff;
                pBltParms->pBlt         = (SCODE (GPE::*) (struct GPEBltParms *)) AcceleratedFillRect;
                bTryAccelSoft           = FALSE;
                break;

            case    0xF0F0: // PATCOPY
            if(pBltParms->solidColor != -1)
            {
                pBltParms->pBlt         = (SCODE (GPE::*) (struct GPEBltParms *)) AcceleratedFillRect;
                bTryAccelSoft           = FALSE;
            }
            break;

            case    0x5A5A: // PATINVERT
            case    0x6666: // SRCINVERT
            case    0x8888: // SRCAND
            case    0xCCCC: // SRCCOPY
            case    0xEEEE: // SRCPAINT
            default:
                break;
        }
        
        //
        // I think that wait for busy should be here to prevent the hardware
        // and software blits from interfering with each other.
        //
        WaitForNotBusy();
    }

    //
    // If we don't use the Hardware ROP, try to find a software blit if one is 
    // available.
    //
    if(bTryAccelSoft)
    {
        //
        // see if there are any optimized software blits available
        //
        EmulatedBltSelect02(pBltParms);
        EmulatedBltSelect08(pBltParms);
        EmulatedBltSelect16(pBltParms);
    }

    return S_OK;
}

//****************************************************************************
// GPEAccel::BltComplete
//****************************************************************************
// 
SCODE   GPEAccel::BltComplete(GPEBltParms *blitParameters)
{
    DEBUGMSG (GPE_ZONE_INIT, (TEXT("GPEAccel::BltComplete\r\n")));

    return S_OK;
}

//****************************************************************************
// GPEAccel::InVBlank
//****************************************************************************
// We don't have to worry about blanking.
//
INT    GPEAccel::InVBlank(void)
{
    DEBUGMSG (GPE_ZONE_INIT, (TEXT("GPEAccel::InVBlank\r\n")));
    return 0;
}

//****************************************************************************
// PrintPalette
//****************************************************************************
// Debug routine to print out the current palette
// 
//
void PrintPalette()
{
    #ifdef DEBUG
    ULONG   ulEntry;
    DEBUGMSG (GPE_ZONE_PALETTE, (L"GPEAccel: Current Palette, "));
    
    //
    // If the print Palette zone is enabled print out the palette whenever
    // we open the palette.
    //
    if(GPE_ZONE_PALETTE)
    {
        for(ulEntry = 0; ulEntry < 256 ; ulEntry+=4)
        {
            DEBUGMSG
            (
                GPE_ZONE_PALETTE, 
                (
                    L"Entry 0x%03x:  0x%08x  0x%08x  0x%08x  0x%08x\n",
                    ulEntry,
                    RASTER_COLOR_LUT[ulEntry],
                    RASTER_COLOR_LUT[ulEntry + 1],
                    RASTER_COLOR_LUT[ulEntry + 2],
                    RASTER_COLOR_LUT[ulEntry + 3]
                )
            );
        }
    }        
    #endif //DEBUG
}
//****************************************************************************
// GPEAccel::SetPalette
//****************************************************************************
// Set up the Color Look up table.   There are two LUT's in hardware.
// the lookup table that is visible is not the one that is accessable.
// 
//
SCODE  GPEAccel::SetPalette
(
    const PALETTEENTRY  *source, 
    USHORT              firstEntry, 
    USHORT              numEntries
)
{
    DEBUGMSG (GPE_ZONE_INIT, (TEXT("GPEAccel::SetPalette\r\n")));
    ULONG   ulEntry;
    ULONG   ulCount;

    if (firstEntry < 0 || firstEntry + numEntries > 256 || source == NULL)
    {
        RETAILMSG(1,(TEXT("SetPalette invalid arguments\r\n")));
        return  E_INVALIDARG;
    }

    //
    // Copy into our palette.
    //
    memcpy((void *)&m_Palette[firstEntry], source, sizeof(PALETTEENTRY) * numEntries);
    

    //
    // I would do a memory copy but the red and blue
    // palette entries are reversed.
    //
    for(ulEntry = firstEntry ; ulEntry < numEntries; ulEntry++)
    {
        unsigned char red, green, blue;

        //
        // Get the values for Red, Green and Blue.
        //
        red     = source[ulEntry].peRed ;
        green   = source[ulEntry].peGreen;
        blue    = source[ulEntry].peBlue;

        //
        // Program up the Color lookup table.
        //
        RASTER_COLOR_LUT[ulEntry] = ((ULONG)red<< 16) + ((ULONG)green << 8) + (ULONG)blue;
    }
    
    //
    // Switch to the other LUT and program the same values.
    //                                       
    *RASTER_LUTCONT          ^= LUTCONT_SWTCH;
    
    //
    // Wait until a palette switch occurs at the end of the frame.
    //
    for(ulCount = 0 ;; ulCount++)
    {
        //
        // Put a small delay to wait for the change.
        //
        Sleep(1);
        
        //
        // Has the switch occured.
        //
        if(((*RASTER_LUTCONT & LUTCONT_SSTAT) && (*RASTER_LUTCONT &LUTCONT_SWTCH)) ||
          (!(*RASTER_LUTCONT & LUTCONT_SSTAT) && !(*RASTER_LUTCONT & LUTCONT_SWTCH)))
        {
            break;
        }
        
        if(ulCount > 100)
        {
            DEBUGMSG (GPE_ZONE_INIT, (TEXT("ERROR: Palette switch never occured.\n")));
        }
    }

    
    //
    // I would do a memory copy but the red and blue
    // palette entries are reversed.
    //
    for(ulEntry = firstEntry ; ulEntry < numEntries; ulEntry++)
    {
        unsigned char    red, green, blue;

        //
        // Get the values for Red, Green and Blue.
        //
        red     = source[ulEntry].peRed ;
        green   = source[ulEntry].peGreen;
        blue    = source[ulEntry].peBlue;

        //
        // Program up the Color lookup table.
        //
        RASTER_COLOR_LUT[ulEntry] = ((ULONG)red<< 16) + ((ULONG)green << 8) + (ULONG)blue;
    }
    
    //
    // Print out the palette to the debugger if the debug zone is enabled.
    //
    PrintPalette();


    return  S_OK;
}

//****************************************************************************
// GPEAccel::GetGraphicsCaps
//****************************************************************************
// 
// 
ULONG   GPEAccel::GetGraphicsCaps()
{
    if (m_pMode)
    {
        //
        // if in 16bpp mode, return GCAPS_GRAY16 to denote that we support 
        // anti-aliased fonts
        if (m_pMode->Bpp == 16)     
        {
            return  GCAPS_GRAY16;
        }
    }
    return  0;
}

//****************************************************************************
// RegisterDDHALAPI
//****************************************************************************
// no DDHAL support
// 
void  RegisterDDHALAPI(void)
{
    return; 
}

ULONG gBitMasks[] = { 0x0001,0x0002,0x0000 };


//****************************************************************************
// DrvGetMasks
//****************************************************************************
//
//
ULONG *APIENTRY DrvGetMasks(DHPDEV dhpdev)
{
    return gBitMasks;
}


//****************************************************************************
// GPEAccel::AcceleratedFillRect
//****************************************************************************
//  Use the accelerated block fill.
// 
//
SCODE  GPEAccel::AcceleratedFillRect (GPEBltParms *pBltParms)
{
    ULONG   ulPhyStart;
    ULONG   ulPhyEnd;
    ULONG   ulBlockControl;

    RECTL    *prclDst   = pBltParms->prclDst;
    GPESurf  *pDst      = pBltParms->pDst;

    int     left    = prclDst->left;
    int     top     = prclDst->top ;
    int     right   = prclDst->right ;
    int     bottom  = prclDst->bottom ;
    int     stride  = pDst->Stride();
    int     BytesPerPixel = EGPEFormatToBpp[pDst->Format()] >> 3;
    ULONG   ulRightByteCount;
    ULONG   ulLeftByteCount;
    // ULONG   ulBlockDestWidth

    //ulPhySize  = width * height * BytesPerPixel;


    DEBUGMSG (GPE_ZONE_INIT, (TEXT("GPEAccel::AcceleratedFillRect\r\n")));


    //
    // Check for negative x or y direction and correct values accordingly
    //
    if (!pBltParms->xPositive)
    {
        // dstX += (width - 1);
        // DstCntl &= ~DST_X_LEFT_TO_RIGHT;
        DebugBreak();
    }

    if (!pBltParms->yPositive)
    {
        // dstY += (height - 1);
        // DstCntl &= ~DST_Y_TOP_TO_BOTTOM;
        DebugBreak();
    }

    //
    // Calculate the number of bytes from the start of the line.
    //
    ulRightByteCount            = right * BytesPerPixel;
    ulLeftByteCount             = left * BytesPerPixel;

    //
    // Start of the Physical buffer.
    //
    ulPhyStart = top    * stride + ulLeftByteCount + pDst->OffsetInVideoMemory();
    ulPhyEnd   = bottom * stride + ulRightByteCount + pDst->OffsetInVideoMemory();


    WaitForNotBusy();

    //
    // Height in line of the block to be Filled.
    //
    *GRAPHICS_BLKDESTHEIGHT     = bottom - top - 1 ;

    //
    // Starting Physical address of the the block to be filled.
    //
    *GRAPHICS_BLKDESTSTRT       = ulPhyStart ;

    //
    // Starting and ending offset within a 32 bit word.
    //
    *GRAPHICS_DESTPIXELSTRT     = ((ulPhyStart & 3) << 3) |
                                  (((ulPhyEnd  - BytesPerPixel)  & 3) <<(DESTPIXELSTRT_EPEL_SHIFT + 3));

    //
    // 
    // BLKDESTWIDTH is the number of full and partial words - 1.
    //
    //
    //   0   1   2   3 | 4   5   6   7 | 8   9   10  11| 12  13
    // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+
    // |   |   |   | X | X | X | X | X | X | X | X | X | X | X |
    // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+
    //                 |               |               |   
    //
    //                 |<--- (ulRightByteCount>>2) --->|
    //                       - (ulLeftByteCount>>2)  
    //            +1 ->|                               |<-  +1
    //  
    //
    *GRAPHICS_BLKDESTWIDTH      = (ulRightByteCount>>2)        +
                                  ((ulRightByteCount & 3)?1:0) +
                                  ((ulLeftByteCount & 3)?1:0)  -
                                  ((ulLeftByteCount + 3)>>2) - 1;


    //
    // Number of words per line.
    //
    *GRAPHICS_DESTLINELENGTH    = stride>>2;

    //
    // These values are all zero.
    //
    *GRAPHICS_BLKSRCSTRT        = 0;
    *GRAPHICS_SRCPIXELSTRT      = 0;
    *GRAPHICS_BLKSRCWIDTH       = 0;
    *GRAPHICS_SRCLINELENGTH     = 0;
    *GRAPHICS_LINEINC           = 0;
    *GRAPHICS_LINEINIT          = 0;
    *GRAPHICS_LINEPATTRN        = 0;
    *GRAPHICS_TRANSPATTRN       = 0;

    //
    // I don't think that this is used.
    //
    *GRAPHICS_BACKGROUND        = 0;

    //
    // I am not sure if the solid color has to be converted to
    //
    *GRAPHICS_BLOCKMASK = pBltParms->solidColor;

    //
    // Set up the block control register.
    //
    //*GRAPHICS_BLOCKCTRL = 0;
    //*GRAPHICS_BLOCKCTRL = ulBlockControl = BLOCKCTRL_FILL;

    //
    // This calculation doesn't work for 32 bits per pixel.
    //
    //*GRAPHICS_BLOCKCTRL = ulBlockControl |= (BytesPerPixel  << (BLOCKCTRL_PIXEL_SHIFT + 1));

    ulBlockControl = BLOCKCTRL_FILL | (BytesPerPixel  << (BLOCKCTRL_PIXEL_SHIFT + 1));

    //
    // Start the graphics process.
    //
    *GRAPHICS_BLOCKCTRL = ulBlockControl | BLOCKCTRL_ENABLE ; 

    return S_OK;
}          


//****************************************************************************
// GPEAccel::PowerHandler
//****************************************************************************
// Routine that powers up and down the video clocks.
// 
//
VOID GPEAccel::PowerHandler( BOOL bOff)
{
    ULONG   ulTemp;

    //
    // Unlock the video attributes register.
    //
    *RASTER_REALITI_SWLOCK   = 0xaa;

    //
    // See if we are power up the system or shutting down the system.
    //
    if(bOff)
    {
        //
        // Clear the Sleep signal.  This turns off the LCD.
        //
        if( m_Registry.fSleepSignalActive )
        {
            ulTemp = *GPIO_PADR;
            *GPIO_PADR = ulTemp & ~0x2;
        }

        *RASTER_VIDEOATTRIBS = ~VIDEOATTRIBS_EN &  m_ulVideoAttrib ;
    }
    else
    {
        //
        // Set the Sleep Signal.  This turns on the LCD.
        //
        if( m_Registry.fSleepSignalActive )
        {
            ulTemp = *GPIO_PADR;
            *GPIO_PADR = ulTemp | 0x2;
        }

        *RASTER_VIDEOATTRIBS = m_ulVideoAttrib ;
    }
}

⌨️ 快捷键说明

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