Exemplo n.º 1
0
// Set the swap interval for the current draw surface.
EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval) {
  EGL_API_ENTRY("%p, %d", dpy, interval);
  EglDisplayImpl* display = EglDisplayImpl::GetDisplay(dpy);
  if (display == NULL || display->IsInitialized() == false) {
    SetError(EGL_BAD_DISPLAY);
    return EGL_FALSE;
  }
  ContextPtr context = GetContext();
  if (context == NULL) {
    SetError(EGL_BAD_CONTEXT);
    return EGL_FALSE;
  }
  if (context->GetSurface() == NULL) {
    SetError(EGL_BAD_SURFACE);
    return EGL_FALSE;
  }
  interval = ClampValue<EGLint>(interval, EglConfigImpl::kMinSwapInterval,
                                EglConfigImpl::kMaxSwapInterval);
  context->GetSurface()->SetSwapInterval(interval);
  return EGL_TRUE;
}
Exemplo n.º 2
0
// Get the surface associated with the current rendering context.
EGLSurface eglGetCurrentSurface(EGLint readdraw) {
  EGL_API_ENTRY("0x%x", readdraw);
  if (readdraw != EGL_READ && readdraw != EGL_DRAW) {
    SetError(EGL_BAD_PARAMETER);
    return EGL_NO_SURFACE;
  }
  ContextPtr context = GetContext();
  if (context == NULL) {
    return EGL_NO_SURFACE;
  }
  SurfacePtr surface = context->GetSurface();
  if (surface == NULL) {
    return EGL_NO_SURFACE;
  }
  return surface->GetKey();
}
Exemplo n.º 3
0
// Get the attribute value for the specified rendering context.
EGLBoolean eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute,
                           EGLint* value) {
  EGL_API_ENTRY("%p, %p, 0x%x, %p", dpy, ctx, attribute, value);
  EglDisplayImpl* display = EglDisplayImpl::GetDisplay(dpy);
  if (display == NULL || display->IsInitialized() == false) {
    SetError(EGL_BAD_DISPLAY);
    return EGL_FALSE;
  }
  ContextPtr context = display->GetContexts().Get(ctx);
  if (context == NULL) {
    SetError(EGL_BAD_CONTEXT);
    return EGL_FALSE;
  }

  switch (attribute) {
    case EGL_CONFIG_ID:
      return display->GetConfigAttribute(context->config, attribute, value);
    case EGL_CONTEXT_CLIENT_TYPE:
      *value = EGL_OPENGL_ES_API;
      return EGL_TRUE;
    case EGL_CONTEXT_CLIENT_VERSION:
      *value = context->GetVersion();
      return EGL_TRUE;
    case EGL_RENDER_BUFFER:
      if (context->GetSurface() == NULL)
        *value = EGL_NONE;
      else
        *value = EGL_BACK_BUFFER;  // single buffer not supported
      return EGL_TRUE;
    case EGL_ARC_UNDERLYING_CONTEXT: {
      NativeContext* native = context->GetNativeContext();
      *value = reinterpret_cast<EGLint>(Native::GetUnderlyingContext(native));
      return EGL_TRUE;
    }
    default:
      ALOGE("Unsupported attribute: %x", attribute);
      SetError(EGL_BAD_ATTRIBUTE);
      return EGL_FALSE;
  }
}