コード例 #1
0
ファイル: eglapi.c プロジェクト: ChillyWillyGuru/RSXGL
EGLBoolean EGLAPIENTRY
eglWaitNative(EGLint engine)
{
   _EGLContext *ctx = _eglGetCurrentContext();
   _EGLDisplay *disp;
   _EGLDriver *drv;
   EGLBoolean ret;

   if (!ctx)
      RETURN_EGL_SUCCESS(NULL, EGL_TRUE);

   disp = ctx->Resource.Display;
   _eglLockMutex(&disp->Mutex);

   /* let bad current context imply bad current surface */
   if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT ||
       _eglGetSurfaceHandle(ctx->DrawSurface) == EGL_NO_SURFACE)
      RETURN_EGL_ERROR(disp, EGL_BAD_CURRENT_SURFACE, EGL_FALSE);

   /* a valid current context implies an initialized current display */
   assert(disp->Initialized);
   drv = disp->Driver;
   ret = drv->API.WaitNative(drv, disp, engine);

   RETURN_EGL_EVAL(disp, ret);
}
コード例 #2
0
ファイル: eglapi.c プロジェクト: ChillyWillyGuru/RSXGL
EGLContext EGLAPIENTRY
eglGetCurrentContext(void)
{
   _EGLContext *ctx = _eglGetCurrentContext();
   EGLContext ret;

   ret = _eglGetContextHandle(ctx);

   RETURN_EGL_SUCCESS(NULL, ret);
}
コード例 #3
0
ファイル: egl_xlib.c プロジェクト: astrofimov/vgallium
/**
 * Called via eglCreateContext(), drv->API.CreateContext().
 */
static EGLContext
xlib_eglCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config,
                      EGLContext share_list, const EGLint *attrib_list)
{
   struct xlib_egl_driver *xdrv = xlib_egl_driver(drv);
   _EGLConfig *conf = _eglLookupConfig(drv, dpy, config);
   struct xlib_egl_context *ctx;
   struct st_context *share_ctx = NULL; /* XXX fix */
   __GLcontextModes visual;

   ctx = CALLOC_STRUCT(xlib_egl_context);
   if (!ctx)
      return EGL_NO_CONTEXT;

   /* let EGL lib init the common stuff */
   if (!_eglInitContext(drv, dpy, &ctx->Base, config, attrib_list)) {
      free(ctx);
      return EGL_NO_CONTEXT;
   }

   /* API-dependent context creation */
   switch (ctx->Base.ClientAPI) {
   case EGL_OPENVG_API:
   case EGL_OPENGL_ES_API:
      _eglLog(_EGL_DEBUG, "Create Context for ES version %d\n",
              ctx->Base.ClientVersion);
      /* fall-through */
   case EGL_OPENGL_API:
      /* create a softpipe context */
      ctx->pipe = softpipe_create(xdrv->screen, xdrv->winsys, NULL);
      /* Now do xlib / state tracker inits here */
      _eglConfigToContextModesRec(conf, &visual);
      ctx->Context = st_create_context(ctx->pipe, &visual, share_ctx);
      break;
   default:
      _eglError(EGL_BAD_MATCH, "eglCreateContext(unsupported API)");
      free(ctx);
      return EGL_NO_CONTEXT;
   }

   _eglSaveContext(&ctx->Base);

   return _eglGetContextHandle(&ctx->Base);
}
コード例 #4
0
ファイル: eglapi.c プロジェクト: ChillyWillyGuru/RSXGL
EGLBoolean EGLAPIENTRY
eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
{
   _EGLContext *ctx = _eglGetCurrentContext();
   _EGLDisplay *disp = _eglLockDisplay(dpy);
   _EGLSurface *surf = _eglLookupSurface(surface, disp);
   _EGLDriver *drv;
   EGLBoolean ret;

   _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv);

   /* surface must be bound to current context in EGL 1.4 */
   if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT ||
       surf != ctx->DrawSurface)
      RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE);

   ret = drv->API.SwapBuffers(drv, disp, surf);

   RETURN_EGL_EVAL(disp, ret);
}
コード例 #5
0
ファイル: eglapi.c プロジェクト: ChillyWillyGuru/RSXGL
EGLBoolean EGLAPIENTRY
eglSwapInterval(EGLDisplay dpy, EGLint interval)
{
   _EGLDisplay *disp = _eglLockDisplay(dpy);
   _EGLContext *ctx = _eglGetCurrentContext();
   _EGLSurface *surf;
   _EGLDriver *drv;
   EGLBoolean ret;

   _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);

   if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT ||
       ctx->Resource.Display != disp)
      RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_FALSE);

   surf = ctx->DrawSurface;
   if (_eglGetSurfaceHandle(surf) == EGL_NO_SURFACE)
      RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE);

   ret = drv->API.SwapInterval(drv, disp, surf, interval);

   RETURN_EGL_EVAL(disp, ret);
}
コード例 #6
0
ファイル: eglsurface.c プロジェクト: ChristophHaag/mesa-mesa
EGLBoolean
_eglQuerySurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surface,
                 EGLint attribute, EGLint *value)
{
   switch (attribute) {
   case EGL_WIDTH:
      *value = surface->Width;
      break;
   case EGL_HEIGHT:
      *value = surface->Height;
      break;
   case EGL_CONFIG_ID:
      *value = surface->Config->ConfigID;
      break;
   case EGL_LARGEST_PBUFFER:
      if (surface->Type == EGL_PBUFFER_BIT)
         *value = surface->LargestPbuffer;
      break;
   case EGL_TEXTURE_FORMAT:
      /* texture attributes: only for pbuffers, no error otherwise */
      if (surface->Type == EGL_PBUFFER_BIT)
         *value = surface->TextureFormat;
      break;
   case EGL_TEXTURE_TARGET:
      if (surface->Type == EGL_PBUFFER_BIT)
         *value = surface->TextureTarget;
      break;
   case EGL_MIPMAP_TEXTURE:
      if (surface->Type == EGL_PBUFFER_BIT)
         *value = surface->MipmapTexture;
      break;
   case EGL_MIPMAP_LEVEL:
      if (surface->Type == EGL_PBUFFER_BIT)
         *value = surface->MipmapLevel;
      break;
   case EGL_SWAP_BEHAVIOR:
      *value = surface->SwapBehavior;
      break;
   case EGL_RENDER_BUFFER:
      /* From the EGL_KHR_mutable_render_buffer spec (v12):
       *
       *    Querying EGL_RENDER_BUFFER returns the buffer which client API
       *    rendering is requested to use. For a window surface, this is the
       *    attribute value specified when the surface was created or last set
       *    via eglSurfaceAttrib.
       *
       * In other words, querying a window surface returns the value most
       * recently *requested* by the user.
       *
       * The paragraph continues in the EGL 1.5 spec (2014.08.27):
       *
       *    For a pbuffer surface, it is always EGL_BACK_BUFFER . For a pixmap
       *    surface, it is always EGL_SINGLE_BUFFER . To determine the actual
       *    buffer being rendered to by a context, call eglQueryContext.
       */
      switch (surface->Type) {
      default:
         unreachable("bad EGLSurface type");
      case EGL_WINDOW_BIT:
         *value = surface->RequestedRenderBuffer;
         break;
      case EGL_PBUFFER_BIT:
         *value = EGL_BACK_BUFFER;
         break;
      case EGL_PIXMAP_BIT:
         *value = EGL_SINGLE_BUFFER;
         break;
      }
      break;
   case EGL_PIXEL_ASPECT_RATIO:
      *value = surface->AspectRatio;
      break;
   case EGL_HORIZONTAL_RESOLUTION:
      *value = surface->HorizontalResolution;
      break;
   case EGL_VERTICAL_RESOLUTION:
      *value = surface->VerticalResolution;
      break;
   case EGL_MULTISAMPLE_RESOLVE:
      *value = surface->MultisampleResolve;
      break;
   case EGL_VG_ALPHA_FORMAT:
      *value = surface->VGAlphaFormat;
      break;
   case EGL_VG_COLORSPACE:
      *value = surface->VGColorspace;
      break;
   case EGL_GL_COLORSPACE_KHR:
      if (!disp->Extensions.KHR_gl_colorspace)
         return _eglError(EGL_BAD_ATTRIBUTE, "eglQuerySurface");

      *value = surface->GLColorspace;
      break;
   case EGL_POST_SUB_BUFFER_SUPPORTED_NV:
      *value = surface->PostSubBufferSupportedNV;
      break;
   case EGL_BUFFER_AGE_EXT:
      /* Both EXT_buffer_age and KHR_partial_update accept EGL_BUFFER_AGE_EXT.
       * To be precise, the KHR one accepts EGL_BUFFER_AGE_KHR which is an
       * alias with the same numeric value.
       */
      if (!disp->Extensions.EXT_buffer_age &&
          !disp->Extensions.KHR_partial_update)
         return _eglError(EGL_BAD_ATTRIBUTE, "eglQuerySurface");

      _EGLContext *ctx = _eglGetCurrentContext();
      EGLint result = drv->API.QueryBufferAge(drv, disp, surface);
      /* error happened */
      if (result < 0)
         return EGL_FALSE;
      if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT ||
          ctx->DrawSurface != surface)
         return _eglError(EGL_BAD_SURFACE, "eglQuerySurface");

      *value = result;
      surface->BufferAgeRead = EGL_TRUE;
      break;
   case EGL_SMPTE2086_DISPLAY_PRIMARY_RX_EXT:
      *value = surface->HdrMetadata.display_primary_r.x;
      break;
   case EGL_SMPTE2086_DISPLAY_PRIMARY_RY_EXT:
      *value = surface->HdrMetadata.display_primary_r.y;
      break;
   case EGL_SMPTE2086_DISPLAY_PRIMARY_GX_EXT:
      *value = surface->HdrMetadata.display_primary_g.x;
      break;
   case EGL_SMPTE2086_DISPLAY_PRIMARY_GY_EXT:
      *value = surface->HdrMetadata.display_primary_g.y;
      break;
   case EGL_SMPTE2086_DISPLAY_PRIMARY_BX_EXT:
      *value = surface->HdrMetadata.display_primary_b.x;
      break;
   case EGL_SMPTE2086_DISPLAY_PRIMARY_BY_EXT:
      *value = surface->HdrMetadata.display_primary_b.y;
      break;
   case EGL_SMPTE2086_WHITE_POINT_X_EXT:
      *value = surface->HdrMetadata.white_point.x;
      break;
   case EGL_SMPTE2086_WHITE_POINT_Y_EXT:
      *value = surface->HdrMetadata.white_point.y;
      break;
   case EGL_SMPTE2086_MAX_LUMINANCE_EXT:
      *value = surface->HdrMetadata.max_luminance;
      break;
   case EGL_SMPTE2086_MIN_LUMINANCE_EXT:
      *value = surface->HdrMetadata.min_luminance;
      break;
   case EGL_CTA861_3_MAX_CONTENT_LIGHT_LEVEL_EXT:
      *value = surface->HdrMetadata.max_cll;
      break;
   case EGL_CTA861_3_MAX_FRAME_AVERAGE_LEVEL_EXT:
      *value = surface->HdrMetadata.max_fall;
      break;
   default:
      return _eglError(EGL_BAD_ATTRIBUTE, "eglQuerySurface");
   }

   return EGL_TRUE;
}
コード例 #7
0
ファイル: eglapi.c プロジェクト: astrofimov/vgallium
EGLContext EGLAPIENTRY
eglGetCurrentContext(void)
{
   _EGLContext *ctx = _eglGetCurrentContext();
   return _eglGetContextHandle(ctx);
}