+#include "pixman-helper.h"
+
#include <assert.h>
#include <stdbool.h>
#include <stdio.h>
}
}
-static void image_fill_color(pixman_image_t *image,
- uint8_t r, uint8_t g, uint8_t b);
-static pixman_image_t *image_from_buffer(struct ds_buffer *buffer,
- enum ds_buffer_data_ptr_access_flag access_flag);
static void view_send_frame_done(struct tinyds_view *view);
static void
if (!output_buffer)
return;
- output_image = image_from_buffer(output_buffer,
+ output_image = pixman_image_from_buffer(output_buffer,
DS_BUFFER_DATA_PTR_ACCESS_WRITE);
if (!output_image) {
ds_buffer_unlock(output_buffer);
return;
}
- image_fill_color(output_image, 80, 80, 80);
+ pixman_image_fill_color(output_image, 80, 80, 80);
wl_list_for_each(view, &output->server->views, link) {
if (!view->mapped)
if (!buffer)
return;
- src_image = image_from_buffer(buffer,
+ src_image = pixman_image_from_buffer(buffer,
DS_BUFFER_DATA_PTR_ACCESS_READ);
pixman_image_composite32(PIXMAN_OP_OVER,
src_image,
view_send_frame_done(view);
}
-static pixman_color_t *
-color_rgb888(pixman_color_t *tmp, uint8_t r, uint8_t g, uint8_t b)
-{
- tmp->alpha = 65535;
- tmp->red = (r << 8) + r;
- tmp->green = (g << 8) + g;
- tmp->blue = (b << 8) +b;
-
- return tmp;
-}
-
-static void
-image_fill_color(pixman_image_t *image, uint8_t r, uint8_t g, uint8_t b)
-{
- pixman_image_t *color_image;
- pixman_color_t color;
-
- color_rgb888(&color, r, g, b);
- color_image = pixman_image_create_solid_fill(&color);
- pixman_image_composite32(PIXMAN_OP_SRC,
- color_image,
- NULL,
- image,
- 0, 0, 0, 0, 0, 0,
- pixman_image_get_width(image),
- pixman_image_get_height(image));
- pixman_image_unref(color_image);
-}
-
-static void
-destroy_pixman_image(pixman_image_t *image TINYDS_UNUSED, void *data)
-{
- struct ds_buffer *buffer = data;
- ds_buffer_end_data_ptr_access(buffer);
- ds_buffer_unlock(buffer);
-}
-
-static uint32_t
-convert_drm_format_to_pixman(uint32_t fmt)
-{
- switch (fmt) {
- case DRM_FORMAT_XRGB8888:
- return PIXMAN_x8r8g8b8;
- case DRM_FORMAT_ARGB8888:
- return PIXMAN_a8r8g8b8;
- default:
- assert(0 && "not reached");
- }
-}
-
-static pixman_image_t *
-image_from_buffer(struct ds_buffer *buffer,
- enum ds_buffer_data_ptr_access_flag access_flag)
-{
- pixman_image_t *image;
- void *data;
- uint32_t format;
- size_t stride;
- int width, height;
-
- ds_buffer_get_size(buffer, &width, &height);
-
- if (!ds_buffer_begin_data_ptr_access(buffer,
- access_flag, &data, &format, &stride))
- return NULL;
-
- format = convert_drm_format_to_pixman(format);
- image = pixman_image_create_bits(format, width, height, data, stride);
- if (!image) {
- ds_buffer_end_data_ptr_access(buffer);
- return NULL;
- }
-
- pixman_image_set_destroy_function(image,
- destroy_pixman_image, ds_buffer_lock(buffer));
-
- return image;
-}
-
static void
view_send_frame_done(struct tinyds_view *view)
{