summaryrefslogtreecommitdiff
path: root/applets/notification_area/status-notifier
diff options
context:
space:
mode:
Diffstat (limited to 'applets/notification_area/status-notifier')
-rw-r--r--applets/notification_area/status-notifier/sn-item-v0.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/applets/notification_area/status-notifier/sn-item-v0.c b/applets/notification_area/status-notifier/sn-item-v0.c
index 0ef0570a..0ab07ce4 100644
--- a/applets/notification_area/status-notifier/sn-item-v0.c
+++ b/applets/notification_area/status-notifier/sn-item-v0.c
@@ -344,6 +344,9 @@ surface_from_variant (GVariant *variant,
cairo_format_t format;
gint stride;
guint32 *data;
+ gint x;
+ gint y;
+ guchar *p;
format = CAIRO_FORMAT_ARGB32;
stride = cairo_format_stride_for_width (format, width);
@@ -358,6 +361,22 @@ surface_from_variant (GVariant *variant,
}
#endif
+ p = (guchar *) data;
+ /* premultiply alpha for Cairo */
+ for (y = 0; y < height; y++)
+ {
+ for (x = 0; x < width; x++)
+ {
+ guchar 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);
}