Re: [PATCH 1/3] gl: Convert images to rgba or a8 formats when uploading with GLESv2
Uli Schlachter <[email protected]>
| Newsgroups | gmane.comp.lib.cairo |
|---|---|
| Message-ID | <[email protected]> |
On 08.12.2016 00:46, Bryce Harrington wrote: > From: Bryce Harrington <[email protected]> > > The GLESv2 backend supports only GL_RGBA and GL_ALPHA as supported > texture formats. So, make _cairo_gl_get_image_format_and_type_gles2 > force conversion of other image formats to either of these two as > appropriate when uploading images. > > Patch originally from Henry Song <[email protected]> > > Bryce Harrington <[email protected]> > > Signed-off-by: Bryce Harrington <[email protected]> > --- > src/cairo-gl-surface.c | 45 +++++++++++++++++++++++++++++++++++++++++ > src/cairo-gl-traps-compositor.c | 30 --------------------------- > 2 files changed, 45 insertions(+), 30 deletions(-) > > diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c > index e5e8205..8ecc3a9 100644 > --- a/src/cairo-gl-surface.c > +++ b/src/cairo-gl-surface.c > @@ -868,12 +868,54 @@ _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst, > cairo_image_surface_t *clone = NULL; > cairo_gl_context_t *ctx; > int cpp; > + cairo_image_surface_t *rgba_clone = NULL; > cairo_int_status_t status = CAIRO_INT_STATUS_SUCCESS; > > status = _cairo_gl_context_acquire (dst->base.device, &ctx); > if (unlikely (status)) > return status; > > + if (_cairo_gl_get_flavor () == CAIRO_GL_FLAVOR_ES2) { > + pixman_format_code_t pixman_format; > + cairo_surface_pattern_t pattern; > + cairo_bool_t require_conversion = FALSE; > + pixman_format = _cairo_is_little_endian () ? PIXMAN_a8b8g8r8 : PIXMAN_r8g8b8a8; > + > + if (src->base.content != CAIRO_CONTENT_ALPHA) { > + if (src->pixman_format != pixman_format) > + require_conversion = TRUE; > + } > + else if (dst->base.content != CAIRO_CONTENT_ALPHA) > + require_conversion = TRUE; > + else { > + if (src->pixman_format == PIXMAN_a1) { Should this perhaps better be src->pixman_format != PIXMAN_a8? Seems safer / more general to me. > + pixman_format = PIXMAN_a8; > + require_conversion = TRUE; > + } > + } [...] Besides that, I don't have enough clue about the requirements of GLES to say anything. Uli -- Happiness can't be found -- it finds you. - Majic -- cairo mailing list [email protected] https://lists.cairographics.org/mailman/listinfo/cairo