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

📄 generic-ws.c

📁 Lido PXA270平台开发板的最新BSP,包括源代码
💻 C
字号:
/**************************************************************************
 Name         : generic-ws.c
 Title        : Wince Window system implementatoin
 Author       : PowerVR
 Created      : December 2003

 Copyright    : 2003 by Imaginationc Technologies Limited. All rights reserved.
              : No part of this software, either material or conceptual 
              : may be copied or distributed, transmitted, transcribed,
              : stored in a retrieval system or translated into any 
              : human or computer language in any form by any means,
              : electronic, mechanical, manual or other-wise, or 
              : disclosed to third parties without the express written
              : permission of Imagination Technologies Limited, Unit 8, HomePark
              : Industrial Estate, King's Langley, Hertfordshire,
              : WD4 8LZ, U.K.

 Description  : Generic Window system functions

 Platform     : WinCE
 Version	  : $Revision: 1.24 $
 Modifications	: 
 $Log: generic-ws.c $
*******************************************************************************/
#define MODULE_ID MODID_GENERICWS

#include "assert.h"
#include "ogles_types.h"
#include "servicesglue.h"
#include "ws.h"
#include "wsglue.h"
#include "eglglue.h"
#include "osglue.h"
#include "egl_internal.h"
#include "drvegl.h"
#include "tls.h"
#include "debug.h"
#include "modid.h"
#include "misc.h"

/* @todo hookup trace */
#define trace(X)

IMG_BOOL
GLESGetDrawableParameters (GLESDrawableHandle hDrawable,
                           GLESDrawableParams *ppsParams)
{
    KEGL_SURFACE *pSurface;
	PVRSRV_SURF *psCurrentRenderSurface;
    TLS tls;

    tls = EGLGetTLSValue ();

    pSurface = hDrawable;

    assert (pSurface!=IMG_NULL);
    assert (ppsParams!=IMG_NULL);

	psCurrentRenderSurface = &pSurface->sCurrentRenderSurface;

  	ppsParams->ui32Width = psCurrentRenderSurface->ui32PixelWidth;
  	ppsParams->ui32Height = psCurrentRenderSurface->ui32PixelHeight;
  	ppsParams->ui32Stride = psCurrentRenderSurface->ui32ByteStride;
  	ppsParams->pvLinSurfaceAddress = psCurrentRenderSurface->psMemInfo->pvLinAddr;
  	ppsParams->ui32HWSurfaceAddress = psCurrentRenderSurface->psMemInfo->uiDevAddr.uiAddr;
  	ppsParams->psSyncInfo = psCurrentRenderSurface->psMemInfo->psSyncInfo;
    ppsParams->eRotationAngle = ROTATE_0;
	ppsParams->ePixelFormat = psCurrentRenderSurface->ePixelFormat;
    ppsParams->psQueueInfo = pSurface->psQueueInfo;
    ppsParams->hRenderSurface = pSurface->hRenderSurface;
    ppsParams->bIsPBuffer = (pSurface->type==EGL_SURFACE_PBUFFER) ? IMG_TRUE : IMG_FALSE;
	ppsParams->eRotationAngle = ROTATE_0;

    if (pSurface->type==EGL_SURFACE_WINDOW)
    {
        switch (pSurface->u.window.ws.ui32RotationAngle)
        {
        case 0:
            ppsParams->eRotationAngle = ROTATE_0;
            break;
        case 90:
            ppsParams->eRotationAngle = ROTATE_90;
            break;
        case 180:
            ppsParams->eRotationAngle = ROTATE_180;
            break;
        case 270:
            ppsParams->eRotationAngle = ROTATE_270;
            break;
        }
    }
    return IMG_TRUE;
}

/*
   <function>
   FUNCTION   : GWS_CreatePBufferDrawable
   PURPOSE    : Create a pbuffer drawable.
   PARAMETERS :
     In:  services_context - Services context.
     In:  dpy - Display.
     In:  pSurface - Surface.
     In:  pbuffer_width - Required width in pixels.
     In:  pbuffer_height - Required height in pixels.
     In:  pbuffer_largest - Allocate largest possible.
     In:  pixel_width - Pixel width in bytes.
     In:  pixel_format - Pixel format.
   RETURNS    :
     EGL_SUCCESS: pixmap conforms to config.
   </function>
 */
EGLint
GWS_CreatePBufferDrawable (GLESSysContext *pSrvCntx,
                           KEGL_DISPLAY *dpy,
                           KEGL_SURFACE *pSurface,
                           EGLint pbuffer_width,
                           EGLint pbuffer_height,
                           EGLint pbuffer_largest,
                           EGLint pixel_width,
                           PVRSRV_PIXEL_FORMAT pixel_format)
{
    IMG_RESULT pvrResult;
 	PVRSRV_SURF *psCurrentRenderSurface = &pSurface->sCurrentRenderSurface;
   	GLESAppHints sAppHints;

    trace ("ws  (egl->ws):  WS_CreatePBufferDrawable ()\n");
    assert (pSurface!=IMG_NULL);
    
    psCurrentRenderSurface->ui32PixelWidth = pbuffer_width;
    psCurrentRenderSurface->ui32PixelHeight = pbuffer_height;
    psCurrentRenderSurface->ePixelFormat = pixel_format;
    psCurrentRenderSurface->ui32ByteStride = pbuffer_width * pixel_width;

	if (PVRSRVCreateCommandQueue (&pSurface->pvrsrv_context->s3D,
                                  GLES_COMMANDQUEUE_SIZE,
                                  &pSurface->psQueueInfo) != PVRSRV_OK)
	{
		DPF ((DBG_ERROR,"Couldn't create a command queue"));
		return EGL_BAD_ALLOC;
	}
	
	GetApplicationHints(&sAppHints);

	if (!GLESCreateRenderSurface (pSrvCntx, &sAppHints, &pSurface->hRenderSurface))
	{
		DPF ((DBG_ERROR, "Couldn't create a render surface"));
		return EGL_BAD_ALLOC;
	}


/* todo: put this definition somewhere sane */
#define MBX1_MINIMUM_RENDER_TARGET_ALIGNMENT	(4096)
    pvrResult = PVRSRVAllocDeviceMem (&pSrvCntx->s3D,
                                      0, /* flags */
				      psCurrentRenderSurface->ui32ByteStride
				      * psCurrentRenderSurface->ui32PixelHeight,
                                      MBX1_MINIMUM_RENDER_TARGET_ALIGNMENT,
                                      &pSurface->u.pbuffer.memInfo);
    if (pvrResult!= PVRSRV_OK)
    {
        /* todo: if pbuffer_largest is set then allocate the largest
           surface possible */
    	return EGL_BAD_ALLOC;
    }
    
    psCurrentRenderSurface->psMemInfo = pSurface->u.pbuffer.memInfo;
    return EGL_SUCCESS;
}

⌨️ 快捷键说明

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