Merge lp:~larsu/notify-osd/crisper-on-hidpi into lp:notify-osd
- crisper-on-hidpi
- Merge into trunk
Proposed by
Lars Karlitski
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Mirco Müller | ||||
Approved revision: | 491 | ||||
Merged at revision: | 489 | ||||
Proposed branch: | lp:~larsu/notify-osd/crisper-on-hidpi | ||||
Merge into: | lp:notify-osd | ||||
Diff against target: |
625 lines (+143/-132) 8 files modified
src/bubble.c (+99/-72) src/raico-blur.c (+13/-3) src/tile.c (+7/-11) src/tile.h (+3/-1) src/util.c (+15/-36) src/util.h (+0/-3) tests/test-grow-bubble.c (+1/-1) tests/test-scroll-text.c (+5/-5) |
||||
To merge this branch: | bzr merge lp:~larsu/notify-osd/crisper-on-hidpi | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mirco Müller (community) | Approve | ||
Review via email: mp+269930@code.launchpad.net |
Commit message
Render in native resolution on hidpi displays
Description of the change
Render in native resolution on hidpi displays
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/bubble.c' | |||
2 | --- src/bubble.c 2014-12-20 21:35:15 +0000 | |||
3 | +++ src/bubble.c 2015-09-02 14:41:24 +0000 | |||
4 | @@ -177,6 +177,23 @@ | |||
5 | 177 | static guint g_bubble_signals[LAST_SIGNAL] = { 0 }; | 177 | static guint g_bubble_signals[LAST_SIGNAL] = { 0 }; |
6 | 178 | gint g_pointer[2]; | 178 | gint g_pointer[2]; |
7 | 179 | 179 | ||
8 | 180 | static cairo_surface_t * | ||
9 | 181 | bubble_create_image_surface (Bubble* self, | ||
10 | 182 | cairo_format_t format, | ||
11 | 183 | gint width, | ||
12 | 184 | gint height) | ||
13 | 185 | { | ||
14 | 186 | cairo_surface_t *surface; | ||
15 | 187 | gint scale; | ||
16 | 188 | |||
17 | 189 | scale = gtk_widget_get_scale_factor (self->priv->widget); | ||
18 | 190 | |||
19 | 191 | surface = cairo_image_surface_create (format, scale * width, scale * height); | ||
20 | 192 | cairo_surface_set_device_scale (surface, scale, scale); | ||
21 | 193 | |||
22 | 194 | return surface; | ||
23 | 195 | } | ||
24 | 196 | |||
25 | 180 | static void | 197 | static void |
26 | 181 | draw_round_rect (cairo_t* cr, | 198 | draw_round_rect (cairo_t* cr, |
27 | 182 | gdouble aspect, // aspect-ratio | 199 | gdouble aspect, // aspect-ratio |
28 | @@ -372,7 +389,8 @@ | |||
29 | 372 | } | 389 | } |
30 | 373 | 390 | ||
31 | 374 | void | 391 | void |
33 | 375 | _draw_shadow (cairo_t* cr, | 392 | _draw_shadow (Bubble* self, |
34 | 393 | cairo_t* cr, | ||
35 | 376 | gdouble width, | 394 | gdouble width, |
36 | 377 | gdouble height, | 395 | gdouble height, |
37 | 378 | gint shadow_radius, | 396 | gint shadow_radius, |
38 | @@ -384,10 +402,13 @@ | |||
39 | 384 | cairo_t* cr_surf = NULL; | 402 | cairo_t* cr_surf = NULL; |
40 | 385 | cairo_matrix_t matrix; | 403 | cairo_matrix_t matrix; |
41 | 386 | raico_blur_t* blur = NULL; | 404 | raico_blur_t* blur = NULL; |
42 | 405 | double x_scale; | ||
43 | 406 | double y_scale; | ||
44 | 387 | 407 | ||
48 | 388 | tmp_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, | 408 | tmp_surface = bubble_create_image_surface (self, |
49 | 389 | 4 * shadow_radius, | 409 | CAIRO_FORMAT_ARGB32, |
50 | 390 | 4 * shadow_radius); | 410 | 4 * shadow_radius, |
51 | 411 | 4 * shadow_radius); | ||
52 | 391 | if (cairo_surface_status (tmp_surface) != CAIRO_STATUS_SUCCESS) { | 412 | if (cairo_surface_status (tmp_surface) != CAIRO_STATUS_SUCCESS) { |
53 | 392 | if (tmp_surface) | 413 | if (tmp_surface) |
54 | 393 | cairo_surface_destroy (tmp_surface); | 414 | cairo_surface_destroy (tmp_surface); |
55 | @@ -433,6 +454,9 @@ | |||
56 | 433 | cairo_image_surface_get_width (tmp_surface) / 2, | 454 | cairo_image_surface_get_width (tmp_surface) / 2, |
57 | 434 | cairo_image_surface_get_height (tmp_surface) / 2, | 455 | cairo_image_surface_get_height (tmp_surface) / 2, |
58 | 435 | cairo_image_surface_get_stride (tmp_surface)); | 456 | cairo_image_surface_get_stride (tmp_surface)); |
59 | 457 | cairo_surface_get_device_scale (tmp_surface, &x_scale, &y_scale); | ||
60 | 458 | cairo_surface_set_device_scale (new_surface, x_scale, y_scale); | ||
61 | 459 | |||
62 | 436 | pattern = cairo_pattern_create_for_surface (new_surface); | 460 | pattern = cairo_pattern_create_for_surface (new_surface); |
63 | 437 | if (cairo_pattern_status (pattern) != CAIRO_STATUS_SUCCESS) | 461 | if (cairo_pattern_status (pattern) != CAIRO_STATUS_SUCCESS) |
64 | 438 | { | 462 | { |
65 | @@ -639,7 +663,6 @@ | |||
66 | 639 | Defaults* d = self->defaults; | 663 | Defaults* d = self->defaults; |
67 | 640 | cairo_t* cr = NULL; | 664 | cairo_t* cr = NULL; |
68 | 641 | cairo_surface_t* scratch = NULL; | 665 | cairo_surface_t* scratch = NULL; |
69 | 642 | cairo_surface_t* dummy = NULL; | ||
70 | 643 | cairo_surface_t* clone = NULL; | 666 | cairo_surface_t* clone = NULL; |
71 | 644 | cairo_surface_t* normal = NULL; | 667 | cairo_surface_t* normal = NULL; |
72 | 645 | cairo_surface_t* blurred = NULL; | 668 | cairo_surface_t* blurred = NULL; |
73 | @@ -654,7 +677,8 @@ | |||
74 | 654 | if (priv->composited) | 677 | if (priv->composited) |
75 | 655 | { | 678 | { |
76 | 656 | scratch_shadow_size = EM2PIXELS (get_shadow_size (self), d); | 679 | scratch_shadow_size = EM2PIXELS (get_shadow_size (self), d); |
78 | 657 | scratch = cairo_image_surface_create ( | 680 | scratch = bubble_create_image_surface ( |
79 | 681 | self, | ||
80 | 658 | CAIRO_FORMAT_ARGB32, | 682 | CAIRO_FORMAT_ARGB32, |
81 | 659 | 3 * scratch_shadow_size, | 683 | 3 * scratch_shadow_size, |
82 | 660 | 3 * scratch_shadow_size); | 684 | 3 * scratch_shadow_size); |
83 | @@ -663,7 +687,8 @@ | |||
84 | 663 | { | 687 | { |
85 | 664 | // We must have at least some width to this scratch surface. | 688 | // We must have at least some width to this scratch surface. |
86 | 665 | scratch_shadow_size = 1; | 689 | scratch_shadow_size = 1; |
88 | 666 | scratch = cairo_image_surface_create ( | 690 | scratch = bubble_create_image_surface ( |
89 | 691 | self, | ||
90 | 667 | CAIRO_FORMAT_RGB24, | 692 | CAIRO_FORMAT_RGB24, |
91 | 668 | 3 * scratch_shadow_size, | 693 | 3 * scratch_shadow_size, |
92 | 669 | 3 * scratch_shadow_size); | 694 | 3 * scratch_shadow_size); |
93 | @@ -715,6 +740,7 @@ | |||
94 | 715 | if (priv->composited) | 740 | if (priv->composited) |
95 | 716 | { | 741 | { |
96 | 717 | _draw_shadow ( | 742 | _draw_shadow ( |
97 | 743 | self, | ||
98 | 718 | cr, | 744 | cr, |
99 | 719 | width, | 745 | width, |
100 | 720 | height, | 746 | height, |
101 | @@ -757,24 +783,10 @@ | |||
102 | 757 | cairo_destroy (cr); | 783 | cairo_destroy (cr); |
103 | 758 | 784 | ||
104 | 759 | // create temp. clone of scratch surface | 785 | // create temp. clone of scratch surface |
113 | 760 | dummy = cairo_image_surface_create_for_data ( | 786 | clone = copy_surface (scratch); |
106 | 761 | cairo_image_surface_get_data (scratch), | ||
107 | 762 | cairo_image_surface_get_format (scratch), | ||
108 | 763 | 3 * scratch_shadow_size, | ||
109 | 764 | 3 * scratch_shadow_size, | ||
110 | 765 | cairo_image_surface_get_stride (scratch)); | ||
111 | 766 | clone = copy_surface (dummy); | ||
112 | 767 | cairo_surface_destroy (dummy); | ||
114 | 768 | 787 | ||
115 | 769 | // create normal surface from that surface-clone | 788 | // create normal surface from that surface-clone |
124 | 770 | dummy = cairo_image_surface_create_for_data ( | 789 | normal = copy_surface (clone); |
117 | 771 | cairo_image_surface_get_data (clone), | ||
118 | 772 | cairo_image_surface_get_format (clone), | ||
119 | 773 | 2 * scratch_shadow_size, | ||
120 | 774 | 2 * scratch_shadow_size, | ||
121 | 775 | cairo_image_surface_get_stride (clone)); | ||
122 | 776 | normal = copy_surface (dummy); | ||
123 | 777 | cairo_surface_destroy (dummy); | ||
125 | 778 | 790 | ||
126 | 779 | // now blur the surface-clone | 791 | // now blur the surface-clone |
127 | 780 | blur = raico_blur_create (RAICO_BLUR_QUALITY_LOW); | 792 | blur = raico_blur_create (RAICO_BLUR_QUALITY_LOW); |
128 | @@ -783,30 +795,26 @@ | |||
129 | 783 | raico_blur_destroy (blur); | 795 | raico_blur_destroy (blur); |
130 | 784 | 796 | ||
131 | 785 | // create blurred version from that blurred surface-clone | 797 | // create blurred version from that blurred surface-clone |
141 | 786 | dummy = cairo_image_surface_create_for_data ( | 798 | blurred = copy_surface (clone); |
142 | 787 | cairo_image_surface_get_data (clone), | 799 | cairo_surface_destroy (clone); |
134 | 788 | cairo_image_surface_get_format (clone), | ||
135 | 789 | 2 * scratch_shadow_size, | ||
136 | 790 | 2 * scratch_shadow_size, | ||
137 | 791 | cairo_image_surface_get_stride (clone)); | ||
138 | 792 | blurred = copy_surface (dummy); | ||
139 | 793 | cairo_surface_destroy (dummy); | ||
140 | 794 | destroy_cloned_surface (clone); | ||
143 | 795 | 800 | ||
144 | 796 | // finally create tile with top-left shadow/background part | 801 | // finally create tile with top-left shadow/background part |
145 | 797 | if (priv->tile_background_part) | 802 | if (priv->tile_background_part) |
146 | 798 | tile_destroy (priv->tile_background_part); | 803 | tile_destroy (priv->tile_background_part); |
150 | 799 | priv->tile_background_part = tile_new_for_padding (normal, blurred); | 804 | priv->tile_background_part = tile_new_for_padding (normal, blurred, |
151 | 800 | destroy_cloned_surface (normal); | 805 | 3 * scratch_shadow_size, |
152 | 801 | destroy_cloned_surface (blurred); | 806 | 3 * scratch_shadow_size); |
153 | 807 | cairo_surface_destroy (normal); | ||
154 | 808 | cairo_surface_destroy (blurred); | ||
155 | 802 | 809 | ||
156 | 803 | // create surface(s) for full shadow/background tile | 810 | // create surface(s) for full shadow/background tile |
157 | 804 | if (priv->composited) | 811 | if (priv->composited) |
158 | 805 | { | 812 | { |
159 | 806 | // we need two RGBA-surfaces | 813 | // we need two RGBA-surfaces |
163 | 807 | normal = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, | 814 | normal = bubble_create_image_surface (self, |
164 | 808 | width, | 815 | CAIRO_FORMAT_ARGB32, |
165 | 809 | height); | 816 | width, |
166 | 817 | height); | ||
167 | 810 | if (cairo_surface_status (normal) != CAIRO_STATUS_SUCCESS) | 818 | if (cairo_surface_status (normal) != CAIRO_STATUS_SUCCESS) |
168 | 811 | { | 819 | { |
169 | 812 | cairo_surface_destroy (scratch); | 820 | cairo_surface_destroy (scratch); |
170 | @@ -817,9 +825,10 @@ | |||
171 | 817 | return; | 825 | return; |
172 | 818 | } | 826 | } |
173 | 819 | 827 | ||
177 | 820 | blurred = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, | 828 | blurred = bubble_create_image_surface (self, |
178 | 821 | width, | 829 | CAIRO_FORMAT_ARGB32, |
179 | 822 | height); | 830 | width, |
180 | 831 | height); | ||
181 | 823 | if (cairo_surface_status (blurred) != CAIRO_STATUS_SUCCESS) | 832 | if (cairo_surface_status (blurred) != CAIRO_STATUS_SUCCESS) |
182 | 824 | { | 833 | { |
183 | 825 | cairo_surface_destroy (normal); | 834 | cairo_surface_destroy (normal); |
184 | @@ -834,9 +843,10 @@ | |||
185 | 834 | else | 843 | else |
186 | 835 | { | 844 | { |
187 | 836 | // we need only one RGB-surface | 845 | // we need only one RGB-surface |
191 | 837 | normal = cairo_image_surface_create (CAIRO_FORMAT_RGB24, | 846 | normal = bubble_create_image_surface (self, |
192 | 838 | width, | 847 | CAIRO_FORMAT_RGB24, |
193 | 839 | height); | 848 | width, |
194 | 849 | height); | ||
195 | 840 | if (cairo_surface_status (normal) != CAIRO_STATUS_SUCCESS) | 850 | if (cairo_surface_status (normal) != CAIRO_STATUS_SUCCESS) |
196 | 841 | { | 851 | { |
197 | 842 | cairo_surface_destroy (scratch); | 852 | cairo_surface_destroy (scratch); |
198 | @@ -921,9 +931,9 @@ | |||
199 | 921 | if (priv->tile_background) | 931 | if (priv->tile_background) |
200 | 922 | tile_destroy (priv->tile_background); | 932 | tile_destroy (priv->tile_background); |
201 | 923 | if (priv->composited) | 933 | if (priv->composited) |
203 | 924 | priv->tile_background = tile_new_for_padding (normal, blurred); | 934 | priv->tile_background = tile_new_for_padding (normal, blurred, width, height); |
204 | 925 | else | 935 | else |
206 | 926 | priv->tile_background = tile_new_for_padding (normal, normal); | 936 | priv->tile_background = tile_new_for_padding (normal, normal, width, height); |
207 | 927 | 937 | ||
208 | 928 | // clean up | 938 | // clean up |
209 | 929 | if (priv->composited) | 939 | if (priv->composited) |
210 | @@ -936,16 +946,18 @@ | |||
211 | 936 | void | 946 | void |
212 | 937 | _refresh_icon (Bubble* self) | 947 | _refresh_icon (Bubble* self) |
213 | 938 | { | 948 | { |
218 | 939 | BubblePrivate* priv = self->priv; | 949 | BubblePrivate* priv = self->priv; |
219 | 940 | Defaults* d = self->defaults; | 950 | Defaults* d = self->defaults; |
220 | 941 | cairo_surface_t* normal = NULL; | 951 | cairo_surface_t* normal = NULL; |
221 | 942 | cairo_t* cr = NULL; | 952 | cairo_surface_t* icon_surface = NULL; |
222 | 953 | cairo_t* cr = NULL; | ||
223 | 943 | 954 | ||
224 | 944 | if (!priv->icon_pixbuf) | 955 | if (!priv->icon_pixbuf) |
225 | 945 | return; | 956 | return; |
226 | 946 | 957 | ||
227 | 947 | // create temp. scratch surface | 958 | // create temp. scratch surface |
229 | 948 | normal = cairo_image_surface_create ( | 959 | normal = bubble_create_image_surface ( |
230 | 960 | self, | ||
231 | 949 | CAIRO_FORMAT_ARGB32, | 961 | CAIRO_FORMAT_ARGB32, |
232 | 950 | EM2PIXELS (defaults_get_icon_size (d), d) + | 962 | EM2PIXELS (defaults_get_icon_size (d), d) + |
233 | 951 | 2 * BUBBLE_CONTENT_BLUR_RADIUS, | 963 | 2 * BUBBLE_CONTENT_BLUR_RADIUS, |
234 | @@ -969,10 +981,12 @@ | |||
235 | 969 | cairo_set_operator (cr, CAIRO_OPERATOR_OVER); | 981 | cairo_set_operator (cr, CAIRO_OPERATOR_OVER); |
236 | 970 | 982 | ||
237 | 971 | // render icon into normal surface | 983 | // render icon into normal surface |
242 | 972 | gdk_cairo_set_source_pixbuf (cr, | 984 | icon_surface = gdk_cairo_surface_create_from_pixbuf (priv->icon_pixbuf, 0, |
243 | 973 | priv->icon_pixbuf, | 985 | gtk_widget_get_window (priv->widget)); |
244 | 974 | BUBBLE_CONTENT_BLUR_RADIUS, | 986 | cairo_set_source_surface (cr, |
245 | 975 | BUBBLE_CONTENT_BLUR_RADIUS); | 987 | icon_surface, |
246 | 988 | BUBBLE_CONTENT_BLUR_RADIUS, | ||
247 | 989 | BUBBLE_CONTENT_BLUR_RADIUS); | ||
248 | 976 | cairo_paint (cr); | 990 | cairo_paint (cr); |
249 | 977 | 991 | ||
250 | 978 | // create the surface/blur-cache from the normal surface | 992 | // create the surface/blur-cache from the normal surface |
251 | @@ -982,6 +996,7 @@ | |||
252 | 982 | 996 | ||
253 | 983 | // clean up | 997 | // clean up |
254 | 984 | cairo_destroy (cr); | 998 | cairo_destroy (cr); |
255 | 999 | cairo_surface_destroy (icon_surface); | ||
256 | 985 | cairo_surface_destroy (normal); | 1000 | cairo_surface_destroy (normal); |
257 | 986 | } | 1001 | } |
258 | 987 | 1002 | ||
259 | @@ -998,7 +1013,8 @@ | |||
260 | 998 | gchar* text_font_face = NULL; | 1013 | gchar* text_font_face = NULL; |
261 | 999 | 1014 | ||
262 | 1000 | // create temp. scratch surface | 1015 | // create temp. scratch surface |
264 | 1001 | normal = cairo_image_surface_create ( | 1016 | normal = bubble_create_image_surface ( |
265 | 1017 | self, | ||
266 | 1002 | CAIRO_FORMAT_ARGB32, | 1018 | CAIRO_FORMAT_ARGB32, |
267 | 1003 | priv->title_width + 2 * BUBBLE_CONTENT_BLUR_RADIUS, | 1019 | priv->title_width + 2 * BUBBLE_CONTENT_BLUR_RADIUS, |
268 | 1004 | priv->title_height + 2 * BUBBLE_CONTENT_BLUR_RADIUS); | 1020 | priv->title_height + 2 * BUBBLE_CONTENT_BLUR_RADIUS); |
269 | @@ -1106,7 +1122,8 @@ | |||
270 | 1106 | gchar* text_font_face = NULL; | 1122 | gchar* text_font_face = NULL; |
271 | 1107 | 1123 | ||
272 | 1108 | // create temp. scratch surface | 1124 | // create temp. scratch surface |
274 | 1109 | normal = cairo_image_surface_create ( | 1125 | normal = bubble_create_image_surface ( |
275 | 1126 | self, | ||
276 | 1110 | CAIRO_FORMAT_ARGB32, | 1127 | CAIRO_FORMAT_ARGB32, |
277 | 1111 | priv->body_width + 2 * BUBBLE_CONTENT_BLUR_RADIUS, | 1128 | priv->body_width + 2 * BUBBLE_CONTENT_BLUR_RADIUS, |
278 | 1112 | priv->body_height + 2 * BUBBLE_CONTENT_BLUR_RADIUS); | 1129 | priv->body_height + 2 * BUBBLE_CONTENT_BLUR_RADIUS); |
279 | @@ -1212,7 +1229,8 @@ | |||
280 | 1212 | cairo_t* cr = NULL; | 1229 | cairo_t* cr = NULL; |
281 | 1213 | 1230 | ||
282 | 1214 | // create temp. scratch surface | 1231 | // create temp. scratch surface |
284 | 1215 | normal = cairo_image_surface_create ( | 1232 | normal = bubble_create_image_surface ( |
285 | 1233 | self, | ||
286 | 1216 | CAIRO_FORMAT_ARGB32, | 1234 | CAIRO_FORMAT_ARGB32, |
287 | 1217 | EM2PIXELS (defaults_get_bubble_width (d), d) - | 1235 | EM2PIXELS (defaults_get_bubble_width (d), d) - |
288 | 1218 | 3 * EM2PIXELS (defaults_get_margin_size (d), d) - | 1236 | 3 * EM2PIXELS (defaults_get_margin_size (d), d) - |
289 | @@ -1810,13 +1828,15 @@ | |||
290 | 1810 | 1828 | ||
291 | 1811 | static | 1829 | static |
292 | 1812 | GdkPixbuf* | 1830 | GdkPixbuf* |
294 | 1813 | load_icon (const gchar* filename, | 1831 | load_icon (Bubble* self, |
295 | 1832 | const gchar* filename, | ||
296 | 1814 | gint icon_size) | 1833 | gint icon_size) |
297 | 1815 | { | 1834 | { |
298 | 1816 | GdkPixbuf* buffer = NULL; | 1835 | GdkPixbuf* buffer = NULL; |
299 | 1817 | GdkPixbuf* pixbuf = NULL; | 1836 | GdkPixbuf* pixbuf = NULL; |
300 | 1818 | GtkIconTheme* theme = NULL; | 1837 | GtkIconTheme* theme = NULL; |
301 | 1819 | GError* error = NULL; | 1838 | GError* error = NULL; |
302 | 1839 | gint scale; | ||
303 | 1820 | 1840 | ||
304 | 1821 | /* sanity check */ | 1841 | /* sanity check */ |
305 | 1822 | g_return_val_if_fail (filename, NULL); | 1842 | g_return_val_if_fail (filename, NULL); |
306 | @@ -1825,25 +1845,28 @@ | |||
307 | 1825 | if (!strncmp (filename, "file://", 7)) | 1845 | if (!strncmp (filename, "file://", 7)) |
308 | 1826 | filename += 7; | 1846 | filename += 7; |
309 | 1827 | 1847 | ||
310 | 1848 | scale = gtk_widget_get_scale_factor (self->priv->widget); | ||
311 | 1849 | |||
312 | 1828 | if (filename[0] == '/') | 1850 | if (filename[0] == '/') |
313 | 1829 | { | 1851 | { |
314 | 1830 | /* load image into pixbuf */ | 1852 | /* load image into pixbuf */ |
315 | 1831 | pixbuf = gdk_pixbuf_new_from_file_at_scale (filename, | 1853 | pixbuf = gdk_pixbuf_new_from_file_at_scale (filename, |
318 | 1832 | icon_size, | 1854 | scale * icon_size, |
319 | 1833 | icon_size, | 1855 | scale * icon_size, |
320 | 1834 | TRUE, | 1856 | TRUE, |
321 | 1835 | NULL); | 1857 | NULL); |
322 | 1836 | } else { | 1858 | } else { |
323 | 1837 | /* TODO: rewrite, check for SVG support, raise apport | 1859 | /* TODO: rewrite, check for SVG support, raise apport |
324 | 1838 | ** notification for low-res icons */ | 1860 | ** notification for low-res icons */ |
325 | 1839 | theme = gtk_icon_theme_get_default (); | 1861 | theme = gtk_icon_theme_get_default (); |
333 | 1840 | buffer = gtk_icon_theme_load_icon (theme, | 1862 | buffer = gtk_icon_theme_load_icon_for_scale (theme, |
334 | 1841 | filename, | 1863 | filename, |
335 | 1842 | icon_size, | 1864 | icon_size, |
336 | 1843 | GTK_ICON_LOOKUP_FORCE_SVG | | 1865 | scale, |
337 | 1844 | GTK_ICON_LOOKUP_GENERIC_FALLBACK | | 1866 | GTK_ICON_LOOKUP_FORCE_SVG | |
338 | 1845 | GTK_ICON_LOOKUP_FORCE_SIZE, | 1867 | GTK_ICON_LOOKUP_GENERIC_FALLBACK | |
339 | 1846 | &error); | 1868 | GTK_ICON_LOOKUP_FORCE_SIZE, |
340 | 1869 | &error); | ||
341 | 1847 | if (error) | 1870 | if (error) |
342 | 1848 | { | 1871 | { |
343 | 1849 | g_print ("loading icon '%s' caused error: '%s'", | 1872 | g_print ("loading icon '%s' caused error: '%s'", |
344 | @@ -2431,7 +2454,8 @@ | |||
345 | 2431 | } | 2454 | } |
346 | 2432 | 2455 | ||
347 | 2433 | d = self->defaults; | 2456 | d = self->defaults; |
349 | 2434 | priv->icon_pixbuf = load_icon (filepath, | 2457 | priv->icon_pixbuf = load_icon (self, |
350 | 2458 | filepath, | ||
351 | 2435 | EM2PIXELS (defaults_get_icon_size (d), d)); | 2459 | EM2PIXELS (defaults_get_icon_size (d), d)); |
352 | 2436 | 2460 | ||
353 | 2437 | _refresh_icon (self); | 2461 | _refresh_icon (self); |
354 | @@ -2474,7 +2498,8 @@ | |||
355 | 2474 | #ifdef TEMPORARY_ICON_PREFIX_WORKAROUND | 2498 | #ifdef TEMPORARY_ICON_PREFIX_WORKAROUND |
356 | 2475 | notify_osd_iconname = g_strdup_printf (NOTIFY_OSD_ICON_PREFIX "-%s", | 2499 | notify_osd_iconname = g_strdup_printf (NOTIFY_OSD_ICON_PREFIX "-%s", |
357 | 2476 | filename); | 2500 | filename); |
359 | 2477 | priv->icon_pixbuf = load_icon (notify_osd_iconname, | 2501 | priv->icon_pixbuf = load_icon (self, |
360 | 2502 | notify_osd_iconname, | ||
361 | 2478 | EM2PIXELS (defaults_get_icon_size (d), | 2503 | EM2PIXELS (defaults_get_icon_size (d), |
362 | 2479 | d)); | 2504 | d)); |
363 | 2480 | g_free (notify_osd_iconname); | 2505 | g_free (notify_osd_iconname); |
364 | @@ -2482,7 +2507,8 @@ | |||
365 | 2482 | 2507 | ||
366 | 2483 | // fallback to non-notify-osd name | 2508 | // fallback to non-notify-osd name |
367 | 2484 | if (!priv->icon_pixbuf) | 2509 | if (!priv->icon_pixbuf) |
369 | 2485 | priv->icon_pixbuf = load_icon (filename, | 2510 | priv->icon_pixbuf = load_icon (self, |
370 | 2511 | filename, | ||
371 | 2486 | EM2PIXELS (defaults_get_icon_size (d), d)); | 2512 | EM2PIXELS (defaults_get_icon_size (d), d)); |
372 | 2487 | 2513 | ||
373 | 2488 | _refresh_icon (self); | 2514 | _refresh_icon (self); |
374 | @@ -3224,7 +3250,7 @@ | |||
375 | 3224 | d = self->defaults; | 3250 | d = self->defaults; |
376 | 3225 | priv = self->priv; | 3251 | priv = self->priv; |
377 | 3226 | 3252 | ||
379 | 3227 | surface = cairo_image_surface_create (CAIRO_FORMAT_A1, 1, 1); | 3253 | surface = bubble_create_image_surface (self, CAIRO_FORMAT_A1, 1, 1); |
380 | 3228 | if (cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS) { | 3254 | if (cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS) { |
381 | 3229 | if (surface) | 3255 | if (surface) |
382 | 3230 | cairo_surface_destroy (surface); | 3256 | cairo_surface_destroy (surface); |
383 | @@ -3418,6 +3444,7 @@ | |||
384 | 3418 | EM2PIXELS (defaults_get_icon_size (d), d), | 3444 | EM2PIXELS (defaults_get_icon_size (d), d), |
385 | 3419 | EM2PIXELS (defaults_get_icon_size (d), d), | 3445 | EM2PIXELS (defaults_get_icon_size (d), d), |
386 | 3420 | GDK_INTERP_BILINEAR); | 3446 | GDK_INTERP_BILINEAR); |
387 | 3447 | g_message ("resizing pixbuf to %d", EM2PIXELS (defaults_get_icon_size (d), d) ); | ||
388 | 3421 | g_object_unref (priv->icon_pixbuf); | 3448 | g_object_unref (priv->icon_pixbuf); |
389 | 3422 | priv->icon_pixbuf = pixbuf; | 3449 | priv->icon_pixbuf = pixbuf; |
390 | 3423 | } | 3450 | } |
391 | 3424 | 3451 | ||
392 | === modified file 'src/raico-blur.c' | |||
393 | --- src/raico-blur.c 2009-11-05 03:13:20 +0000 | |||
394 | +++ src/raico-blur.c 2015-09-02 14:41:24 +0000 | |||
395 | @@ -112,6 +112,9 @@ | |||
396 | 112 | cairo_surface_t* surface) | 112 | cairo_surface_t* surface) |
397 | 113 | { | 113 | { |
398 | 114 | cairo_format_t format; | 114 | cairo_format_t format; |
399 | 115 | double x_scale; | ||
400 | 116 | double y_scale; | ||
401 | 117 | guint radius; | ||
402 | 115 | 118 | ||
403 | 116 | // sanity checks | 119 | // sanity checks |
404 | 117 | if (!blur) | 120 | if (!blur) |
405 | @@ -151,20 +154,27 @@ | |||
406 | 151 | if (blur->priv->radius == 0) | 154 | if (blur->priv->radius == 0) |
407 | 152 | return; | 155 | return; |
408 | 153 | 156 | ||
409 | 157 | /* adjust radius for device scale. We don't support blurring | ||
410 | 158 | * different amounts in x and y, so just use the mean value | ||
411 | 159 | * between cairo's respective device scales (in practice they | ||
412 | 160 | * should always be the same). */ | ||
413 | 161 | cairo_surface_get_device_scale (surface, &x_scale, &y_scale); | ||
414 | 162 | radius = blur->priv->radius * 0.5 * (x_scale + y_scale); | ||
415 | 163 | |||
416 | 154 | // now do the real work | 164 | // now do the real work |
417 | 155 | switch (blur->priv->quality) | 165 | switch (blur->priv->quality) |
418 | 156 | { | 166 | { |
419 | 157 | case RAICO_BLUR_QUALITY_LOW: | 167 | case RAICO_BLUR_QUALITY_LOW: |
421 | 158 | surface_exponential_blur (surface, blur->priv->radius); | 168 | surface_exponential_blur (surface, radius); |
422 | 159 | break; | 169 | break; |
423 | 160 | 170 | ||
424 | 161 | case RAICO_BLUR_QUALITY_MEDIUM: | 171 | case RAICO_BLUR_QUALITY_MEDIUM: |
425 | 162 | //surface_stack_blur (surface, blur->priv->radius); | 172 | //surface_stack_blur (surface, blur->priv->radius); |
427 | 163 | surface_gaussian_blur (surface, blur->priv->radius); | 173 | surface_gaussian_blur (surface, radius); |
428 | 164 | break; | 174 | break; |
429 | 165 | 175 | ||
430 | 166 | case RAICO_BLUR_QUALITY_HIGH: | 176 | case RAICO_BLUR_QUALITY_HIGH: |
432 | 167 | surface_gaussian_blur (surface, blur->priv->radius); | 177 | surface_gaussian_blur (surface, radius); |
433 | 168 | break; | 178 | break; |
434 | 169 | } | 179 | } |
435 | 170 | } | 180 | } |
436 | 171 | 181 | ||
437 | === modified file 'src/tile.c' | |||
438 | --- src/tile.c 2010-12-06 00:17:02 +0000 | |||
439 | +++ src/tile.c 2015-09-02 14:41:24 +0000 | |||
440 | @@ -76,7 +76,9 @@ | |||
441 | 76 | 76 | ||
442 | 77 | tile_t* | 77 | tile_t* |
443 | 78 | tile_new_for_padding (cairo_surface_t* normal, | 78 | tile_new_for_padding (cairo_surface_t* normal, |
445 | 79 | cairo_surface_t* blurred) | 79 | cairo_surface_t* blurred, |
446 | 80 | gint width, | ||
447 | 81 | gint height) | ||
448 | 80 | { | 82 | { |
449 | 81 | tile_private_t* priv = NULL; | 83 | tile_private_t* priv = NULL; |
450 | 82 | tile_t* tile = NULL; | 84 | tile_t* tile = NULL; |
451 | @@ -93,20 +95,14 @@ | |||
452 | 93 | cairo_surface_status (blurred) != CAIRO_STATUS_SUCCESS) | 95 | cairo_surface_status (blurred) != CAIRO_STATUS_SUCCESS) |
453 | 94 | return NULL; | 96 | return NULL; |
454 | 95 | 97 | ||
455 | 96 | if (cairo_image_surface_get_width (normal) != | ||
456 | 97 | cairo_image_surface_get_width (blurred) && | ||
457 | 98 | cairo_image_surface_get_height (normal) != | ||
458 | 99 | cairo_image_surface_get_height (blurred)) | ||
459 | 100 | return NULL; | ||
460 | 101 | |||
461 | 102 | tile->priv = priv; | 98 | tile->priv = priv; |
462 | 103 | 99 | ||
463 | 104 | tile->priv->normal = copy_surface (normal); | 100 | tile->priv->normal = copy_surface (normal); |
464 | 105 | tile->priv->blurred = copy_surface (blurred); | 101 | tile->priv->blurred = copy_surface (blurred); |
465 | 106 | tile->priv->blur_radius = 0; | 102 | tile->priv->blur_radius = 0; |
466 | 107 | tile->priv->use_padding = TRUE; | 103 | tile->priv->use_padding = TRUE; |
469 | 108 | tile->priv->pad_width = cairo_image_surface_get_width (normal); | 104 | tile->priv->pad_width = width; |
470 | 109 | tile->priv->pad_height = cairo_image_surface_get_height (normal); | 105 | tile->priv->pad_height = height; |
471 | 110 | 106 | ||
472 | 111 | return tile; | 107 | return tile; |
473 | 112 | } | 108 | } |
474 | @@ -120,8 +116,8 @@ | |||
475 | 120 | //cairo_surface_write_to_png (tile->priv->normal, "./tile-normal.png"); | 116 | //cairo_surface_write_to_png (tile->priv->normal, "./tile-normal.png"); |
476 | 121 | //cairo_surface_write_to_png (tile->priv->blurred, "./tile-blurred.png"); | 117 | //cairo_surface_write_to_png (tile->priv->blurred, "./tile-blurred.png"); |
477 | 122 | 118 | ||
480 | 123 | destroy_cloned_surface (tile->priv->normal); | 119 | cairo_surface_destroy (tile->priv->normal); |
481 | 124 | destroy_cloned_surface (tile->priv->blurred); | 120 | cairo_surface_destroy (tile->priv->blurred); |
482 | 125 | 121 | ||
483 | 126 | g_free ((gpointer) tile->priv); | 122 | g_free ((gpointer) tile->priv); |
484 | 127 | g_free ((gpointer) tile); | 123 | g_free ((gpointer) tile); |
485 | 128 | 124 | ||
486 | === modified file 'src/tile.h' | |||
487 | --- src/tile.h 2009-07-14 14:11:40 +0000 | |||
488 | +++ src/tile.h 2015-09-02 14:41:24 +0000 | |||
489 | @@ -44,7 +44,9 @@ | |||
490 | 44 | 44 | ||
491 | 45 | tile_t* | 45 | tile_t* |
492 | 46 | tile_new_for_padding (cairo_surface_t* normal, | 46 | tile_new_for_padding (cairo_surface_t* normal, |
494 | 47 | cairo_surface_t* blurred); | 47 | cairo_surface_t* blurred, |
495 | 48 | gint width, | ||
496 | 49 | gint height); | ||
497 | 48 | 50 | ||
498 | 49 | void | 51 | void |
499 | 50 | tile_destroy (tile_t* tile); | 52 | tile_destroy (tile_t* tile); |
500 | 51 | 53 | ||
501 | === modified file 'src/util.c' | |||
502 | --- src/util.c 2009-10-25 06:00:23 +0000 | |||
503 | +++ src/util.c 2015-09-02 14:41:24 +0000 | |||
504 | @@ -139,51 +139,30 @@ | |||
505 | 139 | return text1; | 139 | return text1; |
506 | 140 | } | 140 | } |
507 | 141 | 141 | ||
508 | 142 | gboolean | ||
509 | 143 | destroy_cloned_surface (cairo_surface_t* surface) | ||
510 | 144 | { | ||
511 | 145 | gboolean finalref = FALSE; | ||
512 | 146 | g_return_val_if_fail (surface, FALSE); | ||
513 | 147 | |||
514 | 148 | if (cairo_surface_get_reference_count (surface) == 1) { | ||
515 | 149 | g_free (cairo_image_surface_get_data (surface)); | ||
516 | 150 | finalref = TRUE; | ||
517 | 151 | } | ||
518 | 152 | cairo_surface_destroy (surface); | ||
519 | 153 | return finalref; | ||
520 | 154 | } | ||
521 | 155 | |||
522 | 156 | cairo_surface_t* | 142 | cairo_surface_t* |
523 | 157 | copy_surface (cairo_surface_t* orig) | 143 | copy_surface (cairo_surface_t* orig) |
524 | 158 | { | 144 | { |
525 | 159 | cairo_surface_t* copy = NULL; | 145 | cairo_surface_t* copy = NULL; |
526 | 160 | guchar* pixels_src = NULL; | ||
527 | 161 | guchar* pixels_cpy = NULL; | ||
528 | 162 | cairo_format_t format; | 146 | cairo_format_t format; |
529 | 163 | gint width; | 147 | gint width; |
530 | 164 | gint height; | 148 | gint height; |
538 | 165 | gint stride; | 149 | cairo_t* cr; |
539 | 166 | 150 | double x_scale; | |
540 | 167 | pixels_src = cairo_image_surface_get_data (orig); | 151 | double y_scale; |
541 | 168 | if (!pixels_src) | 152 | |
535 | 169 | return NULL; | ||
536 | 170 | |||
537 | 171 | format = cairo_image_surface_get_format (orig); | ||
542 | 172 | width = cairo_image_surface_get_width (orig); | 153 | width = cairo_image_surface_get_width (orig); |
543 | 173 | height = cairo_image_surface_get_height (orig); | 154 | height = cairo_image_surface_get_height (orig); |
557 | 174 | stride = cairo_image_surface_get_stride (orig); | 155 | format = cairo_image_surface_get_format (orig); |
558 | 175 | 156 | cairo_surface_get_device_scale (orig, &x_scale, &y_scale); | |
559 | 176 | pixels_cpy = g_malloc0 (stride * height); | 157 | |
560 | 177 | if (!pixels_cpy) | 158 | copy = cairo_surface_create_similar_image (orig, format, width, height); |
561 | 178 | return NULL; | 159 | cairo_surface_set_device_scale (copy, x_scale, y_scale); |
562 | 179 | 160 | ||
563 | 180 | memcpy ((void*) pixels_cpy, (void*) pixels_src, height * stride); | 161 | cr = cairo_create (copy); |
564 | 181 | 162 | cairo_set_source_surface (cr, orig, 0, 0); | |
565 | 182 | copy = cairo_image_surface_create_for_data (pixels_cpy, | 163 | cairo_paint (cr); |
566 | 183 | format, | 164 | |
567 | 184 | width, | 165 | cairo_destroy (cr); |
555 | 185 | height, | ||
556 | 186 | stride); | ||
568 | 187 | 166 | ||
569 | 188 | return copy; | 167 | return copy; |
570 | 189 | } | 168 | } |
571 | 190 | 169 | ||
572 | === modified file 'src/util.h' | |||
573 | --- src/util.h 2009-10-25 06:00:23 +0000 | |||
574 | +++ src/util.h 2015-09-02 14:41:24 +0000 | |||
575 | @@ -46,9 +46,6 @@ | |||
576 | 46 | cairo_surface_t* | 46 | cairo_surface_t* |
577 | 47 | copy_surface (cairo_surface_t* orig); | 47 | copy_surface (cairo_surface_t* orig); |
578 | 48 | 48 | ||
579 | 49 | gboolean | ||
580 | 50 | destroy_cloned_surface (cairo_surface_t* surface); | ||
581 | 51 | |||
582 | 52 | gchar* | 49 | gchar* |
583 | 53 | get_wm_name (Display* dpy); | 50 | get_wm_name (Display* dpy); |
584 | 54 | 51 | ||
585 | 55 | 52 | ||
586 | === modified file 'tests/test-grow-bubble.c' | |||
587 | --- tests/test-grow-bubble.c 2014-12-20 18:39:52 +0000 | |||
588 | +++ tests/test-grow-bubble.c 2015-09-02 14:41:24 +0000 | |||
589 | @@ -651,7 +651,7 @@ | |||
590 | 651 | cairo_surface_destroy (tmp); | 651 | cairo_surface_destroy (tmp); |
591 | 652 | cairo_surface_destroy (dummy_surf); | 652 | cairo_surface_destroy (dummy_surf); |
592 | 653 | 653 | ||
594 | 654 | g_tile = tile_new_for_padding (norm_surf, blur_surf); | 654 | g_tile = tile_new_for_padding (norm_surf, blur_surf, width, height); |
595 | 655 | cairo_surface_destroy (norm_surf); | 655 | cairo_surface_destroy (norm_surf); |
596 | 656 | cairo_surface_destroy (blur_surf); | 656 | cairo_surface_destroy (blur_surf); |
597 | 657 | 657 | ||
598 | 658 | 658 | ||
599 | === modified file 'tests/test-scroll-text.c' | |||
600 | --- tests/test-scroll-text.c 2014-12-20 18:39:52 +0000 | |||
601 | +++ tests/test-scroll-text.c 2015-09-02 14:41:24 +0000 | |||
602 | @@ -826,10 +826,10 @@ | |||
603 | 826 | cairo_surface_destroy (tmp); | 826 | cairo_surface_destroy (tmp); |
604 | 827 | 827 | ||
605 | 828 | // actually create the tile with padding in mind | 828 | // actually create the tile with padding in mind |
610 | 829 | tile = tile_new_for_padding (norm_surf, blur_surf); | 829 | tile = tile_new_for_padding (norm_surf, blur_surf, width, height); |
611 | 830 | destroy_cloned_surface (norm_surf); | 830 | cairo_surface_destroy (norm_surf); |
612 | 831 | destroy_cloned_surface (blur_surf); | 831 | cairo_surface_destroy (blur_surf); |
613 | 832 | destroy_cloned_surface (dummy_surf); | 832 | cairo_surface_destroy (dummy_surf); |
614 | 833 | 833 | ||
615 | 834 | cairo_destroy (cr); | 834 | cairo_destroy (cr); |
616 | 835 | cairo_surface_destroy (cr_surf); | 835 | cairo_surface_destroy (cr_surf); |
617 | @@ -852,7 +852,7 @@ | |||
618 | 852 | tile_paint_with_padding (tile, cr, 0.0f, 0.0f, w, h, 0.0f, 1.0f); | 852 | tile_paint_with_padding (tile, cr, 0.0f, 0.0f, w, h, 0.0f, 1.0f); |
619 | 853 | cairo_destroy (cr); | 853 | cairo_destroy (cr); |
620 | 854 | 854 | ||
622 | 855 | g_tile = tile_new_for_padding (norm_surf, blur_surf); | 855 | g_tile = tile_new_for_padding (norm_surf, blur_surf, width, height); |
623 | 856 | 856 | ||
624 | 857 | // clean up | 857 | // clean up |
625 | 858 | tile_destroy (tile); | 858 | tile_destroy (tile); |
Reviewed and tested it. Looking good.