render: Store and use all 16bpc of precision for solid pixels (v2.1)

This plumbs the full width color for solid pictures through to fb, exa,
and glamor. External drivers and acceleration code may wish to make a
similar change for sufficiently new servers.

v2: Don't break ABI (Michel Dänzer)
v2.1: Use the (correct) full color in fb too (Michel Dänzer)

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Adam Jackson 2018-02-23 16:08:10 -05:00
parent 9227237806
commit 8171d4c2d6
7 changed files with 29 additions and 29 deletions

View File

@ -291,7 +291,9 @@ exaTryDriverSolidFill(PicturePtr pSrc,
pixel = exaGetPixmapFirstPixel(pSrcPix);
}
else
pixel = pSrc->pSourcePict->solidFill.color;
miRenderColorToPixel(pSrc->pFormat,
&pSrc->pSourcePict->solidFill.fullcolor,
&pixel);
if (!exaGetRGBAFromPixel(pixel, &red, &green, &blue, &alpha,
pSrc->pFormat, pSrc->format) ||

View File

@ -220,20 +220,10 @@ static pixman_image_t *
create_solid_fill_image(PicturePtr pict)
{
PictSolidFill *solid = &pict->pSourcePict->solidFill;
pixman_color_t color;
CARD32 a, r, g, b;
/* pixman_color_t and xRenderColor have the same layout */
pixman_color_t *color = (pixman_color_t *)&solid->fullcolor;
a = (solid->color & 0xff000000) >> 24;
r = (solid->color & 0x00ff0000) >> 16;
g = (solid->color & 0x0000ff00) >> 8;
b = (solid->color & 0x000000ff) >> 0;
color.alpha = (a << 8) | a;
color.red = (r << 8) | r;
color.green = (g << 8) | g;
color.blue = (b << 8) | b;
return pixman_image_create_solid_fill(&color);
return pixman_image_create_solid_fill(color);
}
static pixman_image_t *

View File

@ -508,12 +508,13 @@ glamor_set_blend(CARD8 op, glamor_program_alpha alpha, PicturePtr dst)
static Bool
use_source_solid(CARD8 op, PicturePtr src, PicturePtr dst, glamor_program *prog)
{
PictSolidFill *solid = &src->pSourcePict->solidFill;
float color[4];
glamor_get_rgba_from_color(&solid->fullcolor, color);
glamor_set_blend(op, prog->alpha, dst);
glUniform4fv(prog->fg_uniform, 1, color);
glamor_set_color_depth(dst->pDrawable->pScreen, 32,
src->pSourcePict->solidFill.color,
prog->fg_uniform);
return TRUE;
}

View File

@ -828,13 +828,11 @@ glamor_composite_choose_shader(CARD8 op,
source_solid_color[3] = 0.0;
}
else if (!source->pDrawable) {
if (source->pSourcePict->type == SourcePictTypeSolidFill) {
SourcePictPtr sp = source->pSourcePict;
if (sp->type == SourcePictTypeSolidFill) {
key.source = SHADER_SOURCE_SOLID;
glamor_get_rgba_from_pixel(source->pSourcePict->solidFill.color,
&source_solid_color[0],
&source_solid_color[1],
&source_solid_color[2],
&source_solid_color[3], PICT_a8r8g8b8);
glamor_get_rgba_from_color(&sp->solidFill.fullcolor,
source_solid_color);
}
else
goto fail;
@ -848,13 +846,11 @@ glamor_composite_choose_shader(CARD8 op,
if (mask) {
if (!mask->pDrawable) {
if (mask->pSourcePict->type == SourcePictTypeSolidFill) {
SourcePictPtr sp = mask->pSourcePict;
if (sp->type == SourcePictTypeSolidFill) {
key.mask = SHADER_MASK_SOLID;
glamor_get_rgba_from_pixel
(mask->pSourcePict->solidFill.color,
&mask_solid_color[0],
&mask_solid_color[1],
&mask_solid_color[2], &mask_solid_color[3], PICT_a8r8g8b8);
glamor_get_rgba_from_color(&sp->solidFill.fullcolor,
mask_solid_color);
}
else
goto fail;

View File

@ -706,6 +706,15 @@ glamor_get_rgba_from_pixel(CARD32 pixel,
return TRUE;
}
static inline void
glamor_get_rgba_from_color(const xRenderColor *color, float rgba[4])
{
rgba[0] = color->red / (float)UINT16_MAX;
rgba[1] = color->green / (float)UINT16_MAX;
rgba[2] = color->blue / (float)UINT16_MAX;
rgba[3] = color->alpha / (float)UINT16_MAX;
}
inline static Bool
glamor_is_large_pixmap(PixmapPtr pixmap)
{

View File

@ -875,6 +875,7 @@ CreateSolidPicture(Picture pid, xRenderColor * color, int *error)
}
pPicture->pSourcePict->type = SourcePictTypeSolidFill;
pPicture->pSourcePict->solidFill.color = xRenderColorToCard32(*color);
memcpy(&pPicture->pSourcePict->solidFill.fullcolor, color, sizeof(*color));
return pPicture;
}

View File

@ -68,6 +68,7 @@ typedef struct pixman_transform PictTransform, *PictTransformPtr;
typedef struct _PictSolidFill {
unsigned int type;
CARD32 color;
xRenderColor fullcolor;
} PictSolidFill, *PictSolidFillPtr;
typedef struct _PictGradientStop {