static int pixman_renderer_read_pixels(struct weston_output *output, pixman_format_code_t format, void *pixels, uint32_t x, uint32_t y, uint32_t width, uint32_t height) { struct pixman_output_state *po = get_output_state(output); pixman_transform_t transform; pixman_image_t *out_buf; if (!po->hw_buffer) { errno = ENODEV; return -1; } out_buf = pixman_image_create_bits(format, width, height, pixels, (PIXMAN_FORMAT_BPP(format) / 8) * width); /* Caller expects vflipped source image */ pixman_transform_init_translate(&transform, pixman_int_to_fixed (x), pixman_int_to_fixed (y - pixman_image_get_height (po->hw_buffer))); pixman_transform_scale(&transform, NULL, pixman_fixed_1, pixman_fixed_minus_1); pixman_image_set_transform(po->hw_buffer, &transform); pixman_image_composite32(PIXMAN_OP_SRC, po->hw_buffer, /* src */ NULL /* mask */, out_buf, /* dest */ 0, 0, /* src_x, src_y */ 0, 0, /* mask_x, mask_y */ 0, 0, /* dest_x, dest_y */ pixman_image_get_width (po->hw_buffer), /* width */ pixman_image_get_height (po->hw_buffer) /* height */); pixman_image_set_transform(po->hw_buffer, NULL); pixman_image_unref(out_buf); return 0; }
void PixmanBitmap::TiledBlit(int ox, int oy, Rect src_rect, Bitmap* src, Rect dst_rect, int opacity) { if (opacity < 0) return; if (opacity > 255) opacity = 255; if (ox >= src_rect.width) ox %= src_rect.width; if (oy >= src_rect.height) ox %= src_rect.height; if (ox < 0) ox += src_rect.width * ((-ox + src_rect.width - 1) / src_rect.width); if (oy < 0) oy += src_rect.height * ((-oy + src_rect.height - 1) / src_rect.height); pixman_image_t* src_bm = GetSubimage(src, src_rect); pixman_image_t* mask; if (opacity < 255) { pixman_color_t tcolor = {0, 0, 0, opacity << 8}; mask = pixman_image_create_solid_fill(&tcolor); } else mask = (pixman_image_t*) NULL; pixman_image_set_repeat(src_bm, PIXMAN_REPEAT_NORMAL); pixman_transform_t xform; pixman_transform_init_translate(&xform, pixman_int_to_fixed(ox), pixman_int_to_fixed(oy)); pixman_image_set_transform(src_bm, &xform); pixman_image_composite32(PIXMAN_OP_OVER, src_bm, mask, bitmap, 0, 0, 0, 0, dst_rect.x, dst_rect.y, dst_rect.width, dst_rect.height); pixman_image_unref(src_bm); if (mask != NULL) pixman_image_unref(mask); RefreshCallback(); }