static void check_and_update_buffer_size(struct xlib_egl_surface *surface) { uint width, height; get_drawable_size(surface->Dpy, surface->Win, &width, &height); st_resize_framebuffer(surface->Framebuffer, width, height); surface->Base.Width = width; surface->Base.Height = height; }
/** * Called via eglCreateWindowSurface(), drv->API.CreateWindowSurface(). */ static EGLSurface xlib_eglCreateWindowSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list) { struct xlib_egl_driver *xdrv = xlib_egl_driver(drv); _EGLDisplay *disp = _eglLookupDisplay(dpy); _EGLConfig *conf = _eglLookupConfig(drv, dpy, config); struct xlib_egl_surface *surf; __GLcontextModes visual; uint width, height; surf = CALLOC_STRUCT(xlib_egl_surface); if (!surf) return EGL_NO_SURFACE; /* Let EGL lib init the common stuff */ if (!_eglInitSurface(drv, dpy, &surf->Base, EGL_WINDOW_BIT, config, attrib_list)) { free(surf); return EGL_NO_SURFACE; } _eglSaveSurface(&surf->Base); /* * Now init the Xlib and gallium stuff */ surf->Win = (Window) window; /* The X window ID */ surf->Dpy = disp->Xdpy; /* The X display */ surf->Gc = XCreateGC(surf->Dpy, surf->Win, 0, NULL); surf->winsys = xdrv->winsys; _eglConfigToContextModesRec(conf, &visual); get_drawable_size(surf->Dpy, surf->Win, &width, &height); get_drawable_visual_info(surf->Dpy, surf->Win, &surf->VisInfo); surf->Base.Width = width; surf->Base.Height = height; /* Create GL statetracker framebuffer */ surf->Framebuffer = st_create_framebuffer(&visual, choose_color_format(&visual), choose_depth_format(&visual), choose_stencil_format(&visual), width, height, (void *) surf); st_resize_framebuffer(surf->Framebuffer, width, height); return _eglGetSurfaceHandle(&surf->Base); }
/** * Return the size of the window (or pixmap) that corresponds to the * given XMesaBuffer. * \param width returns width in pixels * \param height returns height in pixels */ void xmesa_get_window_size(Display *dpy, XMesaBuffer b, GLuint *width, GLuint *height) { XMesaDisplay xmdpy = xmesa_init_display(dpy); Status stat; pipe_mutex_lock(xmdpy->mutex); stat = get_drawable_size(dpy, b->ws.drawable, width, height); pipe_mutex_unlock(xmdpy->mutex); if (!stat) { /* probably querying a window that's recently been destroyed */ _mesa_warning(NULL, "XGetGeometry failed!\n"); *width = *height = 1; } }
/** * Return the size of the window (or pixmap) that corresponds to the * given XMesaBuffer. * \param width returns width in pixels * \param height returns height in pixels */ void xmesa_get_window_size(XMesaDisplay *dpy, XMesaBuffer b, GLuint *width, GLuint *height) { Status stat; _glthread_LOCK_MUTEX(_xmesa_lock); XSync(b->xm_visual->display, 0); /* added for Chromium */ stat = get_drawable_size(dpy, b->frontxrb->pixmap, width, height); _glthread_UNLOCK_MUTEX(_xmesa_lock); if (!stat) { /* probably querying a window that's recently been destroyed */ _mesa_warning(NULL, "XGetGeometry failed!\n"); *width = *height = 1; } }
/** * Allocate a new XMesaBuffer object which corresponds to the given drawable. * Note that XMesaBuffer is derived from struct gl_framebuffer. * The new XMesaBuffer will not have any size (Width=Height=0). * * \param d the corresponding X drawable (window or pixmap) * \param type either WINDOW, PIXMAP or PBUFFER, describing d * \param vis the buffer's visual * \param cmap the window's colormap, if known. * \return new XMesaBuffer or NULL if any problem */ static XMesaBuffer create_xmesa_buffer(Drawable d, BufferType type, XMesaVisual vis, Colormap cmap) { XMesaDisplay xmdpy = xmesa_init_display(vis->display); XMesaBuffer b; uint width, height; ASSERT(type == WINDOW || type == PIXMAP || type == PBUFFER); if (!xmdpy) return NULL; b = (XMesaBuffer) CALLOC_STRUCT(xmesa_buffer); if (!b) return NULL; b->ws.drawable = d; b->ws.visual = vis->visinfo->visual; b->ws.depth = vis->visinfo->depth; b->xm_visual = vis; b->type = type; b->cmap = cmap; get_drawable_size(vis->display, d, &width, &height); /* * Create framebuffer, but we'll plug in our own renderbuffers below. */ b->stfb = xmesa_create_st_framebuffer(xmdpy, b); /* GLX_EXT_texture_from_pixmap */ b->TextureTarget = 0; b->TextureFormat = GLX_TEXTURE_FORMAT_NONE_EXT; b->TextureMipmap = 0; /* insert buffer into linked list */ b->Next = XMesaBufferList; XMesaBufferList = b; return b; }
/** * Called via eglCreateWindowSurface(), drv->API.CreateWindowSurface(). */ static _EGLSurface * xdri_eglCreateWindowSurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, NativeWindowType window, const EGLint *attrib_list) { struct xdri_egl_display *xdri_dpy = lookup_display(dpy); struct xdri_egl_config *xdri_config = lookup_config(conf); struct xdri_egl_surface *xdri_surf; uint width, height; xdri_surf = CALLOC_STRUCT(xdri_egl_surface); if (!xdri_surf) { _eglError(EGL_BAD_ALLOC, "eglCreateWindowSurface"); return NULL; } if (!_eglInitSurface(drv, &xdri_surf->Base, EGL_WINDOW_BIT, &xdri_config->Base, attrib_list)) { free(xdri_surf); return NULL; } xdri_surf->driDrawable = xdri_dpy->psc->driScreen->createDrawable(xdri_dpy->psc, (XID) window, (GLXDrawable) window, xdri_config->mode); if (!xdri_surf->driDrawable) { free(xdri_surf); return NULL; } xdri_surf->drawable = (Drawable) window; get_drawable_size(xdri_dpy->dpy, window, &width, &height); xdri_surf->Base.Width = width; xdri_surf->Base.Height = height; return &xdri_surf->Base; }