diff options
-rw-r--r-- | src/sna/sna_gradient.c | 13 | ||||
-rw-r--r-- | src/sna/sna_render.c | 9 | ||||
-rw-r--r-- | src/sna/sna_render.h | 3 |
3 files changed, 23 insertions, 2 deletions
diff --git a/src/sna/sna_gradient.c b/src/sna/sna_gradient.c index 3f0d7a5a..26e41675 100644 --- a/src/sna/sna_gradient.c +++ b/src/sna/sna_gradient.c @@ -34,6 +34,19 @@ #define xFixedToDouble(f) pixman_fixed_to_double(f) +bool +sna_gradient_is_opaque(const PictGradient *gradient) +{ + int n; + + for (n = 0; n < gradient->nstops; n++) { + if (gradient->stops[n].color.alpha < 0xff00) + return false; + } + + return true; +} + static int sna_gradient_sample_width(PictGradient *gradient) { diff --git a/src/sna/sna_render.c b/src/sna/sna_render.c index dd757dd9..032dba7d 100644 --- a/src/sna/sna_render.c +++ b/src/sna/sna_render.c @@ -1480,8 +1480,13 @@ sna_render_picture_approximate_gradient(struct sna *sna, return -1; } + channel->is_opaque = sna_gradient_is_opaque(picture->pSourcePict); + channel->pict_format = + channel->is_opaque ? PIXMAN_x8r8g8b8 : PIXMAN_a8r8g8b8; + DBG(("%s: gradient is opaque? %d, selecting format %08x\n", + __FUNCTION__, channel->is_opaque, channel->pict_format)); assert(channel->card_format == -1); - channel->pict_format = PIXMAN_a8r8g8b8; + channel->bo = kgem_create_buffer_2d(&sna->kgem, w2, h2, 32, KGEM_BUFFER_WRITE_INPLACE, @@ -1492,7 +1497,7 @@ sna_render_picture_approximate_gradient(struct sna *sna, return 0; } - dst = pixman_image_create_bits(PIXMAN_a8r8g8b8, + dst = pixman_image_create_bits(channel->pict_format, w2, h2, ptr, channel->bo->pitch); if (!dst) { kgem_bo_destroy(&sna->kgem, channel->bo); diff --git a/src/sna/sna_render.h b/src/sna/sna_render.h index d4406c3b..ab69fe02 100644 --- a/src/sna/sna_render.h +++ b/src/sna/sna_render.h @@ -531,6 +531,9 @@ struct kgem_bo * sna_render_get_gradient(struct sna *sna, PictGradient *pattern); +bool +sna_gradient_is_opaque(const PictGradient *gradient); + uint32_t sna_rgba_for_color(uint32_t color, int depth); uint32_t sna_rgba_to_color(uint32_t rgba, uint32_t format); bool sna_get_rgba_from_pixel(uint32_t pixel, |