Пример #1
0
EGLint
Surface::GetAttrib( EGLint attribute, EGLint &value )
{
     D_DEBUG_AT( DFBEGL_Surface, "EGL::Surface::%s( %p, attribute 0x%08x (%d) '%s' )\n",
                 __FUNCTION__, this,
                 attribute, attribute, *ToString<EGLInt>( EGLInt(attribute) ) );

     if (surface == NULL) {
          D_DEBUG_AT( DFBEGL_Surface, "  -> NO SURFACE\n" );
          return EGL_BAD_SURFACE;
     }


     DFBSurfaceCapabilities  caps;
     EGL::Option            *option;

     switch (attribute) {
          case EGL_CONFIG_ID:
               return config->GetAttrib( attribute, &value );

          case EGL_WIDTH:
               surface->GetSize (surface, &value, NULL);
               break;

          case EGL_HEIGHT:
               surface->GetSize (surface, NULL, &value);
               break;

          case EGL_LARGEST_PBUFFER:
               value = EGL_FALSE;
               break;

          case EGL_VG_COLORSPACE:
               value = EGL_COLORSPACE_LINEAR;
               break;

          case EGL_VG_ALPHA_FORMAT:
               surface->GetCapabilities( surface, &caps );
               value = (caps & DSCAPS_PREMULTIPLIED) ? EGL_ALPHA_FORMAT_PRE : EGL_ALPHA_FORMAT_NONPRE;
               break;

          default:
               option = gfx_options.Get<EGL::Option>( ToString<EGLInt>( EGLInt(attribute) ) );
               if (option) {
                    value = option->GetValue();
                    break;
               }

               value = EGL_UNKNOWN;
               return EGL_BAD_PARAMETER;
     }

     return EGL_SUCCESS;
}
Пример #2
0
EGLint
Surface::SetAttrib( EGLint attribute, EGLint value )
{
     D_DEBUG_AT( DFBEGL_Surface, "EGL::Surface::%s( %p, attribute 0x%08x (%d) '%s', value 0x%08x (%d) '%s' )\n",
                 __FUNCTION__, this,
                 attribute, attribute, *ToString<EGLInt>( EGLInt(attribute) ),
                 value, value, (value >= 0x3000 && value < 0x4000) ?  *ToString<EGLInt>( EGLInt(value) ) : "" );

     return EGL_BAD_PARAMETER;
}
Пример #3
0
EGLint
Config::GetAttrib( EGLint attribute, EGLint *value ) const
{
     D_DEBUG_AT( DFBEGL_Config, "EGL::Config::%s( %p, attribute 0x%08x (%d) '%s' )\n",
                 __FUNCTION__, this, attribute, attribute, *ToString<EGLInt>( EGLInt(attribute) ) );

     if (gfx_config) {
          long v;

//          if (attribute == EGL_SURFACE_TYPE) {
//               *value = EGL_WINDOW_BIT | EGL_PIXMAP_BIT | EGL_PBUFFER_BIT;
//               return EGL_SUCCESS;
//          }

          if (gfx_config->GetOption( ToString<EGLInt>( EGLInt(attribute) ), v ) == DFB_OK) {
               *value = v;
               return EGL_SUCCESS;
          }
     }

     return EGL_BAD_ATTRIBUTE;
}
DFBResult
GetConfigAttribs::eglGetConfigAttribs( EGL::Display        &display,
                                       EGLNativePixmapType  native,
                                       EGLint              *attribs,
                                       EGLint               max )
{
     D_DEBUG_AT( DFBEGL_GetConfigAttribs, "%s( display %p, native %p, attribs %p, max %d )\n", __FUNCTION__, &display, native, attribs, max );

     if (!attribs)
          return DFB_INVARG;

     DFB_EGL_ATTRIB_LIST_DEBUG_AT( DFBEGL_GetConfigAttribs, attribs );

     IDirectFBSurface *surface = (IDirectFBSurface *) native;

     for (EGLint *v=attribs; *v != EGL_NONE; v+=2) {
          if (max > 0 && v-attribs >= max) {
               D_DEBUG_AT( DFBEGL_GetConfigAttribs, "  -> max (%d) reached (%ld)\n", max, v-attribs );
               break;
          }

          EGLint                attribute = v[0];
          EGLint                value     = v[1];
          DFBSurfacePixelFormat format;
          DFBDimension          size;

          D_DEBUG_AT( DFBEGL_GetConfigAttribs, "  -> [%ld] 0x%04x '%s'  <- %d (0x%08x)\n", v-attribs, attribute, **EGLInt(attribute), value, value );

          switch (attribute) {
          case EGL_BUFFER_SIZE:
               surface->GetPixelFormat( surface, &format );
               value = DFB_COLOR_BITS_PER_PIXEL( format );
               break;

          case EGL_ALPHA_SIZE:
               surface->GetPixelFormat( surface, &format );
               value = DFB_ALPHA_BITS_PER_PIXEL( format );
               break;

          case EGL_BLUE_SIZE:
          case EGL_GREEN_SIZE:
          case EGL_RED_SIZE:
               surface->GetPixelFormat( surface, &format );
               value = DFB_COLOR_BITS_PER_PIXEL( format ) / 3;//FIXME
               break;

          //case EGL_DEPTH_SIZE:
          //case EGL_STENCIL_SIZE:
          //case EGL_RENDERABLE_TYPE:

          case EGL_SURFACE_TYPE:
               value = EGL_WINDOW_BIT;  // FIXME
               break;

          case EGL_WIDTH:     // keep? not a config attribute actually
               surface->GetSize( surface, &size.w, &size.h );
               value = size.w;
               break;

          case EGL_HEIGHT:    // keep? not a config attribute actually
               surface->GetSize( surface, &size.w, &size.h );
               value = size.h;
               break;

          default:
               D_DEBUG_AT( DFBEGL_GetConfigAttribs, "  -> UNRECOGNIZED!!!\n" );
               continue;
          }

          D_DEBUG_AT( DFBEGL_GetConfigAttribs, "            => %d (0x%08x)\n", value, value );

          v[1] = value;
     }

     D_DEBUG_AT( DFBEGL_GetConfigAttribs, " --> DONE -------------\n" );

     DFB_EGL_ATTRIB_LIST_DEBUG_AT( DFBEGL_GetConfigAttribs, attribs );

     return DFB_OK;
}