Skip to content

Commit

Permalink
composite: Support updating an arbitrary subtree
Browse files Browse the repository at this point in the history
Rename compUpdateWindow to compPaintWindowToParent and split the child
walk to compPaintChildrenToWindow. Calling compPaintChildrenToWindow
allows an arbitrary subtree to be updated, instead of having to update
all the windows. This will be used to make sure all the descendants are
copied to the parent when the parent window contents need to be accessed
in IncludeInferios sub-window mode.

WindowRec has a new member 'damagedDescendants' that is used to keep
track of which subtrees need updating. When a window is damaged,
'damagedDescendants' will be set for all the ancestors, and when a
subtree is updated, the tree walk can be stopped early if no damaged
descendants are present.

CompScreenRec no longer needs the 'damaged' member since the root
window's 'damagedDescendants' provides the same information.

Signed-off-by: Ville Syrjälä <ville.syrjala@nokia.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
  • Loading branch information
Ville Syrjälä authored and keith-packard committed Jan 5, 2011
1 parent b89e6db commit f348028
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 13 deletions.
13 changes: 11 additions & 2 deletions composite/compalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@

#include "compint.h"

void
static void
compScreenUpdate (ScreenPtr pScreen)
{
compCheckTree (pScreen);
compWindowUpdate (pScreen->root);
compPaintChildrenToWindow (pScreen->root);
}

static void
Expand Down Expand Up @@ -84,6 +84,15 @@ compReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure)
pScreen->BlockHandler = compBlockHandler;
}
cw->damaged = TRUE;

/* Mark the ancestors */
pWin = pWin->parent;
while (pWin) {
if (pWin->damagedDescendants)
break;
pWin->damagedDescendants = TRUE;
pWin = pWin->parent;
}
}

static void
Expand Down
4 changes: 2 additions & 2 deletions composite/compinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ compGetImage (DrawablePtr pDrawable,

pScreen->GetImage = cs->GetImage;
if (pDrawable->type == DRAWABLE_WINDOW)
compScreenUpdate (pScreen);
compPaintChildrenToWindow ((WindowPtr) pDrawable);
(*pScreen->GetImage) (pDrawable, sx, sy, w, h, format, planemask, pdstLine);
cs->GetImage = pScreen->GetImage;
pScreen->GetImage = compGetImage;
Expand All @@ -161,7 +161,7 @@ static void compSourceValidate(DrawablePtr pDrawable,

pScreen->SourceValidate = cs->SourceValidate;
if (pDrawable->type == DRAWABLE_WINDOW && subWindowMode == IncludeInferiors)
compScreenUpdate (pScreen);
compPaintChildrenToWindow ((WindowPtr) pDrawable);
if (pScreen->SourceValidate)
(*pScreen->SourceValidate) (pDrawable, x, y, width, height,
subWindowMode);
Expand Down
5 changes: 1 addition & 4 deletions composite/compint.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,7 @@ void
compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);

void
compWindowUpdate (WindowPtr pWin);

void
compScreenUpdate (ScreenPtr pScreen);
compPaintChildrenToWindow (WindowPtr pWin);

WindowPtr
CompositeRealChildHead (WindowPtr pWin);
Expand Down
22 changes: 17 additions & 5 deletions composite/compwindow.c
Original file line number Diff line number Diff line change
Expand Up @@ -720,13 +720,11 @@ compWindowUpdateAutomatic (WindowPtr pWin)
DamageEmpty (cw->damage);
}

void
compWindowUpdate (WindowPtr pWin)
static void
compPaintWindowToParent (WindowPtr pWin)
{
WindowPtr pChild;
compPaintChildrenToWindow (pWin);

for (pChild = pWin->lastChild; pChild; pChild = pChild->prevSib)
compWindowUpdate (pChild);
if (pWin->redirectDraw != RedirectDrawNone)
{
CompWindowPtr cw = GetCompWindow(pWin);
Expand All @@ -739,6 +737,20 @@ compWindowUpdate (WindowPtr pWin)
}
}

void
compPaintChildrenToWindow (WindowPtr pWin)
{
WindowPtr pChild;

if (!pWin->damagedDescendants)
return;

for (pChild = pWin->lastChild; pChild; pChild = pChild->prevSib)
compPaintWindowToParent (pChild);

pWin->damagedDescendants = FALSE;
}

WindowPtr
CompositeRealChildHead (WindowPtr pWin)
{
Expand Down
4 changes: 4 additions & 0 deletions dix/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ SetWindowToDefaults(WindowPtr pWin)
#ifdef ROOTLESS
pWin->rootlessUnhittable = FALSE;
#endif

#ifdef COMPOSITE
pWin->damagedDescendants = FALSE;
#endif
}

static void
Expand Down
3 changes: 3 additions & 0 deletions include/windowstr.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ typedef struct _Window {
#ifdef ROOTLESS
unsigned rootlessUnhittable:1; /* doesn't hit-test */
#endif
#ifdef COMPOSITE
unsigned damagedDescendants:1; /* some descendants are damaged */
#endif
} WindowRec;

/*
Expand Down

0 comments on commit f348028

Please sign in to comment.