Enlightenment CVS committal Author : kwo Project : e16 Module : e
Dir : e16/e/src Modified Files: iclass.c iclass.h iconify.c Log Message: Simplify pseudotrans code, fix iconbox transparency. =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/iclass.c,v retrieving revision 1.85 retrieving revision 1.86 diff -u -3 -r1.85 -r1.86 --- iclass.c 27 Nov 2005 11:02:05 -0000 1.85 +++ iclass.c 29 Dec 2005 02:18:24 -0000 1.86 @@ -840,74 +840,168 @@ return pmap; } -static void -ImagestateMakePmapMask(ImageState * is, Drawable win, PmapMask * pmm, - int make_mask, int w, int h, int image_type) -{ - int trans; - int ww, hh; - #ifdef ENABLE_TRANSPARENCY - Imlib_Image *ii = NULL; +static int +pt_type_to_flags(int image_type) +{ int flags; - Pixmap pmap, mask; - flags = ICLASS_ATTR_OPAQUE; - if (Conf.trans.alpha > 0) + if (Conf.trans.alpha == 0) + return ICLASS_ATTR_OPAQUE; + + switch (image_type) { - switch (image_type) - { - default: - case ST_SOLID: - case ST_BUTTON: - flags = ICLASS_ATTR_OPAQUE; - break; - case ST_BORDER: - flags = Conf.trans.border; - break; - case ST_WIDGET: - flags = Conf.trans.widget; - break; - case ST_ICONBOX: - flags = Conf.trans.iconbox; - break; - case ST_MENU: - flags = Conf.trans.menu; - break; - case ST_MENU_ITEM: - flags = Conf.trans.menu_item; - break; - case ST_TOOLTIP: - flags = Conf.trans.tooltip; - break; - case ST_DIALOG: - flags = Conf.trans.dialog; - break; - case ST_HILIGHT: - flags = Conf.trans.hilight; - break; - case ST_PAGER: - flags = Conf.trans.pager; - break; - case ST_WARPLIST: - flags = Conf.trans.warplist; - break; - } + default: + case ST_SOLID: + case ST_BUTTON: + flags = ICLASS_ATTR_OPAQUE; + break; + case ST_BORDER: + flags = Conf.trans.border; + break; + case ST_WIDGET: + flags = Conf.trans.widget; + break; + case ST_ICONBOX: + flags = Conf.trans.iconbox; + break; + case ST_MENU: + flags = Conf.trans.menu; + break; + case ST_MENU_ITEM: + flags = Conf.trans.menu_item; + break; + case ST_TOOLTIP: + flags = Conf.trans.tooltip; + break; + case ST_DIALOG: + flags = Conf.trans.dialog; + break; + case ST_HILIGHT: + flags = Conf.trans.hilight; + break; + case ST_PAGER: + flags = Conf.trans.pager; + break; + case ST_WARPLIST: + flags = Conf.trans.warplist; + break; } if (flags != ICLASS_ATTR_OPAQUE) flags |= ICLASS_ATTR_USE_CM; + + return flags; +} + +static Imlib_Image * +pt_get_bg_image(Window win, int w, int h, int use_root) +{ + Imlib_Image *ii = NULL; + Window cr, dummy; + Drawable bg; + int xx, yy; + + bg = BackgroundGetPixmap(DeskBackgroundGet(DesksGetCurrent())); + if (use_root || bg == None) + { + cr = VRoot.win; + bg = VRoot.win; + } + else + { + cr = EoGetWin(DesksGetCurrent()); + } + XTranslateCoordinates(disp, win, cr, 0, 0, &xx, &yy, &dummy); +#if 0 + Eprintf("ImagestateMakePmapMask %#lx %d %d %d %d\n", win, xx, yy, w, h); #endif + if (xx < VRoot.w && yy < VRoot.h && xx + w >= 0 && yy + h >= 0) + { + /* Create the background base image */ + imlib_context_set_drawable(bg); + ii = imlib_create_image_from_drawable(0, xx, yy, w, h, + !EServerIsGrabbed()); + } - imlib_context_set_drawable(win); - imlib_context_set_image(is->im); + return ii; +} - ww = imlib_image_get_width(); - hh = imlib_image_get_height(); +static void +pt_blend(Imlib_Image * bg, Imlib_Image * im, int use_cm) +{ + int w, h, iw, ih; - pmm->type = 1; - pmm->pmap = pmm->mask = 0; + imlib_context_set_image(im); + iw = imlib_image_get_width(); + ih = imlib_image_get_height(); + imlib_context_set_image(bg); + w = imlib_image_get_width(); + h = imlib_image_get_height(); + + imlib_context_set_blend(1); +#ifdef ENABLE_THEME_TRANSPARENCY + if (use_cm) + { + imlib_context_set_color_modifier(icm); + } +#endif + imlib_context_set_operation(IMLIB_OP_COPY); + imlib_blend_image_onto_image(im, 0, 0, 0, iw, ih, 0, 0, w, h); + imlib_context_set_blend(0); +#ifdef ENABLE_THEME_TRANSPARENCY + if (use_cm) + { + imlib_context_set_color_modifier(NULL); + } +#endif +} + +#endif + +Imlib_Image * +EImageBlendPT(Imlib_Image * im, Window win, int w, int h, int image_type) +{ + Imlib_Image *bg; + int flags; + + if (!im) + return NULL; + +#ifdef ENABLE_TRANSPARENCY + flags = pt_type_to_flags(image_type); + if (flags != ICLASS_ATTR_OPAQUE) + { + bg = pt_get_bg_image(win, w, h, flags & ICLASS_ATTR_GLASS); + pt_blend(bg, im, flags & ICLASS_ATTR_USE_CM); + } + else +#else + flags = image_type; + win = None; +#endif + { + int ww, hh; + + imlib_context_set_image(im); + ww = imlib_image_get_width(); + hh = imlib_image_get_height(); + bg = imlib_create_cropped_scaled_image(0, 0, ww, hh, w, h); + } + + return bg; +} +static void +ImagestateMakePmapMask(ImageState * is, Drawable win, PmapMask * pmm, + int make_mask, int w, int h, int image_type) +{ #ifdef ENABLE_TRANSPARENCY + Imlib_Image *ii = NULL; + int flags; + Pixmap pmap, mask; + + flags = pt_type_to_flags(image_type); + /* * is->transparent flags: * 0x01: Use desktop background pixmap as base @@ -917,37 +1011,9 @@ if (is->transparent && imlib_image_has_alpha()) flags = is->transparent; - trans = (flags != ICLASS_ATTR_OPAQUE); - - if (trans) + if (flags != ICLASS_ATTR_OPAQUE) { - Window cr, dummy; - Drawable bg; - int xx, yy; - - bg = BackgroundGetPixmap(DeskBackgroundGet(DesksGetCurrent())); - if ((flags & ICLASS_ATTR_GLASS) || (bg == None)) - { - cr = VRoot.win; - bg = VRoot.win; - } - else - { - cr = EoGetWin(DesksGetCurrent()); - } - XTranslateCoordinates(disp, win, cr, 0, 0, &xx, &yy, &dummy); -#if 0 - Eprintf("ImagestateMakePmapMask %#lx %d %d %d %d\n", win, xx, yy, w, h); -#endif - if (xx < VRoot.w && yy < VRoot.h && xx + w >= 0 && yy + h >= 0) - { - /* Create the background base image */ - imlib_context_set_drawable(bg); - ii = imlib_create_image_from_drawable(0, xx, yy, w, h, - !EServerIsGrabbed()); - imlib_context_set_image(ii); - imlib_context_set_drawable(win); - } + ii = pt_get_bg_image(win, w, h, flags & ICLASS_ATTR_GLASS); } else { @@ -955,54 +1021,23 @@ Eprintf("ImagestateMakePmapMask %#lx %d %d\n", win, w, h); #endif } -#else - trans = 0; -#endif - if (is->pixmapfillstyle == FILL_STRETCH || trans) + if (ii) { -#ifdef ENABLE_TRANSPARENCY - if (ii) - { - imlib_context_set_blend(1); -#ifdef ENABLE_THEME_TRANSPARENCY - if (flags & ICLASS_ATTR_USE_CM) - { - imlib_context_set_color_modifier(icm); - } -#endif - imlib_context_set_operation(IMLIB_OP_COPY); - imlib_blend_image_onto_image(is->im, 0, 0, 0, ww, hh, 0, 0, w, h); - imlib_context_set_blend(0); -#ifdef ENABLE_THEME_TRANSPARENCY - if (flags & ICLASS_ATTR_USE_CM) - { - imlib_context_set_color_modifier(NULL); - } -#if 0 /* Do we ever need to free it? */ - imlib_free_color_modifier(); -#endif -#endif - } + imlib_context_set_drawable(win); + pt_blend(ii, is->im, flags & ICLASS_ATTR_USE_CM); - if (ii) - { - pmm->type = 0; - pmap = ECreatePixmap(win, w, h, VRoot.depth); - imlib_context_set_drawable(pmap); - imlib_render_image_on_drawable_at_size(0, 0, w, h); - imlib_context_set_drawable(win); - pmm->pmap = pmap; - pmm->mask = None; - } - else - { - pmm->type = 1; - imlib_render_pixmaps_for_whole_image_at_size(&pmm->pmap, - &pmm->mask, w, h); - } + pmm->type = 0; + pmm->pmap = pmap = ECreatePixmap(win, w, h, VRoot.depth); + pmm->mask = None; + pmm->w = w; + pmm->h = h; + imlib_context_set_image(ii); + imlib_context_set_drawable(pmap); + imlib_render_image_on_drawable_at_size(0, 0, w, h); + imlib_context_set_drawable(win); - if (ii && make_mask && !(flags & ICLASS_ATTR_NO_CLIP)) + if (make_mask && !(flags & ICLASS_ATTR_NO_CLIP)) { imlib_context_set_image(is->im); if (imlib_image_has_alpha()) @@ -1017,17 +1052,33 @@ imlib_free_pixmap_and_mask(pmap); } } + imlib_context_set_image(ii); + imlib_free_image_and_decache(); + } + else #else - pmm->type = 1; - imlib_render_pixmaps_for_whole_image_at_size(&pmm->pmap, &pmm->mask, - w, h); + make_mask = 0; + image_type = 0; #endif /* ENABLE_TRANSPARENCY */ + if (is->pixmapfillstyle == FILL_STRETCH) + { + pmm->type = 1; + pmm->pmap = pmm->mask = None; pmm->w = w; pmm->h = h; + imlib_context_set_image(is->im); + imlib_context_set_drawable(win); + imlib_render_pixmaps_for_whole_image_at_size(&pmm->pmap, &pmm->mask, + w, h); } else { - int cw, ch, pw, ph; + int ww, hh, cw, ch, pw, ph; + + imlib_context_set_image(is->im); + + ww = imlib_image_get_width(); + hh = imlib_image_get_height(); pw = w; ph = h; @@ -1053,22 +1104,14 @@ ch = 1; ph = h / ch; } - imlib_render_pixmaps_for_whole_image_at_size(&pmm->pmap, &pmm->mask, - pw, ph); + pmm->type = 1; + pmm->pmap = pmm->mask = None; pmm->w = pw; pmm->h = ph; + imlib_context_set_drawable(win); + imlib_render_pixmaps_for_whole_image_at_size(&pmm->pmap, &pmm->mask, + pw, ph); } - -#ifdef ENABLE_TRANSPARENCY - if (ii) - { - imlib_context_set_image(ii); - imlib_free_image_and_decache(); - } -#else - make_mask = 0; - image_type = 0; -#endif } static void =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/iclass.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- iclass.h 6 Nov 2005 17:34:31 -0000 1.5 +++ iclass.h 29 Dec 2005 02:18:25 -0000 1.6 @@ -99,6 +99,10 @@ #define TransparencyUpdateNeeded() 0 #define ImageclassIsTransparent(ic) 0 #endif + +Imlib_Image *EImageBlendPT(Imlib_Image * im, Window win, int w, int h, + int image_type); + void ImageclassIncRefcount(ImageClass * ic); void ImageclassDecRefcount(ImageClass * ic); const char *ImageclassGetName(ImageClass * ic); =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/iconify.c,v retrieving revision 1.191 retrieving revision 1.192 diff -u -3 -r1.191 -r1.192 --- iconify.c 22 Dec 2005 18:43:15 -0000 1.191 +++ iconify.c 29 Dec 2005 02:18:25 -0000 1.192 @@ -1639,11 +1639,10 @@ { /* Start out with iconbox image class image */ im2 = ImageclassGetImage(ib->ic_box, 0, 0, STATE_NORMAL); + im = EImageBlendPT(im2, ib->icon_win, ib_w0, ib_h0, ST_ICONBOX); imlib_context_set_image(im2); - ww = imlib_image_get_width(); - hh = imlib_image_get_height(); - im = imlib_create_cropped_scaled_image(0, 0, ww, hh, ib_w0, ib_h0); imlib_free_image(); + imlib_context_set_image(im); } else { ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs