Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8322619: Parts of SG no longer update during rendering - overlapping - culling - dirty #1451

Closed
Closed
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ private boolean needToRenderCache(BaseTransform renderXform, double[] xformInfo,
if (lastXDelta != 0 || lastYDelta != 0) {
if (Math.abs(lastXDelta) >= cacheBounds.width || Math.abs(lastYDelta) >= cacheBounds.height ||
Math.rint(lastXDelta) != lastXDelta || Math.rint(lastYDelta) != lastYDelta) {
node.clearDirtyTree(); // Need to clear dirty (by translation) flags in the children
lastXDelta = lastYDelta = 0;
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public void addToRemoved(NGNode n) {
}

@Override
protected void clearDirty() {
public void clearDirty() {
super.clearDirty();
if (removed != null) removed.clear();
}
Expand Down Expand Up @@ -246,10 +246,6 @@ protected void renderContent(Graphics g) {
if (renderRoot.hasNext()) {
renderRoot.next();
startPos = orderedChildren.indexOf(renderRoot.getCurrentNode());

for (int i = 0; i < startPos; ++i) {
orderedChildren.get(i).clearDirtyTree();
}
} else {
g.setRenderRoot(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -900,11 +900,23 @@ public final boolean isClean() {
/**
* Clears the dirty flag. This should only happen during rendering.
*/
protected void clearDirty() {
dirty = DirtyFlag.CLEAN;
childDirty = false;
dirtyBounds.makeEmpty();
dirtyChildrenAccumulated = 0;
public void clearDirty() {
if (dirty != DirtyFlag.CLEAN || childDirty) {
dirty = DirtyFlag.CLEAN;
childDirty = false;
dirtyBounds.makeEmpty();
dirtyChildrenAccumulated = 0;

if (this instanceof NGGroup) {
List<NGNode> children = ((NGGroup) this).getChildren();
for (NGNode child : children) {
child.clearDirty();
}
}
}
if (getClipNode() != null) {
getClipNode().clearDirty();
}
}

/**
Expand All @@ -921,22 +933,6 @@ public void clearPainted() {
}
}

public void clearDirtyTree() {
clearDirty();
if (getClipNode() != null) {
getClipNode().clearDirtyTree();
}
if (this instanceof NGGroup) {
List<NGNode> children = ((NGGroup) this).getChildren();
for (int i = 0; i < children.size(); ++i) {
NGNode child = children.get(i);
if (child.dirty != DirtyFlag.CLEAN || child.childDirty) {
child.clearDirtyTree();
}
}
}
}

/**
* Invalidates the cache, if it is in use. There are several operations
* which need to cause the cached raster to become invalid so that a
Expand Down Expand Up @@ -1408,12 +1404,6 @@ void markCullRegions(
mask = mask << 2;
}//for

// If we are going to cull a node/group that's dirty,
// make sure it's dirty flags are properly cleared.
if (cullingBits == 0 && (dirty != DirtyFlag.CLEAN || childDirty)) {
clearDirtyTree();
}

// System.out.printf("%s bits: %s bounds: %s\n",
// this, Integer.toBinaryString(cullingBits), TEMP_RECT_BOUNDS);
}
Expand Down Expand Up @@ -1955,8 +1945,7 @@ public final void render(Graphics g) {
if (PULSE_LOGGING_ENABLED) {
PulseLogger.incrementCounter("Nodes visited during render");
}
// Clear the visuals changed flag
clearDirty();

// If it isn't visible, then punt
if (!visible || opacity == 0f) return;

Expand Down Expand Up @@ -2126,7 +2115,6 @@ private void renderNodeBlendMode(Graphics g) {

BaseBounds clipBounds = getClippedBounds(new RectBounds(), curXform);
if (clipBounds.isEmpty()) {
clearDirtyTree();
return;
}

Expand All @@ -2151,7 +2139,6 @@ private void renderNodeBlendMode(Graphics g) {
PrDrawable contentImg = (PrDrawable)
Effect.getCompatibleImage(fctx, clipRect.width, clipRect.height);
if (contentImg == null) {
clearDirtyTree();
return;
}
Graphics gContentImg = contentImg.createGraphics();
Expand Down Expand Up @@ -2201,21 +2188,17 @@ private void renderRectClip(Graphics g, NGRectangle clipNode) {
if (newClip.isEmpty() ||
newClip.getWidth() == 0 ||
newClip.getHeight() == 0) {
clearDirtyTree();
return;
}
// REMIND: avoid garbage by changing setClipRect to accept xywh
g.setClipRect(new Rectangle(newClip));
renderForClip(g);
g.setClipRect(curClip);
clipNode.clearDirty(); // as render() is not called on the clipNode,
// make sure the dirty flags are cleared
}

void renderClip(Graphics g) {
// if clip's opacity is 0 there's nothing to render
if (getClipNode().getOpacity() == 0.0) {
clearDirtyTree();
return;
}

Expand All @@ -2224,7 +2207,6 @@ void renderClip(Graphics g) {

BaseBounds clipBounds = getClippedBounds(new RectBounds(), curXform);
if (clipBounds.isEmpty()) {
clearDirtyTree();
return;
}

Expand Down Expand Up @@ -2256,13 +2238,6 @@ void renderClip(Graphics g) {
clipInput.flush();
nodeInput.flush();
g.setClipRect(savedClip);
// There may have been some errors in the application of the
// effect and we would not know to what extent the nodes were
// rendered and cleared or left dirty. clearDirtyTree() will
// clear both this node its clip node, and it will not recurse
// to the children unless they are still marked dirty. It should
// be cheap if there was no problem and thorough if there was...
clearDirtyTree();
return;
}

Expand All @@ -2271,7 +2246,6 @@ void renderClip(Graphics g) {
PrDrawable contentImg = (PrDrawable)
Effect.getCompatibleImage(fctx, clipRect.width, clipRect.height);
if (contentImg == null) {
clearDirtyTree();
return;
}
Graphics gContentImg = contentImg.createGraphics();
Expand All @@ -2286,7 +2260,6 @@ void renderClip(Graphics g) {
PrDrawable clipImg = (PrDrawable)
Effect.getCompatibleImage(fctx, clipRect.width, clipRect.height);
if (clipImg == null) {
getClipNode().clearDirtyTree();
Effect.releaseCompatibleImage(fctx, contentImg);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,13 +439,13 @@ public void setOpaqueInsets(float top, float right, float bottom, float left) {
}

/**
* When cleaning the dirty tree, we also have to keep in mind
* When cleaning the dirty flag, we also have to keep in mind
* the NGShape used by the NGRegion
*/
@Override public void clearDirtyTree() {
super.clearDirtyTree();
@Override public void clearDirty() {
super.clearDirty();
if (ngShape != null) {
ngShape.clearDirtyTree();
ngShape.clearDirty();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ public void markContentDirty() {
visualsChanged();
}

@Override
public void clearDirty() {
super.clearDirty();
if (root != null) {
root.clearDirty();
}
}

@Override
protected void visualsChanged() {
renderSG = true;
Expand Down Expand Up @@ -220,7 +228,6 @@ protected void renderContent(Graphics g) {
applyBackgroundFillPaint(rttGraphics);

root.render(rttGraphics);
root.clearDirtyTree();
renderSG = false;
}
if (msaa) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ protected void paintImpl(final Graphics backBufferGraphics) {
}
root.clearPainted();
}

// Ensure the dirty flags are cleared
root.clearDirty();
}

/**
Expand Down Expand Up @@ -449,8 +452,6 @@ private void doPaint(Graphics g, NodePath renderRootPath) {
if (renderRootPath != null) {
if (renderRootPath.isEmpty()) {
// empty render path indicates that no rendering is needed.
// There may be occluded dirty Nodes however, so we need to clear them
root.clearDirtyTree();
return;
}
// If the path is not empty, the first node must be the root node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public DirtyRegionClipTest(Creator creator, Polluter polluter) {
// clean them all up so that when we perform the test, it is from the
// starting point of a completely cleaned tree
root.render(TestGraphics.TEST_GRAPHICS);
root.clearDirty();
}

@Test public void sanityCheck() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public GridDirtyRegionTest(Creator creator, Polluter polluter) {
// clean them all up so that when we perform the test, it is from the
// starting point of a completely cleaned tree
root.render(TestGraphics.TEST_GRAPHICS);
root.clearDirty();
}

@Test public void sanityCheck() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public void dirtyRegionWithinOpaqueRegion() {
*/
@Test
public void dirtyRegionWithinOpaqueRegion_Clean() {
root.clearDirtyTree();
root.clearDirty();
NodePath rootPath = getRenderRoot(root, 20, 20, 70, 70);
assertRenderRoot(null, rootPath);
}
Expand All @@ -159,7 +159,7 @@ public void dirtyRegionMatchesOpaqueRegion() {
*/
@Test
public void dirtyRegionMatchesOpaqueRegion_Clean() {
root.clearDirtyTree();
root.clearDirty();
NodePath rootPath = getRenderRoot(root, 10, 10, 90, 90);
assertRenderRoot(null, rootPath);
}
Expand All @@ -180,7 +180,7 @@ public void dirtyRegionWithinOpaqueRegionTouchesTop() {
*/
@Test
public void dirtyRegionWithinOpaqueRegionTouchesTop_Clean() {
root.clearDirtyTree();
root.clearDirty();
NodePath rootPath = getRenderRoot(root, 20, 10, 70, 70);
assertRenderRoot(null, rootPath);
}
Expand All @@ -200,7 +200,7 @@ public void dirtyRegionWithinOpaqueRegionTouchesRight() {
*/
@Test
public void dirtyRegionWithinOpaqueRegionTouchesRight_Clean() {
root.clearDirtyTree();
root.clearDirty();
NodePath rootPath = getRenderRoot(root, 20, 20, 80, 70);
assertRenderRoot(null, rootPath);
}
Expand All @@ -221,7 +221,7 @@ public void dirtyRegionWithinOpaqueRegionTouchesBottom() {
*/
@Test
public void dirtyRegionWithinOpaqueRegionTouchesBottom_Clean() {
root.clearDirtyTree();
root.clearDirty();
NodePath rootPath = getRenderRoot(root, 20, 20, 70, 80);
assertRenderRoot(null, rootPath);
}
Expand All @@ -242,7 +242,7 @@ public void dirtyRegionWithinOpaqueRegionTouchesLeft() {
*/
@Test
public void dirtyRegionWithinOpaqueRegionTouchesLeft_Clean() {
root.clearDirtyTree();
root.clearDirty();
NodePath rootPath = getRenderRoot(root, 10, 20, 70, 70);
assertRenderRoot(null, rootPath);
}
Expand All @@ -255,7 +255,7 @@ public void opaqueRegionWithinDirtyRegion() {

@Test
public void opaqueRegionWithinDirtyRegion_Clean() {
root.clearDirtyTree();
root.clearDirty();
NodePath rootPath = getRenderRoot(root, 0, 0, 110, 110);
assertRenderRoot(root, rootPath);
}
Expand All @@ -268,7 +268,7 @@ public void dirtyRegionIntersectsOpaqueRegionTop() {

@Test
public void dirtyRegionIntersectsOpaqueRegionTop_Clean() {
root.clearDirtyTree();
root.clearDirty();
NodePath rootPath = getRenderRoot(root, 20, 0, 70, 30);
assertRenderRoot(root, rootPath);
}
Expand All @@ -281,7 +281,7 @@ public void dirtyRegionIntersectsOpaqueRegionRight() {

@Test
public void dirtyRegionIntersectsOpaqueRegionRight_Clean() {
root.clearDirtyTree();
root.clearDirty();
NodePath rootPath = getRenderRoot(root, 90, 20, 30, 70);
assertRenderRoot(root, rootPath);
}
Expand All @@ -294,7 +294,7 @@ public void dirtyRegionIntersectsOpaqueRegionBottom() {

@Test
public void dirtyRegionIntersectsOpaqueRegionBottom_Clean() {
root.clearDirtyTree();
root.clearDirty();
NodePath rootPath = getRenderRoot(root, 20, 90, 70, 30);
assertRenderRoot(root, rootPath);
}
Expand All @@ -307,7 +307,7 @@ public void dirtyRegionIntersectsOpaqueRegionLeft() {

@Test
public void dirtyRegionIntersectsOpaqueRegionLeft_Clean() {
root.clearDirtyTree();
root.clearDirty();
NodePath rootPath = getRenderRoot(root, 0, 20, 30, 70);
assertRenderRoot(root, rootPath);
}
Expand All @@ -320,7 +320,7 @@ public void dirtyRegionCompletelyOutsideOfOpaqueRegion() {

@Test
public void dirtyRegionCompletelyOutsideOfOpaqueRegion_Clean() {
root.clearDirtyTree();
root.clearDirty();
NodePath rootPath = getRenderRoot(root, 0, 0, 5, 5);
assertRenderRoot(root, rootPath);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ public void clearDirty() {

NGRegion peer = NodeHelper.getPeer(r);
assertFalse(peer.isClean());
peer.clearDirtyTree();
peer.clearDirty();
assertTrue(peer.isClean());

lineTo.setX(200);
Expand Down
Loading