📄 cfg.c
字号:
PURPOSE :
Generate a specific configuration from the configuration
handle. The generic EGL component determines a generic EGL base
configuration and a window system interface configuration variant
from the EGLConfig supplied. The appropriate generic EGL base
configuration is generated and passed to the window system
interface to construct the required window system variant.
PARAMETERS : In: pDpy - Display
In: eglCfg - Configuration required.
Out: ppCfg - Receives the generated configuration.
RETURNS : EGL_SUCCESS - Success
Other EGL error code - failure.
</function>
*/
EGLint
CFG_GenerateVariant (KEGL_DISPLAY *pDpy,
EGLConfig EglCfg,
KEGL_CONFIG **ppCfg)
{
EGLint iEglVariant = (EglCfg-1) % _EglVariantCount ();
EGLint iWsVariant = (EglCfg-1) / _EglVariantCount ();
assert (pDpy!=IMG_NULL);
assert (ppCfg!=IMG_NULL);
if (EglCfg<=0 || EglCfg > CFG_Variants (pDpy))
return EGL_BAD_CONFIG;
*ppCfg = WS_DeriveCfg (pDpy, _BuildBaseCfg (iEglVariant), iWsVariant);
*ppCfg = CFGC_CopyNl (*ppCfg);
if (!CFGC_SetAttrib (*ppCfg, EGL_CONFIG_ID, EglCfg))
{
CFGC_Unlink (*ppCfg);
return EGL_BAD_ALLOC;
}
return EGL_SUCCESS;
}
/*
<function>
FUNCTION : CFG_Match
PURPOSE : Determine if a candidate config meets the selection criteria
provided in a requested config.
PARAMETERS : In: pRequestedCfg - The requested configuration.
In: pCandidate - The candidate configuration.
RETURNS : EGL_TRUE - candiate matches the selection criteria
EGL_FALSE - candiate does not match the selection criteria
</function>
*/
EGLBoolean
CFG_Match (KEGL_CONFIG *pRequestedCfg,
KEGL_CONFIG *pCandidate)
{
EGLint iAttribIndex;
for (iAttribIndex=0; aAttribNames[iAttribIndex]!=EGL_NONE; iAttribIndex++)
{
EGLint iRequestValue;
EGLint iAttrib;
iAttrib = aAttribNames[iAttribIndex];
iRequestValue = CFGC_GetAttrib (pRequestedCfg, iAttrib);
if (iRequestValue == EGL_DONT_CARE)
continue;
switch (aAttribMatchCriteria[iAttribIndex])
{
case smaller:
/* The EGL Specification is clear about the distinction
between selection and sorting. Note the bizarre
behaviour that criteria 'smaller' means >= for
selection but < for sorting. */
if (CFGC_GetAttrib (pCandidate, iAttrib) < iRequestValue)
return EGL_FALSE;
break;
case larger:
if (CFGC_GetAttrib (pCandidate, iAttrib) < iRequestValue)
return EGL_FALSE;
break;
case exact:
if (iRequestValue != CFGC_GetAttrib (pCandidate, iAttrib))
return EGL_FALSE;
break;
case mask:
if ((iRequestValue & CFGC_GetAttrib (pCandidate, iAttrib)) != iRequestValue)
return EGL_FALSE;
break;
}
}
return EGL_TRUE;
}
/*
<function>
FUNCTION : CFG_PrepareConfigFilter
PURPOSE :
Prepare a requested configuration. Creates a configuration with
default values assigned to attributes as defined in the egl
specification. Attribute values provided in an attribute list are
then inserted into the configuration overwriting the default
values. Finally requested attribute values which cannot be modified
by the attribute list are fixed up.
PARAMETERS : pAttribList - attribute list
RETURNS : requested configuration or IMG_NULL.
</function>
*/
KEGL_CONFIG *
CFG_PrepareConfigFilter (const EGLint *pAttribList)
{
KEGL_CONFIG *pDfltCfg;
KEGL_CONFIG *pCopyCfg;
KEGL_CONFIG *pRqstCfg;
pDfltCfg = CFGC_CreateAvArray (aAttribDflts);
if(pAttribList == IMG_NULL)
{
pCopyCfg = pDfltCfg;
}
else
{
pCopyCfg = CFGC_ModifyAvArrayNl (pDfltCfg, pAttribList);
}
pRqstCfg = CFGC_CopyNl (pCopyCfg);
if (pRqstCfg==IMG_NULL)
return IMG_NULL;
/* Fixup the entries to enforce the specification. */
if (!CFGC_SetAttrib (pRqstCfg, EGL_MAX_PBUFFER_WIDTH, EGL_DONT_CARE))
goto failed;
if (!CFGC_SetAttrib (pRqstCfg, EGL_MAX_PBUFFER_HEIGHT, EGL_DONT_CARE))
goto failed;
if (!CFGC_SetAttrib (pRqstCfg, EGL_MAX_PBUFFER_PIXELS, EGL_DONT_CARE))
goto failed;
if (!CFGC_SetAttrib (pRqstCfg, EGL_NATIVE_VISUAL_ID, EGL_DONT_CARE))
goto failed;
if ((CFGC_GetAttrib (pRqstCfg, EGL_SURFACE_TYPE) & EGL_WINDOW_BIT)==0)
{
if (!CFGC_SetAttrib (pRqstCfg, EGL_NATIVE_VISUAL_TYPE,
EGL_DONT_CARE))
goto failed;
}
/* We have no native visuals therefore visual type is always ignored */
if (!CFGC_SetAttrib (pRqstCfg, EGL_NATIVE_VISUAL_TYPE, EGL_DONT_CARE))
goto failed;
if (CFGC_GetAttrib (pRqstCfg, EGL_TRANSPARENT_TYPE)==EGL_NONE)
{
if (!CFGC_SetAttrib (pRqstCfg,EGL_TRANSPARENT_RED_VALUE,
EGL_DONT_CARE))
goto failed;
if (!CFGC_SetAttrib (pRqstCfg, EGL_TRANSPARENT_GREEN_VALUE,
EGL_DONT_CARE))
goto failed;
if (!CFGC_SetAttrib (pRqstCfg, EGL_TRANSPARENT_BLUE_VALUE,
EGL_DONT_CARE))
goto failed;
}
return pRqstCfg;
failed:
CFGC_Unlink (pRqstCfg);
return IMG_NULL;
}
/*
<function>
FUNCTION : CFG_CompatibleConfigs
PURPOSE :
Test if two configs are compatible, based on definition of
compatible from k-egl specification section 2.2. A context and a
*surface* are considered compatible if they:
- have colour and ancillary buffers of the same depth
- were created with respect to the same display.
PARAMETERS : In: pCfgA - config
In: pCfgB - config
RETURNS : EGL_TRUE - Compatible.
EGL_FALSE - Not compatible.
</function>
*/
EGLBoolean
CFG_CompatibleConfigs (KEGL_CONFIG *pCfgA,
KEGL_CONFIG *pCfgB)
{
EGLint aCheckAttrib [] =
{
EGL_ALPHA_SIZE, EGL_RED_SIZE, EGL_GREEN_SIZE, EGL_BLUE_SIZE,
EGL_DEPTH_SIZE, EGL_STENCIL_SIZE, EGL_NONE
};
EGLint i;
assert (pCfgA!=IMG_NULL);
assert (pCfgB!=IMG_NULL);
for (i=0; aCheckAttrib[i]!=EGL_NONE; i++)
if (CFGC_GetAttrib (pCfgA, aCheckAttrib[i]) !=
CFGC_GetAttrib (pCfgB, aCheckAttrib[i]))
return EGL_FALSE;
return EGL_TRUE;
}
/*
<function>
FUNCTION : CFG_Compare
PURPOSE : Determine a sort order between two configurations. This
function is used as a callback to qsort_s.
PARAMETERS : In: pA - 1st configuration
In: pB - 2nd configuration
In: pState - the values array used to track the selection
criteria applied to each configuration.
RETURNS :
0 :: a == b
<0 :: a < b
>0 :: a > b
</function>
*/
EGLint
CFG_Compare (void *pA, void *pB, void *pState)
{
KEGL_CONFIG *pCfgA = *(KEGL_CONFIG **)pA;
KEGL_CONFIG *pCfgB = *(KEGL_CONFIG **)pB;
KEGL_CONFIG *pRqstCfg = pState;
EGLint aColourBits;
EGLint bColourBits;
if (CFGC_GetAttrib (pCfgA, EGL_CONFIG_CAVEAT) !=
CFGC_GetAttrib (pCfgB, EGL_CONFIG_CAVEAT))
return
_CaveatOrder (CFGC_GetAttrib (pCfgA, EGL_CONFIG_CAVEAT)) -
_CaveatOrder (CFGC_GetAttrib (pCfgB, EGL_CONFIG_CAVEAT));
aColourBits = _TotalColourBits (pCfgA, pRqstCfg);
bColourBits = _TotalColourBits (pCfgB, pRqstCfg);
if (aColourBits != bColourBits)
return bColourBits - aColourBits;
if (CFGC_GetAttrib (pCfgA, EGL_BUFFER_SIZE) !=
CFGC_GetAttrib (pCfgB, EGL_BUFFER_SIZE))
return
CFGC_GetAttrib (pCfgA, EGL_BUFFER_SIZE) -
CFGC_GetAttrib (pCfgB, EGL_BUFFER_SIZE);
if (CFGC_GetAttrib (pCfgA, EGL_SAMPLE_BUFFERS) !=
CFGC_GetAttrib (pCfgB, EGL_SAMPLE_BUFFERS))
return
CFGC_GetAttrib (pCfgA, EGL_SAMPLE_BUFFERS) -
CFGC_GetAttrib (pCfgB, EGL_SAMPLE_BUFFERS);
if (CFGC_GetAttrib (pCfgA, EGL_SAMPLES) !=
CFGC_GetAttrib (pCfgB, EGL_SAMPLES))
return CFGC_GetAttrib (pCfgA, EGL_SAMPLES) -
CFGC_GetAttrib (pCfgB, EGL_SAMPLES);
if (CFGC_GetAttrib (pCfgA, EGL_DEPTH_SIZE) !=
CFGC_GetAttrib (pCfgB, EGL_DEPTH_SIZE))
return
CFGC_GetAttrib (pCfgA, EGL_DEPTH_SIZE) -
CFGC_GetAttrib (pCfgB, EGL_DEPTH_SIZE);
if (CFGC_GetAttrib (pCfgA, EGL_STENCIL_SIZE) !=
CFGC_GetAttrib (pCfgB, EGL_STENCIL_SIZE))
return
CFGC_GetAttrib (pCfgA, EGL_STENCIL_SIZE) -
CFGC_GetAttrib (pCfgB, EGL_STENCIL_SIZE);
if (WS_CompareNativeVisualType (
CFGC_GetAttrib (pCfgA, EGL_NATIVE_VISUAL_TYPE),
CFGC_GetAttrib (pCfgB, EGL_NATIVE_VISUAL_TYPE)) != 0)
return
WS_CompareNativeVisualType (
CFGC_GetAttrib(pCfgA, EGL_NATIVE_VISUAL_TYPE),
CFGC_GetAttrib(pCfgB, EGL_NATIVE_VISUAL_TYPE));
return
CFGC_GetAttrib (pCfgA, EGL_CONFIG_ID) -
CFGC_GetAttrib (pCfgB, EGL_CONFIG_ID);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -