示例#1
0
/**
 * Typical fallback routine for eglChooseConfig
 */
EGLBoolean
_eglChooseConfig(_EGLDriver *drv, _EGLDisplay *disp, const EGLint *attrib_list,
                 EGLConfig *configs, EGLint config_size, EGLint *num_configs)
{
   _EGLConfig criteria;

   if (!_eglParseConfigAttribList(&criteria, disp, attrib_list))
      return _eglError(EGL_BAD_ATTRIBUTE, "eglChooseConfig");

   return _eglFilterConfigArray(disp->Configs,
         configs, config_size, num_configs,
         _eglFallbackMatch, _eglFallbackCompare,
         (void *) &criteria);
}
示例#2
0
/**
 * Typical fallback routine for eglChooseConfig
 */
EGLBoolean
_eglChooseConfig(_EGLDriver *drv, _EGLDisplay *disp, const EGLint *attrib_list,
                 EGLConfig *configs, EGLint config_size, EGLint *num_configs)
{
   _EGLConfig **configList, criteria;
   EGLint i, count;

   if (!num_configs)
      return _eglError(EGL_BAD_PARAMETER, "eglChooseConfigs");

   _eglInitConfig(&criteria, disp, 0);
   if (!_eglParseConfigAttribList(&criteria, attrib_list))
      return _eglError(EGL_BAD_ATTRIBUTE, "eglChooseConfig");

   /* allocate array of config pointers */
   configList = (_EGLConfig **)
      malloc(disp->NumConfigs * sizeof(_EGLConfig *));
   if (!configList)
      return _eglError(EGL_BAD_ALLOC, "eglChooseConfig(out of memory)");

   /* perform selection of configs */
   count = 0;
   for (i = 0; i < disp->NumConfigs; i++) {
      if (_eglMatchConfig(disp->Configs[i], &criteria))
         configList[count++] = disp->Configs[i];
   }

   /* perform sorting of configs */
   if (configs && count) {
      _eglSortConfigs((const _EGLConfig **) configList, count,
                      _eglFallbackCompare, (void *) &criteria);
      count = MIN2(count, config_size);
      for (i = 0; i < count; i++)
         configs[i] = _eglGetConfigHandle(configList[i]);
   }

   free(configList);

   *num_configs = count;

   return EGL_TRUE;
}
static EGLBoolean
egl_g3d_choose_config(_EGLDriver *drv, _EGLDisplay *dpy, const EGLint *attribs,
                      EGLConfig *configs, EGLint size, EGLint *num_configs)
{
   struct egl_g3d_choose_config_data data;

   if (!_eglParseConfigAttribList(&data.criteria, dpy, attribs))
      return _eglError(EGL_BAD_ATTRIBUTE, "eglChooseConfig");

   data.format = PIPE_FORMAT_NONE;
   if (data.criteria.MatchNativePixmap != EGL_NONE &&
       data.criteria.MatchNativePixmap != EGL_DONT_CARE) {
      struct egl_g3d_display *gdpy = egl_g3d_display(dpy);

      if (!gdpy->native->get_pixmap_format(gdpy->native,
               (EGLNativePixmapType) data.criteria.MatchNativePixmap,
               &data.format))
         return _eglError(EGL_BAD_NATIVE_PIXMAP, "eglChooseConfig");
   }

   return _eglFilterConfigArray(dpy->Configs, configs, size, num_configs,
         egl_g3d_match_config, egl_g3d_compare_config, &data);
}