6896068: SunGraphics2D exposes a reference to itself while non fully initialised
Introduce a new Interface to mark the Loops based pipes and initialise the loops accordingly. Reviewed-by: flar, rkennke
This commit is contained in:
parent
32f47acd27
commit
041e6cb967
@ -257,7 +257,6 @@ public final class SunGraphics2D
|
||||
font = defaultFont;
|
||||
}
|
||||
|
||||
loops = sd.getRenderLoops(this);
|
||||
setDevClip(sd.getBounds());
|
||||
invalidatePipe();
|
||||
}
|
||||
@ -367,6 +366,7 @@ public final class SunGraphics2D
|
||||
shapepipe = invalidpipe;
|
||||
textpipe = invalidpipe;
|
||||
imagepipe = invalidpipe;
|
||||
loops = null;
|
||||
}
|
||||
|
||||
public void validatePipe() {
|
||||
|
@ -69,6 +69,7 @@ import sun.java2d.pipe.DrawImagePipe;
|
||||
import sun.java2d.pipe.DrawImage;
|
||||
import sun.awt.SunHints;
|
||||
import sun.awt.image.SurfaceManager;
|
||||
import sun.java2d.pipe.LoopBasedPipe;
|
||||
|
||||
/**
|
||||
* This class provides various pieces of information relevant to a
|
||||
@ -506,7 +507,6 @@ public abstract class SurfaceData
|
||||
sg2d.textpipe = solidTextRenderer;
|
||||
}
|
||||
sg2d.shapepipe = colorPrimitives;
|
||||
sg2d.loops = getRenderLoops(sg2d);
|
||||
// assert(sg2d.surfaceData == this);
|
||||
}
|
||||
} else if (sg2d.compositeState == sg2d.COMP_CUSTOM) {
|
||||
@ -603,9 +603,18 @@ public abstract class SurfaceData
|
||||
|
||||
sg2d.textpipe = getTextPipe(sg2d, false /* AA==OFF */);
|
||||
sg2d.shapepipe = colorPrimitives;
|
||||
sg2d.loops = getRenderLoops(sg2d);
|
||||
// assert(sg2d.surfaceData == this);
|
||||
}
|
||||
|
||||
// check for loops
|
||||
if (sg2d.textpipe instanceof LoopBasedPipe ||
|
||||
sg2d.shapepipe instanceof LoopBasedPipe ||
|
||||
sg2d.fillpipe instanceof LoopBasedPipe ||
|
||||
sg2d.drawpipe instanceof LoopBasedPipe ||
|
||||
sg2d.imagepipe instanceof LoopBasedPipe)
|
||||
{
|
||||
sg2d.loops = getRenderLoops(sg2d);
|
||||
}
|
||||
}
|
||||
|
||||
/* Return the text pipe to be used based on the graphics AA hint setting,
|
||||
|
@ -34,8 +34,9 @@ import sun.font.GlyphList;
|
||||
* a solid source colour to an opaque destination.
|
||||
*/
|
||||
|
||||
public class AATextRenderer extends GlyphListLoopPipe {
|
||||
|
||||
public class AATextRenderer extends GlyphListLoopPipe
|
||||
implements LoopBasedPipe
|
||||
{
|
||||
protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl) {
|
||||
sg2d.loops.drawGlyphListAALoop.DrawGlyphListAA(sg2d, sg2d.surfaceData,
|
||||
gl);
|
||||
|
@ -36,8 +36,9 @@ import sun.font.GlyphList;
|
||||
* the installed loop may not match the glyphvector.
|
||||
*/
|
||||
|
||||
public abstract class GlyphListLoopPipe extends GlyphListPipe {
|
||||
|
||||
public abstract class GlyphListLoopPipe extends GlyphListPipe
|
||||
implements LoopBasedPipe
|
||||
{
|
||||
protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl,
|
||||
int aaHint) {
|
||||
switch (aaHint) {
|
||||
|
37
jdk/src/share/classes/sun/java2d/pipe/LoopBasedPipe.java
Normal file
37
jdk/src/share/classes/sun/java2d/pipe/LoopBasedPipe.java
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package sun.java2d.pipe;
|
||||
|
||||
/**
|
||||
* This is a marker interface used by Pipes that need RenderLoops.
|
||||
* RenderLoops are validated in SurfaceData when a pipe is recognised to
|
||||
* implement this interface.
|
||||
*
|
||||
* @author Mario Torre <neugens@aicas.com>
|
||||
*/
|
||||
public interface LoopBasedPipe {
|
||||
|
||||
}
|
@ -46,7 +46,8 @@ import sun.awt.SunHints;
|
||||
public class LoopPipe
|
||||
implements PixelDrawPipe,
|
||||
PixelFillPipe,
|
||||
ShapeDrawPipe
|
||||
ShapeDrawPipe,
|
||||
LoopBasedPipe
|
||||
{
|
||||
final static RenderingEngine RenderEngine = RenderingEngine.getInstance();
|
||||
|
||||
|
@ -35,8 +35,9 @@ import sun.font.GlyphList;
|
||||
* a solid source colour to an opaque destination.
|
||||
*/
|
||||
|
||||
public class SolidTextRenderer extends GlyphListLoopPipe {
|
||||
|
||||
public class SolidTextRenderer extends GlyphListLoopPipe
|
||||
implements LoopBasedPipe
|
||||
{
|
||||
protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl) {
|
||||
sg2d.loops.drawGlyphListLoop.DrawGlyphList(sg2d, sg2d.surfaceData, gl);
|
||||
}
|
||||
|
@ -65,7 +65,9 @@ public abstract class SpanShapeRenderer implements ShapeDrawPipe {
|
||||
}
|
||||
}
|
||||
|
||||
public static class Simple extends SpanShapeRenderer {
|
||||
public static class Simple extends SpanShapeRenderer
|
||||
implements LoopBasedPipe
|
||||
{
|
||||
public Object startSequence(SunGraphics2D sg, Shape s,
|
||||
Rectangle devR, int[] bbox) {
|
||||
return sg;
|
||||
|
@ -388,7 +388,10 @@ public abstract class X11SurfaceData extends SurfaceData {
|
||||
// if a GlyphVector overrides the AA setting.
|
||||
// We use getRenderLoops() rather than setting solidloops
|
||||
// directly so that we get the appropriate loops in XOR mode.
|
||||
if (sg2d.loops == null) {
|
||||
// assert(some pipe will always be a LoopBasedPipe)
|
||||
sg2d.loops = getRenderLoops(sg2d);
|
||||
}
|
||||
} else {
|
||||
super.validatePipe(sg2d);
|
||||
}
|
||||
|
@ -210,7 +210,10 @@ public class GDIWindowSurfaceData extends SurfaceData {
|
||||
// if a GlyphVector overrides the AA setting.
|
||||
// We use getRenderLoops() rather than setting solidloops
|
||||
// directly so that we get the appropriate loops in XOR mode.
|
||||
if (sg2d.loops == null) {
|
||||
// assert(some pipe will always be a LoopBasedPipe)
|
||||
sg2d.loops = getRenderLoops(sg2d);
|
||||
}
|
||||
} else {
|
||||
super.validatePipe(sg2d);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user