Merge lp:~robert-ancell/unity-greeter/dead-gaussian-blur-code into lp:unity-greeter

Proposed by Robert Ancell
Status: Merged
Approved by: Robert Ancell
Approved revision: 1227
Merged at revision: 1228
Proposed branch: lp:~robert-ancell/unity-greeter/dead-gaussian-blur-code
Merge into: lp:unity-greeter
Diff against target: 85 lines (+0/-75)
1 file modified
src/cairo-utils.vala (+0/-75)
To merge this branch: bzr merge lp:~robert-ancell/unity-greeter/dead-gaussian-blur-code
Reviewer Review Type Date Requested Status
Robert Ancell Approve
Review via email: mp+217702@code.launchpad.net

Commit message

Drop unused code for Gaussian blur

To post a comment you must log in.
Revision history for this message
Robert Ancell (robert-ancell) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/cairo-utils.vala'
--- src/cairo-utils.vala 2013-11-12 07:20:48 +0000
+++ src/cairo-utils.vala 2014-04-30 00:14:04 +0000
@@ -38,81 +38,6 @@
38 c.rel_curve_to (0, -kappa, radius - kappa, -radius, radius, -radius);38 c.rel_curve_to (0, -kappa, radius - kappa, -radius, radius, -radius);
39}39}
4040
41class GaussianBlur
42{
43 /* Gaussian Blur, based on Mirco Mueller work on notify-osd */
44
45 public static void surface (Cairo.ImageSurface surface, uint radius, double sigma = 0.0f)
46 {
47 if (surface.get_format () != Cairo.Format.ARGB32)
48 {
49 warning ("Impossible to blur a non ARGB32-formatted ImageSurface");
50 return;
51 }
52
53 surface.flush ();
54
55 double radiusf = Math.fabs (radius) + 1.0f;
56
57 if (sigma == 0.0f)
58 sigma = Math.sqrt (-(radiusf * radiusf) / (2.0f * Math.log (1.0f / 255.0f)));
59
60 int w = surface.get_width ();
61 int h = surface.get_height ();
62 int s = surface.get_stride ();
63
64 // create pixman image for cairo image surface
65 unowned uchar[] p = surface.get_data ();
66 var src = new Pixman.Image.bits (Pixman.Format.A8R8G8B8, w, h, p, s);
67
68 // attach gaussian kernel to pixman image
69 var params = create_gaussian_blur_kernel ((int) radius, sigma);
70 src.set_filter (Pixman.Filter.CONVOLUTION, params);
71
72 // render blured image to new pixman image
73 Pixman.Image.composite (Pixman.Operation.SRC, src, null, src,
74 0, 0, 0, 0, 0, 0, (uint16) w, (uint16) h);
75
76 surface.mark_dirty ();
77 }
78
79 private static Pixman.Fixed[] create_gaussian_blur_kernel (int radius, double sigma)
80 {
81 double scale2 = 2.0f * sigma * sigma;
82 double scale1 = 1.0f / (Math.PI * scale2);
83 int size = 2 * radius + 1;
84 int n_params = size * size;
85 double sum = 0;
86
87 var tmp = new double[n_params];
88
89 // caluclate gaussian kernel in floating point format
90 for (int i = 0, x = -radius; x <= radius; ++x)
91 {
92 for (int y = -radius; y <= radius; ++y, ++i)
93 {
94 double u = x * x;
95 double v = y * y;
96
97 tmp[i] = scale1 * Math.exp (-(u+v)/scale2);
98
99 sum += tmp[i];
100 }
101 }
102
103 // normalize gaussian kernel and convert to fixed point format
104 var params = new Pixman.Fixed[n_params + 2];
105
106 params[0] = Pixman.Fixed.int (size);
107 params[1] = Pixman.Fixed.int (size);
108
109 for (int i = 2; i < params.length; ++i)
110 params[i] = Pixman.Fixed.double (tmp[i] / sum);
111
112 return params;
113 }
114}
115
116class ExponentialBlur41class ExponentialBlur
117{42{
118 /* Exponential Blur, based on the Nux version */43 /* Exponential Blur, based on the Nux version */

Subscribers

People subscribed via source and target branches