// Retarget the current texture to the specified surface buffer. EGLBoolean eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) { EGL_API_ENTRY("%p, %p, %d", dpy, surface, buffer); EglDisplayImpl* display = EglDisplayImpl::GetDisplay(dpy); if (display == NULL || display->IsInitialized() == false) { SetError(EGL_BAD_DISPLAY); return EGL_FALSE; } SurfacePtr s = display->GetSurfaces().Get(surface); if (s == NULL) { SetError(EGL_BAD_SURFACE); return EGL_FALSE; } if (buffer != EGL_BACK_BUFFER) { SetError(EGL_BAD_PARAMETER); return EGL_FALSE; } if (s->GetTextureFormat() == EGL_NO_TEXTURE) { SetError(EGL_BAD_MATCH); return EGL_FALSE; } if (!(s->GetSurfaceType() & EGL_PBUFFER_BIT)) { SetError(EGL_BAD_SURFACE); return EGL_FALSE; } s->BindTexImage(); return EGL_TRUE; }
// Get the attribute value for the specified surface. EGLBoolean eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint* value) { EGL_API_ENTRY("%p, %p, 0x%x, %p", dpy, surface, attribute, value); EglDisplayImpl* display = EglDisplayImpl::GetDisplay(dpy); if (display == NULL || display->IsInitialized() == false) { SetError(EGL_BAD_DISPLAY); return EGL_FALSE; } SurfacePtr s = display->GetSurfaces().Get(surface); if (s == NULL) { SetError(EGL_BAD_SURFACE); return EGL_FALSE; } switch (attribute) { case EGL_CONFIG_ID: return display->GetConfigAttribute(s->config, EGL_CONFIG_ID, value); case EGL_WIDTH: *value = s->GetWidth(); return EGL_TRUE; case EGL_HEIGHT: *value = s->GetHeight(); return EGL_TRUE; case EGL_TEXTURE_FORMAT: *value = s->GetTextureFormat(); return EGL_TRUE; case EGL_TEXTURE_TARGET: *value = s->GetTextureTarget(); return EGL_TRUE; case EGL_SWAP_BEHAVIOR: *value = EGL_BUFFER_DESTROYED; return EGL_TRUE; case EGL_LARGEST_PBUFFER: // Not modified for a window or pixmap surface. // Ignore it when creating a pbuffer surface. if (s->GetSurfaceType() & EGL_PBUFFER_BIT) { *value = EGL_FALSE; } return EGL_TRUE; default: LOG_ALWAYS_FATAL("Unsupported attribute: %x", attribute); SetError(EGL_BAD_ATTRIBUTE); return EGL_FALSE; } }