From: sasha Date: Thu, 16 Aug 2007 21:26:20 +0000 (+0000) Subject: reimplemted delayed rendering of the background pixmap with some logic to use differe... X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=7ade7d497a82c5b6dc4844294817df2238669921;p=dana%2Furxvt.git reimplemted delayed rendering of the background pixmap with some logic to use different timeouts for different rendering algorithms --- diff --git a/src/command.C b/src/command.C index 70ac4e22..f6a59126 100644 --- a/src/command.C +++ b/src/command.C @@ -1476,6 +1476,9 @@ rxvt_term::x_cb (XEvent &ev) break; case ConfigureNotify: +/* fprintf (stderr, "ConfigureNotify for %X, parent is %X, geom is %dx%d%+d%+d, old geom was %dx%d\n", + ev.xconfigure.window, parent[0], ev.xconfigure.width, ev.xconfigure.height, ev.xconfigure.x, ev.xconfigure.y, + szHint.width, szHint.height);*/ if (ev.xconfigure.window == parent[0]) { while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) @@ -1490,8 +1493,7 @@ rxvt_term::x_cb (XEvent &ev) { #ifdef ENABLE_TRANSPARENCY if (option (Opt_transparent)) - if (bgPixmap.render ()) - scr_touch (false); + update_background (); #endif } HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); @@ -1829,7 +1831,7 @@ rxvt_term::rootwin_cb (XEvent &ev) || ev.xproperty.atom == xa[XA_ESETROOT_PMAP_ID]) { bgPixmap.set_root_pixmap (); - bgPixmap.render (); + update_background (); } break; } @@ -3430,7 +3432,7 @@ rxvt_term::process_xterm_seq (int op, const char *str, char resp) else changed = bgPixmap.unset_tint (); if (changed) - bgPixmap.render (); + update_background (); } break; @@ -3469,10 +3471,7 @@ rxvt_term::process_xterm_seq (int op, const char *str, char resp) str = strchr (str, ';'); } if (changed) - { - bgPixmap.render (); - scr_touch (true); - } + update_background (); } break; #endif diff --git a/src/main.C b/src/main.C index 5ff6f8b8..7c5bf96c 100644 --- a/src/main.C +++ b/src/main.C @@ -153,8 +153,8 @@ rxvt_term::rxvt_term () #if ENABLE_TRANSPARENCY || ENABLE_PERL rootwin_ev (this, &rxvt_term::rootwin_cb), #endif -#if ENABLE_TRANSPARENCY - check_our_parents_ev(this, &rxvt_term::check_our_parents_cb), +#if HAVE_BG_PIXMAP + update_background_ev(this, &rxvt_term::update_background_cb), #endif #ifdef HAVE_SCROLLBARS scrollbar_ev (this, &rxvt_term::x_cb), @@ -508,7 +508,6 @@ rxvt_term::init (int argc, const char *const *argv, stringvec *envv) #endif #ifdef HAVE_BG_PIXMAP { - bool changed = false; bgPixmap.set_target (this); #ifdef ENABLE_TRANSPARENCY @@ -523,7 +522,6 @@ rxvt_term::init (int argc, const char *const *argv, stringvec *envv) bgPixmap.set_tint (pix_colors_focused [Color_tint]); if (rs [Rs_shade]) bgPixmap.set_shade (rs [Rs_shade]); - changed = true; bgPixmap.set_root_pixmap (); XSelectInput (dpy, display->root, PropertyChangeMask); @@ -544,14 +542,13 @@ rxvt_term::init (int argc, const char *const *argv, stringvec *envv) else bgPixmap.set_defaultGeometry (); - changed = bgPixmap.set_file (rs[Rs_backgroundPixmap]); + bgPixmap.set_file (rs[Rs_backgroundPixmap]); } + /* do not want to render Pixmap yet if we are size/position dependant - + * wait for ConfigureNotify at least */ + if (!bgPixmap.window_size_sensitive ()) + update_background(); #endif - if (changed) - { - bgPixmap.render (); - scr_touch (true); - } } #endif @@ -1154,7 +1151,7 @@ rxvt_term::resize_all_windows (unsigned int newwidth, unsigned int newheight, in #ifdef XPM_BACKGROUND /* TODO: replace with update_pixmap() that should unify transparency and bg image handling ! */ if (bgPixmap.window_size_sensitive ()) - bgPixmap.render (); + update_background (); #endif scr_clear (); diff --git a/src/rxvt.h b/src/rxvt.h index a31877a2..2d3086fa 100644 --- a/src/rxvt.h +++ b/src/rxvt.h @@ -241,15 +241,23 @@ struct bgPixmap_t { }; unsigned long make_transparency_pixmap ();/* returns combination of the above flags */ # endif + double invalid_since; Pixmap pixmap; unsigned int pmap_width, pmap_height; unsigned int pmap_depth; bool window_size_sensitive (); + bool need_client_side_rendering (); void apply (); bool render (); - void invalidate () { flags |= isInvalid; }; + void invalidate () { + if (!(flags & isInvalid)) + { + flags |= isInvalid; + invalid_since = NOW; + } + }; }; #else # undef HAVE_BG_PIXMAP @@ -1158,10 +1166,10 @@ struct rxvt_term : zero_initialized, rxvt_vars, rxvt_screen { void rootwin_cb (XEvent &xev); xevent_watcher rootwin_ev; #endif -#if ENABLE_TRANSPARENCY - int check_our_parents (); - void check_our_parents_cb (time_watcher &w); - time_watcher check_our_parents_ev; +#ifdef HAVE_BG_PIXMAP + int update_background (); + void update_background_cb (time_watcher &w); + time_watcher update_background_ev; #endif void x_cb (XEvent &xev); diff --git a/src/xpm.C b/src/xpm.C index 6e58ec96..72448804 100644 --- a/src/xpm.C +++ b/src/xpm.C @@ -90,6 +90,23 @@ bgPixmap_t::window_size_sensitive () return false; } +bool bgPixmap_t::need_client_side_rendering () +{ +# ifdef HAVE_AFTERIMAGE + if (original_asim != NULL) + return true; +#endif +# ifdef ENABLE_TRANSPARENCY + if (flags & isTransparent) + { + if ((flags & blurNeeded) + || ((flags & tintNeeded) && !(flags & tintServerSide))) + return true; + } +# endif + return false; +} + # ifdef XPM_BACKGROUND static inline bool check_set_scale_value (int geom_flags, int flag, unsigned int &scale, unsigned int new_value) @@ -599,6 +616,10 @@ bgPixmap_t::set_blur_radius (const char *geom) ++changed; v_blurRadius = vr; } + if (v_blurRadius == 0 && h_blurRadius == 0) + flags &= ~blurNeeded; + else + flags |= blurNeeded; return (changed>0); } @@ -901,6 +922,19 @@ bgPixmap_t::render () as_tint = shading2tint32 (&as_shade); } + + if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL) + { + ASImage* tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, + (original_asim == NULL || tint == TINT_LEAVE_SAME)?ASA_XImage:ASA_ASImage, + 100, ASIMAGE_QUALITY_DEFAULT); + if (tmp) + { + destroy_asimage (&background); + background = tmp; + } + } + if (render_asim (background, as_tint)) flags = flags & ~isInvalid; if (background) @@ -1045,6 +1079,7 @@ rxvt_term::get_window_origin (int &x, int &y) { Window cr; XTranslateCoordinates (dpy, parent[0], display->root, 0, 0, &x, &y, &cr); +/* fprintf( stderr, "origin is %+d%+d\n", x, y);*/ } Pixmap @@ -1310,17 +1345,37 @@ ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm * Do transparency updates if required */ int -rxvt_term::check_our_parents () +rxvt_term::update_background () { - check_our_parents_ev.stop (); - check_our_parents_ev.start (NOW + .1); + bgPixmap.invalidate(); + /* no chance of real time refresh if we are blurring ! */ + if (bgPixmap.invalid_since + 0.5 < NOW && !(bgPixmap.flags & bgPixmap_t::blurNeeded)) + bgPixmap.render(); + else + { + update_background_ev.stop (); + if (!bgPixmap.need_client_side_rendering()) + update_background_ev.start (NOW + .05); + else if (bgPixmap.flags & bgPixmap_t::blurNeeded) + update_background_ev.start (NOW + .2); /* very slow !!! */ + else + update_background_ev.start (NOW + .07); + } return 0; } void -rxvt_term::check_our_parents_cb (time_watcher &w) +rxvt_term::update_background_cb (time_watcher &w) { + bgPixmap.render (); +} +#endif /* HAVE_BG_PIXMAP */ + + #if 0 /* replaced by a bgPixmap_t::render() - leve here temporarily for reference */ +void +rxvt_term::check_our_parents_cb (time_watcher &w) +{ int i, aformat, rootdepth; unsigned long nitems, bytes_after; @@ -1528,6 +1583,5 @@ rxvt_term::check_our_parents_cb (time_watcher &w) flush (); } } -#endif } -#endif +#endif