Skip to content
Commits on Source (25)
......@@ -974,39 +974,6 @@ struct weston_plane {
struct weston_drm_format_array;
struct weston_renderer {
int (*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);
void (*repaint_output)(struct weston_output *output,
pixman_region32_t *output_damage);
void (*flush_damage)(struct weston_surface *surface,
struct weston_buffer *buffer);
void (*attach)(struct weston_surface *es, struct weston_buffer *buffer);
void (*destroy)(struct weston_compositor *ec);
/** See weston_surface_get_content_size() */
void (*surface_get_content_size)(struct weston_surface *surface,
int *width, int *height);
/** See weston_surface_copy_content() */
int (*surface_copy_content)(struct weston_surface *surface,
void *target, size_t size,
int src_x, int src_y,
int width, int height);
/** See weston_compositor_import_dmabuf() */
bool (*import_dmabuf)(struct weston_compositor *ec,
struct linux_dmabuf_buffer *buffer);
const struct weston_drm_format_array *
(*get_supported_formats)(struct weston_compositor *ec);
bool (*fill_buffer_info)(struct weston_compositor *ec,
struct weston_buffer *buffer);
};
enum weston_capability {
/* backend/renderer supports arbitrary rotation */
WESTON_CAP_ROTATION_ANY = 0x0001,
......@@ -1252,6 +1219,9 @@ struct weston_buffer {
ORIGIN_TOP_LEFT, /* buffer content starts at (0,0) */
ORIGIN_BOTTOM_LEFT, /* buffer content starts at (0, height) */
} buffer_origin;
bool direct_display;
void *renderer_private;
void *backend_private;
const struct pixel_format_info *pixel_format;
......
......@@ -2444,6 +2444,7 @@ weston_buffer_from_resource(struct weston_compositor *ec,
} else if ((dmabuf = linux_dmabuf_buffer_get(buffer->resource))) {
buffer->type = WESTON_BUFFER_DMABUF;
buffer->dmabuf = dmabuf;
buffer->direct_display = dmabuf->direct_display;
buffer->width = dmabuf->attributes.width;
buffer->height = dmabuf->attributes.height;
buffer->pixel_format =
......@@ -2656,6 +2657,7 @@ weston_surface_attach_solid(struct weston_surface *surface,
surface->is_opaque = true;
pixman_region32_init_rect(&surface->opaque, 0, 0, w, h);
} else {
surface->is_opaque = false;
pixman_region32_init(&surface->opaque);
}
}
......@@ -2688,6 +2690,9 @@ weston_surface_attach(struct weston_surface *surface,
weston_surface_calculate_size_from_buffer(surface);
weston_presentation_feedback_discard_list(&surface->feedback_list);
if (buffer)
surface->is_opaque = pixel_format_is_opaque(buffer->pixel_format);
}
/** weston_compositor_damage_all
......@@ -4580,8 +4585,7 @@ weston_surface_set_label_func(struct weston_surface *surface,
*
* Retrieves the raw surface content size in pixels for the given surface.
* This is the whole content size in buffer pixels. If the surface
* has no content or the renderer does not implement this feature,
* zeroes are returned.
* has no content, zeroes are returned.
*
* This function is used to determine the buffer size needed for
* a weston_surface_copy_content() call.
......@@ -4590,15 +4594,15 @@ WL_EXPORT void
weston_surface_get_content_size(struct weston_surface *surface,
int *width, int *height)
{
struct weston_renderer *rer = surface->compositor->renderer;
struct weston_buffer *buffer = surface->buffer_ref.buffer;
if (!rer->surface_get_content_size) {
if (buffer) {
*width = buffer->width;
*height = buffer->height;
} else {
*width = 0;
*height = 0;
return;
}
rer->surface_get_content_size(surface, width, height);
}
/** Get the bounding box of a surface and its subsurfaces
......@@ -7726,6 +7730,9 @@ debug_scene_view_print_buffer(FILE *fp, struct weston_view *view)
buffer->width, buffer->height);
if (buffer->buffer_origin == ORIGIN_BOTTOM_LEFT)
fprintf(fp, "\t\t\tbottom-left origin\n");
if (buffer->direct_display)
fprintf(fp, "\t\t\tdirect-display buffer (no renderer access)\n");
}
static void
......
......@@ -43,6 +43,37 @@
#include <libweston/libweston.h>
#include "color.h"
/* compositor <-> renderer interface */
struct weston_renderer {
int (*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);
void (*repaint_output)(struct weston_output *output,
pixman_region32_t *output_damage);
void (*flush_damage)(struct weston_surface *surface,
struct weston_buffer *buffer);
void (*attach)(struct weston_surface *es, struct weston_buffer *buffer);
void (*destroy)(struct weston_compositor *ec);
/** See weston_surface_copy_content() */
int (*surface_copy_content)(struct weston_surface *surface,
void *target, size_t size,
int src_x, int src_y,
int width, int height);
/** See weston_compositor_import_dmabuf() */
bool (*import_dmabuf)(struct weston_compositor *ec,
struct linux_dmabuf_buffer *buffer);
const struct weston_drm_format_array *
(*get_supported_formats)(struct weston_compositor *ec);
bool (*fill_buffer_info)(struct weston_compositor *ec,
struct weston_buffer *buffer);
};
/* weston_buffer */
void
......
......@@ -714,8 +714,6 @@ pixman_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer)
return;
}
es->is_opaque = pixel_format_is_opaque(pixel_info);
ps->image = pixman_image_create_bits(pixel_info->pixman_format,
buffer->width, buffer->height,
wl_shm_buffer_get_data(shm_buffer),
......@@ -810,21 +808,6 @@ pixman_renderer_destroy(struct weston_compositor *ec)
ec->renderer = NULL;
}
static void
pixman_renderer_surface_get_content_size(struct weston_surface *surface,
int *width, int *height)
{
struct pixman_surface_state *ps = get_surface_state(surface);
if (ps->image) {
*width = pixman_image_get_width(ps->image);
*height = pixman_image_get_height(ps->image);
} else {
*width = 0;
*height = 0;
}
}
static int
pixman_renderer_surface_copy_content(struct weston_surface *surface,
void *target, size_t size,
......@@ -896,8 +879,6 @@ pixman_renderer_init(struct weston_compositor *ec)
renderer->base.flush_damage = pixman_renderer_flush_damage;
renderer->base.attach = pixman_renderer_attach;
renderer->base.destroy = pixman_renderer_destroy;
renderer->base.surface_get_content_size =
pixman_renderer_surface_get_content_size;
renderer->base.surface_copy_content =
pixman_renderer_surface_copy_content;
ec->renderer = &renderer->base;
......
This diff is collapsed.