public
Description: a tiny graphical app kit for ruby
Homepage: http://code.whytheluckystiff.net/shoes
Clone URL: git://github.com/why/shoes.git
Search Repo:
 * shoes/ruby.c: simplify the image filters slightly by having them modify 
 the existing cairo surface rather than trying to create new ones.
why (author)
Mon May 12 16:52:58 -0700 2008
commit  65d242fbee1015ce07d2f5124e4c4ac6fab24cd2
tree    0b4b17f164e129dc8d68b3a084b3321d95bb2fa4
parent  879069d618e4475d23906a17c5aa6d8b14407c71
...
214
215
216
217
 
218
219
220
...
214
215
216
 
217
218
219
220
0
@@ -214,7 +214,7 @@ typedef struct {
0
 #endif
0
 } shoes_timer;
0
 
0
-typedef cairo_t *(*shoes_effect_filter)(cairo_t *, void *);
0
+typedef void (*shoes_effect_filter)(cairo_t *, void *);
0
 
0
 typedef struct {
0
   shoes_effect_filter filter;
...
1068
1069
1070
1071
1072
 
 
 
 
 
 
1073
1074
 
1075
1076
1077
...
1081
1082
1083
1084
 
1085
1086
1087
...
1134
1135
1136
1137
1138
1139
1140
 
1141
1142
1143
...
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
 
 
 
 
 
1174
1175
1176
 
1177
1178
1179
1180
1181
 
1182
1183
1184
 
1185
1186
1187
1188
1189
 
1190
1191
1192
1193
 
1194
1195
 
1196
1197
1198
...
1315
1316
1317
1318
 
1319
1320
1321
...
1068
1069
1070
 
 
1071
1072
1073
1074
1075
1076
1077
 
1078
1079
1080
1081
...
1085
1086
1087
 
1088
1089
1090
1091
...
1138
1139
1140
 
1141
1142
 
1143
1144
1145
1146
...
1167
1168
1169
 
 
 
 
 
 
 
1170
1171
1172
1173
1174
1175
1176
 
1177
1178
1179
1180
1181
 
1182
1183
1184
 
1185
1186
1187
1188
1189
 
1190
1191
1192
1193
 
1194
1195
 
1196
1197
1198
1199
...
1316
1317
1318
 
1319
1320
1321
1322
0
@@ -1068,10 +1068,14 @@ box_blur(unsigned char *in, unsigned char *out,
0
   unsigned int len = 4 * width * height
0
    
0
 #define RAW_FILTER_END(self_t) \
0
- cr = cairo_create(target); \
0
- cairo_surface_destroy(source);
0
+ cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR); \
0
+ cairo_paint(cr); \
0
+ cairo_set_operator(cr, CAIRO_OPERATOR_OVER); \
0
+ cairo_set_source_surface(cr, target, 0, 0); \
0
+ cairo_paint(cr); \
0
+ cairo_surface_destroy(target);
0
 
0
-cairo_t *
0
+void
0
 shoes_gaussian_blur_filter(cairo_t *cr, void *data)
0
 {
0
   shoes_effect *fx = (shoes_effect *)data;
0
@@ -1081,7 +1085,7 @@ shoes_gaussian_blur_filter(cairo_t *cr, void *data)
0
   float blur_y = ATTR2(dbl, fx->attr, height, blur_d);
0
 
0
   if (blur_x < 0 || blur_y < 0)
0
- return cr;
0
+ return;
0
 
0
   if (blur_x == 0 || blur_y == 0)
0
     memset(out, 0, len);
0
@@ -1134,10 +1138,9 @@ shoes_gaussian_blur_filter(cairo_t *cr, void *data)
0
 
0
   SHOE_FREE(tmp);
0
   RAW_FILTER_END(fx);
0
- return cr;
0
 }
0
 
0
-static cairo_t *
0
+static void
0
 shoes_layer_blur_filter(cairo_t *cr, void *data, cairo_operator_t blur_op,
0
   cairo_operator_t merge_op, int distance)
0
 {
0
@@ -1164,35 +1167,33 @@ shoes_layer_blur_filter(cairo_t *cr, void *data, cairo_operator_t blur_op,
0
   }
0
   cairo_rectangle(cr2, 0, 0, width, height);
0
   cairo_paint(cr2);
0
- cairo_t *cr3 = shoes_gaussian_blur_filter(cr2, data);
0
- cairo_set_operator(cr3, merge_op);
0
- cairo_set_source_surface(cr3, source, 0, 0);
0
- cairo_paint(cr3);
0
-
0
- cairo_destroy(cr);
0
- return cr3;
0
+ shoes_gaussian_blur_filter(cr2, data);
0
+ cairo_set_operator(cr, merge_op);
0
+ cairo_set_source_surface(cr, target, 0, 0);
0
+ cairo_paint(cr);
0
+ cairo_destroy(cr2);
0
 }
0
 
0
-cairo_t *
0
+void
0
 shoes_shadow_filter(cairo_t *cr, void *data)
0
 {
0
   shoes_effect *fx = (shoes_effect *)data;
0
   int distance = ATTR2(int, fx->attr, distance, 4);
0
- return shoes_layer_blur_filter(cr, data, CAIRO_OPERATOR_IN, CAIRO_OPERATOR_OVER, distance);
0
+ shoes_layer_blur_filter(cr, data, CAIRO_OPERATOR_IN, CAIRO_OPERATOR_OVER, distance);
0
 }
0
 
0
-cairo_t *
0
+void
0
 shoes_glow_filter(cairo_t *cr, void *data)
0
 {
0
   shoes_effect *fx = (shoes_effect *)data;
0
   cairo_operator_t blur_op = CAIRO_OPERATOR_IN;
0
- cairo_operator_t merge_op = CAIRO_OPERATOR_OVER;
0
+ cairo_operator_t merge_op = CAIRO_OPERATOR_DEST_OVER;
0
   if (RTEST(ATTR(fx->attr, inner)))
0
   {
0
     blur_op = CAIRO_OPERATOR_OUT;
0
- merge_op = CAIRO_OPERATOR_DEST_ATOP;
0
+ merge_op = CAIRO_OPERATOR_ATOP;
0
   }
0
- return shoes_layer_blur_filter(cr, data, blur_op, merge_op, 0);
0
+ shoes_layer_blur_filter(cr, data, blur_op, merge_op, 0);
0
 }
0
 
0
 VALUE
0
@@ -1315,7 +1316,7 @@ shoes_effect_draw(VALUE self, VALUE c, VALUE actual)
0
 
0
   if (RTEST(actual))
0
   {
0
- canvas->cr = self_t->filter(canvas->cr, (void *)self_t);
0
+ self_t->filter(canvas->cr, (void *)self_t);
0
   }
0
 
0
   self_t->place = place;

Comments

    No one has commented yet.