Enlightenment CVS committal Author : raster Project : e17 Module : apps/e
Dir : e17/apps/e/src/modules/dropshadow Modified Files: e_mod_main.c e_mod_main.h Log Message: start of shaped client/border/menu support ... dropshaodw is SLOW with this. =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/modules/dropshadow/e_mod_main.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -3 -r1.14 -r1.15 --- e_mod_main.c 12 Apr 2005 03:34:28 -0000 1.14 +++ e_mod_main.c 13 Apr 2005 15:52:34 -0000 1.15 @@ -157,6 +157,7 @@ E_CONFIG_VAL(D, T, shadow_x, INT); E_CONFIG_VAL(D, T, shadow_y, INT); E_CONFIG_VAL(D, T, blur_size, INT); + E_CONFIG_VAL(D, T, quality, INT); E_CONFIG_VAL(D, T, shadow_darkness, DOUBLE); ds->conf = e_config_domain_load("module.dropshadow", ds->conf_edd); @@ -166,13 +167,15 @@ ds->conf->shadow_x = 4; ds->conf->shadow_y = 4; ds->conf->blur_size = 10; + ds->conf->quality = 2; ds->conf->shadow_darkness = 0.5; } E_CONFIG_LIMIT(ds->conf->shadow_x, -200, 200); E_CONFIG_LIMIT(ds->conf->shadow_y, -200, 200); E_CONFIG_LIMIT(ds->conf->blur_size, 1, 120); + E_CONFIG_LIMIT(ds->conf->quality, 1, 10); E_CONFIG_LIMIT(ds->conf->shadow_darkness, 0.0, 1.0); - + if (ds->conf->shadow_x >= ds->conf->blur_size) ds->conf->shadow_x = ds->conf->blur_size - 1; if (ds->conf->shadow_y >= ds->conf->blur_size) @@ -222,6 +225,7 @@ } if (ds->idler_before) e_main_idler_before_del(ds->idler_before); if (ds->table.gauss) free(ds->table.gauss); + if (ds->table.gauss2) free(ds->table.gauss2); _ds_shared_free(ds); free(ds); } @@ -831,12 +835,23 @@ Evas_List *l; Shpix *sp; int shw, shh, bsz, shx, shy; + int x1, y1, x2, y2; + int q; + q = sh->ds->conf->quality; if ((!rects) && (sh->toosmall)) sh->square = 1; else sh->square = 0; - + + /* FIXME: find "minimum" center of the shape rects - if any */ + /* idea - take rects, run thru list. for each rect start x + * check all rects with a y > than this one. (will come later + * in the list). keep track of the last y point and id this rect x + * spans this line then advance new y point by rect size if it + * immediately joins it... + + */ shx = sh->ds->conf->shadow_x; shy = sh->ds->conf->shadow_y; shw = sh->w; @@ -849,56 +864,114 @@ sh->use_shared = 0; } - sp = _ds_shpix_new(shw + (bsz * 2), shh + (bsz * 2)); + sp = _ds_shpix_new((shw + (bsz * 2)) / q, (shh + (bsz * 2)) / q); if (sp) { + int slx, sly, slw, slh; + if (!rects) { - _ds_shpix_fill(sp, 0, 0, shw + (bsz * 2), bsz, 0); - _ds_shpix_fill(sp, 0, bsz + shh, shw + (bsz * 2), bsz, 0); - _ds_shpix_fill(sp, 0, bsz, bsz, shh, 0); - _ds_shpix_fill(sp, bsz + shw, bsz, bsz, shh, 0); - _ds_shpix_fill(sp, bsz, bsz, shw, shh, 255); + /* FIXME; rounding errors - fix as below in else{} */ + _ds_shpix_fill(sp, 0, 0, (shw + (bsz * 2)) / q, (bsz) / q, 0); + _ds_shpix_fill(sp, 0, (bsz + shh) / q, (shw + (bsz * 2)) / q, (bsz) / q, 0); + _ds_shpix_fill(sp, 0, (bsz) / q, (bsz) / q, (shh) / q, 0); + _ds_shpix_fill(sp, (bsz + shw) / q, (bsz) / q, (bsz) / q, (shh) / q, 0); + _ds_shpix_fill(sp, (bsz) / q, (bsz) / q, (shw) / q, (shh) / q, 255); } else { + _ds_shpix_fill(sp, 0, 0, (shw + (bsz * 2)) / q, (shh + (bsz * 2)) / q, 0); for (l = rects; l; l = l->next) { E_Rect *r; r = l->data; - _ds_shpix_fill(sp, bsz + r->x, bsz + r->y, r->w, r->h, 255); + x1 = (bsz + r->x) / q; + y1 = (bsz + r->y) / q; + x2 = (bsz + r->x + r->w - 1) / q; + y2 = (bsz + r->y + r->h - 1) / q; + _ds_shpix_fill(sp, x1, y1, (x2 - x1) + 1, (y2 - y1) + 1, 255); } } - _ds_shpix_blur(sp, 0, 0, shw + (bsz * 2), shh + (bsz * 2), - sh->ds->table.gauss, bsz); - - _ds_shpix_object_set(sp, sh->object[0], 0, 0, - shw + (bsz * 2), shh + (bsz * 2)); - - evas_object_move(sh->object[0], - sh->x + shx - bsz, - sh->y + shy - bsz); - evas_object_image_border_set(sh->object[0], - 0, 0, 0, 0); - evas_object_resize(sh->object[0], - sh->w + (bsz * 2), - sh->h + (bsz * 2)); - evas_object_image_fill_set(sh->object[0], 0, 0, - sh->w + (bsz * 2), - sh->h + (bsz * 2)); - _ds_object_unset(sh->object[1]); - _ds_object_unset(sh->object[2]); - _ds_object_unset(sh->object[3]); - _ds_shpix_free(sp); - } - - if (evas_object_visible_get(sh->object[0])) - { - evas_object_hide(sh->object[1]); - evas_object_hide(sh->object[2]); - evas_object_hide(sh->object[3]); + e_container_shape_solid_rect_get(sh->shape, &slx, &sly, &slw, &slh); + slx += bsz; + sly += bsz; + slw -= bsz * 2; + slh -= bsz * 2; + slw = (slw - 1 + slx) / q; + slh = (slh - 1 + sly) / q; + slx /= q; + sly /= q; + slw = slw - slx + 1; + slh = slh - sly + 1; + if ((slw > 0) && (slh > 0)) + { + /* FIXME: handle as 4 separate shadow obj's - not 1 */ + _ds_shpix_blur(sp, 0, 0, + (shw + (bsz * 2)) / q, + (shh + (bsz * 2)) / q, + sh->ds->table.gauss2, (bsz) / q); + _ds_shpix_object_set(sp, sh->object[0], 0, 0, + (shw + (bsz * 2)) / q, (shh + (bsz * 2)) / q); + + evas_object_move(sh->object[0], + sh->x + shx - bsz, + sh->y + shy - bsz); + evas_object_image_smooth_scale_set(sh->object[0], 1); + evas_object_image_border_set(sh->object[0], + 0, 0, 0, 0); + evas_object_resize(sh->object[0], + sh->w + (bsz * 2), + sh->h + (bsz * 2)); + evas_object_image_fill_set(sh->object[0], 0, 0, + sh->w + (bsz * 2), + sh->h + (bsz * 2)); + _ds_object_unset(sh->object[1]); + _ds_object_unset(sh->object[2]); + _ds_object_unset(sh->object[3]); + _ds_shpix_free(sp); + + if (evas_object_visible_get(sh->object[0])) + { + evas_object_hide(sh->object[1]); + evas_object_hide(sh->object[2]); + evas_object_hide(sh->object[3]); + } + } + else + { + _ds_shpix_blur(sp, 0, 0, + (shw + (bsz * 2)) / q, + (shh + (bsz * 2)) / q, + sh->ds->table.gauss2, (bsz) / q); + _ds_shpix_object_set(sp, sh->object[0], 0, 0, + (shw + (bsz * 2)) / q, (shh + (bsz * 2)) / q); + + evas_object_move(sh->object[0], + sh->x + shx - bsz, + sh->y + shy - bsz); + evas_object_image_smooth_scale_set(sh->object[0], 1); + evas_object_image_border_set(sh->object[0], + 0, 0, 0, 0); + evas_object_resize(sh->object[0], + sh->w + (bsz * 2), + sh->h + (bsz * 2)); + evas_object_image_fill_set(sh->object[0], 0, 0, + sh->w + (bsz * 2), + sh->h + (bsz * 2)); + _ds_object_unset(sh->object[1]); + _ds_object_unset(sh->object[2]); + _ds_object_unset(sh->object[3]); + _ds_shpix_free(sp); + + if (evas_object_visible_get(sh->object[0])) + { + evas_object_hide(sh->object[1]); + evas_object_hide(sh->object[2]); + evas_object_hide(sh->object[3]); + } + } } } else @@ -965,6 +1038,7 @@ _ds_shstore_object_set(sh->ds->shared.shadow[2], sh->object[2]); _ds_shstore_object_set(sh->ds->shared.shadow[3], sh->object[3]); + evas_object_image_smooth_scale_set(sh->object[0], 0); evas_object_move(sh->object[0], sh->x + shx - bsz, sh->y + shy - bsz); @@ -977,6 +1051,7 @@ sh->w + (bsz) * 2, bsz - shy); + evas_object_image_smooth_scale_set(sh->object[1], 0); evas_object_move(sh->object[1], sh->x + shx - bsz, sh->y); @@ -989,6 +1064,7 @@ bsz - shx, sh->h); + evas_object_image_smooth_scale_set(sh->object[2], 0); evas_object_move(sh->object[2], sh->x + sh->w, sh->y); @@ -1001,6 +1077,7 @@ bsz + shx, sh->h); + evas_object_image_smooth_scale_set(sh->object[3], 0); evas_object_move(sh->object[3], sh->x + shx - bsz, sh->y + sh->h); @@ -1100,7 +1177,8 @@ _ds_blur_init(Dropshadow *ds) { int i; - + int q; + if (ds->table.gauss) free(ds->table.gauss); ds->table.gauss_size = (ds->conf->blur_size * 2) - 1; ds->table.gauss = calloc(1, ds->table.gauss_size * sizeof(unsigned char)); @@ -1115,6 +1193,22 @@ ds->table.gauss[ds->conf->blur_size - 1 - i] = _ds_gauss_int(-1.5 + (v * 3.0)) * 255.0; } + + q = ds->conf->quality; + if (ds->table.gauss2) free(ds->table.gauss2); + ds->table.gauss2_size = ((ds->conf->blur_size / q) * 2) - 1; + ds->table.gauss2 = calloc(1, ds->table.gauss2_size * sizeof(unsigned char)); + + ds->table.gauss[(ds->conf->blur_size / q) - 1] = 255; + for (i = 1; i < ((ds->conf->blur_size / q) - 1); i++) + { + double v; + + v = (double)i / ((ds->conf->blur_size / q) - 2); + ds->table.gauss2[(ds->conf->blur_size / q) - 1 + i] = + ds->table.gauss2[(ds->conf->blur_size / q) - 1 - i] = + _ds_gauss_int(-1.5 + (v * 3.0)) * 255.0; + } } static double @@ -1420,7 +1514,6 @@ evas_object_image_size_set(o, w, h); evas_object_image_alpha_set(o, 1); - evas_object_image_smooth_scale_set(o, 0); pix2 = evas_object_image_data_get(o, 1); if (pix2) { @@ -1625,7 +1718,6 @@ evas_object_image_data_set(o, st->pix); evas_object_image_data_update_add(o, 0, 0, st->w, st->h); evas_object_image_alpha_set(o, 1); - evas_object_image_smooth_scale_set(o, 0); } static void =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/modules/dropshadow/e_mod_main.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- e_mod_main.h 12 Apr 2005 03:34:28 -0000 1.6 +++ e_mod_main.h 13 Apr 2005 15:52:34 -0000 1.7 @@ -23,6 +23,7 @@ { int shadow_x, shadow_y; int blur_size; + int quality; double shadow_darkness; }; @@ -39,6 +40,8 @@ struct { unsigned char *gauss; int gauss_size; + unsigned char *gauss2; + int gauss2_size; } table; struct { ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs