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

📄 gfx_osi_engine.c

📁 IBM source for pallas/vulcan/vesta
💻 C
📖 第 1 页 / 共 3 页
字号:
//vulcan/drv/gfx/gfx_osi_engine.c/*----------------------------------------------------------------------------+||       This source code has been made available to you by IBM on an AS-IS|       basis.  Anyone receiving this source is licensed under IBM|       copyrights to use it in any way he or she deems fit, including|       copying it, modifying it, compiling it, and redistributing it either|       with or without modifications.  No license under IBM patents or|       patent applications is to be implied by the copyright license.||       Any user of this software should understand that IBM cannot provide|       technical support for this software and will not be responsible for|       any consequences resulting from the use of this software.||       Any person who transfers this source code or any derivative work|       must include the IBM copyright notice, this paragraph, and the|       preceding two paragraphs in the transferred software.||       COPYRIGHT   I B M   CORPORATION 1998|       LICENSED MATERIAL  -  PROGRAM PROPERTY OF I B M+----------------------------------------------------------------------------*/////Comment: //  Software implementation of basic 2D graphics engine//Revision Log:   //  Jun/18/2002                                                  Created by YYD#include "os/os-types.h"#include "os/os-generic.h"#include "gfx_surface.h"#include "gfx_osi.h"#include "gfx_osi_engine.h"//#define  __GFX_OSI_G2D_DEBUG #ifdef __GFX_OSI_G2D_DEBUG    #define __DRV_DEBUG#endif#include "os/drv_debug.h"#ifndef NULL    // My local NULL definition    #define NULL ((void *)0)#endifGFX_PALETTE_T *__gfx_osi_g2d_select_palette(GFX_SURFACE_T *pSrc, GFX_SURFACE_T *pDes, GFX_PALETTE_T *pTempPal){    int i, numpal, k, steps;    GFX_PALETTE_T *pPal;    if(!IS_GFX_SURFACE_CLUT(pSrc->uPlaneConfig)) return NULL;    if(!pTempPal) return pSrc->pPalette;    if(!pSrc->pPalette)     // we need to create raw palette    {        numpal = 1<<pSrc->plane[0].uPixelSize;        steps = 255/(numpal-1);        for(i=0, k=0; i<numpal; i++, k+=steps)            pTempPal[i].a = pTempPal[i].r = pTempPal[i].g = pTempPal[i].b = k;        return pTempPal;    }    if(IS_GFX_SURFACE_YUV(pSrc->uPlaneConfig))    {        if(G2D_CLUT8 == GET_GFX_SURFACE_DATA_TYPE(pDes->uPlaneConfig) || IS_GFX_SURFACE_YUV(pDes->uPlaneConfig))            pPal = pSrc->pPalette;        else if(!IS_GFX_SURFACE_YUV(pDes->uPlaneConfig))        {            // yuv 2 rgb palette            pPal = pTempPal;            numpal = 1<<pSrc->plane[0].uPixelSize;            for(i=numpal-1; i>=0; i--)            {                gfx_osi_ycbcr2rgb(pSrc->pPalette[i].r, pSrc->pPalette[i].g, pSrc->pPalette[i].b,  &pPal[i].r, &pPal[i].g, &pPal[i].b);                pPal[i].a = pSrc->pPalette[i].a;            }        }    }    else  // rgb palette    {        if(IS_GFX_SURFACE_CLUT(pDes->uPlaneConfig) || !IS_GFX_SURFACE_YUV(pDes->uPlaneConfig))            pPal = pSrc->pPalette;        else        {            // yuv 2 rgb palette            pPal = pTempPal;            numpal = 1<<pSrc->plane[0].uPixelSize;            for(i=numpal-1; i>=0; i--)            {                gfx_osi_rgb2ycbcr(pSrc->pPalette[i].r, pSrc->pPalette[i].g, pSrc->pPalette[i].b,  &pPal[i].r, &pPal[i].g, &pPal[i].b);                pPal[i].a = pSrc->pPalette[i].a;            }        }    }    return pPal;}void __gfx_osi_g2d_fillblt8(BYTE *pdes,  INT bpldes, INT nDesX, INT nDesY,                UINT uWidth, UINT uHeight, UINT uFill){    int y;    pdes = pdes + nDesX + nDesY*bpldes;    for(y=0; y<uHeight; y++)    {        _OS_MEMSET(pdes, uFill, uWidth);        pdes += bpldes;    }}void __gfx_osi_g2d_fillblt32(BYTE *pdes,  INT bpldes, INT nDesX, INT nDesY,                UINT uWidth, UINT uHeight, UINT32 uFill){    UINT y;    pdes = pdes + (nDesX<<2) + nDesY*bpldes;    for(y=0; y<uHeight; y++)    {        register UINT32 *pBuf = (UINT32 *)pdes;        register UINT x;        for(x=0; x<uWidth; x++)            *(pBuf++) = uFill;        pdes += bpldes;    }}void __gfx_osi_g2d_fillblt1(BYTE *pdes,  INT bpldes, INT nDesX, INT nDesY,                UINT uWidth, UINT uHeight, UINT uFill){    UINT y, s;    register BYTE *pBuf;    pBuf = pdes + (nDesX>>3) + nDesY*bpldes;    if(uFill & 1) uFill = 0xff;    else uFill = 0;    s = nDesX & 0x07;    if(s || uWidth < 8) // start    {        register BYTE umsk, ufil;        if(uWidth + s >= 8)        {            umsk = 0xff << (8-s);            ufil = uFill & ~ umsk;            uWidth -= 8-s;        }        else        {            umsk = (0xff << (8-s)) | (0xff >> (s+uWidth));            ufil = uFill & ~ umsk;            uWidth = 0;        }        for(y=0; y<uHeight; y++)        {            *pBuf = (*pBuf & umsk) | ufil;            pBuf += bpldes;        }        nDesX += s;        pBuf = pdes + (nDesX>>3) + nDesY*bpldes;    }    s = uWidth&7;    if(s)   // tailing    {        register BYTE umsk, ufil;        umsk = 0xff >> s;        ufil = uFill & ~ umsk;        pBuf = pdes + uWidth/8;        for(y=0; y<uHeight; y++)        {            *pBuf = (*pBuf & umsk) | ufil;            pBuf += bpldes;        }        if(uWidth < 8)            return;        pBuf = pdes + (nDesX>>3) + nDesY*bpldes;    }    uWidth >>=3;    for(y=0; y<uHeight; y++)    {        _OS_MEMSET(pBuf, uFill, uWidth);        pBuf += bpldes;    }}void __gfx_osi_g2d_fillblt_uv(BYTE *pdes,  INT bpldes, INT nDesX, INT nDesY,                UINT uWidth, UINT uHeight, UINT uFill){    int y,x;    pdes = pdes + nDesX + nDesY*bpldes;    for(y=0; y<uHeight; y++)    {        UINT16 *puv = (UINT16 *)pdes;        for(x=0; x<uWidth; x+=2)        {            *(puv++) = uFill;        }        pdes += bpldes;    }}void __gfx_osi_g2d_maskflt8(BYTE *pdes,  INT bpldes, INT nDesX, INT nDesY,                UINT uWidth, UINT uHeight, BYTE *psrc, INT bplsrc, INT nSrcX,  INT nSrcY, UINT uForeGround){    UINT y;    register UINT x, s;    register BYTE *pBuf;    pBuf = psrc + (nSrcX>>3) + nSrcY*bplsrc;    pdes = pdes + nDesX + nDesY*bpldes;        for(y=0; y<uHeight; y++)    {        s = nSrcX&7;        for(x=0; x<uWidth; x++, s++)            if(pBuf[s>>3] & (0x80 >> (s&7)))                pdes[x] = uForeGround;        pBuf += bplsrc;        pdes += bpldes;    }}void __gfx_osi_g2d_maskflt32(BYTE *pdes,  INT bpldes, INT nDesX, INT nDesY,                UINT uWidth, UINT uHeight, BYTE *psrc, INT bplsrc, INT nSrcX,  INT nSrcY, UINT32 uForeGround){    UINT y;    register UINT x, s;    register BYTE *pBuf;    pBuf = psrc + (nSrcX>>3) + nSrcY*bplsrc;    pdes = pdes + (nDesX<<2) + nDesY*bpldes;        for(y=0; y<uHeight; y++)    {        register UINT32 *pDestBuf = (UINT32 *)pdes;        s = nSrcX&7;        for(x=0; x<uWidth; x++, s++)            if(pBuf[s>>3] & (0x80 >> (s&7)))                pDestBuf[x] = uForeGround;        pBuf += bplsrc;        pdes += bpldes;    }}void __gfx_osi_g2d_maskflt_uv(BYTE *pdes,  INT bpldes, INT nDesX, INT nDesY,                UINT uWidth, UINT uHeight, BYTE *psrc, INT bplsrc, INT nSrcX,  INT nSrcY, UINT uForeGround){    UINT y;    register UINT x, s;    register BYTE *pBuf;    BYTE uf, vf;    pBuf = psrc + (nSrcX>>3) + nSrcY*bplsrc;    pdes = pdes + nDesX + nDesY*bpldes;        uf = uForeGround>>8;    vf = uForeGround&0xff;    for(y=0; y<uHeight; y++)    {        s = nSrcX&7;        for(x=0; x<uWidth; x++, s++)        {            if(pBuf[s>>3] & (0x80 >> (s&7)))            {                if(x&1) // u                    pdes[x] =  uf;                else  // v                    pdes[x] = vf;            }        }        pBuf += bplsrc;        pdes += bpldes;    }}void __gfx_osi_g2d_bitblt8(BYTE *pdes,  INT bpldes, INT nDesX, INT nDesY,                UINT uWidth, UINT uHeight, BYTE *psrc, INT bplsrc, INT nSrcX,  INT nSrcY){    int y;    psrc = psrc + nSrcX + nSrcY*bplsrc;    pdes = pdes + nDesX + nDesY*bpldes;    for(y=0; y<uHeight; y++)    {        _OS_MEMCPY(pdes, psrc, uWidth);        psrc += bplsrc;        pdes += bpldes;    }}// uColor = 0/a, 1/r, 2/g, 3/bvoid __gfx_osi_g2d_bitblt_clut_8(BYTE *pdes,  INT bpldes, INT nDesX, INT nDesY,                UINT uWidth, UINT uHeight, BYTE *psrc, INT bplsrc, INT nSrcX,  INT nSrcY, GFX_PALETTE_T *pPal, UINT uColor){    int y, x;    psrc = psrc + nSrcX + nSrcY*bplsrc;    pdes = pdes + nDesX + nDesY*bpldes;    switch(uColor)    {    case 0:   // a        for(y=0; y<uHeight; y++)        {            for(x=0; x<uWidth; x++)            {                pdes[x] = pPal[psrc[x]].a;            }            psrc += bplsrc;            pdes += bpldes;        }        break;    case 1: // r        for(y=0; y<uHeight; y++)        {            for(x=0; x<uWidth; x++)            {                pdes[x] = pPal[psrc[x]].r;            }            psrc += bplsrc;            pdes += bpldes;        }        break;    case 2: // g        for(y=0; y<uHeight; y++)        {            for(x=0; x<uWidth; x++)            {                pdes[x] = pPal[psrc[x]].g;            }            psrc += bplsrc;            pdes += bpldes;        }        break;    case 3: // b        for(y=0; y<uHeight; y++)        {            for(x=0; x<uWidth; x++)            {                pdes[x] = pPal[psrc[x]].b;            }            psrc += bplsrc;            pdes += bpldes;        }        break;    default:        break;    }}void __gfx_osi_g2d_bitblt_clut_uv(BYTE *pdes,  INT bpldes, INT nDesX, INT nDesY,                UINT uWidth, UINT uHeight, BYTE *psrc, INT bplsrc, INT nSrcX,  INT nSrcY, GFX_PALETTE_T *pPal){    int y, x;    psrc = psrc + nSrcX + nSrcY*bplsrc;    pdes = pdes + nDesX + nDesY*bpldes;    for(y=0; y<uHeight; y++)    {        for(x=0; x<uWidth; x+=2)        {            // instead of averaging, we  choose one color components from each pixel in pairs            pdes[x  ] = pPal[psrc[x  ]].g;  // u            pdes[x+1] = pPal[psrc[x+1]].b;  // v        }        psrc += bplsrc;        pdes += bpldes;    }}void __gfx_osi_g2d_bitblt_1_8(BYTE *pdes,  INT bpldes, INT nDesX, INT nDesY,                UINT uWidth, UINT uHeight, BYTE *psrc, INT bplsrc, INT nSrcX,  INT nSrcY, UINT uForeGround, UINT uBackGround){    UINT y;    register UINT x, s;    register BYTE *pBuf;    pBuf = psrc + (nSrcX>>3) + nSrcY*bplsrc;    pdes = pdes + nDesX + nDesY*bpldes;        PDEBUGE("1bit SrcX = %d, Y = %d, W = %d, H= %d, bpl=%d, s=%d\n", nSrcX, nSrcY, uWidth, uHeight, bplsrc, s);    for(y=0; y<uHeight; y++)    {        s = nSrcX&7;        for(x=0; x<uWidth; x++, s++)            pdes[x] = (pBuf[s>>3] & (0x80 >> (s&7))) ? uForeGround : uBackGround;        pBuf += bplsrc;        pdes += bpldes;    }}void __gfx_osi_g2d_bitblt_1_32(BYTE *pdes,  INT bpldes, INT nDesX, INT nDesY,                UINT uWidth, UINT uHeight, BYTE *psrc, INT bplsrc, INT nSrcX,  INT nSrcY, UINT32 uForeGround, UINT32 uBackGround){    UINT y;    register UINT x, s;    register BYTE *pBuf;    pBuf = psrc + (nSrcX>>3) + nSrcY*bplsrc;    pdes = pdes + (nDesX<<2) + nDesY*bpldes;        for(y=0; y<uHeight; y++)    {        register UINT32 *pDestBuf = (UINT32 *)pdes;        s = nSrcX&7;        for(x=0; x<uWidth; x++, s++)            pDestBuf[x] = (pBuf[s>>3] & (0x80 >> (s&7))) ? uForeGround : uBackGround;        pBuf += bplsrc;        pdes += bpldes;    }}void __gfx_osi_g2d_bitblt_1_uv(BYTE *pdes,  INT bpldes, INT nDesX, INT nDesY,                UINT uWidth, UINT uHeight, BYTE *psrc, INT bplsrc, INT nSrcX,  INT nSrcY, UINT uForeGround, UINT uBackGround){    UINT y;    register UINT x, s;    register BYTE *pBuf;    BYTE uf, vf, ub, vb;    pBuf = psrc + (nSrcX>>3) + nSrcY*bplsrc;    pdes = pdes + nDesX + nDesY*bpldes;        uf = uForeGround>>8;    vf = uForeGround&0xff;    ub = uBackGround>>8;    vb = uBackGround&0xff;    for(y=0; y<uHeight; y++)    {        s = nSrcX&7;        for(x=0; x<uWidth; x++, s++)        {            if(x&1) // u                pdes[x] = (pBuf[s>>3] & (0x80 >> (s&7))) ? uf : ub;            else  // v

⌨️ 快捷键说明

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