static void *swrast_fbdev_create_drawable(struct native_fbdev_screen *hfbdev_screen, int fd, bool want_fence, unsigned xoffset, unsigned yoffset, unsigned width, unsigned height) { struct swrast_fbdev_screen *fbdev_screen = swrast_fbdev_screen(hfbdev_screen); struct fbdev_sw_drawable *drawable = CALLOC_STRUCT(fbdev_sw_drawable); struct fb_var_screeninfo vinfo; struct fb_fix_screeninfo finfo; if (fd != fbdev_screen->fd) return NULL; if (ioctl(fd, FBIOGET_VSCREENINFO, &vinfo)) return NULL; if (ioctl(fd, FBIOGET_FSCREENINFO, &finfo)) return NULL; /* sanitize the values */ if (xoffset + width > vinfo.xres_virtual) { if (xoffset > vinfo.xres_virtual) width = 0; else width = vinfo.xres_virtual - xoffset; } if (yoffset + height > vinfo.yres_virtual) { if (yoffset > vinfo.yres_virtual) height = 0; else height = vinfo.yres_virtual - yoffset; } drawable->format = vinfo_to_format(&vinfo); drawable->x = xoffset; drawable->y = yoffset; drawable->width = width; drawable->height = height; if(drawable->format == PIPE_FORMAT_NONE || !drawable->width || !drawable->height) { FREE(drawable); return NULL; } return drawable; }
static boolean fbdev_display_init_config(struct native_display *ndpy) { struct fbdev_display *fbdpy = fbdev_display(ndpy); struct native_config *nconf = &fbdpy->config; if (ioctl(fbdpy->fd, FBIOGET_VSCREENINFO, &fbdpy->config_vinfo)) return FALSE; nconf->color_format = vinfo_to_format(&fbdpy->config_vinfo); if (nconf->color_format == PIPE_FORMAT_NONE) return FALSE; nconf->buffer_mask = (1 << NATIVE_ATTACHMENT_BACK_LEFT); nconf->window_bit = TRUE; return TRUE; }
static boolean fbdev_surface_update_drawable(struct native_surface *nsurf, const struct fb_var_screeninfo *vinfo) { struct fbdev_surface *fbsurf = fbdev_surface(nsurf); unsigned x, y, width, height; x = vinfo->xoffset; y = vinfo->yoffset; width = MIN2(vinfo->xres, fbsurf->width); height = MIN2(vinfo->yres, fbsurf->height); /* sanitize the values */ if (x + width > vinfo->xres_virtual) { if (x > vinfo->xres_virtual) width = 0; else width = vinfo->xres_virtual - x; } if (y + height > vinfo->yres_virtual) { if (y > vinfo->yres_virtual) height = 0; else height = vinfo->yres_virtual - y; } fbsurf->drawable.format = vinfo_to_format(vinfo); fbsurf->drawable.x = vinfo->xoffset; fbsurf->drawable.y = vinfo->yoffset; fbsurf->drawable.width = vinfo->xres; fbsurf->drawable.height = vinfo->yres; return (fbsurf->drawable.format != PIPE_FORMAT_NONE && fbsurf->drawable.width && fbsurf->drawable.height); }