Enlightenment CVS committal

Author  : kwo
Project : e16
Module  : e

Dir     : e16/e/src


Modified Files:
        coords.c ecompmgr.c eobj.c 


Log Message:
CM: Avoid creating/destroying regions.

===================================================================
RCS file: /cvs/e/e16/e/src/coords.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -3 -r1.45 -r1.46
--- coords.c    13 Jan 2007 19:14:27 -0000      1.45
+++ coords.c    11 Jul 2007 08:44:12 -0000      1.46
@@ -114,6 +114,7 @@
    cx -= x;
    cy -= y;
 #endif
+   md = cw != EobjGetW(eo) || ch != EobjGetH(eo);      /* md is change size 
flag */
    EobjMoveResize(eo, cx, cy, cw, ch);
 
    if (!eo->shown)
@@ -126,6 +127,9 @@
 
    ITApply(eo->win, ic, NULL, cw, ch, STATE_NORMAL, 1, 0, ST_SOLID,
           tc, NULL, s);
+
+   if (md)                     /* Assuming that shape change only happens when 
size changes too */
+      EobjShapeUpdate(eo, 0);
 
    EFlush();
 }
===================================================================
RCS file: /cvs/e/e16/e/src/ecompmgr.c,v
retrieving revision 1.156
retrieving revision 1.157
diff -u -3 -r1.156 -r1.157
--- ecompmgr.c  11 Jul 2007 08:27:14 -0000      1.156
+++ ecompmgr.c  11 Jul 2007 08:44:12 -0000      1.157
@@ -80,12 +80,13 @@
 
 #define INV_POS     0x01
 #define INV_SIZE    0x02
-#define INV_CLIP    0x04
-#define INV_OPACITY 0x08
-#define INV_SHADOW  0x10
-#define INV_PIXMAP  0x20
-#define INV_PICTURE 0x40
-#define INV_GEOM    (INV_POS | INV_SIZE)
+#define INV_SHAPE   0x04
+#define INV_CLIP    0x08
+#define INV_OPACITY 0x10
+#define INV_SHADOW  0x20
+#define INV_PIXMAP  0x40
+#define INV_PICTURE 0x80
+#define INV_GEOM    (INV_POS | INV_SIZE | INV_SHAPE)
 #define INV_ALL     (INV_POS | INV_SIZE | INV_CLIP | INV_OPACITY | INV_SHADOW 
| INV_PIXMAP)
 
 typedef struct _cmhook ECmWinInfo;
@@ -101,12 +102,16 @@
    unsigned            fading:1;
    unsigned            fadeout:1;
    unsigned            has_shadow:1;
+   unsigned            have_shape:1;   /* Region validity - shape */
+   unsigned            have_extents:1; /* Region validity - extents */
+   unsigned            have_clip:1;    /* Region validity - clip */
    Damage              damage;
    Picture             picture;
    Picture             pict_alpha;     /* Solid, current opacity */
    XserverRegion       shape;
    XserverRegion       extents;
    XserverRegion       clip;
+   int                 shape_x, shape_y;
 #if ENABLE_SHADOWS
    Picture             shadow_alpha;   /* Solid, sharp * current opacity */
    Picture             shadow_pict;    /* Blurred shaped shadow */
@@ -211,6 +216,7 @@
 static Picture      rootBuffer;
 
 static XserverRegion rgn_tmp;  /* Region for temporary use */
+static XserverRegion rgn_tmp2; /* Region for temporary use */
 
 static ESelection  *wm_cm_sel = NULL;
 
@@ -727,7 +733,7 @@
    damage = ERegionCopy(rgn_tmp, damage);
 
 #if USE_CLIP_RELATIVE_TO_DESK
-   if (cw->clip != None && eo->type != EOBJ_TYPE_DESK)
+   if (cw->have_clip && eo->type != EOBJ_TYPE_DESK)
       ERegionSubtract(damage, cw->clip);
 #endif
 
@@ -735,7 +741,7 @@
       ERegionTranslate(damage, EoGetX(dsk), EoGetY(dsk));
 
 #if !USE_CLIP_RELATIVE_TO_DESK
-   if (cw->clip != None && eo->type != EOBJ_TYPE_DESK)
+   if (cw->have_clip && eo->type != EOBJ_TYPE_DESK)
       ERegionSubtract(damage, cw->clip);
 #endif
    if (!eo->ghost)
@@ -999,15 +1005,14 @@
 
 #endif /* ENABLE_SHADOWS */
 
-static XserverRegion win_shape(EObj * eo);
+static void         ECompMgrWinSetShape(EObj * eo);
 
 /* Region of window in screen coordinates, including shadows */
-static              XserverRegion
-win_extents(EObj * eo)
+static void
+ECompMgrWinSetExtents(EObj * eo)
 {
    ECmWinInfo         *cw = eo->cmhook;
    XRectangle          r, sr;
-   XserverRegion       rgn;
    unsigned int        bw;
 
    /* FIXME - Get this right */
@@ -1042,6 +1047,9 @@
        r.height = cw->rch;
      }
 
+   if (cw->extents == None)
+      cw->extents = ERegionCreate();
+
 #if ENABLE_SHADOWS
    cw->has_shadow = (Mode_compmgr.shadow_mode != ECM_SHADOWS_OFF) &&
       eo->shadow && (EShapeCheck(eo->win) >= 0);
@@ -1101,23 +1109,25 @@
    if (sr.y + sr.height > r.y + r.height)
       r.height = sr.y + sr.height - r.y;
 
-   rgn = ERegionCreateRect(r.x, r.y, r.width, r.height);
+   ERegionSetRect(cw->extents, r.x, r.y, r.width, r.height);
    goto done;
 
  skip_shadow:
 #endif
 
    /* No shadow - extents = shape */
-   if (cw->shape == None)
-      cw->shape = win_shape(eo);
-   rgn = ERegionClone(cw->shape);
+   if (!cw->have_shape)
+      ECompMgrWinSetShape(eo);
+   ERegionCopy(cw->extents, cw->shape);
 
  done:
+   cw->have_extents = 1;
+
    D2printf("extents %#lx %d %d %d %d\n", EobjGetXwin(eo), r.x, r.y, r.width,
            r.height);
 
    if (EDebug(EDBUG_TYPE_COMPMGR3))
-      ERegionShow("extents", rgn);
+      ERegionShow("extents", cw->extents);
 
 #if 0                          /* FIXME - Set picture clip region */
    if (cw->shadow_pict)
@@ -1130,35 +1140,43 @@
        ERegionDestroy(clip);
      }
 #endif
-   return rgn;
 }
 
 /* Region of shaped window in screen coordinates */
-static              XserverRegion
-win_shape(EObj * eo)
+static void
+ECompMgrWinSetShape(EObj * eo)
 {
-   XserverRegion       border;
+   ECmWinInfo         *cw = eo->cmhook;
    int                 x, y;
 
-   border = ERegionCreateFromWindow(EobjGetXwin(eo));
+   if (cw->shape == None)
+     {
+       cw->shape = ERegionCreateFromWindow(EobjGetXwin(eo));
 
-   if (WinIsShaped(EobjGetWin(eo)) > 0)
+       if (WinIsShaped(EobjGetWin(eo)) > 0)
+         {
+            /* Intersect with window size to get effective bounding region */
+            ERegionSetRect(rgn_tmp, 0, 0, EobjGetW(eo), EobjGetH(eo));
+            ERegionIntersect(cw->shape, rgn_tmp);
+         }
+       x = EobjGetX(eo) + EobjGetBW(eo);
+       y = EobjGetY(eo) + EobjGetBW(eo);
+     }
+   else
      {
-       /* Intersect with window size to get effective bounding region */
-       ERegionSetRect(rgn_tmp, 0, 0, EobjGetW(eo), EobjGetH(eo));
-       ERegionIntersect(border, rgn_tmp);
+       x = EobjGetX(eo) + EobjGetBW(eo) - cw->shape_x;
+       y = EobjGetY(eo) + EobjGetBW(eo) - cw->shape_y;
      }
 
-   /* translate this */
-   x = EobjGetX(eo) + EobjGetBW(eo);
-   y = EobjGetY(eo) + EobjGetBW(eo);
-   ERegionTranslate(border, x, y);
+   ERegionTranslate(cw->shape, x, y);
+
+   cw->shape_x = EobjGetX(eo) + EobjGetBW(eo);
+   cw->shape_y = EobjGetY(eo) + EobjGetBW(eo);
+   cw->have_shape = 1;
 
    D2printf("shape %#lx: %d %d\n", EobjGetXwin(eo), x, y);
    if (EDebug(EDBUG_TYPE_COMPMGR3))
-      ERegionShow("shape", border);
-
-   return border;
+      ERegionShow("shape", cw->shape);
 }
 
 Pixmap
@@ -1199,8 +1217,10 @@
           what |= INV_PICTURE;
      }
 
-   if (what & INV_GEOM)
+   if (what & (INV_SIZE | INV_SHAPE))
       REGION_DESTROY(cw->shape);
+   if (what & INV_GEOM)
+      cw->have_shape = 0;
 
    if (what & INV_PICTURE)
       PICTURE_DESTROY(cw->picture);
@@ -1209,7 +1229,7 @@
       PICTURE_DESTROY(cw->pict_alpha);
 
    if (what & (INV_CLIP | INV_GEOM))
-      REGION_DESTROY(cw->clip);
+      cw->have_clip = 0;
 
 #if ENABLE_SHADOWS
    if (what & (INV_SIZE | INV_SHADOW))
@@ -1219,7 +1239,7 @@
 #endif
 
    if (what & (INV_GEOM | INV_SHADOW))
-      REGION_DESTROY(cw->extents);
+      cw->have_extents = 0;
 }
 
 static void
@@ -1427,8 +1447,8 @@
 
    D1printf("ECompMgrWinMap %#lx\n", EobjGetXwin(eo));
 
-   if (cw->extents == None)
-      cw->extents = win_extents(eo);
+   if (!cw->have_extents)
+      ECompMgrWinSetExtents(eo);
 
    _ECM_SET_STACK_CHANGED();
    ECompMgrDamageMergeObject(eo, cw->extents);
@@ -1561,7 +1581,6 @@
 ECompMgrWinMoveResize(EObj * eo, int change_xy, int change_wh, int change_bw)
 {
    ECmWinInfo         *cw = eo->cmhook;
-   XserverRegion       damage;
    int                 invalidate;
 
    D1printf("ECompMgrWinMoveResize %#lx xy=%d wh=%d bw=%d\n",
@@ -1585,28 +1604,29 @@
        return;
      }
 
-   /* Invalidate old window region */
-   damage = cw->extents;
-   cw->extents = None;
    if (EDebug(EDBUG_TYPE_COMPMGR3))
-      ERegionShow("old-extents:", damage);
+      ERegionShow("old-extents:", cw->extents);
 
 #if 0                          /* FIXME - We shouldn't have to update clip if 
transparent */
    if (cw->mode == WINDOW_UNREDIR || cw->mode == WINDOW_SOLID)
 #endif
       _ECM_SET_CLIP_CHANGED();
-   ECompMgrWinInvalidate(eo, invalidate);
 
-   /* Invalidate new window region */
-   cw->extents = win_extents(eo);
-   if (damage != None)
-     {
-       ERegionUnion(damage, cw->extents);
-       ECompMgrDamageMergeObject(eo, damage);
-       ERegionDestroy(damage);
+   if (cw->have_extents)
+     {
+       /* Invalidate old window region */
+       ERegionCopy(rgn_tmp2, cw->extents);
+       ECompMgrWinInvalidate(eo, invalidate);
+       /* Invalidate new window region */
+       ECompMgrWinSetExtents(eo);
+       ERegionUnion(rgn_tmp2, cw->extents);
+       ECompMgrDamageMergeObject(eo, rgn_tmp2);
      }
    else
      {
+       ECompMgrWinInvalidate(eo, invalidate);
+       /* Invalidate new window region */
+       ECompMgrWinSetExtents(eo);
        ECompMgrDamageMergeObject(eo, cw->extents);
      }
 }
@@ -1639,7 +1659,7 @@
        /* Enable shadow */
        ECompMgrWinInvalidate(eo, INV_SHADOW);
        eo->shadow = shadow;
-       cw->extents = win_extents(eo);
+       ECompMgrWinSetExtents(eo);
        ECompMgrDamageMergeObject(eo, cw->extents);
      }
  done:
@@ -1692,7 +1712,7 @@
        ECompMgrWinInvalidate(eo, INV_POS);
 
        /* Find new window region */
-       cw->extents = win_extents(eo);
+       ECompMgrWinSetExtents(eo);
      }
    eo->desk = dsk;
    _ECM_SET_STACK_CHANGED();
@@ -1719,8 +1739,8 @@
       return;
 
    ECompMgrDamageMergeObject(eo, cw->extents);
-   ECompMgrWinInvalidate(eo, INV_POS); /* Invalidate extents and shape */
-   cw->extents = win_extents(eo);
+   ECompMgrWinInvalidate(eo, INV_SHAPE);       /* Invalidate extents and shape 
*/
+   ECompMgrWinSetExtents(eo);
    ECompMgrDamageMergeObject(eo, cw->extents);
    _ECM_SET_CLIP_CHANGED();
 }
@@ -1768,6 +1788,8 @@
      }
 
    ECompMgrWinInvalidate(eo, INV_ALL);
+   REGION_DESTROY(cw->extents);
+   REGION_DESTROY(cw->clip);
 
    _EFREE(eo->cmhook);
 
@@ -1854,7 +1876,7 @@
        cw = eo->cmhook;
        if (!cw)
           continue;
-       REGION_DESTROY(cw->clip);
+       cw->have_clip = 0;
      }
 }
 
@@ -1894,12 +1916,12 @@
           continue;
 
        /* Region of shaped window in screen coordinates */
-       if (cw->shape == None)
-          cw->shape = win_shape(eo);
+       if (!cw->have_shape)
+          ECompMgrWinSetShape(eo);
 
        /* Region of window in screen coordinates, including shadows */
-       if (cw->extents == None)
-          cw->extents = win_extents(eo);
+       if (!cw->have_extents)
+          ECompMgrWinSetExtents(eo);
 
        D3printf(" - %#lx desk=%d shown=%d fading=%d fadeout=%d\n",
                 EobjGetXwin(eo), eo->desk->num, eo->shown, cw->fading,
@@ -1942,6 +1964,7 @@
        if (cw->clip == None)
           cw->clip = ERegionCreate();
        ERegionCopy(cw->clip, clip);
+       cw->have_clip = 1;
 
        ECompMgrWinSetPicts(eo);
 
@@ -2040,13 +2063,6 @@
 
    cw = eo->cmhook;
 
-#if 0                          /* FIXME - Remove? */
-   if (!cw->shape)
-      cw->shape = win_shape(eo);
-   if (!cw->extents)
-      cw->extents = win_extents(eo);
-#endif
-
    if (rgn_clip == None)
       rgn_clip = ERegionCreate();
 
@@ -2453,6 +2469,7 @@
    Mode_compmgr.got_damage = 0;
 
    rgn_tmp = ERegionCreate();
+   rgn_tmp2 = ERegionCreate();
 
    EventCallbackRegister(VRoot.win, 0, ECompMgrHandleRootEvent, NULL);
 
@@ -2516,6 +2533,7 @@
    Mode_compmgr.got_damage = 0;
    REGION_DESTROY(Mode_compmgr.damage);
    REGION_DESTROY(rgn_tmp);
+   REGION_DESTROY(rgn_tmp2);
 
    if (Conf_compmgr.mode == ECM_MODE_ROOT)
       XCompositeUnredirectSubwindows(disp, VRoot.xwin, 
CompositeRedirectManual);
===================================================================
RCS file: /cvs/e/e16/e/src/eobj.c,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -3 -r1.95 -r1.96
--- eobj.c      24 Jun 2007 16:48:16 -0000      1.95
+++ eobj.c      11 Jul 2007 08:44:12 -0000      1.96
@@ -380,11 +380,11 @@
    if (!eo->shown)
       return;
 
-   EUnmapWindow(eo->win);
 #if USE_COMPOSITE
    if (eo->cmhook)
       ECompMgrWinUnmap(eo);
 #endif
+   EUnmapWindow(eo->win);
    eo->shown = 0;
 }
 



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to