changeset: 3681:4891ad29a0b1 user: Richard Bair date: Fri May 17 14:58:59 2013 -0700 summary: Fix padding of dirty regions so as to avoid padding unless we're dealing with lcd text diff -r f4959e3fb0e5 -r 4891ad29a0b1 javafx-sg-common/src/com/sun/javafx/sg/BaseNode.java --- a/javafx-sg-common/src/com/sun/javafx/sg/BaseNode.java Fri May 17 13:32:27 2013 -0700 +++ b/javafx-sg-common/src/com/sun/javafx/sg/BaseNode.java Fri May 17 14:58:59 2013 -0700 @@ -25,12 +25,13 @@ package com.sun.javafx.sg; +import java.util.List; import com.sun.javafx.geom.BaseBounds; import com.sun.javafx.geom.BoxBounds; import com.sun.javafx.geom.DirtyRegionContainer; import com.sun.javafx.geom.DirtyRegionPool; +import com.sun.javafx.geom.RectBounds; import com.sun.javafx.geom.Rectangle; -import com.sun.javafx.geom.RectBounds; import com.sun.javafx.geom.transform.Affine3D; import com.sun.javafx.geom.transform.BaseTransform; import com.sun.javafx.geom.transform.GeneralTransform3D; @@ -39,10 +40,8 @@ import com.sun.scenario.effect.Effect; import com.sun.scenario.effect.FilterContext; import com.sun.scenario.effect.ImageData; -import java.util.List; -import static com.sun.javafx.logging.PulseLogger.PULSE_LOGGING_ENABLED; -import static com.sun.javafx.logging.PulseLogger.PULSE_LOGGER; +import static com.sun.javafx.logging.PulseLogger.*; /** * BaseNode is the abstract base class implementing PGNode, and forming @@ -1161,17 +1160,29 @@ // to it (after slightly padding it for good luck) to get the scene // coordinates for this. Note that for SGText this implementation should not // be used (as this shortcut doesn't seem to work well with text). - region = region.deriveWithNewBounds(region.getMinX() - 1.0f, - region.getMinY() - 1.0f, + float pad = luckyPad(); + region = region.deriveWithNewBounds(region.getMinX() - pad, + region.getMinY() - pad, region.getMinZ(), - region.getMaxX() + 1.0f, - region.getMaxY() + 1.0f, + region.getMaxX() + pad, + region.getMaxY() + pad, region.getMaxZ()); region = tx.transform(region, region); region = pvTx.transform(region, region); } return region; } + + /** + * LCD Text creates some painful situations where, due to the LCD text + * algorithm, we end up with some pixels touched that are normally outside + * the bounds. To compensate, we need a hook for NGText to add padding. + * + * @return The lucky number. + */ + protected float luckyPad() { + return 0f; + } /** * Marks if the node has some visuals and that the bounds change diff -r f4959e3fb0e5 -r 4891ad29a0b1 javafx-sg-prism/src/com/sun/javafx/sg/prism/NGText.java --- a/javafx-sg-prism/src/com/sun/javafx/sg/prism/NGText.java Fri May 17 13:32:27 2013 -0700 +++ b/javafx-sg-prism/src/com/sun/javafx/sg/prism/NGText.java Fri May 17 14:58:59 2013 -0700 @@ -338,4 +338,16 @@ } } } + + /** + * Provide some lucky padding in the case that we are rendering LCD + * text since there might be some pixels that lie outside the normally + * computed content bounds. + * + * @return some padding if this is LCD text. + */ + @Override protected float luckyPad() { + return fontSmoothingType == FontResource.AA_LCD ? 2f : 0f; + } + }