[gnome-panel] status-notifier: cairo wants premultiplied alpha
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel] status-notifier: cairo wants premultiplied alpha
- Date: Wed, 25 Jan 2017 11:55:00 +0000 (UTC)
commit d7eeee3b4594814c4b7b18550383631a7a06839a
Author: Colomban Wendling <cwendling hypra fr>
Date: Tue Jan 24 15:28:40 2017 +0100
status-notifier: cairo wants premultiplied alpha
ARGBA32 data sent from client is not (and must not be)
premultiplied alpha.
https://bugzilla.gnome.org/show_bug.cgi?id=777698
modules/external/status-notifier/sn-item-v0.c | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/modules/external/status-notifier/sn-item-v0.c b/modules/external/status-notifier/sn-item-v0.c
index ef86a01..4624e16 100644
--- a/modules/external/status-notifier/sn-item-v0.c
+++ b/modules/external/status-notifier/sn-item-v0.c
@@ -310,6 +310,8 @@ surface_from_variant (GVariant *variant,
cairo_format_t format;
gint stride;
guint32 *data;
+ guchar *p;
+ gint y;
format = CAIRO_FORMAT_ARGB32;
stride = cairo_format_stride_for_width (format, width);
@@ -324,6 +326,29 @@ surface_from_variant (GVariant *variant,
}
#endif
+ /* CAIRO_FORMAT_ARGB32 wants premultiplied alpha, but data sent from
+ * client is not (and must not be) premultiplied alpha.
+ */
+
+ p = (guchar *) data;
+ for (y = 0; y < height; y++)
+ {
+ gint x;
+
+ for (x = 0; x < width; x++)
+ {
+ guchar alpha;
+
+ alpha = p[x * 4 + 3];
+
+ p[x * 4 + 0] = (p[x * 4 + 0] * alpha) / 255;
+ p[x * 4 + 1] = (p[x * 4 + 1] * alpha) / 255;
+ p[x * 4 + 2] = (p[x * 4 + 2] * alpha) / 255;
+ }
+
+ p += stride;
+ }
+
return cairo_image_surface_create_for_data ((guchar *) data, format,
width, height, stride);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]