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:
parent
9227237806
commit
8171d4c2d6
|
@ -291,7 +291,9 @@ exaTryDriverSolidFill(PicturePtr pSrc,
|
||||||
pixel = exaGetPixmapFirstPixel(pSrcPix);
|
pixel = exaGetPixmapFirstPixel(pSrcPix);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
pixel = pSrc->pSourcePict->solidFill.color;
|
miRenderColorToPixel(pSrc->pFormat,
|
||||||
|
&pSrc->pSourcePict->solidFill.fullcolor,
|
||||||
|
&pixel);
|
||||||
|
|
||||||
if (!exaGetRGBAFromPixel(pixel, &red, &green, &blue, &alpha,
|
if (!exaGetRGBAFromPixel(pixel, &red, &green, &blue, &alpha,
|
||||||
pSrc->pFormat, pSrc->format) ||
|
pSrc->pFormat, pSrc->format) ||
|
||||||
|
|
16
fb/fbpict.c
16
fb/fbpict.c
|
@ -220,20 +220,10 @@ static pixman_image_t *
|
||||||
create_solid_fill_image(PicturePtr pict)
|
create_solid_fill_image(PicturePtr pict)
|
||||||
{
|
{
|
||||||
PictSolidFill *solid = &pict->pSourcePict->solidFill;
|
PictSolidFill *solid = &pict->pSourcePict->solidFill;
|
||||||
pixman_color_t color;
|
/* pixman_color_t and xRenderColor have the same layout */
|
||||||
CARD32 a, r, g, b;
|
pixman_color_t *color = (pixman_color_t *)&solid->fullcolor;
|
||||||
|
|
||||||
a = (solid->color & 0xff000000) >> 24;
|
return pixman_image_create_solid_fill(color);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static pixman_image_t *
|
static pixman_image_t *
|
||||||
|
|
|
@ -508,12 +508,13 @@ glamor_set_blend(CARD8 op, glamor_program_alpha alpha, PicturePtr dst)
|
||||||
static Bool
|
static Bool
|
||||||
use_source_solid(CARD8 op, PicturePtr src, PicturePtr dst, glamor_program *prog)
|
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);
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -828,13 +828,11 @@ glamor_composite_choose_shader(CARD8 op,
|
||||||
source_solid_color[3] = 0.0;
|
source_solid_color[3] = 0.0;
|
||||||
}
|
}
|
||||||
else if (!source->pDrawable) {
|
else if (!source->pDrawable) {
|
||||||
if (source->pSourcePict->type == SourcePictTypeSolidFill) {
|
SourcePictPtr sp = source->pSourcePict;
|
||||||
|
if (sp->type == SourcePictTypeSolidFill) {
|
||||||
key.source = SHADER_SOURCE_SOLID;
|
key.source = SHADER_SOURCE_SOLID;
|
||||||
glamor_get_rgba_from_pixel(source->pSourcePict->solidFill.color,
|
glamor_get_rgba_from_color(&sp->solidFill.fullcolor,
|
||||||
&source_solid_color[0],
|
source_solid_color);
|
||||||
&source_solid_color[1],
|
|
||||||
&source_solid_color[2],
|
|
||||||
&source_solid_color[3], PICT_a8r8g8b8);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
goto fail;
|
goto fail;
|
||||||
|
@ -848,13 +846,11 @@ glamor_composite_choose_shader(CARD8 op,
|
||||||
|
|
||||||
if (mask) {
|
if (mask) {
|
||||||
if (!mask->pDrawable) {
|
if (!mask->pDrawable) {
|
||||||
if (mask->pSourcePict->type == SourcePictTypeSolidFill) {
|
SourcePictPtr sp = mask->pSourcePict;
|
||||||
|
if (sp->type == SourcePictTypeSolidFill) {
|
||||||
key.mask = SHADER_MASK_SOLID;
|
key.mask = SHADER_MASK_SOLID;
|
||||||
glamor_get_rgba_from_pixel
|
glamor_get_rgba_from_color(&sp->solidFill.fullcolor,
|
||||||
(mask->pSourcePict->solidFill.color,
|
mask_solid_color);
|
||||||
&mask_solid_color[0],
|
|
||||||
&mask_solid_color[1],
|
|
||||||
&mask_solid_color[2], &mask_solid_color[3], PICT_a8r8g8b8);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
|
@ -706,6 +706,15 @@ glamor_get_rgba_from_pixel(CARD32 pixel,
|
||||||
return TRUE;
|
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
|
inline static Bool
|
||||||
glamor_is_large_pixmap(PixmapPtr pixmap)
|
glamor_is_large_pixmap(PixmapPtr pixmap)
|
||||||
{
|
{
|
||||||
|
|
|
@ -875,6 +875,7 @@ CreateSolidPicture(Picture pid, xRenderColor * color, int *error)
|
||||||
}
|
}
|
||||||
pPicture->pSourcePict->type = SourcePictTypeSolidFill;
|
pPicture->pSourcePict->type = SourcePictTypeSolidFill;
|
||||||
pPicture->pSourcePict->solidFill.color = xRenderColorToCard32(*color);
|
pPicture->pSourcePict->solidFill.color = xRenderColorToCard32(*color);
|
||||||
|
memcpy(&pPicture->pSourcePict->solidFill.fullcolor, color, sizeof(*color));
|
||||||
return pPicture;
|
return pPicture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,7 @@ typedef struct pixman_transform PictTransform, *PictTransformPtr;
|
||||||
typedef struct _PictSolidFill {
|
typedef struct _PictSolidFill {
|
||||||
unsigned int type;
|
unsigned int type;
|
||||||
CARD32 color;
|
CARD32 color;
|
||||||
|
xRenderColor fullcolor;
|
||||||
} PictSolidFill, *PictSolidFillPtr;
|
} PictSolidFill, *PictSolidFillPtr;
|
||||||
|
|
||||||
typedef struct _PictGradientStop {
|
typedef struct _PictGradientStop {
|
||||||
|
|
Loading…
Reference in New Issue