65 import java.awt.Transparency;
66 import java.awt.font.GlyphVector;
67 import java.awt.font.TextLayout;
68 import sun.font.FontDesignMetrics;
69 import sun.font.FontUtilities;
70 import sun.java2d.pipe.PixelDrawPipe;
71 import sun.java2d.pipe.PixelFillPipe;
72 import sun.java2d.pipe.ShapeDrawPipe;
73 import sun.java2d.pipe.ValidatePipe;
74 import sun.java2d.pipe.ShapeSpanIterator;
75 import sun.java2d.pipe.Region;
76 import sun.java2d.pipe.TextPipe;
77 import sun.java2d.pipe.DrawImagePipe;
78 import sun.java2d.pipe.LoopPipe;
79 import sun.java2d.loops.FontInfo;
80 import sun.java2d.loops.RenderLoops;
81 import sun.java2d.loops.CompositeType;
82 import sun.java2d.loops.SurfaceType;
83 import sun.java2d.loops.Blit;
84 import sun.java2d.loops.MaskFill;
85 import sun.font.FontManager;
86 import java.awt.font.FontRenderContext;
87 import sun.java2d.loops.XORComposite;
88 import sun.awt.ConstrainableGraphics;
89 import sun.awt.SunHints;
90 import java.util.Map;
91 import java.util.Iterator;
92 import sun.java2d.DestSurfaceProvider;
93 import sun.misc.PerformanceLogger;
94
95 /**
96 * This is a the master Graphics2D superclass for all of the Sun
97 * Graphics implementations. This class relies on subclasses to
98 * manage the various device information, but provides an overall
99 * general framework for performing all of the requests in the
100 * Graphics and Graphics2D APIs.
101 *
102 * @author Jim Graham
103 */
104 public final class SunGraphics2D
105 extends Graphics2D
924 if (paint instanceof Color) {
925 setColor((Color) paint);
926 return;
927 }
928 if (paint == null || this.paint == paint) {
929 return;
930 }
931 this.paint = paint;
932 if (imageComp == CompositeType.SrcOverNoEa) {
933 // special case where compState depends on opacity of paint
934 if (paint.getTransparency() == Transparency.OPAQUE) {
935 if (compositeState != COMP_ISCOPY) {
936 compositeState = COMP_ISCOPY;
937 }
938 } else {
939 if (compositeState == COMP_ISCOPY) {
940 compositeState = COMP_ALPHA;
941 }
942 }
943 }
944 Class paintClass = paint.getClass();
945 if (paintClass == GradientPaint.class) {
946 paintState = PAINT_GRADIENT;
947 } else if (paintClass == LinearGradientPaint.class) {
948 paintState = PAINT_LIN_GRADIENT;
949 } else if (paintClass == RadialGradientPaint.class) {
950 paintState = PAINT_RAD_GRADIENT;
951 } else if (paintClass == TexturePaint.class) {
952 paintState = PAINT_TEXTURE;
953 } else {
954 paintState = PAINT_CUSTOM;
955 }
956 validFontInfo = false;
957 invalidatePipe();
958 }
959
960 static final int NON_UNIFORM_SCALE_MASK =
961 (AffineTransform.TYPE_GENERAL_TRANSFORM |
962 AffineTransform.TYPE_GENERAL_SCALE);
963 public static final double MinPenSizeAA =
964 sun.java2d.pipe.RenderingEngine.getInstance().getMinimumAAPenSize();
1263 return null;
1264 }
1265
1266 /**
1267 * Sets the preferences for the rendering algorithms.
1268 * Hint categories include controls for rendering quality and
1269 * overall time/quality trade-off in the rendering process.
1270 * @param hints The rendering hints to be set
1271 * @see RenderingHints
1272 */
1273 public void setRenderingHints(Map<?,?> hints) {
1274 this.hints = null;
1275 renderHint = SunHints.INTVAL_RENDER_DEFAULT;
1276 antialiasHint = SunHints.INTVAL_ANTIALIAS_OFF;
1277 textAntialiasHint = SunHints.INTVAL_TEXT_ANTIALIAS_DEFAULT;
1278 fractionalMetricsHint = SunHints.INTVAL_FRACTIONALMETRICS_OFF;
1279 lcdTextContrast = lcdTextContrastDefaultValue;
1280 interpolationHint = -1;
1281 interpolationType = AffineTransformOp.TYPE_NEAREST_NEIGHBOR;
1282 boolean customHintPresent = false;
1283 Iterator iter = hints.keySet().iterator();
1284 while (iter.hasNext()) {
1285 Object key = iter.next();
1286 if (key == SunHints.KEY_RENDERING ||
1287 key == SunHints.KEY_ANTIALIASING ||
1288 key == SunHints.KEY_TEXT_ANTIALIASING ||
1289 key == SunHints.KEY_FRACTIONALMETRICS ||
1290 key == SunHints.KEY_TEXT_ANTIALIAS_LCD_CONTRAST ||
1291 key == SunHints.KEY_STROKE_CONTROL ||
1292 key == SunHints.KEY_INTERPOLATION)
1293 {
1294 setRenderingHint((Key) key, hints.get(key));
1295 } else {
1296 customHintPresent = true;
1297 }
1298 }
1299 if (customHintPresent) {
1300 this.hints = makeHints(hints);
1301 }
1302 invalidatePipe();
1303 }
1304
1305 /**
1306 * Adds a number of preferences for the rendering algorithms.
1307 * Hint categories include controls for rendering quality and
1308 * overall time/quality trade-off in the rendering process.
1309 * @param hints The rendering hints to be set
1310 * @see RenderingHints
1311 */
1312 public void addRenderingHints(Map<?,?> hints) {
1313 boolean customHintPresent = false;
1314 Iterator iter = hints.keySet().iterator();
1315 while (iter.hasNext()) {
1316 Object key = iter.next();
1317 if (key == SunHints.KEY_RENDERING ||
1318 key == SunHints.KEY_ANTIALIASING ||
1319 key == SunHints.KEY_TEXT_ANTIALIASING ||
1320 key == SunHints.KEY_FRACTIONALMETRICS ||
1321 key == SunHints.KEY_TEXT_ANTIALIAS_LCD_CONTRAST ||
1322 key == SunHints.KEY_STROKE_CONTROL ||
1323 key == SunHints.KEY_INTERPOLATION)
1324 {
1325 setRenderingHint((Key) key, hints.get(key));
1326 } else {
1327 customHintPresent = true;
1328 }
1329 }
1330 if (customHintPresent) {
1331 if (this.hints == null) {
1332 this.hints = makeHints(hints);
1333 } else {
1334 this.hints.putAll(hints);
|
65 import java.awt.Transparency;
66 import java.awt.font.GlyphVector;
67 import java.awt.font.TextLayout;
68 import sun.font.FontDesignMetrics;
69 import sun.font.FontUtilities;
70 import sun.java2d.pipe.PixelDrawPipe;
71 import sun.java2d.pipe.PixelFillPipe;
72 import sun.java2d.pipe.ShapeDrawPipe;
73 import sun.java2d.pipe.ValidatePipe;
74 import sun.java2d.pipe.ShapeSpanIterator;
75 import sun.java2d.pipe.Region;
76 import sun.java2d.pipe.TextPipe;
77 import sun.java2d.pipe.DrawImagePipe;
78 import sun.java2d.pipe.LoopPipe;
79 import sun.java2d.loops.FontInfo;
80 import sun.java2d.loops.RenderLoops;
81 import sun.java2d.loops.CompositeType;
82 import sun.java2d.loops.SurfaceType;
83 import sun.java2d.loops.Blit;
84 import sun.java2d.loops.MaskFill;
85 import java.awt.font.FontRenderContext;
86 import sun.java2d.loops.XORComposite;
87 import sun.awt.ConstrainableGraphics;
88 import sun.awt.SunHints;
89 import java.util.Map;
90 import java.util.Iterator;
91 import sun.java2d.DestSurfaceProvider;
92 import sun.misc.PerformanceLogger;
93
94 /**
95 * This is a the master Graphics2D superclass for all of the Sun
96 * Graphics implementations. This class relies on subclasses to
97 * manage the various device information, but provides an overall
98 * general framework for performing all of the requests in the
99 * Graphics and Graphics2D APIs.
100 *
101 * @author Jim Graham
102 */
103 public final class SunGraphics2D
104 extends Graphics2D
923 if (paint instanceof Color) {
924 setColor((Color) paint);
925 return;
926 }
927 if (paint == null || this.paint == paint) {
928 return;
929 }
930 this.paint = paint;
931 if (imageComp == CompositeType.SrcOverNoEa) {
932 // special case where compState depends on opacity of paint
933 if (paint.getTransparency() == Transparency.OPAQUE) {
934 if (compositeState != COMP_ISCOPY) {
935 compositeState = COMP_ISCOPY;
936 }
937 } else {
938 if (compositeState == COMP_ISCOPY) {
939 compositeState = COMP_ALPHA;
940 }
941 }
942 }
943 Class<? extends Paint> paintClass = paint.getClass();
944 if (paintClass == GradientPaint.class) {
945 paintState = PAINT_GRADIENT;
946 } else if (paintClass == LinearGradientPaint.class) {
947 paintState = PAINT_LIN_GRADIENT;
948 } else if (paintClass == RadialGradientPaint.class) {
949 paintState = PAINT_RAD_GRADIENT;
950 } else if (paintClass == TexturePaint.class) {
951 paintState = PAINT_TEXTURE;
952 } else {
953 paintState = PAINT_CUSTOM;
954 }
955 validFontInfo = false;
956 invalidatePipe();
957 }
958
959 static final int NON_UNIFORM_SCALE_MASK =
960 (AffineTransform.TYPE_GENERAL_TRANSFORM |
961 AffineTransform.TYPE_GENERAL_SCALE);
962 public static final double MinPenSizeAA =
963 sun.java2d.pipe.RenderingEngine.getInstance().getMinimumAAPenSize();
1262 return null;
1263 }
1264
1265 /**
1266 * Sets the preferences for the rendering algorithms.
1267 * Hint categories include controls for rendering quality and
1268 * overall time/quality trade-off in the rendering process.
1269 * @param hints The rendering hints to be set
1270 * @see RenderingHints
1271 */
1272 public void setRenderingHints(Map<?,?> hints) {
1273 this.hints = null;
1274 renderHint = SunHints.INTVAL_RENDER_DEFAULT;
1275 antialiasHint = SunHints.INTVAL_ANTIALIAS_OFF;
1276 textAntialiasHint = SunHints.INTVAL_TEXT_ANTIALIAS_DEFAULT;
1277 fractionalMetricsHint = SunHints.INTVAL_FRACTIONALMETRICS_OFF;
1278 lcdTextContrast = lcdTextContrastDefaultValue;
1279 interpolationHint = -1;
1280 interpolationType = AffineTransformOp.TYPE_NEAREST_NEIGHBOR;
1281 boolean customHintPresent = false;
1282 Iterator<?> iter = hints.keySet().iterator();
1283 while (iter.hasNext()) {
1284 Object key = iter.next();
1285 if (key == SunHints.KEY_RENDERING ||
1286 key == SunHints.KEY_ANTIALIASING ||
1287 key == SunHints.KEY_TEXT_ANTIALIASING ||
1288 key == SunHints.KEY_FRACTIONALMETRICS ||
1289 key == SunHints.KEY_TEXT_ANTIALIAS_LCD_CONTRAST ||
1290 key == SunHints.KEY_STROKE_CONTROL ||
1291 key == SunHints.KEY_INTERPOLATION)
1292 {
1293 setRenderingHint((Key) key, hints.get(key));
1294 } else {
1295 customHintPresent = true;
1296 }
1297 }
1298 if (customHintPresent) {
1299 this.hints = makeHints(hints);
1300 }
1301 invalidatePipe();
1302 }
1303
1304 /**
1305 * Adds a number of preferences for the rendering algorithms.
1306 * Hint categories include controls for rendering quality and
1307 * overall time/quality trade-off in the rendering process.
1308 * @param hints The rendering hints to be set
1309 * @see RenderingHints
1310 */
1311 public void addRenderingHints(Map<?,?> hints) {
1312 boolean customHintPresent = false;
1313 Iterator<?> iter = hints.keySet().iterator();
1314 while (iter.hasNext()) {
1315 Object key = iter.next();
1316 if (key == SunHints.KEY_RENDERING ||
1317 key == SunHints.KEY_ANTIALIASING ||
1318 key == SunHints.KEY_TEXT_ANTIALIASING ||
1319 key == SunHints.KEY_FRACTIONALMETRICS ||
1320 key == SunHints.KEY_TEXT_ANTIALIAS_LCD_CONTRAST ||
1321 key == SunHints.KEY_STROKE_CONTROL ||
1322 key == SunHints.KEY_INTERPOLATION)
1323 {
1324 setRenderingHint((Key) key, hints.get(key));
1325 } else {
1326 customHintPresent = true;
1327 }
1328 }
1329 if (customHintPresent) {
1330 if (this.hints == null) {
1331 this.hints = makeHints(hints);
1332 } else {
1333 this.hints.putAll(hints);
|