Example #1
0
static int
glamor_get_tex_format_type_from_pixmap(PixmapPtr pixmap,
                                       GLenum *format,
                                       GLenum *type,
                                       int *no_alpha,
                                       int *revert, int *swap_rb, int is_upload)
{
    glamor_pixmap_private *pixmap_priv;
    PictFormatShort pict_format;
    glamor_screen_private *glamor_priv =
        glamor_get_screen_private(pixmap->drawable.pScreen);

    pixmap_priv = glamor_get_pixmap_private(pixmap);
    if (GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv))
        pict_format = pixmap_priv->base.picture->format;
    else
        pict_format = format_for_depth(pixmap->drawable.depth);

    if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
        return glamor_get_tex_format_type_from_pictformat_gl(pict_format,
                                                             format, type,
                                                             no_alpha,
                                                             revert,
                                                             swap_rb,
                                                             is_upload);
    } else {
        return glamor_get_tex_format_type_from_pictformat_gles2(pict_format,
                                                                format, type,
                                                                no_alpha,
                                                                revert,
                                                                swap_rb,
                                                                is_upload);
    }
}
void
glamor_set_color_depth(ScreenPtr      pScreen,
                       int            depth,
                       CARD32         pixel,
                       GLint          uniform)
{
    glamor_screen_private *glamor_priv = glamor_get_screen_private(pScreen);
    float       color[4];

    glamor_get_rgba_from_pixel(pixel,
                               &color[0], &color[1], &color[2], &color[3],
                               format_for_depth(depth));

    if ((depth == 1 || depth == 8) &&
        glamor_priv->one_channel_format == GL_RED)
      color[0] = color[3];

    glUniform4fv(uniform, 1, color);
}