52 import sun.java2d.loops.DrawGlyphListLCD;
53 import sun.java2d.pipe.LoopPipe;
54 import sun.java2d.pipe.CompositePipe;
55 import sun.java2d.pipe.GeneralCompositePipe;
56 import sun.java2d.pipe.SpanClipRenderer;
57 import sun.java2d.pipe.SpanShapeRenderer;
58 import sun.java2d.pipe.AAShapePipe;
59 import sun.java2d.pipe.AlphaPaintPipe;
60 import sun.java2d.pipe.AlphaColorPipe;
61 import sun.java2d.pipe.PixelToShapeConverter;
62 import sun.java2d.pipe.TextPipe;
63 import sun.java2d.pipe.TextRenderer;
64 import sun.java2d.pipe.AATextRenderer;
65 import sun.java2d.pipe.LCDTextRenderer;
66 import sun.java2d.pipe.SolidTextRenderer;
67 import sun.java2d.pipe.OutlineTextRenderer;
68 import sun.java2d.pipe.DrawImagePipe;
69 import sun.java2d.pipe.DrawImage;
70 import sun.awt.SunHints;
71 import sun.awt.image.SurfaceManager;
72
73 /**
74 * This class provides various pieces of information relevant to a
75 * particular drawing surface. The information obtained from this
76 * object describes the pixels of a particular instance of a drawing
77 * surface and can only be shared among the various graphics objects
78 * that target the same BufferedImage or the same screen Component.
79 * <p>
80 * Each SurfaceData object holds a StateTrackableDelegate object
81 * which tracks both changes to the content of the pixels of this
82 * surface and changes to the overall state of the pixels - such
83 * as becoming invalid or losing the surface. The delegate is
84 * marked "dirty" whenever the setSurfaceLost() or invalidate()
85 * methods are called and should also be marked "dirty" by the
86 * rendering pipelines whenever they modify the pixels of this
87 * SurfaceData.
88 * <p>
89 * If you get a StateTracker from a SurfaceData and it reports
90 * that it is still "current", then you can trust that the pixels
91 * have not changed and that the SurfaceData is still valid and
489 // and unclipped on two separate rendering passes.
490 // Unfortunately, all of the clipped glyph rendering
491 // pipelines rely on the use of the MaskBlit operation
492 // which is not defined for XOR.
493 sg2d.textpipe = outlineTextRenderer;
494 } else {
495 if (sg2d.transformState >= sg2d.TRANSFORM_TRANSLATESCALE) {
496 sg2d.drawpipe = colorViaShape;
497 sg2d.fillpipe = colorViaShape;
498 } else {
499 if (sg2d.strokeState != sg2d.STROKE_THIN) {
500 sg2d.drawpipe = colorViaShape;
501 } else {
502 sg2d.drawpipe = colorPrimitives;
503 }
504 sg2d.fillpipe = colorPrimitives;
505 }
506 sg2d.textpipe = solidTextRenderer;
507 }
508 sg2d.shapepipe = colorPrimitives;
509 sg2d.loops = getRenderLoops(sg2d);
510 // assert(sg2d.surfaceData == this);
511 }
512 } else if (sg2d.compositeState == sg2d.COMP_CUSTOM) {
513 if (sg2d.antialiasHint == SunHints.INTVAL_ANTIALIAS_ON) {
514 if (sg2d.clipState == sg2d.CLIP_SHAPE) {
515 sg2d.drawpipe = AAClipCompViaShape;
516 sg2d.fillpipe = AAClipCompViaShape;
517 sg2d.shapepipe = AAClipCompShape;
518 sg2d.textpipe = clipCompText;
519 } else {
520 sg2d.drawpipe = AACompViaShape;
521 sg2d.fillpipe = AACompViaShape;
522 sg2d.shapepipe = AACompShape;
523 sg2d.textpipe = compText;
524 }
525 } else {
526 sg2d.drawpipe = compViaShape;
527 sg2d.fillpipe = compViaShape;
528 sg2d.shapepipe = compShape;
529 if (sg2d.clipState == sg2d.CLIP_SHAPE) {
586 sg2d.textpipe = clipPaintText;
587 } else {
588 sg2d.textpipe = paintText;
589 }
590 }
591 } else {
592 if (sg2d.transformState >= sg2d.TRANSFORM_TRANSLATESCALE) {
593 sg2d.drawpipe = colorViaShape;
594 sg2d.fillpipe = colorViaShape;
595 } else {
596 if (sg2d.strokeState != sg2d.STROKE_THIN) {
597 sg2d.drawpipe = colorViaShape;
598 } else {
599 sg2d.drawpipe = colorPrimitives;
600 }
601 sg2d.fillpipe = colorPrimitives;
602 }
603
604 sg2d.textpipe = getTextPipe(sg2d, false /* AA==OFF */);
605 sg2d.shapepipe = colorPrimitives;
606 sg2d.loops = getRenderLoops(sg2d);
607 // assert(sg2d.surfaceData == this);
608 }
609 }
610
611 /* Return the text pipe to be used based on the graphics AA hint setting,
612 * and the rest of the graphics state is compatible with these loops.
613 * If the text AA hint is "DEFAULT", then the AA graphics hint requests
614 * the AA text renderer, else it requests the B&W text renderer.
615 */
616 private TextPipe getTextPipe(SunGraphics2D sg2d, boolean aaHintIsOn) {
617
618 /* Try to avoid calling getFontInfo() unless its needed to
619 * resolve one of the new AA types.
620 */
621 switch (sg2d.textAntialiasHint) {
622 case SunHints.INTVAL_TEXT_ANTIALIAS_DEFAULT:
623 if (aaHintIsOn) {
624 return aaTextRenderer;
625 } else {
626 return solidTextRenderer;
627 }
628 case SunHints.INTVAL_TEXT_ANTIALIAS_OFF:
|
52 import sun.java2d.loops.DrawGlyphListLCD;
53 import sun.java2d.pipe.LoopPipe;
54 import sun.java2d.pipe.CompositePipe;
55 import sun.java2d.pipe.GeneralCompositePipe;
56 import sun.java2d.pipe.SpanClipRenderer;
57 import sun.java2d.pipe.SpanShapeRenderer;
58 import sun.java2d.pipe.AAShapePipe;
59 import sun.java2d.pipe.AlphaPaintPipe;
60 import sun.java2d.pipe.AlphaColorPipe;
61 import sun.java2d.pipe.PixelToShapeConverter;
62 import sun.java2d.pipe.TextPipe;
63 import sun.java2d.pipe.TextRenderer;
64 import sun.java2d.pipe.AATextRenderer;
65 import sun.java2d.pipe.LCDTextRenderer;
66 import sun.java2d.pipe.SolidTextRenderer;
67 import sun.java2d.pipe.OutlineTextRenderer;
68 import sun.java2d.pipe.DrawImagePipe;
69 import sun.java2d.pipe.DrawImage;
70 import sun.awt.SunHints;
71 import sun.awt.image.SurfaceManager;
72 import sun.java2d.pipe.LoopBasedPipe;
73
74 /**
75 * This class provides various pieces of information relevant to a
76 * particular drawing surface. The information obtained from this
77 * object describes the pixels of a particular instance of a drawing
78 * surface and can only be shared among the various graphics objects
79 * that target the same BufferedImage or the same screen Component.
80 * <p>
81 * Each SurfaceData object holds a StateTrackableDelegate object
82 * which tracks both changes to the content of the pixels of this
83 * surface and changes to the overall state of the pixels - such
84 * as becoming invalid or losing the surface. The delegate is
85 * marked "dirty" whenever the setSurfaceLost() or invalidate()
86 * methods are called and should also be marked "dirty" by the
87 * rendering pipelines whenever they modify the pixels of this
88 * SurfaceData.
89 * <p>
90 * If you get a StateTracker from a SurfaceData and it reports
91 * that it is still "current", then you can trust that the pixels
92 * have not changed and that the SurfaceData is still valid and
490 // and unclipped on two separate rendering passes.
491 // Unfortunately, all of the clipped glyph rendering
492 // pipelines rely on the use of the MaskBlit operation
493 // which is not defined for XOR.
494 sg2d.textpipe = outlineTextRenderer;
495 } else {
496 if (sg2d.transformState >= sg2d.TRANSFORM_TRANSLATESCALE) {
497 sg2d.drawpipe = colorViaShape;
498 sg2d.fillpipe = colorViaShape;
499 } else {
500 if (sg2d.strokeState != sg2d.STROKE_THIN) {
501 sg2d.drawpipe = colorViaShape;
502 } else {
503 sg2d.drawpipe = colorPrimitives;
504 }
505 sg2d.fillpipe = colorPrimitives;
506 }
507 sg2d.textpipe = solidTextRenderer;
508 }
509 sg2d.shapepipe = colorPrimitives;
510 // assert(sg2d.surfaceData == this);
511 }
512 } else if (sg2d.compositeState == sg2d.COMP_CUSTOM) {
513 if (sg2d.antialiasHint == SunHints.INTVAL_ANTIALIAS_ON) {
514 if (sg2d.clipState == sg2d.CLIP_SHAPE) {
515 sg2d.drawpipe = AAClipCompViaShape;
516 sg2d.fillpipe = AAClipCompViaShape;
517 sg2d.shapepipe = AAClipCompShape;
518 sg2d.textpipe = clipCompText;
519 } else {
520 sg2d.drawpipe = AACompViaShape;
521 sg2d.fillpipe = AACompViaShape;
522 sg2d.shapepipe = AACompShape;
523 sg2d.textpipe = compText;
524 }
525 } else {
526 sg2d.drawpipe = compViaShape;
527 sg2d.fillpipe = compViaShape;
528 sg2d.shapepipe = compShape;
529 if (sg2d.clipState == sg2d.CLIP_SHAPE) {
586 sg2d.textpipe = clipPaintText;
587 } else {
588 sg2d.textpipe = paintText;
589 }
590 }
591 } else {
592 if (sg2d.transformState >= sg2d.TRANSFORM_TRANSLATESCALE) {
593 sg2d.drawpipe = colorViaShape;
594 sg2d.fillpipe = colorViaShape;
595 } else {
596 if (sg2d.strokeState != sg2d.STROKE_THIN) {
597 sg2d.drawpipe = colorViaShape;
598 } else {
599 sg2d.drawpipe = colorPrimitives;
600 }
601 sg2d.fillpipe = colorPrimitives;
602 }
603
604 sg2d.textpipe = getTextPipe(sg2d, false /* AA==OFF */);
605 sg2d.shapepipe = colorPrimitives;
606 // assert(sg2d.surfaceData == this);
607 }
608
609 // check for loops
610 if (sg2d.textpipe instanceof LoopBasedPipe ||
611 sg2d.shapepipe instanceof LoopBasedPipe ||
612 sg2d.fillpipe instanceof LoopBasedPipe ||
613 sg2d.drawpipe instanceof LoopBasedPipe ||
614 sg2d.imagepipe instanceof LoopBasedPipe)
615 {
616 sg2d.loops = getRenderLoops(sg2d);
617 }
618 }
619
620 /* Return the text pipe to be used based on the graphics AA hint setting,
621 * and the rest of the graphics state is compatible with these loops.
622 * If the text AA hint is "DEFAULT", then the AA graphics hint requests
623 * the AA text renderer, else it requests the B&W text renderer.
624 */
625 private TextPipe getTextPipe(SunGraphics2D sg2d, boolean aaHintIsOn) {
626
627 /* Try to avoid calling getFontInfo() unless its needed to
628 * resolve one of the new AA types.
629 */
630 switch (sg2d.textAntialiasHint) {
631 case SunHints.INTVAL_TEXT_ANTIALIAS_DEFAULT:
632 if (aaHintIsOn) {
633 return aaTextRenderer;
634 } else {
635 return solidTextRenderer;
636 }
637 case SunHints.INTVAL_TEXT_ANTIALIAS_OFF:
|