diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2015-09-21 17:42:30 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2015-09-21 19:40:03 +0200 |
commit | ec5e539809ec8d2bcdfbdfb70d080fc5edd217ea (patch) | |
tree | cf8e807eaa06ed1d1ef7357567fbcecd10075334 /src/cairo-utils.vala | |
parent | 72ff799b774500d38b1835761738eb52eb972944 (diff) | |
download | arctica-greeter-ec5e539809ec8d2bcdfbdfb70d080fc5edd217ea.tar.gz arctica-greeter-ec5e539809ec8d2bcdfbdfb70d080fc5edd217ea.tar.bz2 arctica-greeter-ec5e539809ec8d2bcdfbdfb70d080fc5edd217ea.zip |
Rebase against unity from Ubuntu 15.04
Diffstat (limited to 'src/cairo-utils.vala')
-rw-r--r-- | src/cairo-utils.vala | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/src/cairo-utils.vala b/src/cairo-utils.vala index a30a580..1bf0d85 100644 --- a/src/cairo-utils.vala +++ b/src/cairo-utils.vala @@ -38,81 +38,6 @@ public void rounded_rectangle (Cairo.Context c, double x, double y, c.rel_curve_to (0, -kappa, radius - kappa, -radius, radius, -radius); } -class GaussianBlur -{ - /* Gaussian Blur, based on Mirco Mueller work on notify-osd */ - - public static void surface (Cairo.ImageSurface surface, uint radius, double sigma = 0.0f) - { - if (surface.get_format () != Cairo.Format.ARGB32) - { - warning ("Impossible to blur a non ARGB32-formatted ImageSurface"); - return; - } - - surface.flush (); - - double radiusf = Math.fabs (radius) + 1.0f; - - if (sigma == 0.0f) - sigma = Math.sqrt (-(radiusf * radiusf) / (2.0f * Math.log (1.0f / 255.0f))); - - int w = surface.get_width (); - int h = surface.get_height (); - int s = surface.get_stride (); - - // create pixman image for cairo image surface - unowned uchar[] p = surface.get_data (); - var src = new Pixman.Image.bits (Pixman.Format.A8R8G8B8, w, h, p, s); - - // attach gaussian kernel to pixman image - var params = create_gaussian_blur_kernel ((int) radius, sigma); - src.set_filter (Pixman.Filter.CONVOLUTION, params); - - // render blured image to new pixman image - Pixman.Image.composite (Pixman.Operation.SRC, src, null, src, - 0, 0, 0, 0, 0, 0, (uint16) w, (uint16) h); - - surface.mark_dirty (); - } - - private static Pixman.Fixed[] create_gaussian_blur_kernel (int radius, double sigma) - { - double scale2 = 2.0f * sigma * sigma; - double scale1 = 1.0f / (Math.PI * scale2); - int size = 2 * radius + 1; - int n_params = size * size; - double sum = 0; - - var tmp = new double[n_params]; - - // caluclate gaussian kernel in floating point format - for (int i = 0, x = -radius; x <= radius; ++x) - { - for (int y = -radius; y <= radius; ++y, ++i) - { - double u = x * x; - double v = y * y; - - tmp[i] = scale1 * Math.exp (-(u+v)/scale2); - - sum += tmp[i]; - } - } - - // normalize gaussian kernel and convert to fixed point format - var params = new Pixman.Fixed[n_params + 2]; - - params[0] = Pixman.Fixed.int (size); - params[1] = Pixman.Fixed.int (size); - - for (int i = 2; i < params.length; ++i) - params[i] = Pixman.Fixed.double (tmp[i] / sum); - - return params; - } -} - class ExponentialBlur { /* Exponential Blur, based on the Nux version */ |