[metacity] compositor-xrender: create extents only if window needs shadow
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity] compositor-xrender: create extents only if window needs shadow
- Date: Fri, 18 Oct 2019 23:46:12 +0000 (UTC)
commit b6e77dda6eae7d843b83998f5f19bc84ec8adb15
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Sat Oct 19 00:06:04 2019 +0300
compositor-xrender: create extents only if window needs shadow
src/compositor/meta-compositor-xrender.c | 91 ++++++++++++++++----------------
1 file changed, 46 insertions(+), 45 deletions(-)
---
diff --git a/src/compositor/meta-compositor-xrender.c b/src/compositor/meta-compositor-xrender.c
index d461877a..2ebe3242 100644
--- a/src/compositor/meta-compositor-xrender.c
+++ b/src/compositor/meta-compositor-xrender.c
@@ -920,68 +920,66 @@ window_has_shadow (MetaCompositorXRender *xrender,
return FALSE;
}
-
static XserverRegion
win_extents (MetaCompositorXRender *xrender,
MetaCompWindow *cw)
{
XRectangle r;
+ MetaFrame *frame;
+ MetaFrameBorders borders;
+ XRectangle sr;
+
+ if (!cw->needs_shadow)
+ return None;
r.x = cw->rect.x;
r.y = cw->rect.y;
r.width = cw->rect.width;
r.height = cw->rect.height;
- if (cw->needs_shadow)
- {
- MetaFrame *frame;
- MetaFrameBorders borders;
- XRectangle sr;
+ frame = meta_window_get_frame (cw->window);
+ meta_frame_calc_borders (frame, &borders);
- frame = meta_window_get_frame (cw->window);
- meta_frame_calc_borders (frame, &borders);
+ cw->shadow_dx = (int) shadow_offsets_x [cw->shadow_type] + borders.invisible.left;
+ cw->shadow_dy = (int) shadow_offsets_y [cw->shadow_type] + borders.invisible.top;
- cw->shadow_dx = (int) shadow_offsets_x [cw->shadow_type] + borders.invisible.left;
- cw->shadow_dy = (int) shadow_offsets_y [cw->shadow_type] + borders.invisible.top;
-
- if (!cw->shadow)
- {
- double opacity = SHADOW_OPACITY;
- int invisible_width = borders.invisible.left + borders.invisible.right;
- int invisible_height = borders.invisible.top + borders.invisible.bottom;
+ if (!cw->shadow)
+ {
+ double opacity = SHADOW_OPACITY;
+ int invisible_width = borders.invisible.left + borders.invisible.right;
+ int invisible_height = borders.invisible.top + borders.invisible.bottom;
- if (cw->window->opacity != (guint) OPAQUE)
- opacity = opacity * ((double) cw->window->opacity) / ((double) OPAQUE);
+ if (cw->window->opacity != (guint) OPAQUE)
+ opacity = opacity * ((double) cw->window->opacity) / ((double) OPAQUE);
- cw->shadow = shadow_picture (xrender, cw, opacity, borders,
- cw->rect.width - invisible_width,
- cw->rect.height - invisible_height,
- &cw->shadow_width, &cw->shadow_height);
- }
+ cw->shadow = shadow_picture (xrender, cw, opacity, borders,
+ cw->rect.width - invisible_width,
+ cw->rect.height - invisible_height,
+ &cw->shadow_width, &cw->shadow_height);
+ }
- sr.x = cw->rect.x + cw->shadow_dx;
- sr.y = cw->rect.y + cw->shadow_dy;
- sr.width = cw->shadow_width;
- sr.height = cw->shadow_height;
+ sr.x = cw->rect.x + cw->shadow_dx;
+ sr.y = cw->rect.y + cw->shadow_dy;
+ sr.width = cw->shadow_width;
+ sr.height = cw->shadow_height;
- if (sr.x < r.x)
- {
- r.width = (r.x + r.width) - sr.x;
- r.x = sr.x;
- }
+ if (sr.x < r.x)
+ {
+ r.width = (r.x + r.width) - sr.x;
+ r.x = sr.x;
+ }
- if (sr.y < r.y)
- {
- r.height = (r.y + r.height) - sr.y;
- r.y = sr.y;
- }
+ if (sr.y < r.y)
+ {
+ r.height = (r.y + r.height) - sr.y;
+ r.y = sr.y;
+ }
- if (sr.x + sr.width > r.x + r.width)
- r.width = sr.x + sr.width - r.x;
+ if (sr.x + sr.width > r.x + r.width)
+ r.width = sr.x + sr.width - r.x;
- if (sr.y + sr.height > r.y + r.height)
- r.height = sr.y + sr.height - r.y;
- }
+ if (sr.y + sr.height > r.y + r.height)
+ r.height = sr.y + sr.height - r.y;
return XFixesCreateRegion (xrender->xdisplay, &r, 1);
}
@@ -1824,9 +1822,12 @@ meta_compositor_xrender_pre_paint (MetaCompositor *compositor)
{
cw->extents = win_extents (xrender, cw);
- meta_compositor_add_damage (compositor,
- "meta_compositor_xrender_pre_paint",
- cw->extents);
+ if (cw->extents != None)
+ {
+ meta_compositor_add_damage (compositor,
+ "meta_compositor_xrender_pre_paint",
+ cw->extents);
+ }
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]