📄 srv.c
字号:
/****************************************************************************
*
* Name : srv.c
* Title : Service Interface.
* Author : Marcus Shawcroft
* Created : 4 Nov 2003
*
* Copyright : 2003-2004 by Imagination 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 : Service interface for Khronos EGL.
*
* Platform : ALL
*
* $Date: 2004/09/28 14:42:29 $ $Revision: 1.8 $
* $Log: srv.c $
*
****************************************************************************/
#include "drvegl.h"
#include "img_defs.h"
#include "img_types.h"
#include "ogles_types.h"
#include "services.h"
#include "servicesglue.h"
#include "srv.h"
const static struct
{
EGLint format;
EGLint alpha_size;
EGLint red_size;
EGLint green_size;
EGLint blue_size;
EGLint pixel_size;
} _formats [] = {
{PVRSRV_PIXEL_FORMAT_RGB565, 0, 5, 6, 5, 2},
{PVRSRV_PIXEL_FORMAT_ARGB1555, 1, 5, 5, 5, 2},
{PVRSRV_PIXEL_FORMAT_ARGB8888, 8, 8, 8, 8, 4},
{0, 0, 0, 0, 0, 0}};
#define A(N,V,A,R,G,B,W) N,
const PVRSRV_PIXEL_FORMAT SRV_pixel_format [] =
{
#include "pixel-format.def"
#undef A
};
#define A(N,V,A,R,G,B,W) A,
const EGLint SRV_pixel_format_alpha [] =
{
#include "pixel-format.def"
#undef A
0
};
#define A(N,V,A,R,G,B,W) R,
const EGLint SRV_pixel_format_red [] =
{
#include "pixel-format.def"
#undef A
0
};
#define A(N,V,A,R,G,B,W) G,
const EGLint SRV_pixel_format_green [] =
{
#include "pixel-format.def"
#undef A
0
};
#define A(N,V,A,R,G,B,W) B,
const EGLint SRV_pixel_format_blue [] =
{
#include "pixel-format.def"
#undef A
0
};
#define A(N,V,A,R,G,B,W) W,
const EGLint SRV_pixel_format_width [] =
{
#include "pixel-format.def"
#undef A
0
};
/***************************************************************************
*
* FUNCTION : SRV_FindGLESPixelFormat
* PURPOSE : Search for a GLES pixel format that matches ARGB pixel widths.
* PARAMETERS : In: a - alpha channel width
* In: r - red channel width
* In: g - green channel width
* In: b - blue channel width
* Out: pixel_size - receives the pixel width in bytes
* RETURNS : pixel format
*
****************************************************************************/
EGLint SRV_FindGLESPixelFormat (EGLint a,
EGLint r,
EGLint g,
EGLint b,
EGLint *pixel_size)
{
EGLint i;
for (i=0; _formats[i].pixel_size!=0; i++)
{
if ( r == _formats[i].red_size
&& g == _formats[i].green_size
&& b == _formats[i].blue_size
&& a == _formats[i].alpha_size)
{
if (pixel_size!=IMG_NULL)
*pixel_size = _formats[i].pixel_size;
return( (EGLint)(_formats[i].format) );
}
}
return -1;
}
/****************************************************************************
*
* FUNCTION : SRV_FindPVRPixelFormat
* PURPOSE : Search for a GLES pixel format that matches ARGB pixel widths.
* PARAMETERS : In: a - alpha channel width
* In: r - red channel width
* In: g - green channel width
* In: b - blue channel width
* Out: pixel_format - receives pixel format.
* Out: pixel_width - receives pixel width in bytes.
* RETURNS : EGL_TRUE - Success.
* EGL_FALSE - Failure.
*
***************************************************************************/
EGLBoolean SRV_FindPVRPixelFormat (EGLint a,
EGLint r,
EGLint g,
EGLint b,
PVRSRV_PIXEL_FORMAT *pixel_format,
EGLint *pixel_width)
{
EGLint i;
for (i=1; SRV_pixel_format[i]!=0; i++)
{
if ( r == SRV_pixel_format_red[i]
&& g == SRV_pixel_format_green[i]
&& b == SRV_pixel_format_blue[i]
&& a == SRV_pixel_format_alpha[i])
{
if (pixel_format!=IMG_NULL)
*pixel_format = SRV_pixel_format[i];
if (pixel_width!=IMG_NULL)
*pixel_width = SRV_pixel_format_width[i]>>3;
return EGL_TRUE;
}
}
return EGL_FALSE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -