diff options
Diffstat (limited to 'src/windows/classes/sun/java2d/d3d/D3DMaskFill.java')
-rw-r--r-- | src/windows/classes/sun/java2d/d3d/D3DMaskFill.java | 122 |
1 files changed, 29 insertions, 93 deletions
diff --git a/src/windows/classes/sun/java2d/d3d/D3DMaskFill.java b/src/windows/classes/sun/java2d/d3d/D3DMaskFill.java index 1f0abcbbf..51a54cd23 100644 --- a/src/windows/classes/sun/java2d/d3d/D3DMaskFill.java +++ b/src/windows/classes/sun/java2d/d3d/D3DMaskFill.java @@ -1,5 +1,5 @@ /* - * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007-2008 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 @@ -25,115 +25,51 @@ package sun.java2d.d3d; -import java.awt.AlphaComposite; import java.awt.Composite; import sun.java2d.SunGraphics2D; -import sun.java2d.SurfaceData; import sun.java2d.loops.GraphicsPrimitive; import sun.java2d.loops.GraphicsPrimitiveMgr; import sun.java2d.loops.CompositeType; import sun.java2d.loops.SurfaceType; -import sun.java2d.loops.MaskFill; -import static sun.java2d.d3d.D3DSurfaceData.*; +import sun.java2d.pipe.BufferedMaskFill; +import static sun.java2d.loops.CompositeType.*; +import static sun.java2d.loops.SurfaceType.*; -/** - * The MaskFill operation is expressed as: - * dst = ((src <MODE> dst) * pathA) + (dst * (1 - pathA)) - * - * The D3D implementation of the MaskFill operation differs from the above - * equation because it is not possible to perform such a complex operation in - * D3d (without the use of advanced techniques like fragment shaders and - * multitexturing). Therefore, the D3DMaskFill operation is expressed as: - * dst = (src * pathA) <SrcOver> dst - * - * This simplified formula is only equivalent to the "true" MaskFill equation - * in the following situations: - * - <MODE> is SrcOver - * - <MODE> is Src, extra alpha == 1.0, and the source color is opaque - * - * Therefore, we register D3DMaskFill primitives for only the SurfaceType and - * CompositeType restrictions mentioned above. In addition for the Src - * case, we must override the composite with a SrcOver (no extra alpha) - * instance, so that we set up the D3d blending mode to match the - * D3DMaskFill equation. - */ -public class D3DMaskFill extends MaskFill { +class D3DMaskFill extends BufferedMaskFill { - public static void register() { + static void register() { GraphicsPrimitive[] primitives = { - new D3DMaskFill(SurfaceType.AnyColor, - CompositeType.SrcOver, - IntRgbD3D), - new D3DMaskFill(SurfaceType.OpaqueColor, - CompositeType.SrcNoEa, - IntRgbD3D), - - new D3DMaskFill(SurfaceType.AnyColor, - CompositeType.SrcOver, - Ushort565RgbD3D), - new D3DMaskFill(SurfaceType.OpaqueColor, - CompositeType.SrcNoEa, - Ushort565RgbD3D), - - new D3DMaskFill(SurfaceType.AnyColor, - CompositeType.SrcOver, - IntRgbxD3D), - new D3DMaskFill(SurfaceType.OpaqueColor, - CompositeType.SrcNoEa, - IntRgbxD3D), - - new D3DMaskFill(SurfaceType.AnyColor, - CompositeType.SrcOver, - Ushort555RgbD3D), - new D3DMaskFill(SurfaceType.OpaqueColor, - CompositeType.SrcNoEa, - Ushort555RgbD3D), - - new D3DMaskFill(SurfaceType.AnyColor, - CompositeType.SrcOver, - Ushort555RgbxD3D), - new D3DMaskFill(SurfaceType.OpaqueColor, - CompositeType.SrcNoEa, - Ushort555RgbxD3D), - - new D3DMaskFill(SurfaceType.AnyColor, - CompositeType.SrcOver, - ThreeByteBgrD3D), - new D3DMaskFill(SurfaceType.OpaqueColor, - CompositeType.SrcNoEa, - ThreeByteBgrD3D), + new D3DMaskFill(AnyColor, SrcOver), + new D3DMaskFill(OpaqueColor, SrcNoEa), + new D3DMaskFill(GradientPaint, SrcOver), + new D3DMaskFill(OpaqueGradientPaint, SrcNoEa), + new D3DMaskFill(LinearGradientPaint, SrcOver), + new D3DMaskFill(OpaqueLinearGradientPaint, SrcNoEa), + new D3DMaskFill(RadialGradientPaint, SrcOver), + new D3DMaskFill(OpaqueRadialGradientPaint, SrcNoEa), + new D3DMaskFill(TexturePaint, SrcOver), + new D3DMaskFill(OpaqueTexturePaint, SrcNoEa), }; GraphicsPrimitiveMgr.register(primitives); } - D3DMaskFill(SurfaceType srcType, CompositeType compType, - SurfaceType dstType) { - super(srcType, compType, dstType); + protected D3DMaskFill(SurfaceType srcType, CompositeType compType) { + super(D3DRenderQueue.getInstance(), + srcType, compType, D3DSurfaceData.D3DSurface); } - private native void MaskFill(long pData, long pCtx, - int x, int y, int w, int h, - byte[] mask, int maskoff, int maskscan); + @Override + protected native void maskFill(int x, int y, int w, int h, + int maskoff, int maskscan, int masklen, + byte[] mask); @Override - public void MaskFill(SunGraphics2D sg2d, SurfaceData sData, - Composite comp, - int x, int y, int w, int h, - byte[] mask, int maskoff, int maskscan) + protected void validateContext(SunGraphics2D sg2d, + Composite comp, int ctxflags) { - AlphaComposite acomp = (AlphaComposite)comp; - if (acomp.getRule() != AlphaComposite.SRC_OVER) { - comp = AlphaComposite.SrcOver; - } - - synchronized (D3DContext.LOCK) { - long pCtx = D3DContext.getContext(sData, sData, - sg2d.getCompClip(), comp, - null, sg2d.eargb, - D3DContext.NO_CONTEXT_FLAGS); - - MaskFill(sData.getNativeOps(), pCtx, x, y, w, h, - mask, maskoff, maskscan); - } + D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData; + D3DContext.validateContext(dstData, dstData, + sg2d.getCompClip(), comp, + null, sg2d.paint, sg2d, ctxflags); } } |