mirror of
https://github.com/labwc/labwc.git
synced 2025-11-06 13:29:58 -05:00
buffer: always set buffer->{cairo,surface} for simplification
This commit is contained in:
parent
d2a864dfe7
commit
c48324975d
5 changed files with 20 additions and 61 deletions
|
|
@ -112,32 +112,3 @@ set_cairo_color(cairo_t *cairo, const float *c)
|
|||
cairo_set_source_rgba(cairo, c[0] / alpha, c[1] / alpha,
|
||||
c[2] / alpha, alpha);
|
||||
}
|
||||
|
||||
struct surface_context
|
||||
get_cairo_surface_from_lab_data_buffer(struct lab_data_buffer *buffer)
|
||||
{
|
||||
/* Handle CAIRO_FORMAT_ARGB32 buffers */
|
||||
if (buffer->cairo) {
|
||||
return (struct surface_context){
|
||||
.is_duplicate = false,
|
||||
.surface = cairo_get_target(buffer->cairo),
|
||||
};
|
||||
}
|
||||
|
||||
/* Handle DRM_FORMAT_ARGB8888 buffers */
|
||||
int w = buffer->base.width;
|
||||
int h = buffer->base.height;
|
||||
cairo_surface_t *surface =
|
||||
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h);
|
||||
if (!surface) {
|
||||
return (struct surface_context){0};
|
||||
}
|
||||
unsigned char *data = cairo_image_surface_get_data(surface);
|
||||
cairo_surface_flush(surface);
|
||||
memcpy(data, buffer->data, h * buffer->stride);
|
||||
cairo_surface_mark_dirty(surface);
|
||||
return (struct surface_context){
|
||||
.is_duplicate = true,
|
||||
.surface = surface,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue