static void fill (pixman_image_t *image, uint32_t pixel) { uint8_t *data = (uint8_t *)pixman_image_get_data (image); int bytes_per_pixel = PIXMAN_FORMAT_BPP (pixman_image_get_format (image)) / 8; int n_bytes = pixman_image_get_stride (image) * pixman_image_get_height (image); int i; switch (bytes_per_pixel) { case 4: for (i = 0; i < n_bytes / 4; ++i) ((uint32_t *)data)[i] = pixel; break; case 2: pixel &= 0xffff; for (i = 0; i < n_bytes / 2; ++i) ((uint16_t *)data)[i] = pixel; break; case 1: pixel &= 0xff; for (i = 0; i < n_bytes; ++i) ((uint8_t *)data)[i] = pixel; break; default: assert (0); break; } }
static cairo_bool_t _cairo_image_surface_is_alpha_only (cairo_image_surface_t *surface) { int bpp, alpha, red, green, blue; if (surface->format != (cairo_format_t) -1) return surface->format == CAIRO_FORMAT_A1 || surface->format == CAIRO_FORMAT_A8; pixman_format_get_masks (pixman_image_get_format (surface->pixman_image), &bpp, &alpha, &red, &green, &blue); return red == 0 && blue == 0 && green == 0; }
WL_EXPORT void pixman_renderer_output_set_buffer(struct weston_output *output, pixman_image_t *buffer) { struct pixman_output_state *po = get_output_state(output); if (po->hw_buffer) pixman_image_unref(po->hw_buffer); po->hw_buffer = buffer; if (po->hw_buffer) { output->compositor->read_format = pixman_image_get_format(po->hw_buffer); pixman_image_ref(po->hw_buffer); } }
static void composite_clipped(pixman_image_t *src, pixman_image_t *mask, pixman_image_t *dest, const pixman_transform_t *transform, pixman_filter_t filter, pixman_region32_t *src_clip) { int n_box; pixman_box32_t *boxes; int32_t dest_width; int32_t dest_height; int src_stride; int bitspp; pixman_format_code_t src_format; void *src_data; int i; /* Hardcoded to use PIXMAN_OP_OVER, because sampling outside of * a Pixman image produces (0,0,0,0) instead of discarding the * fragment. */ dest_width = pixman_image_get_width(dest); dest_height = pixman_image_get_height(dest); src_format = pixman_image_get_format(src); src_stride = pixman_image_get_stride(src); bitspp = PIXMAN_FORMAT_BPP(src_format); src_data = pixman_image_get_data(src); assert(src_format); /* This would be massive overdraw, except when n_box is 1. */ boxes = pixman_region32_rectangles(src_clip, &n_box); for (i = 0; i < n_box; i++) { uint8_t *ptr = src_data; pixman_image_t *boximg; pixman_transform_t adj = *transform; ptr += boxes[i].y1 * src_stride; ptr += boxes[i].x1 * bitspp / 8; boximg = pixman_image_create_bits_no_clear(src_format, boxes[i].x2 - boxes[i].x1, boxes[i].y2 - boxes[i].y1, (uint32_t *)ptr, src_stride); pixman_transform_translate(&adj, NULL, pixman_int_to_fixed(-boxes[i].x1), pixman_int_to_fixed(-boxes[i].y1)); pixman_image_set_transform(boximg, &adj); pixman_image_set_filter(boximg, filter, NULL, 0); pixman_image_composite32(PIXMAN_OP_OVER, boximg, mask, dest, 0, 0, /* src_x, src_y */ 0, 0, /* mask_x, mask_y */ 0, 0, /* dest_x, dest_y */ dest_width, dest_height); pixman_image_unref(boximg); } if (n_box > 1) { static bool warned = false; if (!warned) weston_log("Pixman-renderer warning: %dx overdraw\n", n_box); warned = true; } }