{
struct gbm_dri_surface *surf = (struct gbm_dri_surface *) _surf;
struct dri2_egl_surface *dri2_surf = surf->dri_private;
- unsigned i;
- for (i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
+ for (unsigned i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
if (dri2_surf->color_buffers[i].bo == bo) {
dri2_surf->color_buffers[i].locked = false;
+ break;
}
}
}
{
struct gbm_dri_surface *surf = (struct gbm_dri_surface *) _surf;
struct dri2_egl_surface *dri2_surf = surf->dri_private;
- unsigned i;
- for (i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++)
+ for (unsigned i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++)
if (!dri2_surf->color_buffers[i].locked)
return 1;
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
- unsigned i;
dri2_dpy->core->destroyDrawable(dri2_surf->dri_drawable);
- for (i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
+ for (unsigned i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
if (dri2_surf->color_buffers[i].bo)
gbm_bo_destroy(dri2_surf->color_buffers[i].bo);
}
- for (i = 0; i < __DRI_BUFFER_COUNT; i++) {
+ for (unsigned i = 0; i < __DRI_BUFFER_COUNT; i++) {
if (dri2_surf->dri_buffers[i])
dri2_dpy->dri2->releaseBuffer(dri2_dpy->dri_screen,
dri2_surf->dri_buffers[i]);
dri2_egl_display(dri2_surf->base.Resource.Display);
struct gbm_dri_surface *surf = dri2_surf->gbm_surf;
int age = 0;
- unsigned i;
if (dri2_surf->back == NULL) {
- for (i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
+ for (unsigned i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
if (!dri2_surf->color_buffers[i].locked &&
dri2_surf->color_buffers[i].age >= age) {
dri2_surf->back = &dri2_surf->color_buffers[i];
if (dri2_surf->back->bo == NULL) {
if (surf->base.modifiers)
dri2_surf->back->bo = gbm_bo_create_with_modifiers(&dri2_dpy->gbm_dri->base,
- surf->base.width, surf->base.height,
+ surf->base.width,
+ surf->base.height,
surf->base.format,
surf->base.modifiers,
surf->base.count);
struct dri2_egl_surface *dri2_surf = loaderPrivate;
int i, j;
- dri2_surf->buffer_count = 0;
for (i = 0, j = 0; i < 2 * count; i += 2, j++) {
assert(attachments[i] < __DRI_BUFFER_COUNT);
- assert(dri2_surf->buffer_count < 5);
+ assert(j < ARRAY_SIZE(dri2_surf->buffers));
switch (attachments[i]) {
case __DRI_BUFFER_BACK_LEFT:
unsigned int *attachments_with_format;
__DRIbuffer *buffer;
const unsigned int format = 32;
- int i;
attachments_with_format = calloc(count, 2 * sizeof(unsigned int));
if (!attachments_with_format) {
return NULL;
}
- for (i = 0; i < count; ++i) {
+ for (int i = 0; i < count; ++i) {
attachments_with_format[2*i] = attachments[i];
attachments_with_format[2*i + 1] = format;
}
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw);
- unsigned i;
if (!dri2_dpy->flush) {
dri2_dpy->core->swapBuffers(dri2_surf->dri_drawable);
if (dri2_surf->base.Type == EGL_WINDOW_BIT) {
if (dri2_surf->current)
_eglError(EGL_BAD_SURFACE, "dri2_swap_buffers");
- for (i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++)
+ for (unsigned i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++)
if (dri2_surf->color_buffers[i].age > 0)
dri2_surf->color_buffers[i].age++;
/* Make sure we have a back buffer in case we're swapping without
* ever rendering. */
- if (get_back_bo(dri2_surf) < 0) {
- _eglError(EGL_BAD_ALLOC, "dri2_swap_buffers");
- return EGL_FALSE;
- }
+ if (get_back_bo(dri2_surf) < 0)
+ return _eglError(EGL_BAD_ALLOC, "dri2_swap_buffers");
dri2_surf->current = dri2_surf->back;
dri2_surf->current->age = 1;
return NULL;
}
- if (!_eglInitImage(&dri2_img->base, disp)) {
- free(dri2_img);
- return NULL;
- }
+ _eglInitImage(&dri2_img->base, disp);
dri2_img->dri_image = dri2_dpy->image->dupImage(dri_bo->image, dri2_img);
if (dri2_img->dri_image == NULL) {
void *loaderPrivate)
{
struct dri2_egl_surface *dri2_surf = loaderPrivate;
- int internal_stride, i;
+ int internal_stride;
struct gbm_dri_bo *bo;
+ uint32_t bpp;
+ int x_bytes, width_bytes;
+ char *src, *dst;
if (op != __DRI_SWRAST_IMAGE_OP_DRAW &&
op != __DRI_SWRAST_IMAGE_OP_SWAP)
return;
bo = gbm_dri_bo(dri2_surf->current->bo);
+
+ bpp = gbm_bo_get_bpp(&bo->base);
+ if (bpp == 0)
+ return;
+
+ x_bytes = x * (bpp >> 3);
+ width_bytes = width * (bpp >> 3);
+
if (gbm_dri_bo_map_dumb(bo) == NULL)
return;
internal_stride = bo->base.stride;
- for (i = 0; i < height; i++) {
- memcpy(bo->map + (x + i) * internal_stride + y,
- data + i * stride, stride);
+ dst = bo->map + x_bytes + (y * internal_stride);
+ src = data;
+
+ for (int i = 0; i < height; i++) {
+ memcpy(dst, src, width_bytes);
+ dst += internal_stride;
+ src += stride;
}
gbm_dri_bo_unmap_dumb(bo);
void *loaderPrivate)
{
struct dri2_egl_surface *dri2_surf = loaderPrivate;
- int internal_stride, stride, i;
+ int internal_stride, stride;
struct gbm_dri_bo *bo;
+ uint32_t bpp;
+ int x_bytes, width_bytes;
+ char *src, *dst;
if (get_swrast_front_bo(dri2_surf) < 0)
return;
bo = gbm_dri_bo(dri2_surf->current->bo);
- if (gbm_dri_bo_map_dumb(bo) == NULL)
+
+ bpp = gbm_bo_get_bpp(&bo->base);
+ if (bpp == 0)
return;
+ x_bytes = x * (bpp >> 3);
+ width_bytes = width * (bpp >> 3);
+
internal_stride = bo->base.stride;
- stride = width * 4;
+ stride = width_bytes;
- for (i = 0; i < height; i++) {
- memcpy(data + i * stride,
- bo->map + (x + i) * internal_stride + y, stride);
+ if (gbm_dri_bo_map_dumb(bo) == NULL)
+ return;
+
+ dst = data;
+ src = bo->map + x_bytes + (y * internal_stride);
+
+ for (int i = 0; i < height; i++) {
+ memcpy(dst, src, width_bytes);
+ dst += stride;
+ src += internal_stride;
}
gbm_dri_bo_unmap_dumb(bo);
{ GBM_FORMAT_ARGB8888, 0x00ff0000, 0xff000000 },
{ GBM_FORMAT_RGB565, 0x0000f800, 0x00000000 },
};
- EGLint attr_list[] = {
- EGL_NATIVE_VISUAL_ID, 0,
- EGL_NONE,
- };
+
unsigned int format_count[ARRAY_SIZE(visuals)] = { 0 };
- unsigned int count, i, j;
+ unsigned int config_count = 0;
- count = 0;
- for (i = 0; dri2_dpy->driver_configs[i]; i++) {
+ for (unsigned i = 0; dri2_dpy->driver_configs[i]; i++) {
unsigned int red, alpha;
dri2_dpy->core->getConfigAttrib(dri2_dpy->driver_configs[i],
dri2_dpy->core->getConfigAttrib(dri2_dpy->driver_configs[i],
__DRI_ATTRIB_ALPHA_MASK, &alpha);
- for (j = 0; j < ARRAY_SIZE(visuals); j++) {
+ for (unsigned j = 0; j < ARRAY_SIZE(visuals); j++) {
struct dri2_egl_config *dri2_conf;
if (visuals[j].red_mask != red || visuals[j].alpha_mask != alpha)
continue;
- attr_list[1] = visuals[j].format;
+ const EGLint attr_list[] = {
+ EGL_NATIVE_VISUAL_ID, visuals[j].format,
+ EGL_NONE,
+ };
dri2_conf = dri2_add_config(disp, dri2_dpy->driver_configs[i],
- count + 1, EGL_WINDOW_BIT, attr_list, NULL);
+ config_count + 1, EGL_WINDOW_BIT, attr_list, NULL);
if (dri2_conf) {
- count++;
+ if (dri2_conf->base.ConfigID == config_count + 1)
+ config_count++;
format_count[j]++;
}
}
}
- for (i = 0; i < ARRAY_SIZE(format_count); i++) {
+ for (unsigned i = 0; i < ARRAY_SIZE(format_count); i++) {
if (!format_count[i]) {
_eglLog(_EGL_DEBUG, "No DRI config supports native format 0x%x",
visuals[i].format);
}
}
- return (count != 0);
+ return (config_count != 0);
}
static const struct dri2_egl_display_vtbl dri2_drm_display_vtbl = {