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

📄 wince_ws.c

📁 Lido PXA270平台开发板的最新BSP,包括源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
	if(surface->u.window.ws.ui8BackBuffers)
	{
		PVRSRVFreeDeviceMem (&surface->pvrsrv_context->s3D,surface->u.window.ws.apsSurfaces[1]);
	}
	else
	{
		return EGL_SUCCESS;		
	}
	if(surface->u.window.ws.ui8BackBuffers>1)
	{
		PVRSRVFreeDeviceMem (&surface->pvrsrv_context->s3D,surface->u.window.ws.apsSurfaces[2]);
	}

	surface->u.window.ws.psPrimary_surface	 = 		dpy->ws.psPrimary_surface;
	psCurrentRenderSurface->ui32PixelWidth 	 =		dpy->ws.psPrimary_surface->ui32PixelWidth;
	psCurrentRenderSurface->ui32PixelHeight 	 =		dpy->ws.psPrimary_surface->ui32PixelHeight;
	psCurrentRenderSurface->ePixelFormat 	 =		dpy->ws.psPrimary_surface->ePixelFormat;
	psCurrentRenderSurface->ui32ByteStride 	 =		dpy->ws.psPrimary_surface->ui32ByteStride;

	pt.x = 0;
	pt.y = 0;
	ClientToScreen( hWnd, &pt );
	surface->u.window.ws.n32XPos = pt.x;
	surface->u.window.ws.n32YPos = pt.y;
	GetClientRect(hWnd,&rc);
	pt.x=rc.right;
	pt.y=rc.bottom;
	ClientToScreen( hWnd, &pt );
	surface->u.window.ws.ui32Width			= pt.x-surface->u.window.ws.n32XPos;
	surface->u.window.ws.ui32Height			= pt.y-surface->u.window.ws.n32YPos;

	RotateWindowCoordinates(&surface->u.window.ws);

	psCurrentRenderSurface->ui32PixelWidth		= surface->u.window.ws.ui32Width;
	psCurrentRenderSurface->ui32PixelHeight 	= surface->u.window.ws.ui32Height;

	switch(psCurrentRenderSurface->ePixelFormat)
	{
	case PVRSRV_PIXEL_FORMAT_ARGB8888:
		/* The 3D core has a texture stride alignment restriction of 8 pixel units = 32 bytes */
		psCurrentRenderSurface->ui32ByteStride = ((psCurrentRenderSurface->ui32PixelWidth * 4 ) + 0x1F) & 0xFFFFFFE0;
		break;
	case PVRSRV_PIXEL_FORMAT_RGB565:
		/* The 3D core has a texture stride alignment restriction of 8 pixel units = 16 bytes */
		psCurrentRenderSurface->ui32ByteStride = ((psCurrentRenderSurface->ui32PixelWidth * 2 ) + 0x0F) & 0xFFFFFFF0;
		break;
	default:
		// we don't know about any other kind of window surfaces so go away!
		return EGL_BAD_ALLOC;
	}


	if((psCurrentRenderSurface->ui32PixelWidth==surface->u.window.ws.psPrimary_surface->ui32PixelWidth) &&
		(psCurrentRenderSurface->ui32PixelHeight==surface->u.window.ws.psPrimary_surface->ui32PixelHeight) &&
		(psCurrentRenderSurface->ui32ByteStride==surface->u.window.ws.psPrimary_surface->ui32ByteStride))
	{
		ui32Flags=PVRSRV_MEMFLG_FLIPPABLE;
	}


	if(surface->u.window.ws.ui8BackBuffers)
	{

		if (PVRSRVAllocDeviceMem (&surface->pvrsrv_context->s3D,
			ui32Flags,
			psCurrentRenderSurface->ui32ByteStride
			* psCurrentRenderSurface->ui32PixelHeight,
			MBX1_MINIMUM_RENDER_TARGET_ALIGNMENT,
			&surface->u.window.ws.apsSurfaces[1]) != PVRSRV_OK)
		{
			return EGL_BAD_ALLOC;
		}
	}
	if(surface->u.window.ws.ui8BackBuffers>1)
	{	
		if (PVRSRVAllocDeviceMem (&surface->pvrsrv_context->s3D,
			ui32Flags,
			psCurrentRenderSurface->ui32ByteStride
			* psCurrentRenderSurface->ui32PixelHeight,
			MBX1_MINIMUM_RENDER_TARGET_ALIGNMENT,
			&surface->u.window.ws.apsSurfaces[2]) != PVRSRV_OK)

		{
			surface->u.window.ws.ui8BackBuffers=1;
		}
	}

	if(surface->u.window.ws.ui8BackBuffers)
		surface->u.window.ws.ui32NextDisplaySurface=1;
	else
		surface->u.window.ws.ui32NextDisplaySurface=0;

	psCurrentRenderSurface->psMemInfo=surface->u.window.ws.apsSurfaces[surface->u.window.ws.ui32NextDisplaySurface];

	return EGL_SUCCESS;

}




/*****************************************************************************
 FUNCTION	: 	GetRotationAngle
    
 DESCRIPTION: 	Returns the Current rotation angle of the Window system 			 
 PARAMETERS	: 	
 RETURNS	: 	0,90,270,180
*****************************************************************************/
IMG_UINT32 GetRotationAngle()
{
	IMG_UINT32 ui32Angle=0;
	HDC hDC;

	hDC = GetDC(NULL);

	ExtEscape( 
		hDC,            // HDC hdc, 
		DRVESC_GET_PHYS_ROTATION,             // int nEscape, 
		0,                      // in cbOutput, 
		NULL,                    // LPSTR lpszOutData
		sizeof(PDWORD),                      // int cbInput, 
		(LPSTR)&ui32Angle                   // LPCSTR lpszInData,
		);

	ReleaseDC(NULL, hDC);

	switch(ui32Angle)
	{
	case DMDO_0:
		// do nothing.
	default:
		break;
	case DMDO_90:
		ui32Angle=90;
		break;
	case DMDO_180:
		ui32Angle=180;
		break;
	case DMDO_270:
		ui32Angle=270;
		break;
	}
	return ui32Angle;
}


//#define DISPLAYMESSAGES


/*****************************************************************************
 FUNCTION	: 	KEGLWndProc
    
 DESCRIPTION: 	WndProc function which handles window changes, then passes the message 
 				Onto a programs own WndProc 			 
 PARAMETERS	: 	HWND hWnd , UINT Msg, WPARAM wParam, LPARAM lParam)
 				

 RETURNS	: 	Result of Applications WndProc
*****************************************************************************/
LRESULT CALLBACK	KEGLWndProc(HWND hWnd , UINT Msg, WPARAM wParam, LPARAM lParam)
{
	TLS tls = EGLGetTLSValue ();
	POINT pt;
	RECT rc;
	KEGL_SURFACE *psSurface;
	IMG_UINT32 i32Result=0;
	IMG_UINT32 ui32Timeout=100000;
	int xPos,yPos,cX,cY;
	MONITORINFO sMInfo;
	HMONITOR hMonitor;
#ifdef DISPLAYMESSAGES
	LPVOID lpMsgBuf;
	WORD szMessageBuf[256];
#endif
	/* Here we want to handle any movement etc then pass the message along */

	psSurface=_FindWindowSurface(&tls->dpys[0],hWnd);

	if(psSurface&&(!psSurface->u.window.ws.bSecondaryExternalFullScreen))
	{
 		PVRSRV_SURF *psCurrentRenderSurface = &psSurface->sCurrentRenderSurface;
		switch (Msg)
		{
		case WM_MOVE:
			psSurface->u.window.ws.ui32RotationAngle=GetRotationAngle();
			pt.x = 0;
			pt.y = 0;
			ClientToScreen( hWnd, &pt );
			xPos=pt.x;
			yPos=pt.y;

			psSurface->u.window.ws.sWindowRect.i32Top = pt.y;
			psSurface->u.window.ws.sWindowRect.i32Left= pt.x;

			psSurface->u.window.ws.n32XPos = pt.x;
			psSurface->u.window.ws.n32YPos = pt.y;
			GetClientRect(hWnd,&rc);
			pt.x=rc.right;
			pt.y=rc.bottom;
			cX=rc.right;
			cY=rc.bottom;
			ClientToScreen( hWnd, &pt );
			psSurface->u.window.ws.ui32Width			= pt.x-psSurface->u.window.ws.n32XPos;
			psSurface->u.window.ws.ui32Height			= pt.y-psSurface->u.window.ws.n32YPos;

			psSurface->u.window.ws.sWindowRect.i32Bottom= pt.y;
			psSurface->u.window.ws.sWindowRect.i32Right= pt.x;

			RotateWindowCoordinates(&psSurface->u.window.ws);

			psCurrentRenderSurface->ui32PixelWidth	= psSurface->u.window.ws.ui32Width;
			psCurrentRenderSurface->ui32PixelHeight = psSurface->u.window.ws.ui32Height;


			PVRSRVFlushQueue(psSurface->psQueueInfo);
			if(psSurface->u.window.ws.hShadowWnd)
			{
				SetWindowPos(psSurface->u.window.ws.hShadowWnd,hWnd,xPos,yPos,cX,cY,SWP_NOACTIVATE);
			}
			psSurface->u.window.ws.bPosChanged=TRUE;
			break;
		case WM_SIZE:
			psSurface->u.window.ws.ui32RotationAngle=GetRotationAngle();
			UpdateSurfaceSize(&tls->dpys[0], psSurface, hWnd);
			pt.x = 0;
			pt.y = 0;
			ClientToScreen( hWnd, &pt );
			xPos=pt.x;
			yPos=pt.y;
			psSurface->u.window.ws.sWindowRect.i32Top = pt.y;
			psSurface->u.window.ws.sWindowRect.i32Left= pt.x;
			GetClientRect(hWnd,&rc);
			pt.x=rc.right;
			pt.y=rc.bottom;
			cX=rc.right;
			cY=rc.bottom;
			ClientToScreen( hWnd, &pt );
			psSurface->u.window.ws.sWindowRect.i32Bottom= pt.y;
			psSurface->u.window.ws.sWindowRect.i32Right= pt.x;
			PVRSRVFlushQueue(psSurface->psQueueInfo);
			psSurface->u.window.ws.bPosChanged=TRUE;
			if(psSurface->u.window.ws.hShadowWnd)
			{
				SetWindowPos(psSurface->u.window.ws.hShadowWnd,hWnd,xPos,yPos,cX,cY,SWP_NOACTIVATE);
			}
			break;
		case WM_SETTINGCHANGE:
			switch(wParam)
			{
			case SPI_SETWORKAREA:
				psSurface->u.window.ws.ui32RotationAngle=GetRotationAngle();
				UpdateSurfaceSize(&tls->dpys[0], psSurface, hWnd);
				pt.x = 0;
				pt.y = 0;
				ClientToScreen( hWnd, &pt );
				xPos=pt.x;
				yPos=pt.y;
				psSurface->u.window.ws.sWindowRect.i32Top = pt.y;
				psSurface->u.window.ws.sWindowRect.i32Left= pt.x;
				GetClientRect(hWnd,&rc);
				pt.x=rc.right;
				pt.y=rc.bottom;
				cX=rc.right;
				cY=rc.bottom;
				ClientToScreen( hWnd, &pt );
				psSurface->u.window.ws.sWindowRect.i32Bottom= pt.y;
				psSurface->u.window.ws.sWindowRect.i32Right= pt.x;
				PVRSRVFlushQueue(psSurface->psQueueInfo);
				psSurface->u.window.ws.bPosChanged=TRUE;
				hMonitor= MonitorFromWindow(psSurface->u.window.ws.hShadowWnd,MONITOR_DEFAULTTOPRIMARY);

				sMInfo.cbSize=sizeof(sMInfo);
				GetMonitorInfo(hMonitor,  &sMInfo );
				if(psSurface->u.window.ws.hShadowWnd)
				{
					SetWindowPos(psSurface->u.window.ws.hShadowWnd,HWND_TOP,sMInfo.rcMonitor.left,sMInfo.rcMonitor.top,sMInfo.rcMonitor.right-sMInfo.rcMonitor.left,sMInfo.rcMonitor.bottom-sMInfo.rcMonitor.top,SWP_NOACTIVATE);
					SetWindowPos(psSurface->u.window.ws.hShadowWnd,hWnd,xPos,yPos,cX,cY,SWP_NOACTIVATE);
				}
				break;
			}
			break;

	#ifdef DISPLAYMESSAGES
		default:
			wsprintf(szMessageBuf,TEXT("MSG=0x%x"),Msg);
			OutputDebugString(szMessageBuf);
			break;
	#endif


		}
	}
	if( psSurface)
	{
		if(psSurface->u.window.ws.WndProc)
		{
			i32Result = CallWindowProc( (WNDPROC) psSurface->u.window.ws.WndProc,   hWnd,  Msg,  wParam,  lParam );
		}
	}

	return i32Result;
}


/*****************************************************************************
 FUNCTION	: 	SetupShadowWindow
    
 DESCRIPTION: 	Creates a Shadow window behind our rendering window, used to cause windows to redraw behind the window when we move
 PARAMETERS	: 	surface :  A pointer to the surface that we are shadowing
 				
 RETURNS	: 	0
*****************************************************************************/
IMG_UINT32 SetupShadowWindow(KEGL_SURFACE *surface)
{
	HINSTANCE hInstance=GetModuleHandle(NULL);
	POINT ptTopLeft;
	RECT	rc;

	MyRegisterClass(hInstance);
	ptTopLeft.x = 0;
	ptTopLeft.y = 0;
	ClientToScreen( (HWND)surface->u.window.native  , &ptTopLeft );
	GetClientRect( (HWND)surface->u.window.native  ,&rc);

	surface->u.window.ws.hShadowWnd = (void*) CreateWindowEx(WS_EX_TOPMOST|WS_EX_NOANIMATION,TEXT("ShadowWindow"), NULL, WS_VISIBLE,
		ptTopLeft.x, ptTopLeft.y, 	rc.right, rc.bottom, NULL, NULL, hInstance, NULL);


	ShowWindow(surface->u.window.ws.hShadowWnd, 1);
	UpdateWindow(surface->u.window.ws.hShadowWnd);
	SetWindowPos(surface->u.window.ws.hShadowWnd,(HWND)surface->u.window.native,ptTopLeft.x,ptTopLeft.y,rc.right, rc.bottom,SWP_NOACTIVATE);

	return 0;
}




/*****************************************************************************
 FUNCTION	: 	MyRegisterClass
    
 DESCRIPTION: 	Registers the ShadowWindow class for this instance
 PARAMETERS	: 	HINSTACNE hInstance
 				
 RETURNS	: 	The registers class structure
*****************************************************************************/
ATOM MyRegisterClass(HINSTANCE hInstance)
{
	WNDCLASS wc;

	wc.style = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc = (WNDPROC) ShadowWndProc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = hInstance;
	wc.hIcon = 0;
	wc.hCursor = 0;
	wc.lpszMenuName = 0;
	//	wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
	wc.hbrBackground = NULL;
	wc.lpszClassName = TEXT("ShadowWindow");

	return RegisterClass(&wc);
}



/*****************************************************************************
 FUNCTION	: 	ShadowWndProc
    
 DESCRIPTION: 	Dummy WndProc function used by the shadow window 			 
 PARAMETERS	: 	HWND hWnd , UINT Msg, WPARAM wParam, LPARAM lParam)
 				

 RETURNS	: 	Result of Applications WndProc
*****************************************************************************/
LRESULT CALLBACK ShadowWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	PAINTSTRUCT ps;
	HDC hdc;
	switch (message)
	{
	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);
		EndPaint(hWnd, &ps);
		break;
	case WM_DESTROY:
		// Don't post a quit message because this thread is not quitting!
		//			PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}



/*****************************************************************************
 FUNCTION	: 	DoClipping
    
 DESCRIPTION: 	Create a list of blit regions by checking which windows are above us
				in the Z order, adding them to a list of exclusion rectangles, and then calling a funcion to 
				work out the clip list.
 PARAMETERS	: 	NativeWindowType NativeWindow
				KEGL_SURFACE *psSurface

 RETURNS	: 	IMG_TRUE if the clip list has changed since we were last called
*****************************************************************************/
IMG_BOOL DoClipping (NativeWindowType NativeWindow,KEGL_SURFACE *psSurface)
{
	HWND hwCur;
	HWND hWnd;
	static int doit=1;
	DWORD dwAboveCount=0;
	WSRECT rc,MainRect;
	POINT pt;
	PWSREGION psRects=NULL;

	int nRgn;
	DWORD dwIndex;
	HRGN hRgn;
	RGNDATA* RgnData;
	DWORD dwSize;
	RECT* psRect;
	int nHorizontalOffset;
	int nVerticalOffset;
#ifdef DISPLAYMESSAGES
	WORD wszMessageBuf[256];
#endif
	hWnd=hwCur=(HWND)NativeWindow;

	if(IsWindowVisible(hWnd))
	{
		rc=psSurface->u.window.ws.sWindowRect;
		GetClientRect(hWnd,(RECT*)&MainRect);
		pt.x=MainRect.i32Left;
		pt.y=MainRect.i32Top;

⌨️ 快捷键说明

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