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

📄 blt.cpp

📁 WinCE 3.0 BSP, 包含Inter SA1110, Intel_815E, Advantech_PCM9574 等
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/*
 * $Workfile: BLT.CPP $
 * $Revision: 15 $
 * $Date: 4/07/00 8:48a $
 * $Modtime: 4/07/00 8:39a $
 * $Author: Sarma $
 *
 * This module performs the hardware acceleration for various BLT operations.
 * The basic structure of the BLT handler was taken from Microsoft sample
 * driver code.
 *
 * Copyright (c) 1998 National Semiconductor Corporation.
 * All Rights Reserved.
 *
 * This software is the confidential and proprietary information of National 
 * Semiconductor Corporation. ("Confidential Information").
 * You shall not disclose such Confidential Information and shall use it only
 * in accordance with the terms of the license agreement you entered into
 * with National Semiconductor Corporation.
 * This code is supplied as is.
 *
 */

/*
 *$Log: /CE/Platform/Nsc/Drivers/Video/gxvideo/base/BLT.CPP $
 * 
 * 15    4/07/00 8:48a Sarma
 * Removed Cyrix Corporation from the legal/confidentail information.
 * 
 * 14    4/06/00 4:09p Sarma
 * Removed personal messages.
 * 
 * 13    4/06/00 3:41p Sarma
 * Added Scr2Scr and Bmp2Scr Transparency blt, only when Durango interface
 * is being used. The rendering function is provided by Durango and not
 * present in the base driver. Bmp2Scr has relatil messages enabled so
 * that we can see when used, no ap seen using it currently. IT MAY NOT
 * WORK ALSO.
 * 
 * 12    4/06/00 10:33a Hari
 * Removed all Debug messages.
 * Added gfx_set_color_pattern functin for color patterns
 * 
 * 11    3/29/00 9:09a Sarma
 * Added durango interface for rendering.
 * 
 * 10    7/20/99 2:12p Sarma
 * Enabled MaskCopy, and replaced the old logic with a new working one.
 * 
 * 9     12/29/98 11:43a Sarma
 * AcceleratedWxHPatternFill has some problem in ver 2.0, behavior is not
 * known but works fine in ver 2.1.
 * 
 * 8     12/10/98 11:30a Sarma
 * Take the mod (%) of the pattern height and pattern width to arrive at
 * the right pattern location.
 * 
 * 7     12/02/98 5:24p Sarma
 * brush parameters need to be signed in patternfill.
 * 
 * 6     12/02/98 1:51p Sarma
 * converted 16 bit multiple writes into 32 bit writes.
 * 
 * 5     12/01/98 1:09p Sarma
 * Added few more debug statements.
 * 
 * 4     11/25/98 3:15p Sarma
 * AcceleratedWxHPatternFill can handle only pattern copy as here we
 * convert pattern->dest into source->dest.
 * 
 * 3     11/25/98 10:00a Sarma
 * For bitmaps with 1, 2, 4 bit depth's the start offset may end up in an
 * offset within a byte in which case we need to skip that many bits. This
 * was missed out earlier and is been fixed now.
 *$History: BLT.CPP $
 * 
 * *****************  Version 15  *****************
 * User: Sarma        Date: 4/07/00    Time: 8:48a
 * Updated in $/CE/Platform/Nsc/Drivers/Video/gxvideo/base
 * Removed Cyrix Corporation from the legal/confidentail information.
 * 
 * *****************  Version 14  *****************
 * User: Sarma        Date: 4/06/00    Time: 4:09p
 * Updated in $/CE/Platform/Nsc/Drivers/Video/gxvideo/base
 * Removed personal messages.
 * 
 * *****************  Version 13  *****************
 * User: Sarma        Date: 4/06/00    Time: 3:41p
 * Updated in $/CE/Platform/Nsc/Drivers/Video/gxvideo/base
 * Added Scr2Scr and Bmp2Scr Transparency blt, only when Durango interface
 * is being used. The rendering function is provided by Durango and not
 * present in the base driver. Bmp2Scr has relatil messages enabled so
 * that we can see when used, no ap seen using it currently. IT MAY NOT
 * WORK ALSO.
 * 
 * *****************  Version 12  *****************
 * User: Hari         Date: 4/06/00    Time: 10:33a
 * Updated in $/CE/Platform/Nsc/Drivers/Video/gxvideo/base
 * Removed all Debug messages.
 * Added gfx_set_color_pattern functin for color patterns
 * 
 * *****************  Version 11  *****************
 * User: Sarma        Date: 3/29/00    Time: 9:09a
 * Updated in $/CE/Platform/Nsc/Drivers/Video/gxvideo/base
 * Added durango interface for rendering.
 * 
 * *****************  Version 10  *****************
 * User: Sarma        Date: 7/20/99    Time: 2:12p
 * Updated in $/wince/v2.1/gxvideo
 * Enabled MaskCopy, and replaced the old logic with a new working one.
 * 
 * *****************  Version 9  *****************
 * User: Sarma        Date: 12/29/98   Time: 11:43a
 * Updated in $/wince/v2.1/gxvideo
 * AcceleratedWxHPatternFill has some problem in ver 2.0, behavior is not
 * known but works fine in ver 2.1.
 * 
 * *****************  Version 8  *****************
 * User: Sarma        Date: 12/10/98   Time: 11:30a
 * Updated in $/wince/v2.1/gxvideo
 * Take the mod (%) of the pattern height and pattern width to arrive at
 * the right pattern location.
 * 
 * *****************  Version 7  *****************
 * User: Sarma        Date: 12/02/98   Time: 5:24p
 * Updated in $/wince/v2.1/gxvideo
 * brush parameters need to be signed in patternfill.
 * 
 * *****************  Version 6  *****************
 * User: Sarma        Date: 12/02/98   Time: 1:51p
 * Updated in $/wince/v2.1/gxvideo
 * converted 16 bit multiple writes into 32 bit writes.
 * 
 * *****************  Version 5  *****************
 * User: Sarma        Date: 12/01/98   Time: 1:09p
 * Updated in $/wince/v2.1/gxvideo
 * Added few more debug statements.
 * 
 * *****************  Version 4  *****************
 * User: Sarma        Date: 11/25/98   Time: 3:15p
 * Updated in $/wince/v2.1/gxvideo
 * AcceleratedWxHPatternFill can handle only pattern copy as here we
 * convert pattern->dest into source->dest.
 * 
 * *****************  Version 3  *****************
 * User: Sarma        Date: 11/25/98   Time: 10:00a
 * Updated in $/wince/v2.1/gxvideo
 * For bitmaps with 1, 2, 4 bit depth's the start offset may end up in an
 * offset within a byte in which case we need to skip that many bits. This
 * was missed out earlier and is been fixed now.
*/

#include "precomp.h"
#ifdef DURANGO
#include "gfx_rtns.h" //Durango includes
#endif

#define ToggleMode(mode)	((mode) = ((mode)) ? 0 : 1)

//Enable this to execute all the not supported paths too
#define CHECK_ALL 0


//----------------------------------------------------------------------------
// BltPrepare
//
// This routine is called to perform a BLT operation.
//----------------------------------------------------------------------------

SCODE GxVideo::BltPrepare(GPEBltParms *pBltParms )
{
	EGPEFormat format;
	unsigned short rop = (unsigned short)pBltParms->rop4 & 0xFFFF;

	DEBUGMSG(0,(TEXT("GxVideo::BltPrepare rop4: 0x%04x\n"), pBltParms->rop4 ));
#if 0
	DEBUGMSG(0,(TEXT("Dest Format: %d, Dest Rect: t:%d,l:%d,b:%d,r:%d Dest GPESurf 0x%08x\r\n"),
		(int)pBltParms->pDst->Format(),
		pBltParms->prclDst->top,
		pBltParms->prclDst->left,
		pBltParms->prclDst->bottom,
		pBltParms->prclDst->right,
		pBltParms->pDst ));
	if( pBltParms->prclSrc && pBltParms->pSrc )
	{
		DEBUGMSG(0,(TEXT("Src format: %d, Src Rect: %d,%d,%d,%d Src GPESurf 0x%08x\n"),
			(int)pBltParms->pSrc->Format(),
			pBltParms->prclSrc->top,
			pBltParms->prclSrc->left,
			pBltParms->prclSrc->bottom,
			pBltParms->prclSrc->right,
			pBltParms->pSrc ));
	}

	DEBUGMSG(0,(TEXT("Blt preparation phase\n")));
	DEBUGWAIT(0)
#endif

	pBltParms->pBlt = EmulatedBlt; // catch all

//
// Acceleration goes here...
//

#ifdef ENABLE_ACCELERATION

	// CHECK IF DESTINATION IS VIDEO MEMORY
	// Otherwise acceleration cannot be used.

	if(!pBltParms->pDst->InVideoMemory())
		return S_OK;

	// CHECK IF STRETCH BLT
	// No hardware acceleration for GX, may be a request for MXi.

	if (pBltParms->bltFlags & BLT_STRETCH)
	{
		// STRETCH BLT
		DEBUGMSG(0,(TEXT("Stretch Blt!\n")));
		return S_OK;
	}

	// DETERMINE ACTION BASED ON RASTER OPERATION

	DEBUGMSG(0,(TEXT("ROP %X\n"),rop));

	switch( rop )
	{
	case 0x0000:	// BLACKNESS
		DEBUGMSG(0,(TEXT("GxVideo::Blt - BLACKNESS\n")));
		pBltParms->pBlt = (SCODE (GPE::*)(struct GPEBltParms *))AcceleratedFillRect;
		return S_OK;

	case 0xFFFF:	// WHITENESS
		DEBUGMSG(0,(TEXT("GxVideo::Blt - WHITENESS\n")));
		pBltParms->pBlt = (SCODE (GPE::*)(struct GPEBltParms *))AcceleratedFillRect;
		return S_OK;

	case 0xF0F0:	// PATCOPY

		DEBUGMSG(0,(TEXT("GxVideo::Blt - PATCOPY\n")));

		// CHECK IF PATTERN DATA OR SOLID COLOR
		if( pBltParms->solidColor == -1 )
		{
			DEBUGMSG(0,(TEXT("GxVideo::Blt - PATCOPY - patterned brush\n")));
			// PATTERN FILL	(NOT A SOLID COLOR) CAN HADLE 1,8 AND 16 BIT DEPTH ONLY

			//CHECK TO SEE IF THE POINTER IS VALID
			if(!pBltParms->pBrush)
				return S_OK;
 
			format = pBltParms->pBrush->Format();

			DEBUGMSG(0,(TEXT("Pat format1 = %d %X %X %X\n"),
					format,pBltParms->pLookup, pBltParms->pConvert, pBltParms->pColorConverter));

			//GX NEEDS ALL THE PATTERN TO BE OF 8x8 PATTERNS ONLY
			if((pBltParms->pBrush->Width() != 8) ||
				(pBltParms->pBrush->Height() != 8))
			{
				DEBUGMSG(0,(TEXT("GxVideo::Blt - PATCOPY - width , height !=8 \n")));
				//pBltParms->pBlt = (SCODE (GPE::*)(struct GPEBltParms *))AcceleratedWxHPatternFill;
				return S_OK;
			}

			if ((((format == gpe8Bpp) && (Display_BPP == 8)) ||
					((format == gpe16Bpp) && (Display_BPP == 16))) &&
					// CHECK IF COLOR TRANSLATION
					(!(pBltParms->pLookup || pBltParms->pConvert)))
			{
				DEBUGMSG(0,(TEXT("GxVideo::Blt - PATCOPY - Color\n")));

				pBltParms->pBlt = (SCODE (GPE::*)(struct GPEBltParms *))AcceleratedPatternFill;
				return S_OK;
			} 
			//Handle Color Translations Here
			else if (pBltParms->pLookup || pBltParms->pConvert || pBltParms->pColorConverter)
			{
				DEBUGMSG(0,(TEXT("GxVideo::Blt - PATCOPY With Lookup\n")));
				//pBltParms->pBlt = (SCODE (GPE::*)(struct GPEBltParms *))AcceleratedPatternLookupFill;
				return S_OK;
			}
            else if (format == gpe1Bpp)
			{
			DEBUGMSG(0,(TEXT("GxVideo::Blt - PATCOPY - gpe1Bpp\n")));
//			pBltParms->pBlt = (SCODE (GPE::*)(struct GPEBltParms *))AcceleratedPatternFill;
			} 
#if CHEACK_ALL
			else 
			{
				DEBUGMSG(0,(TEXT("GxVideo::Blt - PATCOPY - Unknown\n")));
			}
#endif
		}
		else
		{
			// NORMAL SOLID RECTANGLE FILL
			
			DEBUGMSG(0,(TEXT("GxVideo::Blt - PATCOPY - solid brush\n")));
			SelectSolidColor(GetBltSolidColor(pBltParms));
			pBltParms->pBlt = (SCODE (GPE::*)(struct GPEBltParms *))AcceleratedFillRect;
			return S_OK;
		}
		break;

	case 0xCCCC:	// SRCCOPY

		// CHECK IF VIDEO MEMORY IS THE SOURCE

		if(pBltParms->pSrc->InVideoMemory())
		{
			// SCREEN TO SCREEN BLT
			// Can't perform color translations in hardware.

			if (pBltParms->pLookup || pBltParms->pConvert)
				return S_OK;

			// CHECK IF TRANSPERENT 
			// GX can handle transparency with a strange workaround.  Can add this 
			// later if deemed important.  MXi has a separate request for transparency.

			if( pBltParms->bltFlags & BLT_TRANSPARENT )
			{
				// TRANSPARENT BLT
				// Transparent BLTs do not appear to be used.  It is possible 
				// that a capabilities flag must be set so that the icons use 
				// this functionality.
				// If this is to be added, refer to the Win95 DirectDraw driver
				// source code for an example of how to implement it.  The 
				// transparent color must be loaded into BB1 and the ROP is C6.

#ifndef DURANGO
				DEBUGMSG(0,(TEXT("Transparent Blt!\n")));
// pBltParms->pBlt = (SCODE (GPE::*)(struct GPEBltParms *))AcceleratedRedFill; //SAS
				return S_OK;
#endif
			}

			// FINALLY GOT TO THE NORMAL SCREEN TO SCREEN BLT CASE

			pBltParms->pBlt = (SCODE (GPE::*)(struct GPEBltParms *))AcceleratedSrcCopyBlt;
			return S_OK;
		}
		else
		{
			format = pBltParms->pSrc->Format();
			// CHECK IF MONOCHROME DATA

            if (format == gpe1Bpp)
			{
				// MONOCHROME SYSTEM MEMORY TO SCREEN BLT
				// This does not appear to be used.  Text uses the ROP of 
				// 0xAAF0 instead. 

				// CHECK TO SEE IF TOO LARGE FOR THE BLT BUFFERS
				// Eventually, the AcceleratedBitmapScreenBlt routine 
				// should be able to handle this case (split the  
				// scanlines as needed).  It doesn't yet.

				//SINCE THIS BEING A STRAIGHT COPY WE CAN USE BB0 AND BB1.
				if ((pBltParms->prclDst->right - pBltParms->prclDst->left) <= (int) (BB0_Size_Pixels << 1))
				{
					pBltParms->pBlt = (SCODE (GPE::*)(struct GPEBltParms *))AcceleratedBitmapScreenBlt;
					return S_OK;
				}
#if CHEACK_ALL
				else
				{
					DEBUGMSG(0,(TEXT("GxVideo::Blt - Mono SRCCOPY > BB0\n")));
				}
#endif
			}
			else
			{
				// COLOR SYSTEM MEMORY TO SCREEN BLT
				// For GX, there is no good hardware acceleration for the 
				// "copy" case.  Loading the data into the BLT buffer and 
				// then rendering it to the screen is actually slower than 
				// just putting the data there directly.  Therefore, let
				// the EmulatedBlt code do that.
				DEBUGMSG(0,(TEXT("Blt format1 = %d %X %X %X\n"),
					format,pBltParms->pLookup, pBltParms->pConvert,pBltParms->pColorConverter));

				if ((((format == gpe8Bpp) && (Display_BPP == 8)) ||
					((format == gpe16Bpp) && (Display_BPP == 16))) &&
					// CHECK FOR NO COLOR TRANSLATION
					(!(pBltParms->pLookup || pBltParms->pConvert)))
				{
					// CHECK TO SEE IF TOO LARGE FOR THE BLT BUFFERS

					//SINCE THIS BEING A STRAIGHT COPY WE CAN USE BB0 AND BB1.
					if ((pBltParms->prclDst->right - pBltParms->prclDst->left) <= (int) (BB0_Size_Pixels << 1))
					{
						pBltParms->pBlt = (SCODE (GPE::*)(struct GPEBltParms *))AcceleratedBitmapScreenBlt;
						return S_OK;
					} 
#if CHEACK_ALL
					else

⌨️ 快捷键说明

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