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

📄 cfg.c

📁 Lido PXA270平台开发板的最新BSP,包括源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*************************************************************************
 * Name         : cfg.c
 * Title        : EGL Config Support
 * 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  :
 *
 * Generation and manipulation of EGL configurations.
 * 
 * Platform : ALL
 *
 * $Date: 2004/10/27 14:04:26 $ $Revision: 1.14 $
 * $Log: cfg.c $
 *
 *************************************************************************/

#include "services.h"
#include "cfg-core.h"
#include "drvegl.h"
#include "ogles_types.h"
#include "ws.h"
#include "cfg.h"

/* @todo fixup proper assert functionality */
#define assert(X)

/* Number of configuration variants supported by the generic EGL */
#define CONFIG_VARIANTS 3

static const EGLint
_sb1 [] = 
{ EGL_SAMPLE_BUFFERS, 1,
  EGL_SAMPLES, 2,
  EGL_NONE
};

static const EGLint
_sb2 [] = 
{ EGL_SAMPLE_BUFFERS, 1,
  EGL_SAMPLES, 4,
  EGL_NONE
};

/* This array defines the base configuration attribute values. The
 * base configurations is passed to the WS which creates delta
 * configurations from the base. 
 */
static const EGLint
aBaseAttribs [] =
{
    EGL_BUFFER_SIZE, 0,		/* ws must define */
    EGL_ALPHA_SIZE, 0,		/* ws must define */
    EGL_RED_SIZE, 0,		/* ws must define */
    EGL_GREEN_SIZE, 0,		/* ws must define */
    EGL_BLUE_SIZE, 0,		/* ws must define */
    EGL_DEPTH_SIZE, 24,
    EGL_STENCIL_SIZE, 0,
    EGL_CONFIG_CAVEAT, EGL_NONE,
    EGL_CONFIG_ID, 0,
    EGL_LEVEL, 0,
    EGL_MAX_PBUFFER_HEIGHT, 2048,
    EGL_MAX_PBUFFER_WIDTH, 2048,
    EGL_MAX_PBUFFER_PIXELS, 2048*2048,
    EGL_NATIVE_RENDERABLE, EGL_FALSE,
    EGL_NATIVE_VISUAL_ID, 0,
    EGL_NATIVE_VISUAL_TYPE, EGL_NONE,
    EGL_SAMPLES, 0,
    EGL_SAMPLE_BUFFERS, 0,
    EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT | EGL_PIXMAP_BIT,
    EGL_TRANSPARENT_TYPE, EGL_NONE,
    EGL_TRANSPARENT_RED_VALUE, 0,
    EGL_TRANSPARENT_GREEN_VALUE, 0,
    EGL_TRANSPARENT_BLUE_VALUE, 0,
    EGL_NONE
};

const static enum 
{
    smaller,
    larger,
    exact,
    mask
} aAttribMatchCriteria [] =
{
#define A(N,D,C,P) C,
#include "attrib.def"
#undef A
};

const static EGLint
aAttribNames [] =
{
#define A(N,D,C,P) N,
#include "attrib.def"
#undef A
EGL_NONE
};

const static EGLint
aAttribDflts [] =
{
#define A(N,D,C,P) N, D,
#include "attrib.def"
#undef A
EGL_NONE
};

/*
   <function>
   FUNCTION   : _CaveatOrder
   PURPOSE    : Determine a sort order priority for a caveat.
   PARAMETERS : In:  caveat -
   RETURNS    : Sort priority.
   </function>
 */
static EGLint
_CaveatOrder (EGLint caveat)
{
    switch (caveat)
    {
    case EGL_NONE:
        return 0;
    case EGL_SLOW_CONFIG:
        return 1;
    case EGL_NON_CONFORMANT_CONFIG:
        return 2;
    }
    return 0;
}

/*
   <function>
   FUNCTION   : _ColourDoNotCareOr0
   PURPOSE    : Test if an attribute in an attribute array is either 0 or
                don't care.
   PARAMETERS : In:  pRequestedCfg - requested configuration
                In:  Attrib - attribute
   RETURNS    : EGL_TRUE - attribute is specified don't care or 0
                EGL_FALSE - attribute is specified.
   </function>
 */
static EGLBoolean
_ColourDoNotCareOr0 (KEGL_CONFIG *pRequestedCfg,
                     EGLint Attrib)
{
    EGLint v = CFGC_GetAttrib (pRequestedCfg, Attrib);
    return v == EGL_DONT_CARE || v == 0;
}

/*
   <function>
   FUNCTION   : _ColourDoCareWidthOr0
   PURPOSE    : Find and retreive an attribute value from a configuration.
                If the attribute was either DONT_CARE or 0 in a requested
                configuration return 0.
   PARAMETERS : In:  pCfg - configuration to retreive attribute value from.
                In:  pRequestedCfg - requested configuration to check
                In:  Attrib - attribute to retreive
   RETURNS    : Attribute value or 0.
   </function>
 */
static EGLint
_ColourDoCareWidthOr0 (KEGL_CONFIG *pCfg,
                       KEGL_CONFIG *pRequestedCfg,
                       EGLint Attrib)
{
    if (_ColourDoNotCareOr0 (pRequestedCfg, Attrib))
        return 0;
    return CFGC_GetAttrib (pCfg, Attrib);
}

/*
   <function>
   FUNCTION   : _TotalColourBits
   PURPOSE    :

   Sum the colour bits from a config. Colour bits include RGBA. Only
   colours which are not specified as DON'T CARE or 0 are included in
   the sum.
   
   PARAMETERS : In:  pCfg - configuration to sum colour bits from.
                In:  pRequestedCfg - requested config values.
   RETURNS    : Total significant colour bits.
   </function>
 */
static EGLint
_TotalColourBits (KEGL_CONFIG *pCfg,
                  KEGL_CONFIG *pRequestedCfg)
{
    EGLint iTotal = 0;
    iTotal += _ColourDoCareWidthOr0 (pCfg, pRequestedCfg, EGL_ALPHA_SIZE);
    iTotal += _ColourDoCareWidthOr0 (pCfg, pRequestedCfg, EGL_RED_SIZE);
    iTotal += _ColourDoCareWidthOr0 (pCfg, pRequestedCfg, EGL_GREEN_SIZE);
    iTotal += _ColourDoCareWidthOr0 (pCfg, pRequestedCfg, EGL_BLUE_SIZE);
    return iTotal;
}

/*
   <function>
   FUNCTION   : _EglVariantCount
   PURPOSE    :

   Return the number of basic configurations generated by the generic
   egl layer.
   
   PARAMETERS : None
   RETURNS    : Number of configurations.
   </function>
 */
static EGLint
_EglVariantCount (void)
{
  return CONFIG_VARIANTS;
}

/*
   <function>
   FUNCTION   : _BuildBaseCfg
   PURPOSE    :

   Construct a specified base configuration. The variant supplied will be
   in the range 0..(N-1) where N is the number returned by _EglVariantCount.
   
   PARAMETERS : In:  iEglVariant - Base configuration variant.
   RETURNS    : Configuration or IMG_NULL.
   </function>
 */
static KEGL_CONFIG *
_BuildBaseCfg (EGLint iEglVariant)
{
    KEGL_CONFIG *pCfg;
    pCfg = CFGC_CreateAvArray (aBaseAttribs);
    switch (iEglVariant)
    {
    case 0:
        break;
    case 1:
        pCfg = CFGC_ModifyAvArrayNl (pCfg, _sb1);
        break;
    case 2:
        pCfg = CFGC_ModifyAvArrayNl (pCfg, _sb2);
        break;
    }
  
    return pCfg;
}

/*
   <function>
   FUNCTION   : CFG_variants
   PURPOSE    :

   Determine the number of configurations supported for a specified
   display.  This function queries the window system interface to
   determine the number of configurations variations that can be
   generated from the base configurations defined by the generic EGL
   layer.
   
   PARAMETERS : In:  pDpy - Display.
   RETURNS    : Number of configurations.
   </function>
 */
EGLint
CFG_Variants (KEGL_DISPLAY *pDpy)
{
#if defined(__SH4__)
	return 3;
#else
    return WS_CfgVariants (pDpy) * _EglVariantCount ();
#endif
}

/*
<function>
   FUNCTION   : CFG_GenerateVariant

⌨️ 快捷键说明

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