0
#include "shoes/native.h"
0
#include "shoes/version.h"
0
#include "shoes/http.h"
0
+#include "shoes/effects.h"
0
-VALUE cShoes, cApp, cDialog, cShoesWindow, cMouse, cCanvas, cFlow, cStack, cMask, cWidget, cShape, cImage, cEffect, c
Blur, cShadow, cGlow, cVideo, cTimerBase, cTimer, cEvery, cAnim, cPattern, cBorder, cBackground, cTextBlock, cPara, cBanner, cTitle, cSubtitle, cTagline, cCaption, cInscription, cTextClass, cSpan, cDel, cStrong, cSub, cSup, cCode, cEm, cIns, cLinkUrl, cNative, cButton, cCheck, cRadio, cEditLine, cEditBox, cListBox, cProgress, cColor, cDownload, cResponse, cColors, cLink, cLinkHover, ssNestSlot;
0
+VALUE cShoes, cApp, cDialog, cShoesWindow, cMouse, cCanvas, cFlow, cStack, cMask, cWidget, cShape, cImage, cEffect, c
Video, cTimerBase, cTimer, cEvery, cAnim, cPattern, cBorder, cBackground, cTextBlock, cPara, cBanner, cTitle, cSubtitle, cTagline, cCaption, cInscription, cTextClass, cSpan, cDel, cStrong, cSub, cSup, cCode, cEm, cIns, cLinkUrl, cNative, cButton, cCheck, cRadio, cEditLine, cEditBox, cListBox, cProgress, cColor, cDownload, cResponse, cColors, cLink, cLinkHover, ssNestSlot;
0
VALUE eVlcError, eImageError, eInvMode, eNotImpl;
0
VALUE reHEX_SOURCE, reHEX3_SOURCE, reRGB_SOURCE, reRGBA_SOURCE, reGRAY_SOURCE, reGRAYA_SOURCE, reLF;
0
VALUE symAltQuest, symAltSlash, symAltDot;
0
-ID s_aref, s_mult, s_perc, s_bind, s_gsub, s_keys, s_update, s_
new, s_run, s_to_pattern, s_to_i, s_to_s, s_URI, s_angle, s_arrow, s_autoplay, s_begin, s_body, s_call, s_center, s_change, s_checked, s_checked_q, s_choose, s_click, s_corner, s_curve, s_distance, s_displace_left, s_displace_top, s_downcase, s_draw, s_end, s_fill, s_finish, s_font, s_group, s_hand, s_headers, s_hidden, s_host, s_hover, s_href, s_inner, s_insert, s_items, s_keypress, s_link, s_method, s_motion, s_path, s_port, s_progress, s_release, s_request_uri, s_save, s_wheel, s_stroke, s_scroll, s_start, s_attach, s_leading, s_leave, s_outer, s_points, s_match, s_text, s_title, s_top, s_right, s_bottom, s_left, s_up, s_down, s_height, s_resizable, s_remove, s_strokewidth, s_width, s_margin, s_margin_left, s_margin_right, s_margin_top, s_margin_bottom, s_radius, s_secret, s_now, s_debug, s_error, s_warn, s_info, s_rect, s_oval, s_line, s_star;
0
+ID s_aref, s_mult, s_perc, s_bind, s_gsub, s_keys, s_update, s_
merge, s_new, s_run, s_to_pattern, s_to_i, s_to_s, s_URI, s_angle, s_arrow, s_autoplay, s_begin, s_body, s_call, s_center, s_change, s_checked, s_checked_q, s_choose, s_click, s_corner, s_curve, s_distance, s_displace_left, s_displace_top, s_downcase, s_draw, s_end, s_fill, s_finish, s_font, s_group, s_hand, s_headers, s_hidden, s_host, s_hover, s_href, s_inner, s_insert, s_items, s_keypress, s_link, s_method, s_motion, s_path, s_port, s_progress, s_release, s_request_uri, s_save, s_wheel, s_stroke, s_scroll, s_start, s_attach, s_leading, s_leave, s_outer, s_points, s_match, s_text, s_title, s_top, s_right, s_bottom, s_left, s_up, s_down, s_height, s_resizable, s_remove, s_strokewidth, s_width, s_margin, s_margin_left, s_margin_right, s_margin_top, s_margin_bottom, s_radius, s_secret, s_now, s_debug, s_error, s_warn, s_info, s_blur, s_glow, s_shadow, s_rect, s_oval, s_line, s_star;
0
// Mauricio's instance_eval hack (he bested my cloaker back in 06 Jun 2006)
0
@@ -296,8 +297,8 @@ shoes_place_exact(shoes_place *place, VALUE attr, int ox, int oy)
0
place->dx = ATTR2(int, attr, displace_left, 0);
0
place->dy = ATTR2(int, attr, displace_top, 0);
0
place->flags = FLAG_ABSX | FLAG_ABSY;
0
- place->ix = place->x = NUM2INT(ATTR(attr, left)) + ox;
0
- place->iy = place->y = NUM2INT(ATTR(attr, top)) + oy;
0
+ place->ix = place->x = ATTR2(int, attr, left, 0) + ox;
0
+ place->iy = place->y = ATTR2(int, attr, top, 0) + oy;
0
r = ATTR2(int, attr, radius, 0) * 2;
0
place->iw = place->w = ATTR2(int, attr, width, r);
0
place->ih = place->h = ATTR2(int, attr, height, place->w);
0
@@ -522,9 +523,6 @@ shoes_control_show_ref(SHOES_CONTROL_REF ref)
0
canvas->cy = canvas->endy; \
0
-#define PATTERN_DIM(self_t, x) (self_t->cached != NULL ? self_t->cached->x : 1)
0
-#define PATTERN(self_t) (self_t->cached != NULL ? self_t->cached->pattern : self_t->pattern)
0
#define PATTERN_SCALE(self_t, place, sw) \
0
if (self_t->cached == NULL) \
0
@@ -1027,249 +1025,6 @@ shoes_image_size(VALUE self)
0
return rb_ary_new3(2, INT2NUM(self_t->cached->width), INT2NUM(self_t->cached->height));
0
-box_run(unsigned int size)
0
- unsigned char *tmp = SHOE_ALLOC_N(unsigned char, size * 256);
0
- for (i = 0; i < 256; i++)
0
- memset(tmp + i * size, i, size);
0
-box_blur(unsigned char *in, unsigned char *out,
0
- int stride, shoes_place place,
0
- unsigned int edge1, unsigned int edge2,
0
- const unsigned char *run, int dir)
0
- int i, j1, j2, l, l2, l3, l4, lx, c1, c2, c3, c4, start;
0
- int boxSize = edge1 + edge2 + 1;
0
- c2 = place.y + place.h;
0
- c4 = place.x + place.w;
0
- c2 = place.x + place.w;
0
- c4 = place.y + place.h;
0
- for (j1 = c1; j1 < c2; j1++) {
0
- unsigned int sums[4] = {0, 0, 0, 0};
0
- for (i = 0; i < boxSize; i++) {
0
- pos = min(pos, c4 - 1);
0
- l = stride * pos + lx;
0
- for (j2 = c3; j2 < c4; j2++) {
0
- l2 = stride * j2 + lx;
0
- out[l2] = run[sums[0]];
0
- out[l2 + 1] = run[sums[1]];
0
- out[l2 + 2] = run[sums[2]];
0
- out[l2 + 3] = run[sums[3]];
0
- int last = max(tmp, c3);
0
- int next = min(tmp + boxSize, c4 - 1);
0
- l3 = stride * next + lx;
0
- l4 = stride * last + lx;
0
- sums[0] += in[l3] - in[l4];
0
- sums[1] += in[l3 + 1] - in[l4 + 1];
0
- sums[2] += in[l3 + 2] - in[l4 + 2];
0
- sums[3] += in[l3 + 3] - in[l4 + 3];
0
-#define RAW_FILTER_START(self_t) \
0
- int width, height, stride; \
0
- static const cairo_user_data_key_t key; \
0
- cairo_surface_t *source = cairo_get_target(cr); \
0
- cairo_surface_t *target; \
0
- unsigned char *in = cairo_image_surface_get_data(source); \
0
- self_t->place.x = self_t->place.y = 0; \
0
- self_t->place.w = width = cairo_image_surface_get_width(source); \
0
- self_t->place.h = height = cairo_image_surface_get_height(source); \
0
- stride = cairo_image_surface_get_stride(source); \
0
- out = (guchar *)g_malloc(4 * width * height); \
0
- target = cairo_image_surface_create_for_data((unsigned char *)out, \
0
- CAIRO_FORMAT_ARGB32, \
0
- width, height, 4 * width); \
0
- cairo_surface_set_user_data(target, &key, out, (cairo_destroy_func_t)g_free); \
0
- unsigned int len = 4 * width * height
0
-#define RAW_FILTER_END(self_t) \
0
- cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR); \
0
- cairo_set_operator(cr, CAIRO_OPERATOR_OVER); \
0
- cairo_set_source_surface(cr, target, 0, 0); \
0
- cairo_surface_destroy(target);
0
-shoes_gaussian_blur_filter(cairo_t *cr, void *data)
0
- shoes_effect *fx = (shoes_effect *)data;
0
- float blur_d = ATTR2(dbl, fx->attr, radius, 2.);
0
- float blur_x = ATTR2(dbl, fx->attr, width, blur_d);
0
- float blur_y = ATTR2(dbl, fx->attr, height, blur_d);
0
- if (blur_x < 0 || blur_y < 0)
0
- if (blur_x == 0 || blur_y == 0)
0
- dX = (unsigned int) floor(blur_x * 3*sqrt(2*SHOES_PI)/4 + 0.5);
0
- dY = (unsigned int) floor(blur_y * 3*sqrt(2*SHOES_PI)/4 + 0.5);
0
- unsigned char *tmp = SHOE_ALLOC_N(unsigned char, len);
0
- unsigned char *run = box_run(2 * (dX / 2) + 1);
0
- box_blur(in, tmp, stride, fx->place, dX/2, dX/2, run, BOX_H);
0
- box_blur(tmp, out, stride, fx->place, dX/2, dX/2, run, BOX_H);
0
- box_blur(out, tmp, stride, fx->place, dX/2, dX/2, run, BOX_H);
0
- unsigned char *run1 = box_run(2 * (dX / 2) + 1);
0
- unsigned char *run2 = box_run(2 * (dX / 2));
0
- box_blur(in, tmp, stride, fx->place, dX/2, dX/2 - 1, run2, BOX_H);
0
- box_blur(tmp, out, stride, fx->place, dX/2 - 1, dX/2, run2, BOX_H);
0
- box_blur(out, tmp, stride, fx->place, dX/2, dX/2, run1, BOX_H);
0
- unsigned char *run = box_run(2 * (dY / 2) + 1);
0
- box_blur(tmp, out, stride, fx->place, dY/2, dY/2, run, BOX_V);
0
- box_blur(out, tmp, stride, fx->place, dY/2, dY/2, run, BOX_V);
0
- box_blur(tmp, out, stride, fx->place, dY/2, dY/2, run, BOX_V);
0
- memcpy(out, tmp, len);
0
- unsigned char *run1 = box_run(2 * (dY / 2) + 1);
0
- unsigned char *run2 = box_run(2 * (dY / 2));
0
- box_blur(tmp, out, stride, fx->place, dY/2, dY/2 - 1, run2, BOX_V);
0
- box_blur(out, tmp, stride, fx->place, dY/2 - 1, dY/2, run2, BOX_V);
0
- box_blur(tmp, out, stride, fx->place, dY/2, dY/2, run1, BOX_V);
0
-shoes_layer_blur_filter(cairo_t *cr, void *data, cairo_operator_t blur_op,
0
- cairo_operator_t merge_op, int distance)
0
- shoes_effect *fx = (shoes_effect *)data;
0
- cairo_surface_t *source = cairo_get_target(cr);
0
- int width = cairo_image_surface_get_width(source);
0
- int height = cairo_image_surface_get_height(source);
0
- VALUE fill = ATTR(fx->attr, fill);
0
- Data_Get_Struct(fx->parent, shoes_canvas, canvas);
0
- cairo_surface_t *target = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
0
- cairo_t *cr2 = cairo_create(target);
0
- cairo_set_source_surface(cr2, source, distance, distance);
0
- cairo_set_operator(cr2, blur_op);
0
- bg = ATTR(canvas->attr, fill);
0
- cairo_set_source_rgb(cr2, 0., 0., 0.);
0
- else if (rb_obj_is_kind_of(bg, cColor))
0
- Data_Get_Struct(bg, shoes_color, color);
0
- cairo_set_source_rgba(cr, color->r / 255., color->g / 255., color->b / 255., color->a / 255.);
0
- shoes_pattern *pattern;
0
- Data_Get_Struct(bg, shoes_pattern, pattern);
0
- cairo_set_source(cr2, PATTERN(pattern));
0
- cairo_rectangle(cr2, 0, 0, width, height);
0
- shoes_gaussian_blur_filter(cr2, data);
0
- cairo_set_operator(cr, merge_op);
0
- cairo_set_source_surface(cr, target, 0, 0);
0
-shoes_shadow_filter(cairo_t *cr, void *data)
0
- shoes_effect *fx = (shoes_effect *)data;
0
- int distance = ATTR2(int, fx->attr, distance, 4);
0
- shoes_layer_blur_filter(cr, data, CAIRO_OPERATOR_IN, CAIRO_OPERATOR_DEST_OVER, distance);
0
-shoes_glow_filter(cairo_t *cr, void *data)
0
- shoes_effect *fx = (shoes_effect *)data;
0
- cairo_operator_t blur_op = CAIRO_OPERATOR_IN;
0
- cairo_operator_t merge_op = CAIRO_OPERATOR_DEST_OVER;
0
- if (RTEST(ATTR(fx->attr, inner)))
0
- blur_op = CAIRO_OPERATOR_OUT;
0
- merge_op = CAIRO_OPERATOR_ATOP;
0
- shoes_layer_blur_filter(cr, data, blur_op, merge_op, 0);
0
shoes_image_motion(VALUE self, int x, int y, char *touch)
0
@@ -1341,22 +1096,29 @@ shoes_effect_free(shoes_effect *fx)
0
RUBY_CRITICAL(free(fx));
0
+shoes_effect_for_type(ID name)
0
+ return &shoes_gaussian_blur_filter;
0
+ else if (name == s_shadow)
0
+ return &shoes_shadow_filter;
0
+ else if (name == s_glow)
0
+ return &shoes_glow_filter;
0
-shoes_effect_new(
VALUE klass, VALUE attr, VALUE parent)
0
+shoes_effect_new(
ID name, VALUE attr, VALUE parent)
0
- VALUE obj = shoes_effect_alloc(
klass);
0
+ VALUE obj = shoes_effect_alloc(
cEffect);
0
Data_Get_Struct(obj, shoes_effect, fx);
0
Data_Get_Struct(parent, shoes_canvas, canvas);
0
- fx->filter = &shoes_gaussian_blur_filter;
0
- else if (klass == cShadow)
0
- fx->filter = &shoes_shadow_filter;
0
- else if (klass == cGlow)
0
- fx->filter = &shoes_glow_filter;
0
+ fx->filter = shoes_effect_for_type(name);
0
@@ -1377,10 +1139,8 @@ shoes_effect_draw(VALUE self, VALUE c, VALUE actual)
0
SETUP(shoes_effect, REL_TILE, canvas->width, canvas->height);
0
- self_t->filter(canvas->cr, (void *)self_t);
0
+ if (RTEST(actual) && self_t->filter != NULL)
0
+ self_t->filter(canvas->cr, self_t->attr, &self_t->place);
0
@@ -4183,6 +3943,7 @@ shoes_ruby_init()
0
s_gsub = rb_intern("gsub");
0
s_keys = rb_intern("keys");
0
s_update = rb_intern("update");
0
+ s_merge = rb_intern("merge");
0
s_new = rb_intern("new");
0
s_URI = rb_intern("URI");
0
@@ -4269,6 +4030,9 @@ shoes_ruby_init()
0
s_margin_bottom = rb_intern("margin_bottom");
0
s_radius = rb_intern("radius");
0
s_secret = rb_intern("secret");
0
+ s_blur = rb_intern("blur");
0
+ s_glow = rb_intern("glow");
0
+ s_shadow = rb_intern("shadow");
0
s_rect = rb_intern("rect");
0
s_oval = rb_intern("oval");
0
s_line = rb_intern("line");
0
@@ -4405,6 +4169,9 @@ shoes_ruby_init()
0
rb_define_method(cImage, "oval", CASTHOOK(shoes_canvas_oval), -1);
0
rb_define_method(cImage, "rect", CASTHOOK(shoes_canvas_rect), -1);
0
rb_define_method(cImage, "star", CASTHOOK(shoes_canvas_star), -1);
0
+ rb_define_method(cImage, "blur", CASTHOOK(shoes_canvas_blur), -1);
0
+ rb_define_method(cImage, "glow", CASTHOOK(shoes_canvas_glow), -1);
0
+ rb_define_method(cImage, "shadow", CASTHOOK(shoes_canvas_shadow), -1);
0
rb_define_method(cImage, "path", CASTHOOK(shoes_image_get_path), 0);
0
rb_define_method(cImage, "path=", CASTHOOK(shoes_image_set_path), 1);
0
rb_define_method(cImage, "app", CASTHOOK(shoes_canvas_get_app), 0);
0
@@ -4438,9 +4205,6 @@ shoes_ruby_init()
0
rb_define_alloc_func(cEffect, shoes_effect_alloc);
0
rb_define_method(cEffect, "draw", CASTHOOK(shoes_effect_draw), 2);
0
rb_define_method(cEffect, "remove", CASTHOOK(shoes_basic_remove), 0);
0
- cBlur = rb_define_class_under(cShoes, "Blur", cEffect);
0
- cShadow = rb_define_class_under(cShoes, "Shadow", cEffect);
0
- cGlow = rb_define_class_under(cShoes, "Glow", cEffect);
0
cVideo = rb_define_class_under(cShoes, "Video", rb_cObject);
Comments
No one has commented yet.