提交 beff7858 编写于 作者: F flar

6766342: Improve performance of Ductus rasterizer

Reviewed-by: jgodinez, prr
上级 2dfaa02f
......@@ -224,7 +224,7 @@ $(OBJDIR)/DllUtil.obj:: ../../../src/windows/native/sun/windows/DllUtil.h
$(OBJDIR)/DrawLine.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_DrawLine.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/loops/LineUtils.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
$(OBJDIR)/DrawParallelogram.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_DrawParallelogram.h $(CLASSHDRDIR)/sun_java2d_loops_FillParallelogram.h ../../../src/share/javavm/export/classfile_constants.h ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/loops/LineUtils.h ../../../src/share/native/sun/java2d/loops/LoopMacros.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
$(OBJDIR)/DrawParallelogram.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_DrawParallelogram.h ../../../src/share/javavm/export/classfile_constants.h ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/loops/LineUtils.h ../../../src/share/native/sun/java2d/loops/ParallelogramUtils.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
$(OBJDIR)/DrawPath.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_DrawPath.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/DrawPath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/loops/LineUtils.h ../../../src/share/native/sun/java2d/loops/ProcessPath.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
......@@ -232,7 +232,7 @@ $(OBJDIR)/DrawPolygons.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDR
$(OBJDIR)/DrawRect.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_DrawRect.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/loops/LineUtils.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
$(OBJDIR)/FillParallelogram.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_FillParallelogram.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
$(OBJDIR)/FillParallelogram.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_FillParallelogram.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/loops/ParallelogramUtils.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
$(OBJDIR)/FillPath.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_FillPath.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/DrawPath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/loops/LineUtils.h ../../../src/share/native/sun/java2d/loops/ProcessPath.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
......@@ -284,7 +284,7 @@ $(OBJDIR)/IntRgbx.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h ../../../src/sh
$(OBJDIR)/MaskBlit.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_MaskBlit.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/pipe/Region.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/sun/awt/utility/rect.h ../../../src/windows/native/sun/java2d/j2d_md.h
$(OBJDIR)/MaskFill.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_MaskFill.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
$(OBJDIR)/MaskFill.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_MaskFill.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/loops/ParallelogramUtils.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
$(OBJDIR)/MouseInfo.obj:: $(CLASSHDRDIR)/java_awt_AWTEvent.h $(CLASSHDRDIR)/java_awt_Component.h $(CLASSHDRDIR)/java_awt_Dimension.h $(CLASSHDRDIR)/java_awt_Event.h $(CLASSHDRDIR)/java_awt_event_FocusEvent.h $(CLASSHDRDIR)/java_awt_event_KeyEvent.h $(CLASSHDRDIR)/java_awt_event_MouseEvent.h $(CLASSHDRDIR)/java_awt_event_WindowEvent.h $(CLASSHDRDIR)/java_awt_Font.h $(CLASSHDRDIR)/sun_awt_FontDescriptor.h $(CLASSHDRDIR)/sun_awt_PlatformFont.h $(CLASSHDRDIR)/sun_awt_windows_WComponentPeer.h $(CLASSHDRDIR)/sun_awt_windows_WFontMetrics.h $(CLASSHDRDIR)/sun_awt_windows_WObjectPeer.h $(CLASSHDRDIR)/sun_awt_windows_WToolkit.h ../../../src/share/javavm/export/classfile_constants.h ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/awt/image/cvutils/img_globals.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.h ../../../src/windows/native/sun/windows/alloc.h ../../../src/windows/native/sun/windows/awt.h ../../../src/windows/native/sun/windows/awtmsg.h ../../../src/windows/native/sun/windows/awt_Brush.h ../../../src/windows/native/sun/windows/awt_Component.h ../../../src/windows/native/sun/windows/awt_Debug.h ../../../src/windows/native/sun/windows/awt_Font.h ../../../src/windows/native/sun/windows/awt_GDIObject.h ../../../src/windows/native/sun/windows/awt_Object.h ../../../src/windows/native/sun/windows/awt_Palette.h ../../../src/windows/native/sun/windows/awt_Pen.h ../../../src/windows/native/sun/windows/awt_Toolkit.h ../../../src/windows/native/sun/windows/awt_Win32GraphicsDevice.h ../../../src/windows/native/sun/windows/colordata.h ../../../src/windows/native/sun/windows/Devices.h ../../../src/windows/native/sun/windows/GDIHashtable.h ../../../src/windows/native/sun/windows/Hashtable.h ../../../src/windows/native/sun/windows/ObjectList.h ../../../src/windows/native/sun/windows/stdhdrs.h
......
......@@ -118,6 +118,8 @@ SUNWprivate_1.1 {
Java_sun_java2d_loops_GraphicsPrimitiveMgr_registerNativeLoops;
Java_sun_java2d_loops_MaskBlit_MaskBlit;
Java_sun_java2d_loops_MaskFill_MaskFill;
Java_sun_java2d_loops_MaskFill_FillAAPgram;
Java_sun_java2d_loops_MaskFill_DrawAAPgram;
Java_sun_java2d_loops_TransformHelper_Transform;
Java_sun_java2d_pipe_Region_initIDs;
Java_sun_java2d_pipe_SpanClipRenderer_initIDs;
......
......@@ -115,6 +115,8 @@ SUNWprivate_1.1 {
Java_sun_java2d_loops_GraphicsPrimitiveMgr_registerNativeLoops;
Java_sun_java2d_loops_MaskBlit_MaskBlit;
Java_sun_java2d_loops_MaskFill_MaskFill;
Java_sun_java2d_loops_MaskFill_FillAAPgram;
Java_sun_java2d_loops_MaskFill_DrawAAPgram;
Java_sun_java2d_pipe_BufferedRenderPipe_fillSpans;
Java_sun_java2d_pipe_SpanClipRenderer_initIDs;
sun_awt_image_GifImageDecoder_initIDs;
......
......@@ -635,6 +635,88 @@ public class DuctusRenderingEngine extends RenderingEngine {
return r;
}
/**
* {@inheritDoc}
*/
@Override
public AATileGenerator getAATileGenerator(double x, double y,
double dx1, double dy1,
double dx2, double dy2,
double lw1, double lw2,
Region clip,
int bbox[])
{
// REMIND: Deal with large coordinates!
double ldx1, ldy1, ldx2, ldy2;
boolean innerpgram = (lw1 > 0 && lw2 > 0);
if (innerpgram) {
ldx1 = dx1 * lw1;
ldy1 = dy1 * lw1;
ldx2 = dx2 * lw2;
ldy2 = dy2 * lw2;
x -= (ldx1 + ldx2) / 2.0;
y -= (ldy1 + ldy2) / 2.0;
dx1 += ldx1;
dy1 += ldy1;
dx2 += ldx2;
dy2 += ldy2;
if (lw1 > 1 && lw2 > 1) {
// Inner parallelogram was entirely consumed by stroke...
innerpgram = false;
}
} else {
ldx1 = ldy1 = ldx2 = ldy2 = 0;
}
Rasterizer r = getRasterizer();
r.setUsage(Rasterizer.EOFILL);
r.beginPath();
r.beginSubpath((float) x, (float) y);
r.appendLine((float) (x+dx1), (float) (y+dy1));
r.appendLine((float) (x+dx1+dx2), (float) (y+dy1+dy2));
r.appendLine((float) (x+dx2), (float) (y+dy2));
r.closedSubpath();
if (innerpgram) {
x += ldx1 + ldx2;
y += ldy1 + ldy2;
dx1 -= 2.0 * ldx1;
dy1 -= 2.0 * ldy1;
dx2 -= 2.0 * ldx2;
dy2 -= 2.0 * ldy2;
r.beginSubpath((float) x, (float) y);
r.appendLine((float) (x+dx1), (float) (y+dy1));
r.appendLine((float) (x+dx1+dx2), (float) (y+dy1+dy2));
r.appendLine((float) (x+dx2), (float) (y+dy2));
r.closedSubpath();
}
try {
r.endPath();
r.getAlphaBox(bbox);
clip.clipBoxToBounds(bbox);
if (bbox[0] >= bbox[2] || bbox[1] >= bbox[3]) {
dropRasterizer(r);
return null;
}
r.setOutputArea(bbox[0], bbox[1],
bbox[2] - bbox[0],
bbox[3] - bbox[1]);
} catch (PRException e) {
/*
* This exeption is thrown from the native part of the Ductus
* (only in case of a debug build) to indicate that some
* segments of the path have very large coordinates.
* See 4485298 for more info.
*/
System.err.println("DuctusRenderingEngine.getAATileGenerator: "+e);
}
return r;
}
private void feedConsumer(PathConsumer consumer, PathIterator pi) {
try {
consumer.beginPath();
......
......@@ -367,16 +367,17 @@ public abstract class SurfaceData
public static final TextPipe aaTextRenderer;
public static final TextPipe lcdTextRenderer;
protected static final CompositePipe colorPipe;
protected static final AlphaColorPipe colorPipe;
protected static final PixelToShapeConverter colorViaShape;
protected static final PixelToParallelogramConverter colorViaPgram;
protected static final TextPipe colorText;
protected static final CompositePipe clipColorPipe;
protected static final TextPipe clipColorText;
protected static final AAShapePipe AAColorShape;
protected static final PixelToShapeConverter AAColorViaShape;
protected static final PixelToParallelogramConverter AAColorViaShape;
protected static final PixelToParallelogramConverter AAColorViaPgram;
protected static final AAShapePipe AAClipColorShape;
protected static final PixelToShapeConverter AAClipColorViaShape;
protected static final PixelToParallelogramConverter AAClipColorViaShape;
protected static final CompositePipe paintPipe;
protected static final SpanShapeRenderer paintShape;
......@@ -385,9 +386,9 @@ public abstract class SurfaceData
protected static final CompositePipe clipPaintPipe;
protected static final TextPipe clipPaintText;
protected static final AAShapePipe AAPaintShape;
protected static final PixelToShapeConverter AAPaintViaShape;
protected static final PixelToParallelogramConverter AAPaintViaShape;
protected static final AAShapePipe AAClipPaintShape;
protected static final PixelToShapeConverter AAClipPaintViaShape;
protected static final PixelToParallelogramConverter AAClipPaintViaShape;
protected static final CompositePipe compPipe;
protected static final SpanShapeRenderer compShape;
......@@ -396,9 +397,9 @@ public abstract class SurfaceData
protected static final CompositePipe clipCompPipe;
protected static final TextPipe clipCompText;
protected static final AAShapePipe AACompShape;
protected static final PixelToShapeConverter AACompViaShape;
protected static final PixelToParallelogramConverter AACompViaShape;
protected static final AAShapePipe AAClipCompShape;
protected static final PixelToShapeConverter AAClipCompViaShape;
protected static final PixelToParallelogramConverter AAClipCompViaShape;
protected static final DrawImagePipe imagepipe;
......@@ -427,6 +428,22 @@ public abstract class SurfaceData
}
}
private static PixelToParallelogramConverter
makeConverter(AAShapePipe renderer,
ParallelogramPipe pgrampipe)
{
return new PixelToParallelogramConverter(renderer,
pgrampipe,
1.0/8.0, 0.499,
false);
}
private static PixelToParallelogramConverter
makeConverter(AAShapePipe renderer)
{
return makeConverter(renderer, renderer);
}
static {
colorPrimitives = new LoopPipe();
......@@ -445,9 +462,10 @@ public abstract class SurfaceData
clipColorPipe = new SpanClipRenderer(colorPipe);
clipColorText = new TextRenderer(clipColorPipe);
AAColorShape = new AAShapePipe(colorPipe);
AAColorViaShape = new PixelToShapeConverter(AAColorShape);
AAColorViaShape = makeConverter(AAColorShape);
AAColorViaPgram = makeConverter(AAColorShape, colorPipe);
AAClipColorShape = new AAShapePipe(clipColorPipe);
AAClipColorViaShape = new PixelToShapeConverter(AAClipColorShape);
AAClipColorViaShape = makeConverter(AAClipColorShape);
paintPipe = new AlphaPaintPipe();
paintShape = new SpanShapeRenderer.Composite(paintPipe);
......@@ -456,9 +474,9 @@ public abstract class SurfaceData
clipPaintPipe = new SpanClipRenderer(paintPipe);
clipPaintText = new TextRenderer(clipPaintPipe);
AAPaintShape = new AAShapePipe(paintPipe);
AAPaintViaShape = new PixelToShapeConverter(AAPaintShape);
AAPaintViaShape = makeConverter(AAPaintShape);
AAClipPaintShape = new AAShapePipe(clipPaintPipe);
AAClipPaintViaShape = new PixelToShapeConverter(AAClipPaintShape);
AAClipPaintViaShape = makeConverter(AAClipPaintShape);
compPipe = new GeneralCompositePipe();
compShape = new SpanShapeRenderer.Composite(compPipe);
......@@ -467,9 +485,9 @@ public abstract class SurfaceData
clipCompPipe = new SpanClipRenderer(compPipe);
clipCompText = new TextRenderer(clipCompPipe);
AACompShape = new AAShapePipe(compPipe);
AACompViaShape = new PixelToShapeConverter(AACompShape);
AACompViaShape = makeConverter(AACompShape);
AAClipCompShape = new AAShapePipe(clipCompPipe);
AAClipCompViaShape = new PixelToShapeConverter(AAClipCompShape);
AAClipCompViaShape = makeConverter(AAClipCompShape);
imagepipe = new DrawImage();
}
......@@ -591,12 +609,12 @@ public abstract class SurfaceData
if (sg2d.clipState == sg2d.CLIP_SHAPE) {
sg2d.drawpipe = AAClipCompViaShape;
sg2d.fillpipe = AAClipCompViaShape;
sg2d.shapepipe = AAClipCompShape;
sg2d.shapepipe = AAClipCompViaShape;
sg2d.textpipe = clipCompText;
} else {
sg2d.drawpipe = AACompViaShape;
sg2d.fillpipe = AACompViaShape;
sg2d.shapepipe = AACompShape;
sg2d.shapepipe = AACompViaShape;
sg2d.textpipe = compText;
}
} else {
......@@ -616,12 +634,16 @@ public abstract class SurfaceData
if (sg2d.clipState == sg2d.CLIP_SHAPE) {
sg2d.drawpipe = AAClipColorViaShape;
sg2d.fillpipe = AAClipColorViaShape;
sg2d.shapepipe = AAClipColorShape;
sg2d.shapepipe = AAClipColorViaShape;
sg2d.textpipe = clipColorText;
} else {
sg2d.drawpipe = AAColorViaShape;
sg2d.fillpipe = AAColorViaShape;
sg2d.shapepipe = AAColorShape;
PixelToParallelogramConverter converter =
(sg2d.alphafill.canDoParallelograms()
? AAColorViaPgram
: AAColorViaShape);
sg2d.drawpipe = converter;
sg2d.fillpipe = converter;
sg2d.shapepipe = converter;
if (sg2d.paintState > sg2d.PAINT_OPAQUECOLOR ||
sg2d.compositeState > sg2d.COMP_ISCOPY)
{
......@@ -634,12 +656,12 @@ public abstract class SurfaceData
if (sg2d.clipState == sg2d.CLIP_SHAPE) {
sg2d.drawpipe = AAClipPaintViaShape;
sg2d.fillpipe = AAClipPaintViaShape;
sg2d.shapepipe = AAClipPaintShape;
sg2d.shapepipe = AAClipPaintViaShape;
sg2d.textpipe = clipPaintText;
} else {
sg2d.drawpipe = AAPaintViaShape;
sg2d.fillpipe = AAPaintViaShape;
sg2d.shapepipe = AAPaintShape;
sg2d.shapepipe = AAPaintViaShape;
sg2d.textpipe = paintText;
}
}
......@@ -793,6 +815,18 @@ public abstract class SurfaceData
}
}
private static CompositeType getFillCompositeType(SunGraphics2D sg2d) {
CompositeType compType = sg2d.imageComp;
if (sg2d.compositeState == sg2d.COMP_ISCOPY) {
if (compType == CompositeType.SrcOverNoEa) {
compType = CompositeType.OpaqueSrcOverNoEa;
} else {
compType = CompositeType.SrcNoEa;
}
}
return compType;
}
/**
* Returns a MaskFill object that can be used on this destination
* with the source (paint) and composite types determined by the given
......@@ -802,9 +836,10 @@ public abstract class SurfaceData
* surface) before returning a specific MaskFill object.
*/
protected MaskFill getMaskFill(SunGraphics2D sg2d) {
return MaskFill.getFromCache(getPaintSurfaceType(sg2d),
sg2d.imageComp,
getSurfaceType());
SurfaceType src = getPaintSurfaceType(sg2d);
CompositeType comp = getFillCompositeType(sg2d);
SurfaceType dst = getSurfaceType();
return MaskFill.getFromCache(src, comp, dst);
}
private static RenderCache loopcache = new RenderCache(30);
......@@ -816,9 +851,7 @@ public abstract class SurfaceData
*/
public RenderLoops getRenderLoops(SunGraphics2D sg2d) {
SurfaceType src = getPaintSurfaceType(sg2d);
CompositeType comp = (sg2d.compositeState == sg2d.COMP_ISCOPY
? CompositeType.SrcNoEa
: sg2d.imageComp);
CompositeType comp = getFillCompositeType(sg2d);
SurfaceType dst = sg2d.getSurfaceData().getSurfaceType();
Object o = loopcache.get(src, comp, dst);
......
......@@ -27,6 +27,7 @@ package sun.java2d.loops;
import java.awt.image.BufferedImage;
import java.awt.AlphaComposite;
import java.util.HashMap;
/**
* A CompositeType object provides a chained description of a type of
......@@ -51,6 +52,11 @@ import java.awt.AlphaComposite;
* the indicated algorithm if all of the more specific searches fail.
*/
public final class CompositeType {
private static int unusedUID = 1;
private static final HashMap<String,Integer> compositeUIDMap =
new HashMap<String,Integer>(100);
/*
* CONSTANTS USED BY ALL PRIMITIVES TO DESCRIBE THE COMPOSITING
* ALGORITHMS THEY CAN PERFORM
......@@ -152,6 +158,22 @@ public final class CompositeType {
public static final CompositeType
SrcOverNoEa = SrcOver.deriveSubType(DESC_SRC_OVER_NO_EA);
/*
* A special CompositeType for the case where we are filling in
* SrcOverNoEa mode with an opaque color. In that case then the
* best loop for us to use would be a SrcNoEa loop, but what if
* there is no such loop? In that case then we would end up
* backing off to a Src loop (which should still be fine) or an
* AnyAlpha loop which would be slower than a SrcOver loop in
* most cases.
* The fix is to use the following chain which looks for loops
* in the following order:
* SrcNoEa, Src, SrcOverNoEa, SrcOver, AnyAlpha
*/
public static final CompositeType
OpaqueSrcOverNoEa = SrcOverNoEa.deriveSubType(DESC_SRC)
.deriveSubType(DESC_SRC_NO_EA);
/*
* END OF CompositeType OBJECTS FOR THE VARIOUS CONSTANTS
*/
......@@ -210,7 +232,6 @@ public final class CompositeType {
}
}
private static int unusedUID = 1;
private int uniqueID;
private String desc;
private CompositeType next;
......@@ -218,14 +239,20 @@ public final class CompositeType {
private CompositeType(CompositeType parent, String desc) {
next = parent;
this.desc = desc;
this.uniqueID = makeUniqueID();
this.uniqueID = makeUniqueID(desc);
}
private synchronized static final int makeUniqueID() {
if (unusedUID > 255) {
throw new InternalError("composite type id overflow");
public synchronized static final int makeUniqueID(String desc) {
Integer i = compositeUIDMap.get(desc);
if (i == null) {
if (unusedUID > 255) {
throw new InternalError("composite type id overflow");
}
i = unusedUID++;
compositeUIDMap.put(desc, i);
}
return unusedUID++;
return i;
}
public int getUniqueID() {
......
......@@ -50,6 +50,10 @@ import sun.java2d.SurfaceData;
public class MaskFill extends GraphicsPrimitive
{
public static final String methodSignature = "MaskFill(...)".toString();
public static final String fillPgramSignature =
"FillAAPgram(...)".toString();
public static final String drawPgramSignature =
"DrawAAPgram(...)".toString();
public static final int primTypeID = makePrimTypeID();
......@@ -92,6 +96,14 @@ public class MaskFill extends GraphicsPrimitive
return fill;
}
protected MaskFill(String alternateSignature,
SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(alternateSignature, primTypeID, srctype, comptype, dsttype);
}
protected MaskFill(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
......@@ -115,6 +127,23 @@ public class MaskFill extends GraphicsPrimitive
int x, int y, int w, int h,
byte[] mask, int maskoff, int maskscan);
public native void FillAAPgram(SunGraphics2D sg2d, SurfaceData sData,
Composite comp,
double x, double y,
double dx1, double dy1,
double dx2, double dy2);
public native void DrawAAPgram(SunGraphics2D sg2d, SurfaceData sData,
Composite comp,
double x, double y,
double dx1, double dy1,
double dx2, double dy2,
double lw1, double lw2);
public boolean canDoParallelograms() {
return (getNativePrim() != 0);
}
static {
GraphicsPrimitiveMgr.registerGeneral(new MaskFill(null, null, null));
}
......@@ -182,12 +211,22 @@ public class MaskFill extends GraphicsPrimitive
private static class TraceMaskFill extends MaskFill {
MaskFill target;
MaskFill fillPgramTarget;
MaskFill drawPgramTarget;
public TraceMaskFill(MaskFill target) {
super(target.getSourceType(),
target.getCompositeType(),
target.getDestType());
this.target = target;
this.fillPgramTarget = new MaskFill(fillPgramSignature,
target.getSourceType(),
target.getCompositeType(),
target.getDestType());
this.drawPgramTarget = new MaskFill(drawPgramSignature,
target.getSourceType(),
target.getCompositeType(),
target.getDestType());
}
public GraphicsPrimitive traceWrap() {
......@@ -203,5 +242,32 @@ public class MaskFill extends GraphicsPrimitive
target.MaskFill(sg2d, sData, comp, x, y, w, h,
mask, maskoff, maskscan);
}
public void FillAAPgram(SunGraphics2D sg2d, SurfaceData sData,
Composite comp,
double x, double y,
double dx1, double dy1,
double dx2, double dy2)
{
tracePrimitive(fillPgramTarget);
target.FillAAPgram(sg2d, sData, comp,
x, y, dx1, dy1, dx2, dy2);
}
public void DrawAAPgram(SunGraphics2D sg2d, SurfaceData sData,
Composite comp,
double x, double y,
double dx1, double dy1,
double dx2, double dy2,
double lw1, double lw2)
{
tracePrimitive(drawPgramTarget);
target.DrawAAPgram(sg2d, sData, comp,
x, y, dx1, dy1, dx2, dy2, lw1, lw2);
}
public boolean canDoParallelograms() {
return target.canDoParallelograms();
}
}
}
......@@ -28,6 +28,7 @@ package sun.java2d.pipe;
import java.awt.BasicStroke;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.geom.Rectangle2D;
import java.awt.geom.PathIterator;
import sun.awt.SunHints;
import sun.java2d.SunGraphics2D;
......@@ -39,7 +40,9 @@ import sun.java2d.SunGraphics2D;
* This class sets up the Generator and computes the alpha tiles
* and then passes them on to a CompositePipe object for painting.
*/
public class AAShapePipe implements ShapeDrawPipe {
public class AAShapePipe
implements ShapeDrawPipe, ParallelogramPipe
{
static RenderingEngine renderengine = RenderingEngine.getInstance();
CompositePipe outpipe;
......@@ -65,6 +68,59 @@ public class AAShapePipe implements ShapeDrawPipe {
renderPath(sg, s, null);
}
private static Rectangle2D computeBBox(double x, double y,
double dx1, double dy1,
double dx2, double dy2)
{
double lox, loy, hix, hiy;
lox = hix = x;
loy = hiy = y;
if (dx1 < 0) { lox += dx1; } else { hix += dx1; }
if (dy1 < 0) { loy += dy1; } else { hiy += dy1; }
if (dx2 < 0) { lox += dx2; } else { hix += dx2; }
if (dy2 < 0) { loy += dy2; } else { hiy += dy2; }
return new Rectangle2D.Double(lox, loy, hix-lox, hiy-loy);
}
public void fillParallelogram(SunGraphics2D sg,
double x, double y,
double dx1, double dy1,
double dx2, double dy2)
{
Region clip = sg.getCompClip();
int abox[] = new int[4];
AATileGenerator aatg =
renderengine.getAATileGenerator(x, y, dx1, dy1, dx2, dy2, 0, 0,
clip, abox);
if (aatg == null) {
// Nothing to render
return;
}
renderTiles(sg, computeBBox(x, y, dx1, dy1, dx2, dy2), aatg, abox);
}
public void drawParallelogram(SunGraphics2D sg,
double x, double y,
double dx1, double dy1,
double dx2, double dy2,
double lw1, double lw2)
{
Region clip = sg.getCompClip();
int abox[] = new int[4];
AATileGenerator aatg =
renderengine.getAATileGenerator(x, y, dx1, dy1, dx2, dy2, 0, 0,
clip, abox);
if (aatg == null) {
// Nothing to render
return;
}
// Note that bbox is of the original shape, not the wide path.
// This is appropriate for handing to Paint methods...
renderTiles(sg, computeBBox(x, y, dx1, dy1, dx2, dy2), aatg, abox);
}
private static byte[] theTile;
public synchronized static byte[] getAlphaTile(int len) {
......@@ -85,8 +141,6 @@ public class AAShapePipe implements ShapeDrawPipe {
boolean adjust = (bs != null &&
sg.strokeHint != SunHints.INTVAL_STROKE_PURE);
boolean thin = (sg.strokeState <= sg.STROKE_THINDASHED);
Object context = null;
byte alpha[] = null;
Region clip = sg.getCompClip();
int abox[] = new int[4];
......@@ -98,6 +152,14 @@ public class AAShapePipe implements ShapeDrawPipe {
return;
}
renderTiles(sg, s, aatg, abox);
}
public void renderTiles(SunGraphics2D sg, Shape s,
AATileGenerator aatg, int abox[])
{
Object context = null;
byte alpha[] = null;
try {
context = outpipe.startSequence(sg, s,
new Rectangle(abox[0], abox[1],
......
......@@ -34,7 +34,7 @@ import sun.java2d.SunGraphics2D;
* into a destination that supports direct alpha compositing of a solid
* color, according to one of the rules in the AlphaComposite class.
*/
public class AlphaColorPipe implements CompositePipe {
public class AlphaColorPipe implements CompositePipe, ParallelogramPipe {
public AlphaColorPipe() {
}
......@@ -64,4 +64,23 @@ public class AlphaColorPipe implements CompositePipe {
public void endSequence(Object context) {
return;
}
public void fillParallelogram(SunGraphics2D sg,
double x, double y,
double dx1, double dy1,
double dx2, double dy2)
{
sg.alphafill.FillAAPgram(sg, sg.getSurfaceData(), sg.composite,
x, y, dx1, dy1, dx2, dy2);
}
public void drawParallelogram(SunGraphics2D sg,
double x, double y,
double dx1, double dy1,
double dx2, double dy2,
double lw1, double lw2)
{
sg.alphafill.DrawAAPgram(sg, sg.getSurfaceData(), sg.composite,
x, y, dx1, dy1, dx2, dy2, lw1, lw2);
}
}
......@@ -280,6 +280,72 @@ public abstract class RenderingEngine {
boolean normalize,
int bbox[]);
/**
* Construct an antialiased tile generator for the given parallelogram
* store the bounds of the tile iteration in the bbox parameter.
* The parallelogram is specified as a starting point and 2 delta
* vectors that indicate the slopes of the 2 pairs of sides of the
* parallelogram.
* The 4 corners of the parallelogram are defined by the 4 points:
* <ul>
* <li> {@code x}, {@code y}
* <li> {@code x+dx1}, {@code y+dy1}
* <li> {@code x+dx1+dx2}, {@code y+dy1+dy2}
* <li> {@code x+dx2}, {@code y+dy2}
* </ul>
* The {@code lw1} and {@code lw2} parameters provide a specification
* for an optionally stroked parallelogram if they are positive numbers.
* The {@code lw1} parameter is the ratio of the length of the {@code dx1},
* {@code dx2} delta vector to half of the line width in that same
* direction.
* The {@code lw2} parameter provides the same ratio for the other delta
* vector.
* If {@code lw1} and {@code lw2} are both greater than zero, then
* the parallelogram figure is doubled by both expanding and contracting
* each delta vector by its corresponding {@code lw} value.
* If either (@code lw1) or {@code lw2} are also greater than 1, then
* the inner (contracted) parallelogram disappears and the figure is
* simply a single expanded parallelogram.
* The {@code clip} parameter specifies the current clip in effect
* in device coordinates and can be used to prune the data for the
* operation, but the renderer is not required to perform any
* clipping.
* <p>
* Upon returning, this method will fill the {@code bbox} parameter
* with 4 values indicating the bounds of the iteration of the
* tile generator.
* The iteration order of the tiles will be as specified by the
* pseudo-code:
* <pre>
* for (y = bbox[1]; y < bbox[3]; y += tileheight) {
* for (x = bbox[0]; x < bbox[2]; x += tilewidth) {
* }
* }
* </pre>
* If there is no output to be rendered, this method may return
* null.
*
* @param x the X coordinate of the first corner of the parallelogram
* @param y the Y coordinate of the first corner of the parallelogram
* @param dx1 the X coordinate delta of the first leg of the parallelogram
* @param dy1 the Y coordinate delta of the first leg of the parallelogram
* @param dx2 the X coordinate delta of the second leg of the parallelogram
* @param dy2 the Y coordinate delta of the second leg of the parallelogram
* @param lw1 the line width ratio for the first leg of the parallelogram
* @param lw2 the line width ratio for the second leg of the parallelogram
* @param clip the current clip in effect in device coordinates
* @param bbox returns the bounds of the iteration
* @return the {@code AATileGenerator} instance to be consulted
* for tile coverages, or null if there is no output to render
* @since 1.7
*/
public abstract AATileGenerator getAATileGenerator(double x, double y,
double dx1, double dy1,
double dx2, double dy2,
double lw1, double lw2,
Region clip,
int bbox[]);
/**
* Returns the minimum pen width that the antialiasing rasterizer
* can represent without dropouts occuring.
......@@ -393,5 +459,24 @@ public abstract class RenderingEngine {
bs, thin, normalize,
bbox);
}
public AATileGenerator getAATileGenerator(double x, double y,
double dx1, double dy1,
double dx2, double dy2,
double lw1, double lw2,
Region clip,
int bbox[])
{
System.out.println(name+".getAATileGenerator("+
x+", "+y+", "+
dx1+", "+dy1+", "+
dx2+", "+dy2+", "+
lw1+", "+lw2+", "+
clip+")");
return target.getAATileGenerator(x, y,
dx1, dy1,
dx2, dy2,
lw1, lw2,
clip, bbox);
}
}
}
......@@ -557,6 +557,69 @@ public class PiscesRenderingEngine extends RenderingEngine {
return ptg;
}
public AATileGenerator getAATileGenerator(double x, double y,
double dx1, double dy1,
double dx2, double dy2,
double lw1, double lw2,
Region clip,
int bbox[])
{
// REMIND: Deal with large coordinates!
double ldx1, ldy1, ldx2, ldy2;
boolean innerpgram = (lw1 > 0 && lw2 > 0);
if (innerpgram) {
ldx1 = dx1 * lw1;
ldy1 = dy1 * lw1;
ldx2 = dx2 * lw2;
ldy2 = dy2 * lw2;
x -= (ldx1 + ldx2) / 2.0;
y -= (ldy1 + ldy2) / 2.0;
dx1 += ldx1;
dy1 += ldy1;
dx2 += ldx2;
dy2 += ldy2;
if (lw1 > 1 && lw2 > 1) {
// Inner parallelogram was entirely consumed by stroke...
innerpgram = false;
}
} else {
ldx1 = ldy1 = ldx2 = ldy2 = 0;
}
Renderer r = new Renderer(3, 3,
clip.getLoX(), clip.getLoY(),
clip.getWidth(), clip.getHeight(),
PathIterator.WIND_EVEN_ODD);
r.moveTo((float) x, (float) y);
r.lineTo((float) (x+dx1), (float) (y+dy1));
r.lineTo((float) (x+dx1+dx2), (float) (y+dy1+dy2));
r.lineTo((float) (x+dx2), (float) (y+dy2));
r.closePath();
if (innerpgram) {
x += ldx1 + ldx2;
y += ldy1 + ldy2;
dx1 -= 2.0 * ldx1;
dy1 -= 2.0 * ldy1;
dx2 -= 2.0 * ldx2;
dy2 -= 2.0 * ldy2;
r.moveTo((float) x, (float) y);
r.lineTo((float) (x+dx1), (float) (y+dy1));
r.lineTo((float) (x+dx1+dx2), (float) (y+dy1+dy2));
r.lineTo((float) (x+dx2), (float) (y+dy2));
r.closePath();
}
r.pathDone();
r.endRendering();
PiscesTileGenerator ptg = new PiscesTileGenerator(r, r.MAX_AA_ALPHA);
ptg.getBbox(bbox);
return ptg;
}
/**
* Returns the minimum pen width that the antialiasing rasterizer
* can represent without dropouts occuring.
......
......@@ -26,14 +26,11 @@
#include "math.h"
#include "GraphicsPrimitiveMgr.h"
#include "LineUtils.h"
#include "LoopMacros.h"
#include "Trace.h"
#include "ParallelogramUtils.h"
#include "sun_java2d_loops_FillParallelogram.h"
#include "sun_java2d_loops_DrawParallelogram.h"
DECLARE_SOLID_DRAWLINE(AnyInt);
#define HANDLE_PGRAM_EDGE(X1, Y1, X2, Y2, \
pRasInfo, pixel, pPrim, pFunc, pCompInfo) \
do { \
......@@ -46,28 +43,6 @@ DECLARE_SOLID_DRAWLINE(AnyInt);
ix1, iy1, ix2, iy2, JNI_TRUE); \
} while (0)
#define PGRAM_MIN_MAX(bmin, bmax, v0, dv1, dv2) \
do { \
double vmin, vmax; \
if (dv1 < 0) { \
vmin = v0+dv1; \
vmax = v0; \
} else { \
vmin = v0; \
vmax = v0+dv1; \
} \
if (dv2 < 0) { \
vmin -= dv2; \
} else { \
vmax += dv2; \
} \
bmin = (jint) floor(vmin + 0.5); \
bmax = (jint) floor(vmax + 0.5); \
} while(0)
#define PGRAM_INIT_X(starty, x, y, slope) \
(DblToLong((x) + (slope) * ((starty)+0.5 - (y))) + LongOneHalf - 1)
typedef struct {
jdouble x0;
jdouble y0;
......@@ -136,20 +111,8 @@ Java_sun_java2d_loops_DrawParallelogram_DrawParallelogram
* Sort parallelogram by y values, ensure that each delta vector
* has a non-negative y delta.
*/
if (dy1 < 0) {
x0 += dx1; y0 += dy1;
dx1 = -dx1; dy1 = -dy1;
}
if (dy2 < 0) {
x0 += dx2; y0 += dy2;
dx2 = -dx2; dy2 = -dy2;
}
/* Sort delta vectors so dxy1 is left of dxy2. */
if (dx1 * dy2 > dx2 * dy1) {
double v = dx1; dx1 = dx2; dx2 = v;
v = dy1; dy1 = dy2; dy2 = v;
v = lw1; lw1 = lw2; lw2 = v;
}
SORT_PGRAM(x0, y0, dx1, dy1, dx2, dy2,
v = lw1; lw1 = lw2; lw2 = v;);
// dx,dy for line width in the "1" and "2" directions.
ldx1 = dx1 * lw1;
......@@ -161,7 +124,7 @@ Java_sun_java2d_loops_DrawParallelogram_DrawParallelogram
ox0 = x0 - (ldx1 + ldx2) / 2.0;
oy0 = y0 - (ldy1 + ldy2) / 2.0;
PGRAM_MIN_MAX(ix1, ix2, ox0, dx1+ldx1, dx2+ldx2);
PGRAM_MIN_MAX(ix1, ix2, ox0, dx1+ldx1, dx2+ldx2, JNI_FALSE);
iy1 = (jint) floor(oy0 + 0.5);
iy2 = (jint) floor(oy0 + dy1 + ldy1 + dy2 + ldy2 + 0.5);
......@@ -212,7 +175,7 @@ Java_sun_java2d_loops_DrawParallelogram_DrawParallelogram
// Only need to generate 4 quads if the interior still
// has a hole in it (i.e. if the line width ratios were
// both less than 1.0)
if (lw1 < 1.0f && lw2 < 1.0f) {
if (lw1 < 1.0 && lw2 < 1.0) {
// If the line widths are both less than a pixel wide
// then we can use a drawline function instead for even
// more performance.
......
......@@ -25,31 +25,10 @@
#include "math.h"
#include "GraphicsPrimitiveMgr.h"
#include "ParallelogramUtils.h"
#include "sun_java2d_loops_FillParallelogram.h"
#define PGRAM_MIN_MAX(bmin, bmax, v0, dv1, dv2) \
do { \
double vmin, vmax; \
if (dv1 < 0) { \
vmin = v0+dv1; \
vmax = v0; \
} else { \
vmin = v0; \
vmax = v0+dv1; \
} \
if (dv2 < 0) { \
vmin -= dv2; \
} else { \
vmax += dv2; \
} \
bmin = (jint) floor(vmin + 0.5); \
bmax = (jint) floor(vmax + 0.5); \
} while(0)
#define PGRAM_INIT_X(starty, x, y, slope) \
(DblToLong((x) + (slope) * ((starty)+0.5 - (y))) + LongOneHalf - 1)
/*
* Class: sun_java2d_loops_FillParallelogram
* Method: FillParallelogram
......@@ -76,22 +55,11 @@ Java_sun_java2d_loops_FillParallelogram_FillParallelogram
/*
* Sort parallelogram by y values, ensure that each delta vector
* has a non-negative y delta, and eliminate degenerate parallelograms.
* has a non-negative y delta.
*/
if (dy1 < 0) {
x0 += dx1; y0 += dy1;
dx1 = -dx1; dy1 = -dy1;
}
if (dy2 < 0) {
x0 += dx2; y0 += dy2;
dx2 = -dx2; dy2 = -dy2;
}
/* Sort delta vectors so dxy1 is left of dxy2. */
if (dx1 * dy2 > dx2 * dy1) {
double v = dx1; dx1 = dx2; dx2 = v;
v = dy1; dy1 = dy2; dy2 = v;
}
PGRAM_MIN_MAX(ix1, ix2, x0, dx1, dx2);
SORT_PGRAM(x0, y0, dx1, dy1, dx2, dy2, );
PGRAM_MIN_MAX(ix1, ix2, x0, dx1, dx2, JNI_FALSE);
iy1 = (jint) floor(y0 + 0.5);
iy2 = (jint) floor(y0 + dy1 + dy2 + 0.5);
......
/*
* Copyright (c) 2008, Oracle and/or its affiliates. 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#ifndef ParallelogramUtils_h_Included
#define ParallelogramUtils_h_Included
#ifdef __cplusplus
extern "C" {
#endif
#define PGRAM_MIN_MAX(bmin, bmax, v0, dv1, dv2, AA) \
do { \
double vmin, vmax; \
if (dv1 < 0) { \
vmin = v0+dv1; \
vmax = v0; \
} else { \
vmin = v0; \
vmax = v0+dv1; \
} \
if (dv2 < 0) { \
vmin += dv2; \
} else { \
vmax += dv2; \
} \
if (AA) { \
bmin = (jint) floor(vmin); \
bmax = (jint) ceil(vmax); \
} else { \
bmin = (jint) floor(vmin + 0.5); \
bmax = (jint) floor(vmax + 0.5); \
} \
} while(0)
#define PGRAM_INIT_X(starty, x, y, slope) \
(DblToLong((x) + (slope) * ((starty)+0.5 - (y))) + LongOneHalf - 1)
/*
* Sort parallelogram by y values, ensure that each delta vector
* has a non-negative y delta.
*/
#define SORT_PGRAM(x0, y0, dx1, dy1, dx2, dy2, OTHER_SWAP_CODE) \
do { \
if (dy1 < 0) { \
x0 += dx1; y0 += dy1; \
dx1 = -dx1; dy1 = -dy1; \
} \
if (dy2 < 0) { \
x0 += dx2; y0 += dy2; \
dx2 = -dx2; dy2 = -dy2; \
} \
/* Sort delta vectors so dxy1 is left of dxy2. */ \
if (dx1 * dy2 > dx2 * dy1) { \
double v; \
v = dx1; dx1 = dx2; dx2 = v; \
v = dy1; dy1 = dy2; dy2 = v; \
OTHER_SWAP_CODE \
} \
} while(0)
#endif /* ParallelogramUtils_h_Included */
......@@ -517,13 +517,15 @@ void ADD_SUFF(IntArgbPreSrcMaskFill)(void *rasBase,
ADD_SUFF(AnyIntSetRect)(pRasInfo, 0, 0, width, height,
fgColor, pPrim, pCompInfo);
#else
void *pBase = pRasInfo->rasBase;
pRasInfo->rasBase = rasBase;
if (cnstA != 0xff) {
fgColor = (cnstA << 24) | (cnstR << 16) | (cnstG << 8) | cnstB;
}
ADD_SUFF(AnyIntSetRect)(pRasInfo,
pRasInfo->bounds.x1, pRasInfo->bounds.y1,
pRasInfo->bounds.x2, pRasInfo->bounds.y2,
0, 0, width, height,
fgColor, pPrim, pCompInfo);
pRasInfo->rasBase = pBase;
#endif
return;
}
......@@ -582,11 +584,13 @@ void ADD_SUFF(FourByteAbgrPreSrcMaskFill)(void *rasBase,
}
if (pMask == NULL) {
void *pBase = pRasInfo->rasBase;
pRasInfo->rasBase = rasBase;
fgColor = (cnstR << 24) | (cnstG << 16) | (cnstB << 8) | cnstA;
ADD_SUFF(Any4ByteSetRect)(pRasInfo,
pRasInfo->bounds.x1, pRasInfo->bounds.y1,
pRasInfo->bounds.x2, pRasInfo->bounds.y2,
0, 0, width, height,
fgColor, pPrim, pCompInfo);
pRasInfo->rasBase = pBase;
return;
}
......
......@@ -150,10 +150,12 @@ void ADD_SUFF(IntArgbSrcMaskFill)(void *rasBase,
}
if (pMask == NULL) {
void *pBase = pRasInfo->rasBase;
pRasInfo->rasBase = rasBase;
ADD_SUFF(AnyIntSetRect)(pRasInfo,
pRasInfo->bounds.x1, pRasInfo->bounds.y1,
pRasInfo->bounds.x2, pRasInfo->bounds.y2,
0, 0, width, height,
fgColor, pPrim, pCompInfo);
pRasInfo->rasBase = pBase;
return;
}
......@@ -214,15 +216,17 @@ void ADD_SUFF(FourByteAbgrSrcMaskFill)(void *rasBase,
cnstB = (fgColor ) & 0xff;
if (pMask == NULL) {
void *pBase = pRasInfo->rasBase;
pRasInfo->rasBase = rasBase;
if (cnstA == 0) {
fgColor = 0;
} else {
fgColor = (fgColor << 8) | cnstA;
}
ADD_SUFF(Any4ByteSetRect)(pRasInfo,
pRasInfo->bounds.x1, pRasInfo->bounds.y1,
pRasInfo->bounds.x2, pRasInfo->bounds.y2,
0, 0, width, height,
fgColor, pPrim, pCompInfo);
pRasInfo->rasBase = pBase;
return;
}
......@@ -390,10 +394,12 @@ void ADD_SUFF(IntRgbSrcMaskFill)(void *rasBase,
if (cnstA == 0) fgColor = 0;
if (pMask == NULL) {
void *pBase = pRasInfo->rasBase;
pRasInfo->rasBase = rasBase;
ADD_SUFF(AnyIntSetRect)(pRasInfo,
pRasInfo->bounds.x1, pRasInfo->bounds.y1,
pRasInfo->bounds.x2, pRasInfo->bounds.y2,
0, 0, width, height,
fgColor, pPrim, pCompInfo);
pRasInfo->rasBase = pBase;
return;
}
......@@ -458,10 +464,12 @@ void ADD_SUFF(IntBgrSrcMaskFill)(void *rasBase,
}
if (pMask == NULL) {
void *pBase = pRasInfo->rasBase;
pRasInfo->rasBase = rasBase;
ADD_SUFF(AnyIntSetRect)(pRasInfo,
pRasInfo->bounds.x1, pRasInfo->bounds.y1,
pRasInfo->bounds.x2, pRasInfo->bounds.y2,
0, 0, width, height,
fgColor, pPrim, pCompInfo);
pRasInfo->rasBase = pBase;
return;
}
......@@ -526,10 +534,12 @@ void ADD_SUFF(ThreeByteBgrSrcMaskFill)(void *rasBase,
}
if (pMask == NULL) {
void *pBase = pRasInfo->rasBase;
pRasInfo->rasBase = rasBase;
ADD_SUFF(Any3ByteSetRect)(pRasInfo,
pRasInfo->bounds.x1, pRasInfo->bounds.y1,
pRasInfo->bounds.x2, pRasInfo->bounds.y2,
0, 0, width, height,
fgColor, pPrim, pCompInfo);
pRasInfo->rasBase = pBase;
return;
}
......
Filled AA Pure Rect(5, 29.4, 10, 10)
Stroked AA Pure Rect(5, 4.4, 10, 10)
Stroked AA Line(20, 20, -10, 20)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册